Add `WP_Posts_List_Table::is_base_request()` to determine if the current "view" is the "All" (default) view.
Fixes #24869. git-svn-id: https://develop.svn.wordpress.org/trunk@31828 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8d392d4568
commit
c74d9e6d1c
|
@ -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;
|
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() {
|
protected function get_views() {
|
||||||
global $locked_post_status, $avail_post_stati;
|
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 )
|
foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
|
||||||
$total_posts -= $num_posts->$state;
|
$total_posts -= $num_posts->$state;
|
||||||
|
|
||||||
$class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
|
if ( empty( $class ) && $this->is_base_request() ) {
|
||||||
$status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
|
$class = ' class="current"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$all_inner_html = sprintf(
|
||||||
|
_nx(
|
||||||
|
'All <span class="count">(%s)</span>',
|
||||||
|
'All <span class="count">(%s)</span>',
|
||||||
|
$total_posts,
|
||||||
|
'posts'
|
||||||
|
),
|
||||||
|
number_format_i18n( $total_posts )
|
||||||
|
);
|
||||||
|
|
||||||
|
$status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . $all_inner_html . '</a>';
|
||||||
|
|
||||||
foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
|
foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
|
||||||
$class = '';
|
$class = '';
|
||||||
|
|
Loading…
Reference in New Issue