From 93f0c00cb7340cd16bf537b40cfabd3460505979 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 23 Feb 2008 08:33:44 +0000 Subject: [PATCH] Manage comments rework. WIP git-svn-id: http://svn.automattic.com/wordpress/trunk@6994 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-comments.php | 8 ++++---- wp-includes/comment.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 4566e30c3..4132a6ed7 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -50,8 +50,8 @@ if ( isset($_GET['comment_status']) ) else $comment_status = ''; $status_links = array(); -$num_posts = wp_count_posts('post'); -$stati = array('moderated' => __('Awaiting Moderation'), 'approved' => __('Approved')); +$num_comments = wp_count_comments(); +$stati = array('moderated' => sprintf(__('Awaiting Moderation (%s)'), $num_comments->moderated), 'approved' => __('Approved')); foreach ( $stati as $status => $label ) { $class = ''; @@ -74,7 +74,7 @@ unset($status_links); -

|

+

|

comment_ID; ?>" class=''> comment_post_ID) ) { ?> -
+


| diff --git a/wp-includes/comment.php b/wp-includes/comment.php index a90f7cb4f..383b03d1a 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -446,6 +446,25 @@ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_age return false; } +function wp_count_comments() { + global $wpdb; + + $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} GROUP BY comment_approved", ARRAY_A ); + + $stats = array( ); + $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam'); + foreach( (array) $count as $row_num => $row ) { + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; + } + + foreach ( $approved as $key ) { + if ( empty($stats[$key]) ) + $stats[$key] = 0; + } + + return (object) $stats; +} + /** * wp_delete_comment() - Removes comment ID and maybe updates post comment count *