2003-10-27 02:09:25 -05:00
|
|
|
<?php
|
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');
|
|
|
|
$parent_file = 'edit-comments.php';
|
2006-05-22 13:16:05 -04:00
|
|
|
wp_enqueue_script( 'admin-comments' );
|
2008-01-07 15:38:49 -05:00
|
|
|
wp_enqueue_script('admin-forms');
|
2004-08-22 19:24:50 -04:00
|
|
|
|
2004-07-07 21:10:50 -04:00
|
|
|
if ( !empty( $_POST['delete_comments'] ) ) :
|
2006-05-02 18:36:06 -04:00
|
|
|
check_admin_referer('bulk-comments');
|
2006-03-30 18:12:54 -05:00
|
|
|
|
2004-07-07 21:10:50 -04:00
|
|
|
$i = 0;
|
2004-09-18 01:56:28 -04:00
|
|
|
foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
|
2004-07-07 21:10:50 -04:00
|
|
|
$comment = (int) $comment;
|
2007-03-22 20:59:21 -04:00
|
|
|
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
|
2006-02-14 15:09:13 -05:00
|
|
|
// $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 ( !empty( $_POST['spam_button'] ) )
|
|
|
|
wp_set_comment_status($comment, 'spam');
|
|
|
|
else
|
|
|
|
wp_set_comment_status($comment, 'delete');
|
2004-02-17 05:50:33 -05:00
|
|
|
++$i;
|
2006-02-14 15:09:13 -05:00
|
|
|
}
|
2004-07-07 21:10:50 -04:00
|
|
|
endforeach;
|
2008-02-23 03:01:51 -05:00
|
|
|
/*
|
2006-02-14 15:09:13 -05:00
|
|
|
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
|
2006-12-21 18:06:18 -05:00
|
|
|
if ( !empty( $_POST['spam_button'] ) ) {
|
2007-12-20 12:05:06 -05:00
|
|
|
printf(__ngettext('%s comment marked as spam.', '%s comments marked as spam.', $i), $i);
|
2006-12-21 18:06:18 -05:00
|
|
|
} else {
|
|
|
|
printf(__ngettext('%s comment deleted.', '%s comments deleted.', $i), $i);
|
|
|
|
}
|
2006-02-14 15:09:13 -05:00
|
|
|
echo '</p></div>';
|
2008-02-23 03:01:51 -05:00
|
|
|
*/
|
|
|
|
// TODO redirect with message
|
2004-07-07 21:10:50 -04:00
|
|
|
endif;
|
2004-02-17 05:50:33 -05:00
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
require_once('admin-header.php');
|
|
|
|
if (empty($_GET['mode'])) $mode = 'view';
|
|
|
|
else $mode = attribute_escape($_GET['mode']);
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div class="wrap">
|
|
|
|
<form id="posts-filter" action="" method="get">
|
|
|
|
<h2><?php _e('Manage Comments'); ?></h2>
|
|
|
|
|
|
|
|
<ul class="subsubsub">
|
|
|
|
<?php
|
|
|
|
if ( isset($_GET['comment_status']) )
|
|
|
|
$comment_status = $_GET['comment_status'];
|
|
|
|
else
|
|
|
|
$comment_status = '';
|
|
|
|
$status_links = array();
|
2008-02-23 03:33:44 -05:00
|
|
|
$num_comments = wp_count_comments();
|
|
|
|
$stati = array('moderated' => sprintf(__('Awaiting Moderation (%s)'), $num_comments->moderated), 'approved' => __('Approved'));
|
2008-02-23 03:01:51 -05: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>';
|
|
|
|
}
|
|
|
|
$class = ( '' === $comment_status ) ? ' class="current"' : '';
|
|
|
|
$status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('All Comments')."</a>";
|
|
|
|
echo implode(' |</li>', $status_links) . '</li>';
|
|
|
|
unset($status_links);
|
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<p id="post-search">
|
|
|
|
<input type="text" id="post-search-input" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" />
|
|
|
|
<input type="submit" value="<?php _e( 'Search Comments' ); ?>" class="button" />
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
|
|
|
|
|
2008-02-23 03:33:44 -05:00
|
|
|
<p><a href="?mode=view"><?php _e('Detail View') ?></a> | <a href="?mode=edit"><?php _e('List View') ?></a></p>
|
2008-02-23 03:01:51 -05:00
|
|
|
|
|
|
|
<?php
|
|
|
|
|
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
|
|
|
|
2007-03-27 17:20:16 -04:00
|
|
|
$start = $offset = ( $page - 1 ) * 20;
|
2004-10-05 03:25:21 -04:00
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
list($_comments, $total) = _wp_get_comment_list( $comment_status, isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra
|
2006-11-18 01:52:01 -05:00
|
|
|
|
2007-03-27 17:20:16 -04:00
|
|
|
$comments = array_slice($_comments, 0, 20);
|
|
|
|
$extra_comments = array_slice($_comments, 20);
|
|
|
|
|
|
|
|
$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' => '',
|
2007-03-27 17:20:16 -04:00
|
|
|
'total' => ceil($total / 20),
|
|
|
|
'current' => $page
|
|
|
|
));
|
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
?>
|
2006-11-18 01:52:01 -05:00
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
<br style="clear:both;" />
|
2004-10-05 03:25:21 -04:00
|
|
|
|
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
|
|
|
|
|
|
|
<div style="float: left">
|
|
|
|
<input type="submit" value="<?php _e('Approve'); ?>" name="approveit" class="button-secondary" />
|
|
|
|
<input type="submit" value="<?php _e('Mark as Spam'); ?>" name="spamit" class="button-secondary" />
|
|
|
|
<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary" />
|
|
|
|
<?php wp_nonce_field('bulk-comments'); ?>
|
2007-03-27 17:20:16 -04:00
|
|
|
</div>
|
2004-10-05 03:25:21 -04:00
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
<br style="clear:both;" />
|
|
|
|
</div>
|
2005-08-30 22:39:17 -04:00
|
|
|
|
2008-02-23 03:01:51 -05:00
|
|
|
<br style="clear:both;" />
|
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-02-23 03:01:51 -05:00
|
|
|
<th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
|
|
|
|
<th scope="col"><?php _e('Comment') ?></th>
|
|
|
|
<th scope="col"><?php _e('Date') ?></th>
|
|
|
|
<th scope="col"><?php _e('Actions') ?></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
|
|
|
|
foreach ($comments as $comment) {
|
2007-06-07 20:20:22 -04:00
|
|
|
$post = get_post($comment->comment_post_ID);
|
|
|
|
$authordata = get_userdata($post->post_author);
|
2006-03-28 20:51:55 -05:00
|
|
|
$comment_status = wp_get_comment_status($comment->comment_ID);
|
2004-07-06 14:14:42 -04:00
|
|
|
$class = ('alternate' == $class) ? '' : 'alternate';
|
2006-03-28 20:51:55 -05:00
|
|
|
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
|
2008-02-23 03:01:51 -05:00
|
|
|
$post_link = '<a href="' . get_comment_link() . '">' . get_the_title($comment->comment_post_ID) . '</a>';
|
|
|
|
$author_url = get_comment_author_url();
|
|
|
|
if ( 'http://' == $author_url )
|
|
|
|
$author_url = '';
|
2004-02-17 03:35:04 -05:00
|
|
|
?>
|
2006-03-28 20:51:55 -05:00
|
|
|
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
|
2008-02-23 03:01:51 -05:00
|
|
|
<td style="text-align: center; vertical-align: text-top"><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
|
|
|
|
<td style="vertical-align: text-top">
|
2008-02-23 03:33:44 -05:00
|
|
|
<p><strong class="comment-author"><?php comment_author(); ?></strong><br />
|
2008-02-23 03:01:51 -05:00
|
|
|
<?php if ( !empty($author_url) ) : ?>
|
|
|
|
<a href="<?php echo $author_url ?>"><?php echo $author_url; ?></a> |
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if ( !empty($comment->comment_author_email) ): ?>
|
|
|
|
<?php comment_author_email_link() ?> |
|
|
|
|
<?php endif; ?>
|
|
|
|
<a href="edit-comments.php?s=<?php comment_author_IP() ?>&mode=edit"><?php comment_author_IP() ?></a>
|
|
|
|
<p><?php comment_excerpt(); ?></p>
|
|
|
|
<?php printf(__('From %1$s, %2$s at %3$s'), $post_link, get_the_time(get_option('date_format')), get_the_time()) ?>
|
2006-03-28 20:51:55 -05:00
|
|
|
</td>
|
2008-02-23 03:01:51 -05:00
|
|
|
<td style="vertical-align: text-top"><?php comment_date(); ?></td>
|
|
|
|
<td style="vertical-align: text-top">
|
|
|
|
<?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
|
|
|
|
echo "<a href='comment.php?action=editcomment&c=$comment->comment_ID' class='edit'>" . __('Edit') . "</a> | ";
|
2007-10-09 18:49:42 -04:00
|
|
|
$url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
|
|
|
|
echo "<a href='$url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . "</a> ";
|
2008-02-23 03:01:51 -05:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</td>
|
2004-02-17 03:35:04 -05:00
|
|
|
</tr>
|
2007-09-03 19:32:58 -04:00
|
|
|
<?php
|
2004-02-17 03:35:04 -05:00
|
|
|
} // end foreach
|
2007-10-09 18:49:42 -04:00
|
|
|
?></tbody>
|
|
|
|
</table>
|
2008-02-23 03:01:51 -05:00
|
|
|
|
2006-03-28 20:51:55 -05:00
|
|
|
<div id="ajax-response"></div>
|
2004-02-17 03:35:04 -05:00
|
|
|
<?php
|
2008-02-23 03:01:51 -05:00
|
|
|
} else {
|
2004-02-17 05:50:33 -05:00
|
|
|
?>
|
|
|
|
<p>
|
2004-04-22 23:23:05 -04:00
|
|
|
<strong><?php _e('No results found.') ?></strong>
|
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-02-23 03:01:51 -05:00
|
|
|
<br style="clear:both;" />
|
2003-10-27 02:09:25 -05:00
|
|
|
</div>
|
|
|
|
|
2005-08-30 22:39:17 -04:00
|
|
|
<?php include('admin-footer.php'); ?>
|