WordPress.org

Make WordPress Core

Changeset 47848


Ignore:
Timestamp:
05/23/2020 11:36:36 AM (7 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison for count() calls.

See #49542.

Location:
trunk/src
Files:
15 edited

Legend:

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

    r47808 r47848  
    199199
    200200    // Make sure we set a valid category.
    201     if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {
     201    if ( ! is_array( $link_category ) || 0 === count( $link_category ) ) {
    202202        $link_category = array( get_option( 'default_link_category' ) );
    203203    }
     
    258258function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
    259259    // If $link_categories isn't already an array, make it one:
    260     if ( ! is_array( $link_categories ) || 0 == count( $link_categories ) ) {
     260    if ( ! is_array( $link_categories ) || 0 === count( $link_categories ) ) {
    261261        $link_categories = array( get_option( 'default_link_category' ) );
    262262    }
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r47808 r47848  
    499499
    500500        // Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
    501         if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
     501        if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
    502502            // Only one folder? Then we want its contents.
    503503            $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
  • trunk/src/wp-admin/includes/deprecated.php

    r47555 r47848  
    13401340        while ( true ) {
    13411341            // Abort this foreach loop iteration if there's no plugins left of this type.
    1342             if ( 0 == count($items) )
     1342            if ( 0 === count($items) )
    13431343                continue 2;
    13441344
  • trunk/src/wp-admin/includes/file.php

    r47808 r47848  
    16281628    }
    16291629
    1630     if ( 0 == count( $archive_files ) ) {
     1630    if ( 0 === count( $archive_files ) ) {
    16311631        return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
    16321632    }
  • trunk/src/wp-admin/includes/menu.php

    r47808 r47848  
    169169     * remove the submenu.
    170170     */
    171     if ( ! empty( $submenu[ $data[2] ] ) && 1 == count( $submenu[ $data[2] ] ) ) {
     171    if ( ! empty( $submenu[ $data[2] ] ) && 1 === count( $submenu[ $data[2] ] ) ) {
    172172        $subs      = $submenu[ $data[2] ];
    173173        $first_sub = reset( $subs );
  • trunk/src/wp-admin/includes/ms.php

    r47808 r47848  
    857857    <h1><?php esc_html_e( 'Users' ); ?></h1>
    858858
    859     <?php if ( 1 == count( $users ) ) : ?>
     859    <?php if ( 1 === count( $users ) ) : ?>
    860860        <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
    861861    <?php else : ?>
     
    975975    do_action( 'delete_user_form', $current_user, $allusers );
    976976
    977     if ( 1 == count( $users ) ) :
     977    if ( 1 === count( $users ) ) :
    978978        ?>
    979979        <p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
  • trunk/src/wp-admin/nav-menus.php

    r47808 r47848  
    424424$locations_screen = ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) ? true : false;
    425425
     426$page_count = wp_count_posts( 'page' );
     427
    426428/*
    427429 * If we have one theme location, and zero menus, we take them right
    428430 * into editing their first menu.
    429431 */
    430 $page_count                  = wp_count_posts( 'page' );
    431 $one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
     432if ( 1 === count( get_registered_nav_menus() ) && ! $add_new_screen
     433    && empty( $nav_menus ) && ! empty( $page_count->publish )
     434) {
     435    $one_theme_location_no_menus = true;
     436} else {
     437    $one_theme_location_no_menus = false;
     438}
    432439
    433440$nav_menus_l10n = array(
     
    929936                                <?php
    930937                                $hide_style = '';
    931                                 if ( isset( $menu_items ) && 0 == count( $menu_items ) ) {
     938                                if ( isset( $menu_items ) && 0 === count( $menu_items ) ) {
    932939                                    $hide_style = 'style="display: none;"';
    933940                                }
  • trunk/src/wp-admin/network.php

    r47808 r47848  
    100100        $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), wp_unslash( $_POST['sitename'] ), $base, $subdomain_install );
    101101        if ( is_wp_error( $result ) ) {
    102             if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) {
     102            if ( 1 === count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) {
    103103                network_step2( $result );
    104104            } else {
  • trunk/src/wp-admin/themes.php

    r47835 r47848  
    286286/*
    287287// Certain error codes are less fatal than others. We can still display theme information in most cases.
    288 if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
     288if ( ! $ct->errors() || ( 1 === count( $ct->errors()->get_error_codes() )
    289289    && in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
    290290*/
  • trunk/src/wp-admin/update-core.php

    r47835 r47848  
    4747    } elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) {
    4848        $updates = get_core_updates();
    49         if ( $updates && 1 == count( $updates ) ) {
     49        if ( $updates && 1 === count( $updates ) ) {
    5050            // If the only available update is a partial builds, it doesn't need a language-specific version string.
    5151            $version_string = $update->current;
  • trunk/src/wp-admin/users.php

    r47557 r47848  
    279279        <?php endif; ?>
    280280
    281         <?php if ( 1 == count( $all_userids ) ) : ?>
     281        <?php if ( 1 === count( $all_userids ) ) : ?>
    282282    <p><?php _e( 'You have specified this user for deletion:' ); ?></p>
    283283        <?php else : ?>
     
    416416<h1><?php _e( 'Remove Users from Site' ); ?></h1>
    417417
    418         <?php if ( 1 == count( $userids ) ) : ?>
     418        <?php if ( 1 === count( $userids ) ) : ?>
    419419    <p><?php _e( 'You have specified this user for removal:' ); ?></p>
    420420        <?php else : ?>
  • trunk/src/wp-includes/class-wp-user.php

    r47808 r47848  
    591591     */
    592592    public function set_role( $role ) {
    593         if ( 1 == count( $this->roles ) && current( $this->roles ) == $role ) {
     593        if ( 1 === count( $this->roles ) && current( $this->roles ) == $role ) {
    594594            return;
    595595        }
  • trunk/src/wp-includes/formatting.php

    r47808 r47848  
    407407        $opening_tag = true;
    408408        $name_offset = 1;
    409     } elseif ( 0 == count( $stack ) ) {
     409    } elseif ( 0 === count( $stack ) ) {
    410410        // Stack is empty. Just stop.
    411411        return;
  • trunk/src/wp-includes/post-template.php

    r47808 r47848  
    10731073    if ( ! isset( $custom[ $key ] ) ) {
    10741074        return false;
    1075     } elseif ( 1 == count( $custom[ $key ] ) ) {
     1075    } elseif ( 1 === count( $custom[ $key ] ) ) {
    10761076        return $custom[ $key ][0];
    10771077    } else {
  • trunk/src/wp-includes/post.php

    r47808 r47848  
    37103710
    37113711    // Make sure we set a valid category.
    3712     if ( empty( $post_category ) || 0 == count( $post_category ) || ! is_array( $post_category ) ) {
     3712    if ( empty( $post_category ) || 0 === count( $post_category ) || ! is_array( $post_category ) ) {
    37133713        // 'post' requires at least one category.
    37143714        if ( 'post' === $post_type && 'auto-draft' !== $post_status ) {
     
    46854685            $post_categories = array();
    46864686        }
    4687     } elseif ( 1 == count( $post_categories ) && '' === reset( $post_categories ) ) {
     4687    } elseif ( 1 === count( $post_categories ) && '' === reset( $post_categories ) ) {
    46884688        return true;
    46894689    }
     
    54405440    }
    54415441
    5442     if ( 1 == count( $post_status ) ) {
     5442    if ( 1 === count( $post_status ) ) {
    54435443        $where_post_type = $wpdb->prepare( 'post_type = %s AND post_status = %s', $parsed_args['post_type'], reset( $post_status ) );
    54445444    } else {
Note: See TracChangeset for help on using the changeset viewer.