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

@ -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);
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
<p><a href="?mode=view"><?php _e('Detail View') ?></a> | <a href="?mode=edit"><?php _e('List View') ?></a></p>
<?php
@ -147,7 +147,7 @@ if ($comments) {
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
<td style="text-align: center; vertical-align: text-top"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
<td style="vertical-align: text-top">
<?php comment_author_link(); ?><br />
<p><strong class="comment-author"><?php comment_author(); ?></strong><br />
<?php if ( !empty($author_url) ) : ?>
<a href="<?php echo $author_url ?>"><?php echo $author_url; ?></a> |
<?php endif; ?>

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
*