From a4040ea9285f1f01dc63111acae81d33acce3c54 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 23 Sep 2013 19:08:09 +0000 Subject: [PATCH] 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 --- wp-includes/post.php | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 1d305de18d..4130ffaf1e 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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 ); } /**