Changeset 64589 for trunk/src/wp-includes/post.php
- Timestamp:
- 10/20/2026 05:49:16 AM (30 hours ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/post.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r64583 r64589 3545 3545 * Filters the post counts before the query is run. 3546 3546 * 3547 * Returning a non-null value short-circuits wp_count_posts(), skipping both3548 * the object cache lookup and the database query. This allows the counts to3549 * be served from another source, such as a value pre-computed in the3550 * background, when an exact real-time count is not required.3551 * 3552 * Any registered post status missing from the filtered value areadded3547 * Returning a stdClass object short-circuits wp_count_posts(), skipping 3548 * both the object cache lookup and the database query. This allows the 3549 * counts to be served from another source, such as a value pre-computed in 3550 * the background, when an exact real-time count is not required. 3551 * 3552 * Any registered post status missing from the filtered value is added 3553 3553 * to the result and set to zero. 3554 3554 * … … 3566 3566 $counts = apply_filters( 'pre_wp_count_posts', null, $type, $perm ); 3567 3567 3568 if ( null !== $counts ) {3569 $counts = (object)$counts;3568 if ( $counts instanceof stdClass ) { 3569 $counts = clone $counts; 3570 3570 3571 3571 foreach ( get_post_stati() as $status ) { … … 3669 3669 function wp_count_attachments( $mime_type = '' ) { 3670 3670 global $wpdb; 3671 3672 /** 3673 * Filters the attachment counts before the query is run. 3674 * 3675 * Returning a stdClass object short-circuits wp_count_attachments(), 3676 * skipping both the object cache lookup and the database queries. This 3677 * allows the counts to be served from another source, such as a value 3678 * pre-computed in the background, when an exact real-time count is not 3679 * required. 3680 * 3681 * If the filtered value does not contain a trash count, one is added to the 3682 * result and set to zero. Missing MIME types are not added, as they depend on 3683 * the attachments that exist. The filtered value should therefore contain a 3684 * count for every MIME type matching `$mime_type` that has attachments, 3685 * including types first uploaded after the value was computed, as callers 3686 * may read the count for any MIME type that exists. It should also contain 3687 * only MIME types matching `$mime_type`, with a trash count limited to 3688 * attachments of those types, as the default query does. 3689 * 3690 * The returned value is not cached and passed through the 3691 * {@see 'wp_count_attachments'} filter. 3692 * 3693 * @since 7.2.0 3694 * 3695 * @param stdClass|null $counts An object containing the attachment counts by 3696 * mime type, or null to run the default query. 3697 * Default null. 3698 * @param string|string[] $mime_type Array or comma-separated list of MIME patterns. 3699 */ 3700 $counts = apply_filters( 'pre_wp_count_attachments', null, $mime_type ); 3701 3702 if ( $counts instanceof stdClass ) { 3703 $counts = clone $counts; 3704 3705 if ( ! isset( $counts->trash ) ) { 3706 $counts->trash = 0; 3707 } 3708 3709 /** This filter is documented in wp-includes/post.php */ 3710 return apply_filters( 'wp_count_attachments', $counts, $mime_type ); 3711 } 3671 3712 3672 3713 $cache_key = sprintf(
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)