mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Cache comment count and use count API in menu.php
git-svn-id: https://develop.svn.wordpress.org/trunk@7714 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -451,6 +451,11 @@ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_age
|
||||
function wp_count_comments() {
|
||||
global $wpdb;
|
||||
|
||||
$count = wp_cache_get('comments', 'counts');
|
||||
|
||||
if ( false !== $count )
|
||||
return $count;
|
||||
|
||||
$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} GROUP BY comment_approved", ARRAY_A );
|
||||
|
||||
$stats = array( );
|
||||
@@ -464,7 +469,10 @@ function wp_count_comments() {
|
||||
$stats[$key] = 0;
|
||||
}
|
||||
|
||||
return (object) $stats;
|
||||
$stats = (object) $stats;
|
||||
wp_cache_set('comments', $stats, 'counts');
|
||||
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user