From f17505ed9f8b6f036ecc05c38637eb02e2405eea Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 18 Feb 2010 20:01:10 +0000 Subject: [PATCH] Don't include internal post types in the total. see #9674 git-svn-id: https://develop.svn.wordpress.org/trunk@13198 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/edit.php | 7 ++++++- wp-includes/post.php | 5 ++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 283cced418..9df8117fce 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -228,7 +228,12 @@ if ( $user_posts ) { $allposts = '&all_posts=1'; } -$total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; +$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; + $class = empty($class) && empty($_GET['post_status']) ? ' class="current"' : ''; $status_links[] = "
  • " . sprintf( _nx( 'All (%s)', 'All (%s)', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . ''; diff --git a/wp-includes/post.php b/wp-includes/post.php index a519103afd..b51ba49f54 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1425,10 +1425,9 @@ function wp_count_posts( $type = 'post', $perm = '' ) { $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); - $stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0, 'trash' => 0 ); - foreach( (array) $count as $row_num => $row ) { + $stats = array_fill_keys( get_post_stati(), 0); + foreach ( (array) $count as $row_num => $row ) $stats[$row['post_status']] = $row['num_posts']; - } $stats = (object) $stats; wp_cache_set($cache_key, $stats, 'counts');