- $i = 0;
- foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
- $comment = (int) $comment;
- $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
- $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
- if ( current_user_can('edit_post', $post_id) ) :
- wp_set_comment_status($comment, "delete");
- ++$i;
- endif;
- endforeach;
- echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
-endif;
-
-if (isset($_GET['s'])) {
- $s = $wpdb->escape($_GET['s']);
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
- (comment_author LIKE '%$s%' OR
- comment_author_email LIKE '%$s%' OR
- comment_author_url LIKE ('%$s%') OR
- comment_author_IP LIKE ('%$s%') OR
- comment_content LIKE ('%$s%') ) AND
- comment_approved != 'spam'
- ORDER BY comment_date DESC");
-} else {
- if ( isset($_GET['offset']) )
- $offset = (int) $_GET['offset'] * 20;
+ if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
+ if ( $approved > 0 )
+ $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
+
+ if ( $spammed > 0 ) {
+ $ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
+ $messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
+ }
+
+ if ( $unspammed > 0 )
+ $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
+
+ if ( $trashed > 0 ) {
+ $ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
+ $messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
+ }
+
+ if ( $untrashed > 0 )
+ $messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed );
+
+ if ( $deleted > 0 )
+ $messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
+
+ if ( $same > 0 && $comment = get_comment( $same ) ) {
+ switch ( $comment->comment_approved ) {
+ case '1' :
+ $messages[] = __('This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
+ break;
+ case 'trash' :
+ $messages[] = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>';
+ break;
+ case 'spam' :
+ $messages[] = __( 'This comment is already marked as spam.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
+ break;
+ }
+ }
+
+ echo '<div id="moderated" class="updated"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
+ }
+}
+?>
+
+<form id="comments-form" action="" method="get">
+<ul class="subsubsub">
+<?php
+$status_links = array();
+$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
+//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
+//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
+$stati = array(
+ 'all' => _nx_noop('All', 'All', 'comments'), // singular not used
+ 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'),
+ 'approved' => _n_noop('Approved', 'Approved'), // singular not used
+ 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'),
+ 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')
+ );
+
+if ( !EMPTY_TRASH_DAYS )
+ unset($stati['trash']);
+
+$link = 'edit-comments.php';
+if ( !empty($comment_type) && 'all' != $comment_type )
+ $link = add_query_arg( 'comment_type', $comment_type, $link );
+
+foreach ( $stati as $status => $label ) {
+ $class = ( $status == $comment_status ) ? ' class="current"' : '';
+
+ if ( !isset( $num_comments->$status ) )
+ $num_comments->$status = 10;
+ $link = add_query_arg( 'comment_status', $status, $link );
+ if ( $post_id )
+ $link = add_query_arg( 'p', absint( $post_id ), $link );
+ /*
+ // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
+ if ( !empty( $_GET['s'] ) )
+ $link = add_query_arg( 's', esc_attr( stripslashes( $_GET['s'] ) ), $link );
+ */
+ if ( isset( $label[2] ) )
+ $translated_label = _nx( $label[0], $label[1], $num_comments->$status, $label[2] );