Skip to content

Commit c2f2629

Browse files
Coding Standards: Use strict comparison where strtolower() is involved.
Follow-up to [649], [7736], [18821], [19444], [20886], [20893], [23303], [55642], [55652], [55653], [55654]. Props aristath, poena, afercia, SergeyBiryukov. See #57839. git-svn-id: https://develop.svn.wordpress.org/trunk@55677 602fd350-edb4-49c9-b593-d223f7449a82
1 parent b55b935 commit c2f2629

5 files changed

Lines changed: 32 additions & 13 deletions

File tree

‎src/wp-admin/includes/upgrade.php‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,7 @@ function upgrade_330() {
17391739
$_sidebars_widgets[ $index ][ $i ] = $id;
17401740
continue;
17411741
}
1742+
17421743
$id = sanitize_title( $name );
17431744
if ( isset( $wp_registered_widgets[ $id ] ) ) {
17441745
$_sidebars_widgets[ $index ][ $i ] = $id;
@@ -1748,13 +1749,15 @@ function upgrade_330() {
17481749
$found = false;
17491750

17501751
foreach ( $wp_registered_widgets as $widget_id => $widget ) {
1751-
if ( strtolower( $widget['name'] ) == strtolower( $name ) ) {
1752+
if ( strtolower( $widget['name'] ) === strtolower( $name ) ) {
17521753
$_sidebars_widgets[ $index ][ $i ] = $widget['id'];
1753-
$found = true;
1754+
1755+
$found = true;
17541756
break;
1755-
} elseif ( sanitize_title( $widget['name'] ) == sanitize_title( $name ) ) {
1757+
} elseif ( sanitize_title( $widget['name'] ) === sanitize_title( $name ) ) {
17561758
$_sidebars_widgets[ $index ][ $i ] = $widget['id'];
1757-
$found = true;
1759+
1760+
$found = true;
17581761
break;
17591762
}
17601763
}

‎src/wp-includes/formatting.php‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,13 +3029,26 @@ function make_clickable( $text ) {
30293029
$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>.
30303030
foreach ( $textarr as $piece ) {
30313031

3032-
if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) || preg_match( '|^<script[\s>]|i', $piece ) || preg_match( '|^<style[\s>]|i', $piece ) ) {
3032+
if ( preg_match( '|^<code[\s>]|i', $piece )
3033+
|| preg_match( '|^<pre[\s>]|i', $piece )
3034+
|| preg_match( '|^<script[\s>]|i', $piece )
3035+
|| preg_match( '|^<style[\s>]|i', $piece )
3036+
) {
30333037
$nested_code_pre++;
3034-
} elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) ) {
3038+
} elseif ( $nested_code_pre
3039+
&& ( '</code>' === strtolower( $piece )
3040+
|| '</pre>' === strtolower( $piece )
3041+
|| '</script>' === strtolower( $piece )
3042+
|| '</style>' === strtolower( $piece )
3043+
)
3044+
) {
30353045
$nested_code_pre--;
30363046
}
30373047

3038-
if ( $nested_code_pre || empty( $piece ) || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
3048+
if ( $nested_code_pre
3049+
|| empty( $piece )
3050+
|| ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) )
3051+
) {
30393052
$r .= $piece;
30403053
continue;
30413054
}
@@ -4463,7 +4476,7 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) {
44634476
$protocols = wp_allowed_protocols();
44644477
}
44654478
$good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
4466-
if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) {
4479+
if ( strtolower( $good_protocol_url ) !== strtolower( $url ) ) {
44674480
return '';
44684481
}
44694482
}

‎src/wp-includes/kses.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) {
16401640
* If the given value is an "n" or an "N", the attribute must have a value.
16411641
*/
16421642

1643-
if ( strtolower( $checkvalue ) != $vless ) {
1643+
if ( strtolower( $checkvalue ) !== $vless ) {
16441644
$ok = false;
16451645
}
16461646
break;
@@ -1846,7 +1846,7 @@ function wp_kses_bad_protocol_once2( $scheme, $allowed_protocols ) {
18461846

18471847
$allowed = false;
18481848
foreach ( (array) $allowed_protocols as $one_protocol ) {
1849-
if ( strtolower( $one_protocol ) == $scheme ) {
1849+
if ( strtolower( $one_protocol ) === $scheme ) {
18501850
$allowed = true;
18511851
break;
18521852
}

‎src/wp-includes/post.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4194,7 +4194,10 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
41944194
// On updates, we need to check to see if it's using the old, fixed sanitization context.
41954195
$check_name = sanitize_title( $post_name, '', 'old-save' );
41964196

4197-
if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_id ) == $check_name ) {
4197+
if ( $update
4198+
&& strtolower( urlencode( $post_name ) ) === $check_name
4199+
&& get_post_field( 'post_name', $post_id ) === $check_name
4200+
) {
41984201
$post_name = $check_name;
41994202
} else { // New post, or slug has changed.
42004203
$post_name = sanitize_title( $post_name );

‎src/wp-includes/theme.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,7 +3625,7 @@ function _wp_customize_changeset_filter_insert_post_data( $post_data, $supplied_
36253625
function _wp_customize_loader_settings() {
36263626
$admin_origin = parse_url( admin_url() );
36273627
$home_origin = parse_url( home_url() );
3628-
$cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) );
3628+
$cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
36293629

36303630
$browser = array(
36313631
'mobile' => wp_is_mobile(),
@@ -3690,7 +3690,7 @@ function wp_customize_url( $stylesheet = '' ) {
36903690
function wp_customize_support_script() {
36913691
$admin_origin = parse_url( admin_url() );
36923692
$home_origin = parse_url( home_url() );
3693-
$cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) );
3693+
$cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
36943694
$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
36953695
?>
36963696
<script<?php echo $type_attr; ?>>

0 commit comments

Comments
 (0)