File Admin.php
has 535 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WPPTD\Admin class
*
* @package WPPTD
Admin
has 37 functions (exceeds 20 allowed). Consider refactoring. Open
class Admin {
/**
* @since 0.5.0
* @var WPPTD\Admin|null Holds the instance of this class.
Function enqueue_assets
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function enqueue_assets() {
$screen = get_current_screen();
if ( isset( $screen->taxonomy ) && $screen->taxonomy ) {
$taxonomy = ComponentManager::get( '*.*.' . $screen->taxonomy, 'WPDLib\Components\Menu.WPPTD\Components\PostType.WPPTD\Components\Taxonomy', true );
- 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 get_media_view_strings
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function get_media_view_strings( $strings, $post ) {
if ( $post ) {
$post_type = ComponentManager::get( '*.' . $post->post_type, 'WPDLib\Components\Menu.WPPTD\Components\PostType', true );
if ( $post_type ) {
$labels = $post_type->labels;
- 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
Method term_submit_metabox
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function term_submit_metabox( $term ) {
$screen = get_current_screen();
$tax = $screen->taxonomy;
if ( empty( $tax ) ) {
Function handle_term_bulk_actions
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function handle_term_bulk_actions() {
global $taxnow;
// do not run this on a term edit form
if ( isset( $_GET['tag_ID'] ) ) {
- 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 handle_bulk_actions
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function handle_bulk_actions() {
global $typenow;
$post_type = ComponentManager::get( '*.' . $typenow, 'WPDLib\Components\Menu.WPPTD\Components\PostType', true );
if ( $post_type ) {
- 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 term_submit_metabox
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function term_submit_metabox( $term ) {
$screen = get_current_screen();
$tax = $screen->taxonomy;
if ( empty( $tax ) ) {
- 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 get_post_updated_messages
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function get_post_updated_messages( $messages ) {
global $post;
$permalink = get_permalink( $post->ID );
if ( ! $permalink ) {
- 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 add_taxonomy_hooks
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function add_taxonomy_hooks() {
if ( 0 > version_compare( get_bloginfo( 'version' ), '4.5' ) ) {
add_action( 'load-edit-tags.php', array( $this, 'add_term_or_term_list_help' ) );
} else {
add_action( 'load-edit-tags.php', array( $this, 'add_term_list_help' ) );
- 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
Method enqueue_assets
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function enqueue_assets() {
$screen = get_current_screen();
if ( isset( $screen->taxonomy ) && $screen->taxonomy ) {
$taxonomy = ComponentManager::get( '*.*.' . $screen->taxonomy, 'WPDLib\Components\Menu.WPPTD\Components\PostType.WPPTD\Components\Taxonomy', true );
Function get_bulk_post_updated_messages
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_bulk_post_updated_messages( $messages, $counts ) {
$post_types = ComponentManager::get( '*.*', 'WPDLib\Components\Menu.WPPTD\Components\PostType' );
foreach ( $post_types as $post_type ) {
if ( ! in_array( $post_type->slug, array( 'post', 'page', 'attachment' ) ) ) {
$post_type_messages = $post_type->get_bulk_updated_messages( $counts );
- 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
Method wrap_term_ui_bottom
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function wrap_term_ui_bottom( $term, $taxonomy ) {
?>
</div>
<?php wp_nonce_field( 'wpptd-save-term-' . $taxonomy, 'wpptd_edit_term_' . $taxonomy ); ?>
Function get_term_updated_messages
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function get_term_updated_messages( $messages ) {
$taxonomies = ComponentManager::get( '*.*.*', 'WPDLib\Components\Menu.WPPTD\Components\PostType.WPPTD\Components\Taxonomy' );
foreach ( $taxonomies as $taxonomy ) {
if ( ! in_array( $taxonomy->slug, array( '_item', 'category', 'post_tag' ) ) ) {
$taxonomy_messages = $taxonomy->get_updated_messages();
- 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 initialize_term_ui
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function initialize_term_ui() {
$screen = get_current_screen();
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
return;
}
- 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 handle_term_row_actions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function handle_term_row_actions() {
global $taxnow;
// do not run this on a terms list
if ( ! isset( $_GET['tag_ID'] ) ) {
- 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
Avoid deeply nested control flow statements. Open
if ( wpptd_supports_termmeta() ) {
$taxonomy->enqueue_assets();
}
Avoid deeply nested control flow statements. Open
if ( isset( $labels['insert_into_item'] ) && $labels['insert_into_item'] ) {
$strings['insertIntoPost'] = $labels['insert_into_item'];
}
Avoid deeply nested control flow statements. Open
if ( isset( $labels['uploaded_to_this_item'] ) && $labels['uploaded_to_this_item'] ) {
$strings['uploadedToThisPost'] = $labels['uploaded_to_this_item'];
}
Consider simplifying this complex logical expression. Open
if ( ( 0 <= version_compare( get_bloginfo( 'version' ), '4.5' ) && 'term' === $screen->base ) || ( 0 > version_compare( get_bloginfo( 'version' ), '4.5' ) && 'edit-tags' === $screen->base && isset( $_GET['tag_ID'] ) && is_numeric( $_GET['tag_ID'] ) ) ) {
if ( wpptd_supports_termmeta() ) {
$taxonomy->enqueue_assets();
}
Function add_term_or_term_list_help
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function add_term_or_term_list_help() {
global $taxnow;
$taxonomy = ComponentManager::get( '*.*.' . $taxnow, 'WPDLib\Components\Menu.WPPTD\Components\PostType.WPPTD\Components\Taxonomy', true );
if ( $taxonomy ) {
- 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 handle_row_actions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function handle_row_actions() {
global $typenow;
$post_type = ComponentManager::get( '*.' . $typenow, 'WPDLib\Components\Menu.WPPTD\Components\PostType', true );
if ( $post_type ) {
- 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"