WordPress.org

Make WordPress Core

Changeset 34667


Ignore:
Timestamp:
09/28/2015 07:14:56 PM (4 years ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r34584 r34667  
    8181        $post_type_object = get_post_type_object( $post_type );
    8282
    83         if ( is_multi_author() ) {
    84             $exclude_states   = get_post_stati( array(
    85                 'show_in_admin_all_list' => false,
    86             ) );
    87             $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
    88                 SELECT COUNT( 1 )
    89                 FROM $wpdb->posts
    90                 WHERE post_type = %s
    91                 AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
    92                 AND post_author = %d
    93             ", $post_type, get_current_user_id() ) );
    94         }
     83        $exclude_states   = get_post_stati( array(
     84            'show_in_admin_all_list' => false,
     85        ) );
     86        $this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( "
     87            SELECT COUNT( 1 )
     88            FROM $wpdb->posts
     89            WHERE post_type = %s
     90            AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
     91            AND post_author = %d
     92        ", $post_type, get_current_user_id() ) ) );
    9593
    9694        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'] ) ) {
     
    270268        $all_args = array( 'post_type' => $post_type );
    271269        $mine = '';
     270
     271        // Subtract post types that are not included in the admin all list.
     272        foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
     273            $total_posts -= $num_posts->$state;
     274        }
    272275
    273276        if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) {
     
    296299            $class = '';
    297300        }
    298 
    299         // Subtract post types that are not included in the admin all list.
    300         foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
    301             $total_posts -= $num_posts->$state;
    302301
    303302        if ( empty( $class ) && ( ( $this->is_base_request() && ! $this->user_posts_count ) || isset( $_REQUEST['all_posts'] ) ) ) {
Note: See TracChangeset for help on using the changeset viewer.