File class-wp-theme.php
has 606 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WP_Theme Class
*
* @package WordPress
Function __construct
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $theme_dir, $theme_root, $_child = null ) {
global $wp_theme_directories;
// Initialize caching on first run.
if ( ! isset( self::$persistently_cache ) ) {
- 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
WP_Theme
has 39 functions (exceeds 20 allowed). Consider refactoring. Open
final class WP_Theme implements ArrayAccess {
/**
* Headers for style.css files.
*
Function get_allowed_on_site
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public static function get_allowed_on_site( $blog_id = null ) {
static $allowed_themes = array();
if ( ! $blog_id || ! is_multisite() )
$blog_id = get_current_blog_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
Method __construct
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( $theme_dir, $theme_root, $_child = null ) {
global $wp_theme_directories;
// Initialize caching on first run.
if ( ! isset( self::$persistently_cache ) ) {
Function scandir
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) {
if ( ! is_dir( $path ) )
return false;
if ( $extensions ) {
- 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 get_allowed_on_site
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_allowed_on_site( $blog_id = null ) {
static $allowed_themes = array();
if ( ! $blog_id || ! is_multisite() )
$blog_id = get_current_blog_id();
Method offsetGet
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function offsetGet( $offset ) {
switch ( $offset ) {
case 'Name' :
case 'Title' :
// See note above about using translated data. get() is not ideal.
Function get_page_templates
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function get_page_templates( $post = null ) {
// If you screw up your current theme and we invalidate your parent, most things still work. Let it slide.
if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) )
return array();
- 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 sanitize_header
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function sanitize_header( $header, $value ) {
switch ( $header ) {
case 'Status' :
if ( ! $value ) {
$value = 'publish';
Function markup_header
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function markup_header( $header, $value, $translate ) {
switch ( $header ) {
case 'Name' :
if ( empty( $value ) )
$value = $this->get_stylesheet();
- 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 translate_header
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function translate_header( $header, $value ) {
switch ( $header ) {
case 'Name' :
// Cached for sorting reasons.
if ( isset( $this->name_translated ) )
- 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 markup_header
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function markup_header( $header, $value, $translate ) {
switch ( $header ) {
case 'Name' :
if ( empty( $value ) )
$value = $this->get_stylesheet();
Method __get
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __get( $offset ) {
switch ( $offset ) {
case 'name' :
case 'title' :
return $this->get('Name');
Method translate_header
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function translate_header( $header, $value ) {
switch ( $header ) {
case 'Name' :
// Cached for sorting reasons.
if ( isset( $this->name_translated ) )
Function get_screenshot
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function get_screenshot( $uri = 'uri' ) {
$screenshot = $this->cache_get( 'screenshot' );
if ( $screenshot ) {
if ( 'relative' == $uri )
return $screenshot;
- 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
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function get( $header ) {
if ( ! isset( $this->headers[ $header ] ) )
return false;
if ( ! isset( $this->headers_sanitized ) ) {
- 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 is_allowed
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function is_allowed( $check = 'both', $blog_id = null ) {
if ( ! is_multisite() )
return true;
if ( 'both' == $check || 'network' == $check ) {
- 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 sanitize_header
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function sanitize_header( $header, $value ) {
switch ( $header ) {
case 'Status' :
if ( ! $value ) {
$value = 'publish';
- 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 $this->display('Description');
Avoid too many return
statements within this method. Open
return $this->get_screenshot( 'relative' );
Avoid too many return
statements within this method. Open
return $this->get_screenshot( 'relative' );
Avoid too many return
statements within this method. Open
return $this->get('Tags');
Avoid too many return
statements within this method. Open
return $this->get_template();
Avoid too many return
statements within this method. Open
return $this->get_template();
Avoid too many return
statements within this method. Open
return $this->get_files( 'php', 1, true );
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext;
Avoid too many return
statements within this method. Open
return $this->get_theme_root_uri();
Avoid too many return
statements within this method. Open
return $this->get_stylesheet();
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return $this->get_theme_root_uri();
Avoid too many return
statements within this method. Open
return $this->get_files( 'css', 0, false );
Avoid too many return
statements within this method. Open
return $this->get_theme_root();
Avoid too many return
statements within this method. Open
return $this->get_stylesheet_directory();
Avoid too many return
statements within this method. Open
return $this->get_stylesheet_directory();
Avoid too many return
statements within this method. Open
return $this->get_stylesheet();
Avoid too many return
statements within this method. Open
return $this->display('Author');
Avoid too many return
statements within this method. Open
return $this->display( 'Description');
Avoid too many return
statements within this method. Open
return $this->get( 'Tags' );
Avoid too many return
statements within this method. Open
return $this->get_theme_root();
Avoid too many return
statements within this method. Open
return $this->parent() ? $this->parent()->get('Name') : '';
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return;
Avoid too many return
statements within this method. Open
return $this->get_template_directory();
Avoid too many return
statements within this method. Open
return $this->offsetGet( $offset );
Avoid too many return
statements within this method. Open
return $value;
Avoid too many return
statements within this method. Open
return $this->get( $offset );
Function display
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function display( $header, $markup = true, $translate = true ) {
$value = $this->get( $header );
if ( false === $value ) {
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"