In wp_count_posts(), rename 'count_posts' hook to 'wp_count_posts', for clarity. see #16603.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-09-23 19:08:09 +00:00
parent 8f7e73d0cd
commit a4040ea928

View File

@ -2109,31 +2109,27 @@ function wp_count_posts( $type = 'post', $perm = '' ) {
$query .= ' GROUP BY post_status';
$counts = wp_cache_get( $cache_key, 'counts' );
if ( false !== $counts ) {
/**
* Modify returned post counts by status for the current post type.
*
* @since 3.7.0
*
* @param object $counts An object containing the current post_type's post counts by status.
* @param string $type The post type.
* @param string $perm The permission to determine if the posts are 'readable' by the current user.
*/
return apply_filters( 'count_posts', $counts, $type, $perm );
if ( false === $counts ) {
$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
$counts = array_fill_keys( get_post_stati(), 0 );
foreach ( $results as $row )
$counts[ $row['post_status'] ] = $row['num_posts'];
$counts = (object) $counts;
wp_cache_set( $cache_key, $counts, 'counts' );
}
$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
$counts = array_fill_keys( get_post_stati(), 0 );
foreach ( $results as $row )
$counts[ $row['post_status'] ] = $row['num_posts'];
$counts = (object) $counts;
wp_cache_set( $cache_key, $counts, 'counts' );
//duplicate_hook
return apply_filters( 'count_posts', $counts, $type, $perm );
/**
* Modify returned post counts by status for the current post type.
*
* @since 3.7.0
*
* @param object $counts An object containing the current post_type's post counts by status.
* @param string $type The post type.
* @param string $perm The permission to determine if the posts are 'readable' by the current user.
*/
return apply_filters( 'wp_count_posts', $counts, $type, $perm );
}
/**