Function get_themes
has a Cognitive Complexity of 115 (exceeds 5 allowed). Consider refactoring. Open
function get_themes() {
global $wp_themes, $wp_broken_themes;
if ( isset($wp_themes) )
return $wp_themes;
- 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 search_theme_directories
has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring. Open
function search_theme_directories() {
global $wp_theme_directories, $wp_broken_themes;
if ( empty( $wp_theme_directories ) )
return false;
- 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
File theme.php
has 636 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Theme, template, and stylesheet functions.
*
* @package WordPress
Method get_themes
has 132 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_themes() {
global $wp_themes, $wp_broken_themes;
if ( isset($wp_themes) )
return $wp_themes;
Method search_theme_directories
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function search_theme_directories() {
global $wp_theme_directories, $wp_broken_themes;
if ( empty( $wp_theme_directories ) )
return false;
Method get_theme_data
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function get_theme_data( $theme_file ) {
$default_headers = array(
'Name' => 'Theme Name',
'URI' => 'Theme URI',
'Description' => 'Description',
Function locate_template
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function locate_template($template_names, $load = false) {
if (!is_array($template_names))
return '';
$located = '';
- 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_current_theme
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function get_current_theme() {
if ( $theme = get_option('current_theme') )
return $theme;
$themes = get_themes();
- 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_theme_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function get_theme_data( $theme_file ) {
$default_headers = array(
'Name' => 'Theme Name',
'URI' => 'Theme URI',
'Description' => '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
Avoid deeply nested control flow statements. Open
if ( preg_match('|^\.+$|', $subfile) )
continue;
Avoid deeply nested control flow statements. Open
if ( is_dir( $subdir . '/' . $theme_subdir) && is_readable($subdir . '/' . $theme_subdir) ) {
if ( $theme_subdir{0} == '.' || $theme_subdir == 'CVS' )
continue;
$stylish_dir = @opendir($subdir . '/' . $theme_subdir);
Avoid deeply nested control flow statements. Open
if ( preg_match('|\.php$|', $subfile) )
$template_files[] = "$template_directory/$file/$subfile";
Function current_theme_supports
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function current_theme_supports( $feature ) {
global $_wp_theme_features;
if ( !isset( $_wp_theme_features[$feature] ) )
return false;
- 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 preview_theme
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function preview_theme() {
if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )
return;
if ( !current_user_can( 'switch_themes' ) )
- 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 too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return true;
Function preview_theme_ob_filter_callback
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function preview_theme_ob_filter_callback( $matches ) {
if ( strpos($matches[4], 'onclick') !== false )
$matches[4] = preg_replace('#onclick=([\'"]).*?(?<!\\\)\\1#i', '', $matches[4]); //Strip out any onclicks from rest of <a>. (?<!\\\) means to ignore the '" if its escaped by \ to prevent breaking mid-attribute.
if (
( false !== strpos($matches[3], '/wp-admin/') )
- 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"