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

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47848


git-svn-id: http://core.svn.wordpress.org/trunk@47624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-05-23 11:38:08 +00:00
parent e9282e7389
commit b9751d4efe
16 changed files with 30 additions and 23 deletions

View File

@ -198,7 +198,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
$link_category = ( ! empty( $parsed_args['link_category'] ) ) ? $parsed_args['link_category'] : array();
// Make sure we set a valid category.
if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {
if ( ! is_array( $link_category ) || 0 === count( $link_category ) ) {
$link_category = array( get_option( 'default_link_category' ) );
}
@ -257,7 +257,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
*/
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
if ( ! is_array( $link_categories ) || 0 == count( $link_categories ) ) {
if ( ! is_array( $link_categories ) || 0 === count( $link_categories ) ) {
$link_categories = array( get_option( 'default_link_category' ) );
}

View File

@ -498,7 +498,7 @@ class WP_Upgrader {
$remote_destination = $wp_filesystem->find_folder( $local_destination );
// Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
// Only one folder? Then we want its contents.
$source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
} elseif ( count( $source_files ) == 0 ) {

View File

@ -1339,7 +1339,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
// Pick a random, non-installed plugin.
while ( true ) {
// Abort this foreach loop iteration if there's no plugins left of this type.
if ( 0 == count($items) )
if ( 0 === count($items) )
continue 2;
$item_key = array_rand($items);

View File

@ -1627,7 +1627,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), $archive->errorInfo( true ) );
}
if ( 0 == count( $archive_files ) ) {
if ( 0 === count( $archive_files ) ) {
return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
}

View File

@ -168,7 +168,7 @@ foreach ( $menu as $id => $data ) {
* If there is only one submenu and it is has same destination as the parent,
* remove the submenu.
*/
if ( ! empty( $submenu[ $data[2] ] ) && 1 == count( $submenu[ $data[2] ] ) ) {
if ( ! empty( $submenu[ $data[2] ] ) && 1 === count( $submenu[ $data[2] ] ) ) {
$subs = $submenu[ $data[2] ];
$first_sub = reset( $subs );
if ( $data[2] == $first_sub[2] ) {

View File

@ -856,7 +856,7 @@ function confirm_delete_users( $users ) {
?>
<h1><?php esc_html_e( 'Users' ); ?></h1>
<?php if ( 1 == count( $users ) ) : ?>
<?php if ( 1 === count( $users ) ) : ?>
<p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
@ -974,7 +974,7 @@ function confirm_delete_users( $users ) {
/** This action is documented in wp-admin/users.php */
do_action( 'delete_user_form', $current_user, $allusers );
if ( 1 == count( $users ) ) :
if ( 1 === count( $users ) ) :
?>
<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
<?php else : ?>

View File

@ -423,12 +423,19 @@ $add_new_screen = ( isset( $_GET['menu'] ) && 0 == $_GET['menu'] ) ? true : fals
$locations_screen = ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) ? true : false;
$page_count = wp_count_posts( 'page' );
/*
* If we have one theme location, and zero menus, we take them right
* into editing their first menu.
*/
$page_count = wp_count_posts( 'page' );
$one_theme_location_no_menus = ( 1 == count( get_registered_nav_menus() ) && ! $add_new_screen && empty( $nav_menus ) && ! empty( $page_count->publish ) ) ? true : false;
if ( 1 === count( get_registered_nav_menus() ) && ! $add_new_screen
&& empty( $nav_menus ) && ! empty( $page_count->publish )
) {
$one_theme_location_no_menus = true;
} else {
$one_theme_location_no_menus = false;
}
$nav_menus_l10n = array(
'oneThemeLocationNoMenus' => $one_theme_location_no_menus,
@ -928,7 +935,7 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<?php
$hide_style = '';
if ( isset( $menu_items ) && 0 == count( $menu_items ) ) {
if ( isset( $menu_items ) && 0 === count( $menu_items ) ) {
$hide_style = 'style="display: none;"';
}

View File

@ -99,7 +99,7 @@ if ( $_POST ) {
if ( ! network_domain_check() ) {
$result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), wp_unslash( $_POST['sitename'] ), $base, $subdomain_install );
if ( is_wp_error( $result ) ) {
if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) {
if ( 1 === count( $result->get_error_codes() ) && 'no_wildcard_dns' === $result->get_error_code() ) {
network_step2( $result );
} else {
network_step1( $result );

View File

@ -285,7 +285,7 @@ if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_th
/*
// Certain error codes are less fatal than others. We can still display theme information in most cases.
if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
if ( ! $ct->errors() || ( 1 === count( $ct->errors()->get_error_codes() )
&& in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
*/

View File

@ -46,7 +46,7 @@ function list_core_update( $update ) {
$version_string = $update->current;
} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) {
$updates = get_core_updates();
if ( $updates && 1 == count( $updates ) ) {
if ( $updates && 1 === count( $updates ) ) {
// If the only available update is a partial builds, it doesn't need a language-specific version string.
$version_string = $update->current;
}

View File

@ -278,7 +278,7 @@ switch ( $wp_list_table->current_action() ) {
</div>
<?php endif; ?>
<?php if ( 1 == count( $all_userids ) ) : ?>
<?php if ( 1 === count( $all_userids ) ) : ?>
<p><?php _e( 'You have specified this user for deletion:' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have specified these users for deletion:' ); ?></p>
@ -415,7 +415,7 @@ switch ( $wp_list_table->current_action() ) {
<div class="wrap">
<h1><?php _e( 'Remove Users from Site' ); ?></h1>
<?php if ( 1 == count( $userids ) ) : ?>
<?php if ( 1 === count( $userids ) ) : ?>
<p><?php _e( 'You have specified this user for removal:' ); ?></p>
<?php else : ?>
<p><?php _e( 'You have specified these users for removal:' ); ?></p>

View File

@ -590,7 +590,7 @@ class WP_User {
* @param string $role Role name.
*/
public function set_role( $role ) {
if ( 1 == count( $this->roles ) && current( $this->roles ) == $role ) {
if ( 1 === count( $this->roles ) && current( $this->roles ) == $role ) {
return;
}

View File

@ -406,7 +406,7 @@ function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
if ( isset( $text[1] ) && '/' !== $text[1] ) {
$opening_tag = true;
$name_offset = 1;
} elseif ( 0 == count( $stack ) ) {
} elseif ( 0 === count( $stack ) ) {
// Stack is empty. Just stop.
return;
} else {

View File

@ -1072,7 +1072,7 @@ function post_custom( $key = '' ) {
if ( ! isset( $custom[ $key ] ) ) {
return false;
} elseif ( 1 == count( $custom[ $key ] ) ) {
} elseif ( 1 === count( $custom[ $key ] ) ) {
return $custom[ $key ][0];
} else {
return $custom[ $key ];

View File

@ -3709,7 +3709,7 @@ function wp_insert_post( $postarr, $wp_error = false ) {
}
// Make sure we set a valid category.
if ( empty( $post_category ) || 0 == count( $post_category ) || ! is_array( $post_category ) ) {
if ( empty( $post_category ) || 0 === count( $post_category ) || ! is_array( $post_category ) ) {
// 'post' requires at least one category.
if ( 'post' === $post_type && 'auto-draft' !== $post_status ) {
$post_category = array( get_option( 'default_category' ) );
@ -4684,7 +4684,7 @@ function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $appe
} else {
$post_categories = array();
}
} elseif ( 1 == count( $post_categories ) && '' === reset( $post_categories ) ) {
} elseif ( 1 === count( $post_categories ) && '' === reset( $post_categories ) ) {
return true;
}
@ -5439,7 +5439,7 @@ function get_pages( $args = array() ) {
$where .= $wpdb->prepare( ' AND post_parent = %d ', $parent );
}
if ( 1 == count( $post_status ) ) {
if ( 1 === count( $post_status ) ) {
$where_post_type = $wpdb->prepare( 'post_type = %s AND post_status = %s', $parsed_args['post_type'], reset( $post_status ) );
} else {
$post_status = implode( "', '", $post_status );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-47846';
$wp_version = '5.5-alpha-47848';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.