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.
Built from https://develop.svn.wordpress.org/trunk@55677


git-svn-id: http://core.svn.wordpress.org/trunk@55189 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-04-22 15:19:22 +00:00
parent ead3a2ec81
commit 0c5a04d541
6 changed files with 33 additions and 14 deletions

View File

@ -1739,6 +1739,7 @@ function upgrade_330() {
$_sidebars_widgets[ $index ][ $i ] = $id;
continue;
}
$id = sanitize_title( $name );
if ( isset( $wp_registered_widgets[ $id ] ) ) {
$_sidebars_widgets[ $index ][ $i ] = $id;
@ -1748,13 +1749,15 @@ function upgrade_330() {
$found = false;
foreach ( $wp_registered_widgets as $widget_id => $widget ) {
if ( strtolower( $widget['name'] ) == strtolower( $name ) ) {
if ( strtolower( $widget['name'] ) === strtolower( $name ) ) {
$_sidebars_widgets[ $index ][ $i ] = $widget['id'];
$found = true;
$found = true;
break;
} elseif ( sanitize_title( $widget['name'] ) == sanitize_title( $name ) ) {
} elseif ( sanitize_title( $widget['name'] ) === sanitize_title( $name ) ) {
$_sidebars_widgets[ $index ][ $i ] = $widget['id'];
$found = true;
$found = true;
break;
}
}

View File

@ -3029,13 +3029,26 @@ function make_clickable( $text ) {
$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>.
foreach ( $textarr as $piece ) {
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 ) ) {
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 )
) {
$nested_code_pre++;
} elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) ) {
} elseif ( $nested_code_pre
&& ( '</code>' === strtolower( $piece )
|| '</pre>' === strtolower( $piece )
|| '</script>' === strtolower( $piece )
|| '</style>' === strtolower( $piece )
)
) {
$nested_code_pre--;
}
if ( $nested_code_pre || empty( $piece ) || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
if ( $nested_code_pre
|| empty( $piece )
|| ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) )
) {
$r .= $piece;
continue;
}
@ -4463,7 +4476,7 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) {
$protocols = wp_allowed_protocols();
}
$good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) {
if ( strtolower( $good_protocol_url ) !== strtolower( $url ) ) {
return '';
}
}

View File

@ -1640,7 +1640,7 @@ function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) {
* If the given value is an "n" or an "N", the attribute must have a value.
*/
if ( strtolower( $checkvalue ) != $vless ) {
if ( strtolower( $checkvalue ) !== $vless ) {
$ok = false;
}
break;
@ -1846,7 +1846,7 @@ function wp_kses_bad_protocol_once2( $scheme, $allowed_protocols ) {
$allowed = false;
foreach ( (array) $allowed_protocols as $one_protocol ) {
if ( strtolower( $one_protocol ) == $scheme ) {
if ( strtolower( $one_protocol ) === $scheme ) {
$allowed = true;
break;
}

View File

@ -4194,7 +4194,10 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
// On updates, we need to check to see if it's using the old, fixed sanitization context.
$check_name = sanitize_title( $post_name, '', 'old-save' );
if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_id ) == $check_name ) {
if ( $update
&& strtolower( urlencode( $post_name ) ) === $check_name
&& get_post_field( 'post_name', $post_id ) === $check_name
) {
$post_name = $check_name;
} else { // New post, or slug has changed.
$post_name = sanitize_title( $post_name );

View File

@ -3625,7 +3625,7 @@ function _wp_customize_changeset_filter_insert_post_data( $post_data, $supplied_
function _wp_customize_loader_settings() {
$admin_origin = parse_url( admin_url() );
$home_origin = parse_url( home_url() );
$cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) );
$cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
$browser = array(
'mobile' => wp_is_mobile(),
@ -3690,7 +3690,7 @@ function wp_customize_url( $stylesheet = '' ) {
function wp_customize_support_script() {
$admin_origin = parse_url( admin_url() );
$home_origin = parse_url( home_url() );
$cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) );
$cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
?>
<script<?php echo $type_attr; ?>>

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-55676';
$wp_version = '6.3-alpha-55677';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.