2003-10-27 02:09:25 -05:00
|
|
|
<?php
|
2008-08-16 03:27:34 -04:00
|
|
|
/**
|
|
|
|
* Edit Comments Administration Panel.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** WordPress Administration Bootstrap */
|
2004-10-18 23:03:06 -04:00
|
|
|
require_once('admin.php');
|
2004-04-22 23:23:05 -04:00
|
|
|
|
2006-11-18 02:31:29 -05:00
|
|
|
$title = __('Edit Comments');
|
2006-05-22 13:16:05 -04:00
|
|
|
wp_enqueue_script( 'admin-comments' );
|
2008-08-24 02:56:22 -04:00
|
|
|
wp_enqueue_script( 'admin-forms' );
|
2008-08-29 17:43:34 -04:00
|
|
|
wp_enqueue_script( 'jquery-table-hotkeys' );
|
2004-08-22 19:24:50 -04:00
|
|
|
|
2008-09-08 17:49:26 -04:00
|
|
|
if ( isset( $_POST['delete_all_spam'] ) ) {
|
|
|
|
check_admin_referer('bulk-spam-delete');
|
|
|
|
|
|
|
|
$deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'" );
|
|
|
|
wp_redirect('edit-comments.php?deleted=' . (int) $deleted_spam);
|
|
|
|
}
|
|
|
|
|
2008-08-20 00:06:36 -04:00
|
|
|
if ( !empty( $_REQUEST['delete_comments'] ) && isset($_REQUEST['action']) ) {
|
2006-05-02 18:36:06 -04:00
|
|
|
check_admin_referer('bulk-comments');
|
2006-03-30 18:12:54 -05:00
|
|
|
|
2008-03-02 15:17:30 -05:00
|
|
|
$comments_deleted = $comments_approved = $comments_unapproved = $comments_spammed = 0;
|
2008-02-23 21:33:30 -05:00
|
|
|
foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each
|
2004-07-07 21:10:50 -04:00
|
|
|
$comment = (int) $comment;
|
2008-04-14 12:13:25 -04:00
|
|
|
$post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment) );
|
2008-02-23 21:33:30 -05:00
|
|
|
if ( !current_user_can('edit_post', $post_id) )
|
|
|
|
continue;
|
2008-08-20 00:06:36 -04:00
|
|
|
if ( $_REQUEST['action'] == 'markspam' ) {
|
2008-02-23 21:33:30 -05:00
|
|
|
wp_set_comment_status($comment, 'spam');
|
|
|
|
$comments_spammed++;
|
2008-08-20 00:06:36 -04:00
|
|
|
} elseif ( $_REQUEST['action'] == 'delete' ) {
|
2008-02-23 21:33:30 -05:00
|
|
|
wp_set_comment_status($comment, 'delete');
|
|
|
|
$comments_deleted++;
|
2008-08-20 00:06:36 -04:00
|
|
|
} elseif ( $_REQUEST['action'] == 'approve' ) {
|
2008-02-23 21:33:30 -05:00
|
|
|
wp_set_comment_status($comment, 'approve');
|
|
|
|
$comments_approved++;
|
2008-08-20 00:06:36 -04:00
|
|
|
} elseif ( $_REQUEST['action'] == 'unapprove' ) {
|
2008-02-28 02:04:52 -05:00
|
|
|
wp_set_comment_status($comment, 'hold');
|
|
|
|
$comments_unapproved++;
|
2006-02-14 15:09:13 -05:00
|
|
|
}
|
2004-07-07 21:10:50 -04:00
|
|
|
endforeach;
|
2008-02-28 02:04:52 -05:00
|
|
|
$redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved;
|
2008-07-25 23:51:39 -04:00
|
|
|
if ( isset($_REQUEST['apage']) )
|
|
|
|
$redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
|
2008-02-24 15:28:36 -05:00
|
|
|
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 ( !empty($_GET['_wp_http_referer']) ) {
|
|
|
|
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
|
2008-03-02 15:17:30 -05:00
|
|
|
exit;
|
2008-02-24 15:28:36 -05:00
|
|
|
}
|
2004-02-17 05:50:33 -05:00
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
require_once('admin-header.php');
|
2008-02-23 23:51:47 -05:00
|
|
|
|
2008-08-24 02:56:22 -04:00
|
|
|
$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : attribute_escape($_GET['mode']);
|
2008-02-24 15:28:36 -05:00
|
|
|
|
2008-08-24 02:56:22 -04:00
|
|
|
$comment_status = isset($_GET['comment_status']) ? attribute_escape($_GET['comment_status']) : '';
|
2008-02-28 01:50:25 -05:00
|
|
|
|
2008-08-24 02:56:22 -04:00
|
|
|
$search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
|
2008-03-20 16:28:17 -04:00
|
|
|
$search = attribute_escape( $search_dirty );
|
2008-02-23 03:01:51 -05:00
|
|
|
?>
|
2008-09-08 17:49:26 -04:00
|
|
|
|
2008-09-11 14:54:05 -04:00
|
|
|
<form class="search-form" action="" method="get">
|
|
|
|
<p id="comment-search" class="search-box">
|
|
|
|
<label class="hidden" for="comment-search-input"><?php _e( 'Search Comments' ); ?></label>
|
|
|
|
<input type="text" id="comment-search-input" class="search-input" name="s" value="<?php the_search_query(); ?>" />
|
|
|
|
<input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
|
|
|
|
</p>
|
|
|
|
</form>
|
|
|
|
|
2008-02-23 21:33:30 -05:00
|
|
|
<?php
|
|
|
|
if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
|
|
|
|
$approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
|
|
|
|
$deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
|
|
|
|
$spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0;
|
|
|
|
|
|
|
|
if ( $approved > 0 || $deleted > 0 || $spam > 0 ) {
|
|
|
|
echo '<div id="moderated" class="updated fade"><p>';
|
|
|
|
|
|
|
|
if ( $approved > 0 ) {
|
|
|
|
printf( __ngettext( '%s comment approved', '%s comments approved', $approved ), $approved );
|
|
|
|
echo '<br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $deleted > 0 ) {
|
|
|
|
printf( __ngettext( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
|
|
|
|
echo '<br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $spam > 0 ) {
|
|
|
|
printf( __ngettext( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
|
|
|
|
echo '<br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '</p></div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2008-02-24 19:28:21 -05:00
|
|
|
<div class="wrap">
|
|
|
|
<form id="posts-filter" action="" method="get">
|
|
|
|
<h2><?php _e('Manage Comments'); ?></h2>
|
|
|
|
|
|
|
|
<ul class="subsubsub">
|
|
|
|
<?php
|
|
|
|
$status_links = array();
|
|
|
|
$num_comments = wp_count_comments();
|
2008-08-20 00:06:36 -04:00
|
|
|
$stati = array(
|
|
|
|
'moderated' => sprintf(__ngettext('Awaiting Moderation (%s)', 'Awaiting Moderation (%s)', number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
|
|
|
|
'approved' => _c('Approved|plural'),
|
|
|
|
'spam' => sprintf(__ngettext('Spam (%s)', 'Spam (%s)', number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
|
|
|
|
);
|
2008-03-06 05:23:00 -05:00
|
|
|
$class = ( '' === $comment_status ) ? ' class="current"' : '';
|
2008-03-07 05:05:54 -05:00
|
|
|
$status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>";
|
2008-02-24 19:28:21 -05:00
|
|
|
foreach ( $stati as $status => $label ) {
|
|
|
|
$class = '';
|
|
|
|
|
|
|
|
if ( $status == $comment_status )
|
|
|
|
$class = ' class="current"';
|
|
|
|
|
2008-08-20 00:06:36 -04:00
|
|
|
$status_links[] = "<li class='$status'><a href=\"edit-comments.php?comment_status=$status\"$class>$label</a>";
|
2008-02-24 19:28:21 -05:00
|
|
|
}
|
2008-03-11 03:23:07 -04:00
|
|
|
|
|
|
|
$status_links = apply_filters( 'comment_status_links', $status_links );
|
|
|
|
|
2008-02-24 19:28:21 -05:00
|
|
|
echo implode(' | </li>', $status_links) . '</li>';
|
|
|
|
unset($status_links);
|
|
|
|
?>
|
|
|
|
</ul>
|
2008-02-23 21:33:30 -05:00
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
|
2008-02-24 15:28:36 -05:00
|
|
|
<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
|
2008-02-28 01:50:25 -05:00
|
|
|
</form>
|
2008-02-23 03:01:51 -05:00
|
|
|
|
2008-08-20 00:06:36 -04:00
|
|
|
<!-- crazyhorse
|
2008-02-24 14:41:04 -05:00
|
|
|
<ul class="view-switch">
|
2008-02-24 15:28:36 -05:00
|
|
|
<li <?php if ( 'detail' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'detail', $_SERVER['REQUEST_URI'])) ?>"><?php _e('Detail View') ?></a></li>
|
|
|
|
<li <?php if ( 'list' == $mode ) echo "class='current'" ?>><a href="<?php echo clean_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><?php _e('List View') ?></a></li>
|
2008-02-24 14:41:04 -05:00
|
|
|
</ul>
|
2008-08-20 00:06:36 -04:00
|
|
|
-->
|
2008-02-23 03:01:51 -05:00
|
|
|
|
|
|
|
<?php
|
|
|
|
|
2008-04-30 16:05:25 -04:00
|
|
|
$comments_per_page = apply_filters('comments_per_page', 20, $comment_status);
|
|
|
|
|
2007-03-27 17:20:16 -04:00
|
|
|
if ( isset( $_GET['apage'] ) )
|
2007-08-01 15:41:44 -04:00
|
|
|
$page = abs( (int) $_GET['apage'] );
|
2007-03-27 17:20:16 -04:00
|
|
|
else
|
|
|
|
$page = 1;
|
2007-05-21 08:52:44 -04:00
|
|
|
|
2008-04-30 16:05:25 -04:00
|
|
|
$start = $offset = ( $page - 1 ) * $comments_per_page;
|
2004-10-05 03:25:21 -04:00
|
|
|
|
2008-04-30 16:05:25 -04:00
|
|
|
list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 5 ); // Grab a few extra
|
2006-11-18 01:52:01 -05:00
|
|
|
|
2008-04-30 16:05:25 -04:00
|
|
|
$comments = array_slice($_comments, 0, $comments_per_page);
|
|
|
|
$extra_comments = array_slice($_comments, $comments_per_page);
|
2007-03-27 17:20:16 -04:00
|
|
|
|
|
|
|
$page_links = paginate_links( array(
|
2007-09-03 19:32:58 -04:00
|
|
|
'base' => add_query_arg( 'apage', '%#%' ),
|
2007-05-21 08:52:44 -04:00
|
|
|
'format' => '',
|
2008-04-30 16:05:25 -04:00
|
|
|
'total' => ceil($total / $comments_per_page),
|
2007-03-27 17:20:16 -04:00
|
|
|
'current' => $page
|
|
|
|
));
|
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
?>
|
2006-11-18 01:52:01 -05:00
|
|
|
|
2008-02-28 01:50:25 -05:00
|
|
|
<form id="comments-form" action="" method="post">
|
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
<div class="tablenav">
|
2006-04-19 04:30:56 -04:00
|
|
|
|
|
|
|
<?php
|
2008-02-23 03:01:51 -05:00
|
|
|
if ( $page_links )
|
|
|
|
echo "<div class='tablenav-pages'>$page_links</div>";
|
2006-04-19 04:30:56 -04:00
|
|
|
?>
|
2008-02-23 03:01:51 -05:00
|
|
|
|
2008-03-14 19:58:31 -04:00
|
|
|
<div class="alignleft">
|
2008-08-20 00:06:36 -04:00
|
|
|
<select name="action">
|
2008-08-28 18:09:56 -04:00
|
|
|
<option value="" selected="selected"><?php _e('Actions') ?></option>
|
2008-09-04 14:00:21 -04:00
|
|
|
<?php if ( empty($comment_status) || 'approved' == $comment_status ): ?>
|
2008-08-20 00:06:36 -04:00
|
|
|
<option value="unapprove"><?php _e('Unapprove'); ?></option>
|
2008-09-04 14:00:21 -04:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if ( empty($comment_status) || 'moderated' == $comment_status ): ?>
|
2008-08-28 18:09:56 -04:00
|
|
|
<option value="approve"><?php _e('Approve'); ?></option>
|
2008-02-24 15:42:44 -05:00
|
|
|
<?php endif; ?>
|
2008-08-20 00:06:36 -04:00
|
|
|
<?php if ( 'spam' != $comment_status ): ?>
|
|
|
|
<option value="markspam"><?php _e('Mark as Spam'); ?></option>
|
2008-02-28 02:04:52 -05:00
|
|
|
<?php endif; ?>
|
2008-08-20 00:06:36 -04:00
|
|
|
<option value="delete"><?php _e('Delete'); ?></option>
|
|
|
|
</select>
|
2008-09-25 09:42:34 -04:00
|
|
|
<input type="submit" name="doaction" id="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" />
|
2008-02-23 03:01:51 -05:00
|
|
|
<?php wp_nonce_field('bulk-comments'); ?>
|
2008-07-25 23:51:39 -04:00
|
|
|
<?php if ( isset($_GET['apage']) ) { ?>
|
|
|
|
<input type="hidden" name="apage" value="<?php echo absint( $_GET['apage'] ); ?>" />
|
2008-09-08 17:49:26 -04:00
|
|
|
<?php }
|
|
|
|
|
|
|
|
if ( 'spam' == $comment_status ) {
|
|
|
|
wp_nonce_field('bulk-spam-delete'); ?>
|
|
|
|
<input type="submit" name="delete_all_spam" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" />
|
2008-07-25 23:51:39 -04:00
|
|
|
<?php } ?>
|
2008-09-09 19:14:37 -04:00
|
|
|
<?php do_action('manage_comments_nav', $comment_status); ?>
|
2007-03-27 17:20:16 -04:00
|
|
|
</div>
|
2004-10-05 03:25:21 -04:00
|
|
|
|
2008-03-14 19:58:31 -04:00
|
|
|
<br class="clear" />
|
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
</div>
|
2005-08-30 22:39:17 -04:00
|
|
|
|
2008-03-14 19:58:31 -04:00
|
|
|
<br class="clear" />
|
2004-10-05 03:25:21 -04:00
|
|
|
<?php
|
2008-02-23 03:01:51 -05:00
|
|
|
if ($comments) {
|
|
|
|
?>
|
|
|
|
<table class="widefat">
|
2006-05-10 16:35:10 -04:00
|
|
|
<thead>
|
2004-02-17 03:35:04 -05:00
|
|
|
<tr>
|
2008-04-18 18:23:02 -04:00
|
|
|
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
2008-08-20 00:06:36 -04:00
|
|
|
<th scope="col" class="comment-column"><?php _e('Comment') ?></th>
|
|
|
|
<th scope="col" class="author-column"><?php _e('Author') ?></th>
|
2008-08-24 02:56:22 -04:00
|
|
|
<th scope="col" class="date-column"><?php _e('Submitted') ?></th>
|
2008-08-20 00:06:36 -04:00
|
|
|
<th scope="col" class="response-column"><?php _e('In Response To This Post') ?></th>
|
2006-05-10 16:35:10 -04:00
|
|
|
</tr>
|
2007-10-09 18:49:42 -04:00
|
|
|
</thead>
|
2008-02-23 03:01:51 -05:00
|
|
|
<tbody id="the-comment-list" class="list:comment">
|
|
|
|
<?php
|
2008-02-28 01:50:25 -05:00
|
|
|
foreach ($comments as $comment)
|
2008-02-28 17:12:04 -05:00
|
|
|
_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
|
2004-02-17 03:35:04 -05:00
|
|
|
?>
|
2008-02-28 01:50:25 -05:00
|
|
|
</tbody>
|
|
|
|
<tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
|
|
|
|
<?php
|
|
|
|
foreach ($extra_comments as $comment)
|
2008-02-28 17:12:04 -05:00
|
|
|
_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
|
2008-02-28 01:50:25 -05:00
|
|
|
?>
|
|
|
|
</tbody>
|
2007-10-09 18:49:42 -04:00
|
|
|
</table>
|
2008-02-23 03:01:51 -05:00
|
|
|
|
2008-02-28 01:50:25 -05:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<form id="get-extra-comments" method="post" action="" class="add:the-extra-comment-list:" style="display: none;">
|
|
|
|
<input type="hidden" name="s" value="<?php echo $search; ?>" />
|
|
|
|
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
|
|
|
|
<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
|
|
|
|
<input type="hidden" name="page" value="<?php echo isset($_REQUEST['page']) ? absint( $_REQUEST['page'] ) : 1; ?>" />
|
|
|
|
<?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?>
|
|
|
|
</form>
|
|
|
|
|
2006-03-28 20:51:55 -05:00
|
|
|
<div id="ajax-response"></div>
|
2004-02-17 03:35:04 -05:00
|
|
|
<?php
|
2008-03-11 03:23:07 -04:00
|
|
|
} elseif ( 'moderated' == $_GET['comment_status'] ) {
|
|
|
|
?>
|
|
|
|
<p>
|
|
|
|
<?php _e('No comments awaiting moderation… yet.') ?>
|
|
|
|
</p>
|
|
|
|
<?php
|
|
|
|
} else {
|
2004-02-17 05:50:33 -05:00
|
|
|
?>
|
|
|
|
<p>
|
2008-03-11 03:23:07 -04:00
|
|
|
<?php _e('No results found.') ?>
|
2004-02-17 05:50:33 -05:00
|
|
|
</p>
|
|
|
|
<?php
|
2004-02-17 03:35:04 -05:00
|
|
|
}
|
2008-02-23 03:01:51 -05:00
|
|
|
?>
|
|
|
|
<div class="tablenav">
|
|
|
|
<?php
|
2007-03-27 17:20:16 -04:00
|
|
|
if ( $page_links )
|
2008-02-23 03:01:51 -05:00
|
|
|
echo "<div class='tablenav-pages'>$page_links</div>";
|
2007-03-27 17:20:16 -04:00
|
|
|
?>
|
2008-03-14 19:58:31 -04:00
|
|
|
<br class="clear" />
|
2003-10-27 02:09:25 -05:00
|
|
|
</div>
|
|
|
|
|
2008-02-28 01:50:25 -05:00
|
|
|
</div>
|
|
|
|
|
2008-08-24 02:56:22 -04:00
|
|
|
<?php
|
|
|
|
wp_comment_reply('-1', true, 'detail');
|
2008-08-28 18:09:56 -04:00
|
|
|
include('admin-footer.php'); ?>
|