Make WordPress Core


Ignore:
Timestamp:
11/09/2021 11:04:41 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in wp-admin/includes/ms.php.

Props davidbaumwald, audrasjb.
Fixes #47422.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ms.php

    r51855 r52086  
    2121    }
    2222
    23     if ( '0' != $file['error'] ) { // There's already an error.
     23    if ( $file['error'] > 0 ) { // There's already an error.
    2424        return $file;
    2525    }
     
    4646    }
    4747
    48     if ( '0' != $file['error'] && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
     48    if ( $file['error'] > 0 && ! isset( $_POST['html-upload'] ) && ! wp_doing_ajax() ) {
    4949        wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
    5050    }
     
    6767    global $wpdb;
    6868
     69    $blog_id = (int) $blog_id;
     70
    6971    $switch = false;
    70     if ( get_current_blog_id() != $blog_id ) {
     72    if ( get_current_blog_id() !== $blog_id ) {
    7173        $switch = true;
    7274        switch_to_blog( $blog_id );
     
    8385
    8486    // Don't destroy the initial, main, or root blog.
    85     if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_network->path && $blog->domain == $current_network->domain ) ) ) {
     87    if ( $drop
     88        && ( 1 === $blog_id || is_main_site( $blog_id )
     89            || ( $blog->path === $current_network->path && $blog->domain === $current_network->domain ) )
     90    ) {
    8691        $drop = false;
    8792    }
     
    703708    }
    704709
    705     if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
     710    if ( (int) get_site_option( 'wpmu_upgrade_site' ) !== $wp_db_version ) {
    706711        echo "<div class='update-nag notice notice-warning inline'>" . sprintf(
    707712            /* translators: %s: URL to Upgrade Network screen. */
     
    743748    $post_name = $data['post_name'];
    744749    $c         = 0;
     750
    745751    while ( $c < 10 && get_id_from_blogname( $post_name ) ) {
    746752        $post_name .= mt_rand( 1, 10 );
    747         $c ++;
    748     }
    749     if ( $post_name != $data['post_name'] ) {
     753        $c++;
     754    }
     755
     756    if ( $post_name !== $data['post_name'] ) {
    750757        $data['post_name'] = $post_name;
    751758    }
     759
    752760    return $data;
    753761}
     
    770778        <?php
    771779        $all_blogs    = get_blogs_of_user( get_current_user_id() );
    772         $primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
     780        $primary_blog = (int) get_user_meta( get_current_user_id(), 'primary_blog', true );
    773781        if ( count( $all_blogs ) > 1 ) {
    774782            $found = false;
     
    777785                <?php
    778786                foreach ( (array) $all_blogs as $blog ) {
    779                     if ( $primary_blog == $blog->userblog_id ) {
     787                    if ( $blog->userblog_id === $primary_blog ) {
    780788                        $found = true;
    781789                    }
     
    791799                update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
    792800            }
    793         } elseif ( count( $all_blogs ) == 1 ) {
     801        } elseif ( 1 === count( $all_blogs ) ) {
    794802            $blog = reset( $all_blogs );
    795803            echo esc_url( get_home_url( $blog->userblog_id ) );
    796             if ( $primary_blog != $blog->userblog_id ) { // Set the primary blog again if it's out of sync with blog list.
     804            if ( $blog->userblog_id !== $primary_blog ) { // Set the primary blog again if it's out of sync with blog list.
    797805                update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
    798806            }
     
    819827 */
    820828function can_edit_network( $network_id ) {
    821     if ( get_current_network_id() == $network_id ) {
     829    if ( get_current_network_id() === (int) $network_id ) {
    822830        $result = true;
    823831    } else {
     
    879887    $allusers = (array) $_POST['allusers'];
    880888    foreach ( $allusers as $user_id ) {
    881         if ( '' !== $user_id && '0' != $user_id ) {
     889        if ( '' !== $user_id && '0' !== $user_id ) {
    882890            $delete_user = get_userdata( $user_id );
    883891
Note: See TracChangeset for help on using the changeset viewer.