WordPress.org

Make WordPress Core

Changeset 7714


Ignore:
Timestamp:
04/16/2008 11:45:39 PM (10 years ago)
Author:
ryan
Message:

Cache comment count and use count API in menu.php

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/menu.php

    r7618 r7714  
    2121    $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
    2222
    23 $awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
     23$awaiting_mod = wp_count_comments();
     24$awaiting_mod = $awaiting_mod->moderated;
    2425$menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
    2526$menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='count-$awaiting_mod'><span class='comment-count'>$awaiting_mod</span></span>" ), 'edit_posts', 'edit-comments.php');
  • trunk/wp-includes/comment.php

    r7690 r7714  
    452452    global $wpdb;
    453453
     454    $count = wp_cache_get('comments', 'counts');
     455
     456    if ( false !== $count )
     457        return $count;
     458
    454459    $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} GROUP BY comment_approved", ARRAY_A );
    455460
     
    465470    }
    466471
    467     return (object) $stats;
     472    $stats = (object) $stats;
     473    wp_cache_set('comments', $stats, 'counts');
     474
     475    return $stats;
    468476}
    469477
Note: See TracChangeset for help on using the changeset viewer.