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
1 changed files with 19 additions and 23 deletions

View File

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