From 2ddc438111a6d70b439944bcfea470d666186faa Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 06:05:39 +0000 Subject: [PATCH] List Tables: when comparing string literals (non-numeric in nature) against vars, strict comparison can/should be used. Props wonderboymusic, Viper007Bond. Fixes #21249. git-svn-id: https://develop.svn.wordpress.org/trunk@34383 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-comments-list-table.php | 42 ++++++++-------- src/wp-admin/includes/class-wp-list-table.php | 28 ++++++----- .../includes/class-wp-media-list-table.php | 20 ++++---- .../includes/class-wp-ms-sites-list-table.php | 20 ++++---- .../class-wp-ms-themes-list-table.php | 13 ++--- .../includes/class-wp-ms-users-list-table.php | 11 ++-- .../class-wp-plugin-install-list-table.php | 9 ++-- .../includes/class-wp-plugins-list-table.php | 18 +++---- .../includes/class-wp-posts-list-table.php | 50 +++++++++---------- .../includes/class-wp-terms-list-table.php | 10 ++-- .../class-wp-theme-install-list-table.php | 4 +- .../includes/class-wp-users-list-table.php | 4 +- 12 files changed, 118 insertions(+), 111 deletions(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 67109d71d2..9259017dbc 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -183,10 +183,11 @@ class WP_Comments_List_Table extends WP_List_Table { public function no_items() { global $comment_status; - if ( 'moderated' == $comment_status ) + if ( 'moderated' === $comment_status ) { _e( 'No comments awaiting moderation.' ); - else + } else { _e( 'No comments found.' ); + } } /** @@ -218,7 +219,7 @@ class WP_Comments_List_Table extends WP_List_Table { $link = add_query_arg( 'comment_type', $comment_type, $link ); foreach ( $stati as $status => $label ) { - $class = ( $status == $comment_status ) ? ' class="current"' : ''; + $class = ( $status === $comment_status ) ? ' class="current"' : ''; if ( !isset( $num_comments->$status ) ) $num_comments->$status = 10; @@ -264,10 +265,11 @@ class WP_Comments_List_Table extends WP_List_Table { if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) ) $actions['spam'] = _x( 'Mark as Spam', 'comment' ); - if ( 'trash' == $comment_status ) + if ( 'trash' === $comment_status ) { $actions['untrash'] = __( 'Restore' ); - elseif ( 'spam' == $comment_status ) + } elseif ( 'spam' === $comment_status ) { $actions['unspam'] = _x( 'Not Spam', 'comment' ); + } if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS ) $actions['delete'] = __( 'Delete Permanently' ); @@ -289,7 +291,7 @@ class WP_Comments_List_Table extends WP_List_Table { ?>
+ @@ -1442,7 +1442,7 @@ class WP_Posts_List_Table extends WP_List_Table { post_type ) : + if ( 'page' === $screen->post_type ) : ?> - post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> + post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index a64728c620..2acbfcffc1 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -69,7 +69,7 @@ class WP_Terms_List_Table extends WP_List_Table { public function prepare_items() { $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); - if ( 'post_tag' == $this->screen->taxonomy ) { + if ( 'post_tag' === $this->screen->taxonomy ) { /** * Filter the number of terms displayed per page for the Tags list table. * @@ -88,7 +88,7 @@ class WP_Terms_List_Table extends WP_List_Table { * @param int $tags_per_page Number of tags to be displayed. Default 20. */ $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); - } elseif ( 'category' == $this->screen->taxonomy ) { + } elseif ( 'category' === $this->screen->taxonomy ) { /** * Filter the number of terms displayed per page for the Categories list table. * @@ -153,7 +153,7 @@ class WP_Terms_List_Table extends WP_List_Table { * @return string */ public function current_action() { - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) + if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) return 'bulk-delete'; return parent::current_action(); @@ -171,7 +171,7 @@ class WP_Terms_List_Table extends WP_List_Table { 'slug' => __( 'Slug' ), ); - if ( 'link_category' == $this->screen->taxonomy ) { + if ( 'link_category' === $this->screen->taxonomy ) { $columns['links'] = __( 'Links' ); } else { $columns['posts'] = _x( 'Count', 'Number/count of items' ); @@ -496,7 +496,7 @@ class WP_Terms_List_Table extends WP_List_Table { if ( 'post' != $this->screen->post_type ) $args['post_type'] = $this->screen->post_type; - if ( 'attachment' == $this->screen->post_type ) + if ( 'attachment' === $this->screen->post_type ) return "$count"; return "$count"; diff --git a/src/wp-admin/includes/class-wp-theme-install-list-table.php b/src/wp-admin/includes/class-wp-theme-install-list-table.php index 427c539148..63b11051f5 100644 --- a/src/wp-admin/includes/class-wp-theme-install-list-table.php +++ b/src/wp-admin/includes/class-wp-theme-install-list-table.php @@ -50,7 +50,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table { // These are the tabs which are shown on the page, $tabs = array(); $tabs['dashboard'] = __( 'Search' ); - if ( 'search' == $tab ) + if ( 'search' === $tab ) $tabs['search'] = __( 'Search Results' ); $tabs['upload'] = __( 'Upload' ); $tabs['featured'] = _x( 'Featured', 'themes' ); @@ -163,7 +163,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table { $display_tabs = array(); foreach ( (array) $tabs as $action => $text ) { - $class = ( $action == $tab ) ? ' class="current"' : ''; + $class = ( $action === $tab ) ? ' class="current"' : ''; $href = self_admin_url('theme-install.php?tab=' . $action); $display_tabs['theme-install-'.$action] = "$text"; } diff --git a/src/wp-admin/includes/class-wp-users-list-table.php b/src/wp-admin/includes/class-wp-users-list-table.php index c70db838f3..21f6387133 100644 --- a/src/wp-admin/includes/class-wp-users-list-table.php +++ b/src/wp-admin/includes/class-wp-users-list-table.php @@ -45,7 +45,7 @@ class WP_Users_List_Table extends WP_List_Table { 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, ) ); - $this->is_site_users = 'site-users-network' == $this->screen->id; + $this->is_site_users = 'site-users-network' === $this->screen->id; if ( $this->is_site_users ) $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; @@ -169,7 +169,7 @@ class WP_Users_List_Table extends WP_List_Table { $class = ''; - if ( $this_role == $role ) { + if ( $this_role === $role ) { $class = ' class="current"'; }