From b3745318f49346797ed1a0ac6daaaba3d93ae476 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 5 Dec 2008 23:40:09 +0000 Subject: [PATCH] Allow plugins to hook in a custom comment counter git-svn-id: http://svn.automattic.com/wordpress/trunk@10078 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index 90b8a7b85..b2785db42 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -676,6 +676,10 @@ function wp_count_comments( $post_id = 0 ) { $post_id = (int) $post_id; + $stats = apply_filters('wp_count_comments', array(), $post_id); + if ( !empty($stats) ) + return $stats; + $count = wp_cache_get("comments-{$post_id}", 'counts'); if ( false !== $count ) @@ -688,7 +692,6 @@ function wp_count_comments( $post_id = 0 ) { $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); $total = 0; - $stats = array( ); $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam'); foreach( (array) $count as $row_num => $row ) { $total += $row['num_comments'];