Changeset 64245
- Timestamp:
- 10/08/2026 10:44:53 PM (5 weeks ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
-
src/wp-includes/post.php (modified) (1 diff)
-
tests/phpunit/tests/post/wpCountPosts.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r64235 r64245 3525 3525 } 3526 3526 3527 /** 3528 * Filters the post counts before the query is run. 3529 * 3530 * Returning a non-null value short-circuits wp_count_posts(), skipping both 3531 * the object cache lookup and the database query. This allows the counts to 3532 * be served from another source, such as a value pre-computed in the 3533 * background, when an exact real-time count is not required. 3534 * 3535 * Any registered post status missing from the filtered value are added 3536 * to the result and set to zero. 3537 * 3538 * The returned value is not cached and passed through the 3539 * {@see 'wp_count_posts'} filter. 3540 * 3541 * @since 7.2.0 3542 * 3543 * @param stdClass|null $counts An object containing the post counts by status, 3544 * or null to run the default query. Default null. 3545 * @param string $type Post type. 3546 * @param string $perm The permission to determine if the posts are 'readable' 3547 * by the current user. 3548 */ 3549 $counts = apply_filters( 'pre_wp_count_posts', null, $type, $perm ); 3550 3551 if ( null !== $counts ) { 3552 $counts = (object) $counts; 3553 3554 foreach ( get_post_stati() as $status ) { 3555 if ( ! isset( $counts->{$status} ) ) { 3556 $counts->{$status} = 0; 3557 } 3558 } 3559 3560 /** This filter is documented in wp-includes/post.php */ 3561 return apply_filters( 'wp_count_posts', $counts, $type, $perm ); 3562 } 3563 3527 3564 $cache_key = _count_posts_cache_key( $type, $perm ); 3528 3565
Note:
See TracChangeset
for help on using the changeset viewer.