Make WordPress Core

Ticket #29870: 29870.2.diff

File 29870.2.diff, 1.9 KB (added by wonderboymusic, 10 years ago)
  • src/wp-admin/includes/class-wp-posts-list-table.php

     
    131131
    132132                $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] );
    133133
    134                 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
    135 
    136134                $post_type = $this->screen->post_type;
    137135                $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
    138136
     
    139137                /** This filter is documented in wp-admin/includes/post.php */
    140138                $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
    141139
    142                 if ( $this->hierarchical_display )
    143                         $total_pages = ceil( $total_items / $per_page );
    144                 else
    145                         $total_pages = $wp_query->max_num_pages;
     140                if ( $this->hierarchical_display ) {
     141                        $total_items = $wp_query->post_count;
     142                } else {
     143                        $post_counts = (array) wp_count_posts( $post_type, 'readable' );
    146144
     145                        if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) {
     146                                $total_items = $post_counts[ $_REQUEST['post_status'] ];
     147                        } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
     148                                $total_items = $this->sticky_posts_count;
     149                        } else {
     150                                $total_items = array_sum( $post_counts );
     151
     152                                // Subtract post types that are not included in the admin all list.
     153                                foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
     154                                        $total_items -= $post_counts[ $state ];
     155                                }
     156                        }
     157                }
     158
     159                $total_pages = ceil( $total_items / $per_page );
     160
    147161                if ( ! empty( $_REQUEST['mode'] ) ) {
    148162                        $mode = $_REQUEST['mode'] == 'excerpt' ? 'excerpt' : 'list';
    149163                        set_user_setting ( 'posts_list_mode', $mode );