Posts List Table: check is_multi_author() before attempting to set ->user_posts_count. Also, don't show "Mine" when the count is the same as "All."

Fixes #19609.

Built from https://develop.svn.wordpress.org/trunk@34584


git-svn-id: http://core.svn.wordpress.org/trunk@34548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-26 06:51:26 +00:00
parent 4389962eb8
commit 75b1dde362
2 changed files with 16 additions and 14 deletions

View File

@ -79,16 +79,19 @@ class WP_Posts_List_Table extends WP_List_Table {
$post_type = $this->screen->post_type;
$post_type_object = get_post_type_object( $post_type );
$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() ) );
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() ) );
}
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();
@ -260,13 +263,14 @@ class WP_Posts_List_Table extends WP_List_Table {
$status_links = array();
$num_posts = wp_count_posts( $post_type, 'readable' );
$total_posts = array_sum( (array) $num_posts );
$class = '';
$current_user_id = get_current_user_id();
$all_args = array( 'post_type' => $post_type );
$mine = '';
if ( $this->user_posts_count ) {
if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) {
if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) {
$class = 'current';
}
@ -292,8 +296,6 @@ class WP_Posts_List_Table extends WP_List_Table {
$class = '';
}
$total_posts = array_sum( (array) $num_posts );
// 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;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34583';
$wp_version = '4.4-alpha-34584';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.