From 9271360932537468a30bd6d0e33f1e4265533390 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 28 Sep 2015 19:14:56 +0000 Subject: [PATCH] Correct the logic used when determining whether to display the 'Mine' link on post list tables. It should only be shown when the count for the user's posts differs for the total count of posts. `is_multi_author()` cannot be used because it only considers Posts. Fixes #19609 git-svn-id: https://develop.svn.wordpress.org/trunk@34667 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-posts-list-table.php | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index 02cd5ec9ed..2b4938f38e 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -80,18 +80,16 @@ class WP_Posts_List_Table extends WP_List_Table { $post_type = $this->screen->post_type; $post_type_object = get_post_type_object( $post_type ); - if ( is_multi_author() ) { - $exclude_states = get_post_stati( array( - 'show_in_admin_all_list' => false, - ) ); - $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " - SELECT COUNT( 1 ) - FROM $wpdb->posts - WHERE post_type = %s - AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) - AND post_author = %d - ", $post_type, get_current_user_id() ) ); - } + $exclude_states = get_post_stati( array( + 'show_in_admin_all_list' => false, + ) ); + $this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( " + SELECT COUNT( 1 ) + FROM $wpdb->posts + WHERE post_type = %s + AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) + AND post_author = %d + ", $post_type, get_current_user_id() ) ) ); if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) { $_GET['author'] = get_current_user_id(); @@ -270,6 +268,11 @@ class WP_Posts_List_Table extends WP_List_Table { $all_args = array( 'post_type' => $post_type ); $mine = ''; + // Subtract post types that are not included in the admin all list. + foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { + $total_posts -= $num_posts->$state; + } + if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) { $class = 'current'; @@ -296,10 +299,6 @@ class WP_Posts_List_Table extends WP_List_Table { $class = ''; } - // Subtract post types that are not included in the admin all list. - foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) - $total_posts -= $num_posts->$state; - if ( empty( $class ) && ( ( $this->is_base_request() && ! $this->user_posts_count ) || isset( $_REQUEST['all_posts'] ) ) ) { $class = 'current'; }