X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/959f97d8ecd5c1668103a3e41c795486b944bc68..4f4e083f6f77639c41e2b1ddb200de8e34301cee:/wp-admin/edit-comments.php diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index bc62681b..7df02103 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -1,36 +1,69 @@ escape( $_REQUEST['pagegen_timestamp'] ); + if ( current_user_can('moderate_comments')) { + $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" ); + } else { + $deleted_spam = 0; + } + $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam; + if ( $post_id ) + $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); + wp_redirect( $redirect_to ); +} elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) { check_admin_referer('bulk-comments'); + $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; + + $deleted = $approved = $unapproved = $spammed = 0; + foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each + $comment_id = (int) $comment_id; + $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); - $comments_deleted = $comments_approved = $comments_unapproved = $comments_spammed = 0; - foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each - $comment = (int) $comment; - $post_id = (int) $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) ) + if ( !current_user_can('edit_post', $_post_id) ) continue; - if ( !empty( $_REQUEST['spamit'] ) ) { - wp_set_comment_status($comment, 'spam'); - $comments_spammed++; - } elseif ( !empty( $_REQUEST['deleteit'] ) ) { - wp_set_comment_status($comment, 'delete'); - $comments_deleted++; - } elseif ( !empty( $_REQUEST['approveit'] ) ) { - wp_set_comment_status($comment, 'approve'); - $comments_approved++; - } elseif ( !empty( $_REQUEST['unapproveit'] ) ) { - wp_set_comment_status($comment, 'hold'); - $comments_unapproved++; + + switch( $doaction ) { + case 'markspam' : + wp_set_comment_status($comment_id, 'spam'); + $spammed++; + break; + case 'delete' : + wp_set_comment_status($comment_id, 'delete'); + $deleted++; + break; + case 'approve' : + wp_set_comment_status($comment_id, 'approve'); + $approved++; + break; + case 'unapprove' : + wp_set_comment_status($comment_id, 'hold'); + $unapproved++; + break; } endforeach; - $redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved; + + $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved; + 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']) ) @@ -38,29 +71,36 @@ if ( !empty( $_REQUEST['delete_comments'] ) ) { if ( !empty($_REQUEST['s']) ) $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to); wp_redirect( $redirect_to ); -} elseif ( !empty($_GET['_wp_http_referer']) ) { - wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); +} 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'); -if ( empty($_GET['mode']) ) - $mode = 'detail'; -else - $mode = attribute_escape($_GET['mode']); +$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']); -if ( isset($_GET['comment_status']) ) - $comment_status = attribute_escape($_GET['comment_status']); -else - $comment_status = ''; +$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; +if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam')) ) + $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 ); ?> + +
+ +

' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( stripslashes( $_GET['s'] ) ), 50 ) ) . '' ); ?> +

-if ( isset($_GET['s']) ) - $search_dirty = $_GET['s']; -else - $search_dirty = ''; -$search = attribute_escape( $search_dirty ); -?>

'; if ( $approved > 0 ) { - printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved ); + printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); echo '
'; } if ( $deleted > 0 ) { - printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); + printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); echo '
'; } if ( $spam > 0 ) { - printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); + printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); echo '
'; } @@ -89,109 +129,184 @@ if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['sp } } ?> -

-
-

+
    sprintf(__ngettext('Awaiting Moderation (%s)', 'Awaiting Moderation (%s)', $num_comments->moderated), "$num_comments->moderated"), 'approved' => _c('Approved|plural')); -$class = ( '' === $comment_status ) ? ' class="current"' : ''; -$status_links[] = "
  • ".__('Show All Comments').""; +$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments(); +//, number_format_i18n($num_comments->moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), +//, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") +$stati = array( + 'all' => _n_noop('All', 'All'), // singular not used + 'moderated' => _n_noop('Pending (%s)', 'Pending (%s)'), + 'approved' => _n_noop('Approved', 'Approved'), // singular not used + 'spam' => _n_noop('Spam (%s)', 'Spam (%s)') + ); +$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 = ''; if ( $status == $comment_status ) $class = ' class="current"'; - - $status_links[] = "
  • " . $label . ''; + 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 ); + */ + $status_links[] = "
  • " . sprintf( + _n( $label[0], $label[1], $num_comments->$status ), + number_format_i18n( $num_comments->$status ) + ) . ''; } $status_links = apply_filters( 'comment_status_links', $status_links ); -echo implode(' |
  • ', $status_links) . ''; +echo implode( " |\n", $status_links) . ''; unset($status_links); ?>
-

- - +

- - -
- - - comment_post_ID; +} +$_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids); +foreach ( (array) $_comment_post_ids as $_cpid ) + $_comment_pending_count[$_cpid] = isset( $_comment_pending_count_temp[$_cpid] ) ? $_comment_pending_count_temp[$_cpid] : 0; +if ( empty($_comment_pending_count) ) + $_comment_pending_count = array(); -$comments = array_slice($_comments, 0, 20); -$extra_comments = array_slice($_comments, 20); +$comments = array_slice($_comments, 0, $comments_per_page); +$extra_comments = array_slice($_comments, $comments_per_page); $page_links = paginate_links( array( 'base' => add_query_arg( 'apage', '%#%' ), 'format' => '', - 'total' => ceil($total / 20), + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => ceil($total / $comments_per_page), 'current' => $page )); ?> -
+ + + + + +
-$page_links
"; -?> + +
' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( $start + 1 ), + number_format_i18n( min( $page * $comments_per_page, $total ) ), + '' . number_format_i18n( $total ) . '', + $page_links +); echo $page_links_text; ?>
+ + + + -
- - +
+ - - + + - - + + + + + + + + + + + + + + + +

-
- - +
+ + +
- - - - - - + + + + + + + + + +
+
+$page_links_text
"; +?> + +
+ + + + + + + +
+ +
+
+
- -

- -

- -

- -

- -
-$page_links
"; -?> -
-
+ +

+ + + +

+ + + - +