3 require_once './admin.php';
5 $title = __( 'Moderate Comments' );
6 $parent_file = 'edit-comments.php';
8 wp_enqueue_script( 'admin-comments' );
10 wp_reset_vars( array( 'action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky' ) );
14 if ( isset( $_POST['comment'] ) && is_array( $_POST['comment'] ) ) {
15 foreach ( $_POST['comment'] as $k => $v ) {
16 $comment[intval( $k )] = $v;
20 if ( $action == 'update' ) {
21 check_admin_referer( 'moderate-comments' );
23 if ( !current_user_can( 'moderate_comments' ) ) {
24 wp_die( __( 'Your level is not high enough to moderate comments.' ) );
32 foreach ( $comment as $k => $v ) {
33 if ( $feelinglucky && $v == 'later' ) {
43 wp_set_comment_status( $k, 'delete' );
48 wp_set_comment_status( $k, 'spam' );
53 wp_set_comment_status( $k, 'approve' );
55 if ( get_option( 'comments_notify' ) == true ) {
56 wp_notify_postauthor( $k );
64 wp_redirect( basename( __FILE__ ) . '?ignored=' . $item_ignored . '&deleted=' . $item_deleted . '&approved=' . $item_approved . '&spam=' . $item_spam );
68 require_once './admin-header.php';
70 if ( !current_user_can( 'moderate_comments' ) ) {
71 echo '<div class="wrap"><p>' . __( 'Your level is not high enough to moderate comments.' ) . '</p></div>';
72 include_once './admin-footer.php';
76 if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
77 $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
78 $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
79 $spam = isset( $_GET['ignored'] ) ? (int) $_GET['spam'] : 0;
81 if ( $approved > 0 || $deleted > 0 || $spam > 0 ) {
82 echo '<div id="moderated" class="updated fade"><p>';
84 if ( $approved > 0 ) {
85 printf( __ngettext( '%s comment approved.', '%s comments approved.', $approved ), $approved );
90 printf( __ngettext( '%s comment deleted', '%s comments deleted.', $deleted ), $deleted );
95 printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
107 $comments = $wpdb->get_results( "SELECT * FROM $wpdb->comments WHERE comment_approved = '0'" );
110 echo '<p>' . __( 'Currently there are no comments for you to moderate.' ) . '</p></div>';
111 include_once './admin-footer.php';
115 $total = count( $comments );
118 if ( isset( $_GET['paged'] ) ) {
119 $page = (int) $_GET['paged'];
124 $start = ( $page * $per ) - $per;
125 $stop = $start + $per;
127 $page_links = paginate_links( array(
128 'base' => add_query_arg( 'paged', '%#%' ),
130 'total' => ceil( $total / $per ),
132 'prev_text' => '«',
133 'next_text' => '»'
136 $comments = array_slice( $comments, $start, $stop );
139 <h2><?php _e( 'Moderation Queue' ); ?></h2>
143 echo '<p class="pagenav">' . $page_links . '</p>';
147 <form name="approval" id="approval" action="<?php echo basename( __FILE__ ); ?>" method="post">
148 <?php wp_nonce_field( 'moderate-comments' ); ?>
149 <input type="hidden" name="action" value="update" />
150 <ol id="the-comments-list" class="commentlist">
154 foreach ( $comments as $comment ) {
155 $class = 'js-unapproved';
158 $class .= ' alternate';
161 <li id="comment-<?php comment_ID(); ?>" class="<?php echo $class; ?>">
163 <strong><?php comment_author(); ?></strong>
164 <?php if ( !empty( $comment->comment_author_email ) ) { ?>| <?php comment_author_email_link(); ?> <?php } ?>
165 <?php if ( !empty( $comment->comment_author_url ) && $comment->comment_author_url != 'http://' ) { ?>| <?php comment_author_url_link(); ?> <?php } ?>
166 | <?php _e( 'IP:' ); ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP(); ?>"><?php comment_author_IP(); ?></a>
170 <?php comment_text(); ?>
174 <?php comment_date( __( 'M j, g:i A' ) ); ?> —
175 [ <a href="comment.php?action=editcomment&c=<?php comment_ID(); ?>" title="<?php _e( 'Edit this comment' ); ?>"><?php _e( 'Edit' ); ?></a> |
176 <a href="post.php?action=deletecomment&p=<?php echo $comment->comment_post_ID; ?>" title="<?php _e( 'Delete this comment' ); ?>" onclick="return deleteSomething( 'comment', <?php comment_ID(); ?>, '<?php echo js_escape( sprintf( __( "You are about to delete this comment by '%s'.\n'OK' to delete, 'Cancel' to stop." ), get_comment_author() ) ); ?>', theCommentList );"><?php _e( 'Delete' ); ?></a> ] —
177 <a href="<?php echo get_permalink( $comment->comment_post_ID ); ?>" title="<?php _e( 'View the post' ); ?>"><?php printf( __( 'View post “%s”' ), get_the_title( $comment->comment_post_ID ) ); ?></a>
181 <?php _e( 'Bulk action:' ); ?>
182 <label for="comment-<?php comment_ID(); ?>-approve"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-approve" value="approve" /> <?php _e( 'Approve' ); ?></label>
183 <label for="comment-<?php comment_ID(); ?>-spam"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-spam" value="spam" /> <?php _e( 'Spam' ); ?></label>
184 <label for="comment-<?php comment_ID(); ?>-delete"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-delete" value="delete" /> <?php _e( 'Delete' ); ?></label>
185 <label for="comment-<?php comment_ID(); ?>-nothing"><input type="radio" name="comment[<?php comment_ID(); ?>]" id="comment-<?php comment_ID(); ?>-nothing" value="later" checked="checked" /> <?php _e( 'No action' ); ?></label>
195 echo '<p class="pagenav">' . $page_links . '</p>';
199 <div id="ajax-response"></div>
203 <label for="feelinglucky"><input name="feelinglucky" id="feelinglucky" type="checkbox" value="true" /> <?php _e( 'Delete every comment marked “defer.” <strong>Warning: This can’t be undone.</strong>' ); ?></label>
208 <input type="submit" id="submit" name="submit" value="<?php _e( 'Bulk Moderate Comments »' ); ?>" />
211 <script type="text/javascript">
213 function mark_all_as( what ) {
214 for ( var i = 0; i < document.approval.length; i++ ) {
215 if ( document.approval[i].value == what ) {
216 document.approval[i].checked = true;
221 document.write( '<p><strong><?php _e( 'Mark all:' ); ?></strong> <a href="javascript:mark_all_as(\'approve\')"><?php _e( 'Approved' ); ?></a> – <a href="javascript:mark_all_as(\'spam\')"><?php _e( 'Spam' ); ?></a> – <a href="javascript:mark_all_as(\'delete\')"><?php _e( 'Deleted' ); ?></a> – <a href="javascript:mark_all_as(\'later\')"><?php _e( 'Later' ); ?></a></p>' );
226 <?php include_once './admin-footer.php'; ?>