File class-admin.php
has 630 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Centralized manager for WordPress backend functionality.
*
* @package WP_Stream
Method admin_enqueue_scripts
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function admin_enqueue_scripts( $hook ) {
wp_register_script( 'wp-stream-select2', $this->plugin->locations['url'] . 'ui/lib/select2/js/select2.full.min.js', array( 'jquery' ), '3.5.2', true );
wp_register_style( 'wp-stream-select2', $this->plugin->locations['url'] . 'ui/lib/select2/css/select2.min.css', array(), '3.5.2' );
wp_register_script( 'wp-stream-timeago', $this->plugin->locations['url'] . 'ui/lib/timeago/jquery.timeago.js', array(), '1.4.1', true );
Admin
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class Admin {
/**
* Holds Instance of plugin object
*
Method admin_menu_css
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function admin_menu_css() {
$min = wp_stream_min_suffix();
wp_register_style( 'wp-stream-datepicker', $this->plugin->locations['url'] . 'ui/css/datepicker.' . $min . 'css', array(), $this->plugin->get_version() );
wp_register_style( 'wp-stream-icons', $this->plugin->locations['url'] . 'ui/stream-icons/style.css', array(), $this->plugin->get_version() );
Method __construct
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( $plugin ) {
$this->plugin = $plugin;
add_action( 'init', array( $this, 'init' ) );
Method render_settings_page
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render_settings_page() {
$option_key = $this->plugin->settings->option_key;
$form_action = apply_filters( 'wp_stream_settings_form_action', admin_url( 'options.php' ) );
$page_description = apply_filters( 'wp_stream_settings_form_description', '' );
Method purge_scheduled_action
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function purge_scheduled_action() {
global $wpdb;
// Don't purge when in Network Admin unless Stream is network activated.
if (
Method ajax_filters
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function ajax_filters() {
if ( ! defined( 'DOING_AJAX' ) || ! current_user_can( $this->plugin->admin->settings_cap ) ) {
wp_die( '-1' );
}
Method register_menu
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function register_menu() {
/**
* Filter the main admin menu title
*
* @return string
Function filter_user_caps
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function filter_user_caps( $allcaps, $caps, $args, $user = null ) {
global $wp_roles;
$_wp_roles = isset( $wp_roles ) ? $wp_roles : new WP_Roles();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function render_settings_page
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function render_settings_page() {
$option_key = $this->plugin->settings->option_key;
$form_action = apply_filters( 'wp_stream_settings_form_action', admin_url( 'options.php' ) );
$page_description = apply_filters( 'wp_stream_settings_form_description', '' );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function purge_scheduled_action
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function purge_scheduled_action() {
global $wpdb;
// Don't purge when in Network Admin unless Stream is network activated.
if (
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function notice
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function notice( $message, $is_error = true ) {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$message = wp_strip_all_tags( $message );
if ( $is_error ) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ajax_filters
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function ajax_filters() {
if ( ! defined( 'DOING_AJAX' ) || ! current_user_can( $this->plugin->admin->settings_cap ) ) {
wp_die( '-1' );
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"