Ticket #16603: 16603.diff
File 16603.diff, 1.4 KB (added by , 12 years ago) |
---|
-
wp-includes/post.php
1989 1989 1990 1990 $user = wp_get_current_user(); 1991 1991 1992 $cache_key = $type;1992 $cache_key = 'posts-' . $type; 1993 1993 1994 1994 $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; 1995 1995 if ( 'readable' == $perm && is_user_logged_in() ) { … … 2001 2001 } 2002 2002 $query .= ' GROUP BY post_status'; 2003 2003 2004 $count = wp_cache_get($cache_key, 'counts');2005 if ( false !== $count )2006 return $count;2004 $counts = wp_cache_get( $cache_key, 'counts' ); 2005 if ( false !== $counts ) 2006 return apply_filters( 'count_posts', $counts, $type, $perm ); 2007 2007 2008 $ count =$wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );2008 $results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 2009 2009 2010 $stats = array(); 2011 foreach ( get_post_stati() as $state ) 2012 $stats[$state] = 0; 2010 $counts = array_fill_keys( get_post_stati(), 0 ); 2013 2011 2014 foreach ( (array) $countas $row )2015 $ stats[$row['post_status']] = $row['num_posts'];2012 foreach ( $results as $row ) 2013 $counts[ $row['post_status'] ] = $row['num_posts']; 2016 2014 2017 $ stats = (object) $stats;2018 wp_cache_set( $cache_key, $stats, 'counts');2015 $counts = (object) $counts; 2016 wp_cache_set( $cache_key, $counts, 'counts' ); 2019 2017 2020 return $stats;2018 return apply_filters( 'count_posts', $counts, $type, $perm ); 2021 2019 } 2022 2020 2023 2021 /**