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 = 'delete'; } elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) { $comment_ids = $_REQUEST['delete_comments']; $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2']; } elseif ($_REQUEST['action'] == 'untrash' && isset($_REQUEST['ids'])) { $comment_ids = explode(',', $_REQUEST['ids']); $doaction = 'untrash'; } else wp_redirect($_SERVER['HTTP_REFERER']); $approved = $unapproved = $spammed = $trashed = $untrashed = $deleted = 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 'trash' : wp_trash_comment($comment_id); $trashed++; break; case 'untrash' : wp_untrash_comment($comment_id); $untrashed++; break; case 'delete' : wp_delete_comment($comment_id); $deleted++; break; } } $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&trashed=' . $trashed . '&untrashed=' . $untrashed . '&deleted=' . $deleted . '&ids=' . join(',', $comment_ids); 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', 'trash')) ) $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 ( $trashed > 0 ) {
printf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed );
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
echo ' ' . __('Undo?') . '
';
}
if ( $untrashed > 0 ) {
printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed );
echo '
';
}
if ( $deleted > 0 ) {
printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
echo '
';
}
echo '