From b9751d4efeb03bfe9bd8f537b2d7524d24ffd7dc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 23 May 2020 11:38:08 +0000 Subject: [PATCH] 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 --- wp-admin/includes/bookmark.php | 4 ++-- wp-admin/includes/class-wp-upgrader.php | 2 +- wp-admin/includes/deprecated.php | 2 +- wp-admin/includes/file.php | 2 +- wp-admin/includes/menu.php | 2 +- wp-admin/includes/ms.php | 4 ++-- wp-admin/nav-menus.php | 13 ++++++++++--- wp-admin/network.php | 2 +- wp-admin/themes.php | 2 +- wp-admin/update-core.php | 2 +- wp-admin/users.php | 4 ++-- wp-includes/class-wp-user.php | 2 +- wp-includes/formatting.php | 2 +- wp-includes/post-template.php | 2 +- wp-includes/post.php | 6 +++--- wp-includes/version.php | 2 +- 16 files changed, 30 insertions(+), 23 deletions(-) diff --git a/wp-admin/includes/bookmark.php b/wp-admin/includes/bookmark.php index 124f9cf698..b66513e362 100644 --- a/wp-admin/includes/bookmark.php +++ b/wp-admin/includes/bookmark.php @@ -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' ) ); } diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 902b160de3..8c85c99fb9 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -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 ) { diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php index c37d7f5537..89d7eec437 100644 --- a/wp-admin/includes/deprecated.php +++ b/wp-admin/includes/deprecated.php @@ -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); diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index fb31e5aa6b..9a0f93bac4 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -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.' ) ); } diff --git a/wp-admin/includes/menu.php b/wp-admin/includes/menu.php index d3a09a36c3..7323443949 100644 --- a/wp-admin/includes/menu.php +++ b/wp-admin/includes/menu.php @@ -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] ) { diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index aaffbd2266..bd5462182e 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -856,7 +856,7 @@ function confirm_delete_users( $users ) { ?>

- +

@@ -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 ) ) : ?>

diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index f1a45022d5..65861ed900 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -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'; 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 ); diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 6ee6b14462..5ea32017c3 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -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' ) ) ) ) : ?> */ diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index aa2f91c37d..9ff14eb601 100644 --- a/wp-admin/update-core.php +++ b/wp-admin/update-core.php @@ -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; } diff --git a/wp-admin/users.php b/wp-admin/users.php index 04164d7179..7f85cc7c4d 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -278,7 +278,7 @@ switch ( $wp_list_table->current_action() ) { - +

@@ -415,7 +415,7 @@ switch ( $wp_list_table->current_action() ) {

- +

diff --git a/wp-includes/class-wp-user.php b/wp-includes/class-wp-user.php index abb56b05a0..ffbd63d220 100644 --- a/wp-includes/class-wp-user.php +++ b/wp-includes/class-wp-user.php @@ -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; } diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 7b79a6863a..027d88ffeb 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -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 { diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 5f65b6c6f6..bac6a507bc 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -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 ]; diff --git a/wp-includes/post.php b/wp-includes/post.php index a1eefc2e33..570bb6590b 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index a2ae5d83b1..1d5be769f0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.