mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-01 00:27:38 +02:00
Posts, Post Types: Ensure that all post stati are countable in wp_count_posts
.
When `wp_count_posts()` is cached, it does so with all statuses defaulted to 0. The problem is however, if this is called before all plugins have registered their desired statuses, they won't have that default. Fixes #49685. Props obliviousharmony, SergeyBiryukov. Built from https://develop.svn.wordpress.org/trunk@48497 git-svn-id: http://core.svn.wordpress.org/trunk@48259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
69aaab5108
commit
4a237f2d48
@ -2647,6 +2647,13 @@ function wp_count_posts( $type = 'post', $perm = '' ) {
|
|||||||
|
|
||||||
$counts = wp_cache_get( $cache_key, 'counts' );
|
$counts = wp_cache_get( $cache_key, 'counts' );
|
||||||
if ( false !== $counts ) {
|
if ( false !== $counts ) {
|
||||||
|
// We may have cached this before every status was registered.
|
||||||
|
foreach ( get_post_stati() as $status ) {
|
||||||
|
if ( ! isset( $counts->{$status} ) ) {
|
||||||
|
$counts->{$status} = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** This filter is documented in wp-includes/post.php */
|
/** This filter is documented in wp-includes/post.php */
|
||||||
return apply_filters( 'wp_count_posts', $counts, $type, $perm );
|
return apply_filters( 'wp_count_posts', $counts, $type, $perm );
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-beta2-48496';
|
$wp_version = '5.5-beta2-48497';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user