2003-10-27 08:09:25 +01:00
|
|
|
<?php
|
2004-10-19 05:03:06 +02:00
|
|
|
require_once('admin.php');
|
2004-04-23 05:23:05 +02:00
|
|
|
|
2006-11-18 08:31:29 +01:00
|
|
|
$title = __('Edit Comments');
|
|
|
|
$parent_file = 'edit-comments.php';
|
2006-05-22 19:16:05 +02:00
|
|
|
wp_enqueue_script( 'admin-comments' );
|
2008-01-07 21:38:49 +01:00
|
|
|
wp_enqueue_script('admin-forms');
|
2004-08-23 01:24:50 +02:00
|
|
|
|
2008-02-24 21:28:36 +01:00
|
|
|
if ( !empty( $_REQUEST['delete_comments'] ) ) {
|
2006-05-03 00:36:06 +02:00
|
|
|
check_admin_referer('bulk-comments');
|
2006-03-31 01:12:54 +02:00
|
|
|
|
2008-03-02 21:17:30 +01:00
|
|
|
$comments_deleted = $comments_approved = $comments_unapproved = $comments_spammed = 0;
|
2008-02-24 03:33:30 +01:00
|
|
|
foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each
|
2004-07-08 03:10:50 +02:00
|
|
|
$comment = (int) $comment;
|
2007-03-23 01:59:21 +01:00
|
|
|
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
|
2006-02-14 21:09:13 +01:00
|
|
|
// $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
|
2008-02-24 03:33:30 +01:00
|
|
|
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++;
|
2008-02-28 08:04:52 +01:00
|
|
|
} elseif ( !empty( $_REQUEST['unapproveit'] ) ) {
|
|
|
|
wp_set_comment_status($comment, 'hold');
|
|
|
|
$comments_unapproved++;
|
2006-02-14 21:09:13 +01:00
|
|
|
}
|
2004-07-08 03:10:50 +02:00
|
|
|
endforeach;
|
2008-02-28 08:04:52 +01:00
|
|
|
$redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved;
|
2008-02-24 21:28:36 +01: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 21:17:30 +01:00
|
|
|
exit;
|
2008-02-24 21:28:36 +01:00
|
|
|
}
|
2004-02-17 11:50:33 +01:00
|
|
|
|
2008-02-23 09:01:51 +01:00
|
|
|
require_once('admin-header.php');
|
2008-02-24 05:51:47 +01:00
|
|
|
|
|
|
|
if ( empty($_GET['mode']) )
|
|
|
|
$mode = 'detail';
|
|
|
|
else
|
|
|
|
$mode = attribute_escape($_GET['mode']);
|
2008-02-24 21:28:36 +01:00
|
|
|
|
|
|
|
if ( isset($_GET['comment_status']) )
|
|
|
|
$comment_status = attribute_escape($_GET['comment_status']);
|
|
|
|
else
|
|
|
|
$comment_status = '';
|
2008-02-28 07:50:25 +01:00
|
|
|
|
|
|
|
if ( isset($_GET['s']) )
|
|
|
|
$search_dirty = $_GET['s'];
|
|
|
|
else
|
|
|
|
$search_dirty = '';
|
|
|
|
$search = attribute_escape( $search );
|
2008-02-23 09:01:51 +01:00
|
|
|
?>
|
2008-02-24 03:33:30 +01: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-25 01:28:21 +01: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-03-19 17:00:09 +01:00
|
|
|
$stati = array('moderated' => sprintf(__ngettext('Awaiting Moderation (%s)', 'Awaiting Moderation (%s)', $num_comments->moderated), "<span class='comment-count'>$num_comments->moderated</span>"), 'approved' => _c('Approved|plural'));
|
2008-03-06 11:23:00 +01:00
|
|
|
$class = ( '' === $comment_status ) ? ' class="current"' : '';
|
2008-03-07 11:05:54 +01:00
|
|
|
$status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>";
|
2008-02-25 01:28:21 +01:00
|
|
|
foreach ( $stati as $status => $label ) {
|
|
|
|
$class = '';
|
|
|
|
|
|
|
|
if ( $status == $comment_status )
|
|
|
|
$class = ' class="current"';
|
|
|
|
|
|
|
|
$status_links[] = "<li><a href=\"edit-comments.php?comment_status=$status\"$class>" . $label . '</a>';
|
|
|
|
}
|
2008-03-11 08:23:07 +01:00
|
|
|
|
|
|
|
$status_links = apply_filters( 'comment_status_links', $status_links );
|
|
|
|
|
2008-02-25 01:28:21 +01:00
|
|
|
echo implode(' | </li>', $status_links) . '</li>';
|
|
|
|
unset($status_links);
|
|
|
|
?>
|
|
|
|
</ul>
|
2008-02-24 03:33:30 +01:00
|
|
|
|
2008-02-23 09:01:51 +01:00
|
|
|
<p id="post-search">
|
2008-02-28 07:50:25 +01:00
|
|
|
<input type="text" id="post-search-input" name="s" value="<?php echo $search; ?>" />
|
2008-02-23 09:01:51 +01:00
|
|
|
<input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
|
2008-02-24 21:28:36 +01:00
|
|
|
<input type="hidden" name="comment_status" value="<?php echo $comment_status; ?>" />
|
2008-02-28 07:50:25 +01:00
|
|
|
</form>
|
2008-02-23 09:01:51 +01:00
|
|
|
|
2008-02-24 20:41:04 +01:00
|
|
|
<ul class="view-switch">
|
2008-02-24 21:28:36 +01: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 20:41:04 +01:00
|
|
|
</ul>
|
2008-02-23 09:01:51 +01:00
|
|
|
|
|
|
|
<?php
|
|
|
|
|
2007-03-27 23:20:16 +02:00
|
|
|
if ( isset( $_GET['apage'] ) )
|
2007-08-01 21:41:44 +02:00
|
|
|
$page = abs( (int) $_GET['apage'] );
|
2007-03-27 23:20:16 +02:00
|
|
|
else
|
|
|
|
$page = 1;
|
2007-05-21 14:52:44 +02:00
|
|
|
|
2007-03-27 23:20:16 +02:00
|
|
|
$start = $offset = ( $page - 1 ) * 20;
|
2004-10-05 09:25:21 +02:00
|
|
|
|
2008-02-28 07:50:25 +01:00
|
|
|
list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, 25 ); // Grab a few extra
|
2006-11-18 07:52:01 +01:00
|
|
|
|
2007-03-27 23:20:16 +02:00
|
|
|
$comments = array_slice($_comments, 0, 20);
|
|
|
|
$extra_comments = array_slice($_comments, 20);
|
|
|
|
|
|
|
|
$page_links = paginate_links( array(
|
2007-09-04 01:32:58 +02:00
|
|
|
'base' => add_query_arg( 'apage', '%#%' ),
|
2007-05-21 14:52:44 +02:00
|
|
|
'format' => '',
|
2007-03-27 23:20:16 +02:00
|
|
|
'total' => ceil($total / 20),
|
|
|
|
'current' => $page
|
|
|
|
));
|
|
|
|
|
2008-02-23 09:01:51 +01:00
|
|
|
?>
|
2006-11-18 07:52:01 +01:00
|
|
|
|
2008-02-28 07:50:25 +01:00
|
|
|
<form id="comments-form" action="" method="post">
|
|
|
|
|
2008-02-23 09:01:51 +01:00
|
|
|
<div class="tablenav">
|
2006-04-19 10:30:56 +02:00
|
|
|
|
|
|
|
<?php
|
2008-02-23 09:01:51 +01:00
|
|
|
if ( $page_links )
|
|
|
|
echo "<div class='tablenav-pages'>$page_links</div>";
|
2006-04-19 10:30:56 +02:00
|
|
|
?>
|
2008-02-23 09:01:51 +01:00
|
|
|
|
2008-03-15 00:58:31 +01:00
|
|
|
<div class="alignleft">
|
2008-02-24 21:42:44 +01:00
|
|
|
<?php if ( 'approved' != $comment_status ): ?>
|
2008-02-23 09:01:51 +01:00
|
|
|
<input type="submit" value="<?php _e('Approve'); ?>" name="approveit" class="button-secondary" />
|
2008-02-24 21:42:44 +01:00
|
|
|
<?php endif; ?>
|
2008-02-23 09:01:51 +01:00
|
|
|
<input type="submit" value="<?php _e('Mark as Spam'); ?>" name="spamit" class="button-secondary" />
|
2008-02-28 08:04:52 +01:00
|
|
|
<?php if ( 'moderated' != $comment_status ): ?>
|
|
|
|
<input type="submit" value="<?php _e('Unapprove'); ?>" name="unapproveit" class="button-secondary" />
|
|
|
|
<?php endif; ?>
|
2008-03-07 19:35:24 +01:00
|
|
|
<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
|
2008-02-25 09:20:36 +01:00
|
|
|
<?php do_action('manage_comments_nav', $comment_status); ?>
|
2008-02-23 09:01:51 +01:00
|
|
|
<?php wp_nonce_field('bulk-comments'); ?>
|
2007-03-27 23:20:16 +02:00
|
|
|
</div>
|
2004-10-05 09:25:21 +02:00
|
|
|
|
2008-03-15 00:58:31 +01:00
|
|
|
<br class="clear" />
|
|
|
|
|
2008-02-23 09:01:51 +01:00
|
|
|
</div>
|
2005-08-31 04:39:17 +02:00
|
|
|
|
2008-03-15 00:58:31 +01:00
|
|
|
<br class="clear" />
|
2004-10-05 09:25:21 +02:00
|
|
|
<?php
|
2008-02-23 09:01:51 +01:00
|
|
|
if ($comments) {
|
|
|
|
?>
|
|
|
|
<table class="widefat">
|
2006-05-10 22:35:10 +02:00
|
|
|
<thead>
|
2004-02-17 09:35:04 +01:00
|
|
|
<tr>
|
2008-03-15 00:58:31 +01:00
|
|
|
<th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('comments-form'));" /></th>
|
2008-02-23 09:01:51 +01:00
|
|
|
<th scope="col"><?php _e('Comment') ?></th>
|
|
|
|
<th scope="col"><?php _e('Date') ?></th>
|
2008-03-17 18:20:13 +01:00
|
|
|
<th scope="col" class="action-links"><?php _e('Actions') ?></th>
|
2006-05-10 22:35:10 +02:00
|
|
|
</tr>
|
2007-10-10 00:49:42 +02:00
|
|
|
</thead>
|
2008-02-23 09:01:51 +01:00
|
|
|
<tbody id="the-comment-list" class="list:comment">
|
|
|
|
<?php
|
2008-02-28 07:50:25 +01:00
|
|
|
foreach ($comments as $comment)
|
2008-02-28 23:12:04 +01:00
|
|
|
_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
|
2004-02-17 09:35:04 +01:00
|
|
|
?>
|
2008-02-28 07:50:25 +01:00
|
|
|
</tbody>
|
|
|
|
<tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
|
|
|
|
<?php
|
|
|
|
foreach ($extra_comments as $comment)
|
2008-02-28 23:12:04 +01:00
|
|
|
_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
|
2008-02-28 07:50:25 +01:00
|
|
|
?>
|
|
|
|
</tbody>
|
2007-10-10 00:49:42 +02:00
|
|
|
</table>
|
2008-02-23 09:01:51 +01:00
|
|
|
|
2008-02-28 07:50:25 +01: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-29 03:51:55 +02:00
|
|
|
<div id="ajax-response"></div>
|
2004-02-17 09:35:04 +01:00
|
|
|
<?php
|
2008-03-11 08:23:07 +01:00
|
|
|
} elseif ( 'moderated' == $_GET['comment_status'] ) {
|
|
|
|
?>
|
|
|
|
<p>
|
|
|
|
<?php _e('No comments awaiting moderation… yet.') ?>
|
|
|
|
</p>
|
|
|
|
<?php
|
|
|
|
} else {
|
2004-02-17 11:50:33 +01:00
|
|
|
?>
|
|
|
|
<p>
|
2008-03-11 08:23:07 +01:00
|
|
|
<?php _e('No results found.') ?>
|
2004-02-17 11:50:33 +01:00
|
|
|
</p>
|
|
|
|
<?php
|
2004-02-17 09:35:04 +01:00
|
|
|
}
|
2008-02-23 09:01:51 +01:00
|
|
|
?>
|
|
|
|
<div class="tablenav">
|
|
|
|
<?php
|
2007-03-27 23:20:16 +02:00
|
|
|
if ( $page_links )
|
2008-02-23 09:01:51 +01:00
|
|
|
echo "<div class='tablenav-pages'>$page_links</div>";
|
2007-03-27 23:20:16 +02:00
|
|
|
?>
|
2008-03-15 00:58:31 +01:00
|
|
|
<br class="clear" />
|
2003-10-27 08:09:25 +01:00
|
|
|
</div>
|
|
|
|
|
2008-02-28 07:50:25 +01:00
|
|
|
</div>
|
|
|
|
|
2005-08-31 04:39:17 +02:00
|
|
|
<?php include('admin-footer.php'); ?>
|