File formatting.php
has 1483 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Main WordPress Formatting API.
*
* Handles many functions for formatting output.
Method ent2ncr
has 260 lines of code (exceeds 25 allowed). Consider refactoring. Open
function ent2ncr($text) {
$to_ncr = array(
'"' => '"',
'&' => '&',
'⁄' => '/',
Function force_balance_tags
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
function force_balance_tags( $text ) {
$tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
$single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
$nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves
- 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 remove_accents
has 117 lines of code (exceeds 25 allowed). Consider refactoring. Open
function remove_accents($string) {
if ( !preg_match('/[\x80-\xff]/', $string) )
return $string;
if (seems_utf8($string)) {
Function utf8_uri_encode
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
function utf8_uri_encode( $utf8_string, $length = 0 ) {
$unicode = '';
$values = array();
$num_octets = 1;
$unicode_length = 0;
- 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_option
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sanitize_option($option, $value) {
switch ($option) {
case 'admin_email':
$value = sanitize_email($value);
Method force_balance_tags
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
function force_balance_tags( $text ) {
$tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
$single_tags = array('br', 'hr', 'img', 'input'); //Known single-entity/self-closing tags
$nestable_tags = array('blockquote', 'div', 'span'); //Tags that can be immediately nested within themselves
Function wp_sprintf
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function wp_sprintf( $pattern ) {
$args = func_get_args( );
$len = strlen($pattern);
$start = 0;
$result = '';
- 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_option
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_option($option, $value) {
switch ($option) {
case 'admin_email':
$value = sanitize_email($value);
- 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 human_time_diff
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
if ($diff <= 3600) {
- 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 seems_utf8
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function seems_utf8($str) {
$length = strlen($str);
for ($i=0; $i < $length; $i++) {
$c = ord($str[$i]);
if ($c < 0x80) $n = 0; # 0bbbbbbb
- 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_file_name
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_file_name( $filename ) {
$filename_raw = $filename;
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
$special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
$filename = str_replace($special_chars, '', $filename);
- 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 wptexturize
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wptexturize($text) {
global $wp_cockneyreplace;
static $static_setup = false, $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements;
$output = '';
$curl = '';
Function is_email
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function is_email( $email, $check_dns = false ) {
// Test for the minimum length the email can be
if ( strlen( $email ) < 3 ) {
return apply_filters( 'is_email', false, $email, 'email_too_short' );
}
- 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 _wp_specialchars
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
$string = (string) $string;
if ( 0 === strlen( $string ) ) {
return '';
Method convert_chars
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function convert_chars($content, $deprecated = '') {
// Translation of invalid Unicode references range to valid range
$wp_htmltranswinuni = array(
'€' => '€', // the Euro sign
'' => '',
Function wptexturize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function wptexturize($text) {
global $wp_cockneyreplace;
static $static_setup = false, $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements;
$output = '';
$curl = '';
- 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 _wp_specialchars
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
$string = (string) $string;
if ( 0 === strlen( $string ) ) {
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
Method sanitize_email
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sanitize_email( $email ) {
// Test for the minimum length the email can be
if ( strlen( $email ) < 3 ) {
return apply_filters( 'sanitize_email', '', $email, 'email_too_short' );
}
Method wp_sprintf
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_sprintf( $pattern ) {
$args = func_get_args( );
$len = strlen($pattern);
$start = 0;
$result = '';
Method wpautop
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wpautop($pee, $br = 1) {
if ( trim($pee) === '' )
return '';
$pee = $pee . "\n"; // just to make things a little easier, pad the end
Method wp_specialchars_decode
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
$string = (string) $string;
if ( 0 === strlen( $string ) ) {
return '';
Method is_email
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function is_email( $email, $check_dns = false ) {
// Test for the minimum length the email can be
if ( strlen( $email ) < 3 ) {
return apply_filters( 'is_email', false, $email, 'email_too_short' );
}
Method utf8_uri_encode
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function utf8_uri_encode( $utf8_string, $length = 0 ) {
$unicode = '';
$values = array();
$num_octets = 1;
$unicode_length = 0;
Method sanitize_file_name
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sanitize_file_name( $filename ) {
$filename_raw = $filename;
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
$special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);
$filename = str_replace($special_chars, '', $filename);
Function sanitize_email
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_email( $email ) {
// Test for the minimum length the email can be
if ( strlen( $email ) < 3 ) {
return apply_filters( 'sanitize_email', '', $email, 'email_too_short' );
}
- 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 wp_specialchars_decode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
$string = (string) $string;
if ( 0 === strlen( $string ) ) {
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 _wptexturize_pushpop_element
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function _wptexturize_pushpop_element($text, &$stack, $disabled_elements, $opening = '<', $closing = '>') {
// Check if it is a closing tag -- otherwise assume opening tag
if (strncmp($opening . '/', $text, 2)) {
// Opening? Check $text+1 against disabled elements
if (preg_match('/^' . $disabled_elements . '\b/', substr($text, 1), $matches)) {
- 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 convert_smilies
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function convert_smilies($text) {
global $wp_smiliessearch;
$output = '';
if ( get_option('use_smilies') && !empty($wp_smiliessearch) ) {
// HTML loop taken from texturize function, could possible be consolidated
- 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 wp_check_invalid_utf8
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function wp_check_invalid_utf8( $string, $strip = false ) {
$string = (string) $string;
if ( 0 === strlen( $string ) ) {
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
Method _wptexturize_pushpop_element
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function _wptexturize_pushpop_element($text, &$stack, $disabled_elements, $opening = '<', $closing = '>') {
Function wp_sprintf_l
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function wp_sprintf_l($pattern, $args) {
// Not a match
if ( substr($pattern, 0, 2) != '%l' )
return $pattern;
- 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 iso8601_to_datetime
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function iso8601_to_datetime($date_string, $timezone = 'user') {
$timezone = strtolower($timezone);
if ($timezone == 'gmt') {
- 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 apply_filters( 'is_email', false, $email, 'domain_no_periods' );
Avoid too many return
statements within this method. Open
return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' );
Avoid too many return
statements within this method. Open
return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );
Avoid too many return
statements within this method. Open
return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return apply_filters( 'is_email', false, $email, 'dns_no_rr' );
Avoid too many return
statements within this method. Open
return apply_filters( 'is_email', $email, $email, null );
Avoid too many return
statements within this method. Open
return apply_filters( 'sanitize_email', $email, $email, null );
Avoid too many return
statements within this method. Open
return iconv( 'utf-8', 'utf-8', $string );
Avoid too many return
statements within this method. Open
return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );
Avoid too many return
statements within this method. Open
return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
Avoid too many return
statements within this method. Open
return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
Function clean_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function clean_url( $url, $protocols = null, $context = 'display' ) {
$original_url = $url;
if ('' == $url) return $url;
$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
- 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 _deep_replace
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function _deep_replace($search, $subject){
$found = true;
while($found) {
$found = false;
foreach( (array) $search as $val ) {
- 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"