escape($_REQUEST['comment_status']); $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']); $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" ); $doaction = 'destroy'; } elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) { $comment_ids = $_REQUEST['delete_comments']; $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2']; } else wp_redirect($_SERVER['HTTP_REFERER']); $approved = $unapproved = $spammed = $deleted = $destroyed = 0; foreach ($comment_ids as $comment_id) { // Check the permissions on each $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); if ( !current_user_can('edit_post', $_post_id) ) continue; switch( $doaction ) { case 'approve' : wp_set_comment_status($comment_id, 'approve'); $approved++; break; case 'unapprove' : wp_set_comment_status($comment_id, 'hold'); $unapproved++; break; case 'markspam' : wp_set_comment_status($comment_id, 'spam'); $spammed++; break; case 'delete' : wp_set_comment_status($comment_id, 'delete'); $deleted++; break; case 'destroy' : wp_set_comment_status($comment_id, 'delete'); $destroyed++; break; } } $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&deleted=' . $deleted . '&destroyed=' . $destroyed; if ( $post_id ) $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); if ( isset($_REQUEST['apage']) ) $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to ); if ( !empty($_REQUEST['mode']) ) $redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to); if ( !empty($_REQUEST['comment_status']) ) $redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to); if ( !empty($_REQUEST['s']) ) $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to); wp_redirect( $redirect_to ); } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); exit; } if ( $post_id ) $title = sprintf(__('Edit Comments on “%s”'), wp_html_excerpt(_draft_or_post_title($post_id), 50)); else $title = __('Edit Comments'); require_once('admin-header.php'); $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']); $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'deleted')) ) $comment_status = 'all'; $comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : ''; $search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : ''; $search = esc_attr( $search_dirty ); ?>
';
if ( $approved > 0 ) {
printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
echo '
';
}
if ( $spam > 0 ) {
printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
echo '
';
}
if ( $deleted > 0 ) {
printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
echo '
';
}
if ( $destroyed > 0 ) {
printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed );
echo '
';
}
echo '