From 55ae3f9ea0c7f9fa4f2cca50b0ad237cf135ef6e Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 19 Mar 2015 02:26:26 +0000 Subject: [PATCH] Add `WP_Posts_List_Table::is_base_request()` to determine if the current "view" is the "All" (default) view. Fixes #24869. Built from https://develop.svn.wordpress.org/trunk@31828 git-svn-id: http://core.svn.wordpress.org/trunk@31810 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-posts-list-table.php | 32 +++++++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 022d0293ff..84a163ed4f 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -148,6 +148,21 @@ class WP_Posts_List_Table extends WP_List_Table { echo get_post_type_object( $this->screen->post_type )->labels->not_found; } + /** + * Determine if the current view is the "All" view + * + * @since 4.2.0 + * + * @return boolean + */ + protected function is_base_request() { + if ( empty( $_GET ) ) { + return true; + } elseif ( 1 === count( $_GET ) && ! empty( $_GET['post_type'] ) ) { + return $this->screen->post_type === $_GET['post_type']; + } + } + protected function get_views() { global $locked_post_status, $avail_post_stati; @@ -176,8 +191,21 @@ class WP_Posts_List_Table extends WP_List_Table { foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) $total_posts -= $num_posts->$state; - $class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; - $status_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . ''; + if ( empty( $class ) && $this->is_base_request() ) { + $class = ' class="current"'; + } + + $all_inner_html = sprintf( + _nx( + 'All (%s)', + 'All (%s)', + $total_posts, + 'posts' + ), + number_format_i18n( $total_posts ) + ); + + $status_links['all'] = "" . $all_inner_html . ''; foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { $class = ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index 0067883ab1..44e10e94e3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-beta1-31827'; +$wp_version = '4.2-beta1-31828'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.