Manage comments rework. WIP

git-svn-id: http://svn.automattic.com/wordpress/trunk@6994 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-02-23 08:33:44 +00:00
parent bef4d0e3f1
commit 93f0c00cb7
2 changed files with 23 additions and 4 deletions

View File

@@ -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
*