WordPress.org

Make WordPress Core

Ticket #16603: count-posts_3.2.patch

File count-posts_3.2.patch, 641 bytes (added by kevinB, 4 years ago)

filter wp_count_posts() return value

  • wp-includes/post.php

     
    17961796 
    17971797        $count = wp_cache_get($cache_key, 'counts'); 
    17981798        if ( false !== $count ) 
    1799                 return $count; 
     1799                return apply_filters( 'count_posts', $count, $type, $perm ); 
    18001800 
    18011801        $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A ); 
    18021802 
     
    18101810        $stats = (object) $stats; 
    18111811        wp_cache_set($cache_key, $stats, 'counts'); 
    18121812 
    1813         return $stats; 
     1813        return apply_filters( 'count_posts', $stats, $type, $perm ); 
    18141814} 
    18151815 
    18161816