2003-10-27 07:09:25 +00:00
<? php
2004-10-19 03:03:06 +00:00
require_once ( 'admin.php' );
2004-04-23 03:23:05 +00:00
2006-11-18 07:31:29 +00:00
$title = __ ( 'Edit Comments' );
$parent_file = 'edit-comments.php' ;
2006-05-22 17:16:05 +00:00
wp_enqueue_script ( 'admin-comments' );
2008-01-07 20:38:49 +00:00
wp_enqueue_script ( 'admin-forms' );
2004-08-22 23:24:50 +00:00
2003-12-11 00:22:36 +00:00
require_once ( 'admin-header.php' );
2004-02-17 08:35:04 +00:00
if ( empty ( $_GET [ 'mode' ])) $mode = 'view' ;
2006-12-21 10:10:04 +00:00
else $mode = attribute_escape ( $_GET [ 'mode' ]);
2003-10-27 07:09:25 +00:00
?>
<div class="wrap">
2004-10-05 07:13:51 +00:00
<h2><?php _e('Comments'); ?></h2>
2007-09-03 23:32:58 +00:00
<form name="searchform" action="" method="get" id="editcomments">
<fieldset>
<legend><?php _e('Show Comments That Contain...') ?></legend>
<input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" />
<input type="submit" name="submit" value="<?php _e('Search') ?>" />
2004-02-17 08:35:04 +00:00
<input type="hidden" name="mode" value="<?php echo $mode; ?>" />
2006-08-30 16:40:17 +00:00
<?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?>
2007-09-03 23:32:58 +00:00
</fieldset>
2004-02-13 15:36:28 +00:00
</form>
2004-04-23 03:23:05 +00:00
<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
2003-10-27 07:09:25 +00:00
<?php
2004-07-08 01:10:50 +00:00
if ( !empty( $_POST['delete_comments'] ) ) :
2006-05-02 22:36:06 +00:00
check_admin_referer('bulk-comments');
2006-03-30 23:12:54 +00:00
2004-07-08 01:10:50 +00:00
$i = 0;
2004-09-18 05:56:28 +00:00
foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
2004-07-08 01:10:50 +00:00
$comment = (int) $comment;
2007-03-23 00:59:21 +00:00
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
2006-02-14 20:09:13 +00: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 10:50:33 +00:00
++$i;
2006-02-14 20:09:13 +00:00
}
2004-07-08 01:10:50 +00:00
endforeach;
2006-02-14 20:09:13 +00:00
echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
2006-12-21 23:06:18 +00:00
if ( !empty( $_POST['spam_button'] ) ) {
2007-12-20 17:05:06 +00:00
printf(__ngettext('%s comment marked as spam.', '%s comments marked as spam.', $i), $i);
2006-12-21 23:06:18 +00:00
} else {
printf(__ngettext('%s comment deleted.', '%s comments deleted.', $i), $i);
}
2006-02-14 20:09:13 +00:00
echo '</p></div>';
2004-07-08 01:10:50 +00:00
endif;
2004-02-17 10:50:33 +00:00
2007-03-27 21:20:16 +00:00
if ( isset( $_GET['apage'] ) )
2007-08-01 19:41:44 +00:00
$page = abs( (int) $_GET['apage'] );
2007-03-27 21:20:16 +00:00
else
$page = 1;
2007-05-21 12:52:44 +00:00
2007-03-27 21:20:16 +00:00
$start = $offset = ( $page - 1 ) * 20;
2004-10-05 07:25:21 +00:00
2007-03-27 21:20:16 +00:00
list($_comments, $total) = _wp_get_comment_list( isset($_GET['s']) ? $_GET['s'] : false, $start, 25 ); // Grab a few extra
2006-11-18 06:52:01 +00:00
2007-03-27 21:20:16 +00:00
$comments = array_slice($_comments, 0, 20);
$extra_comments = array_slice($_comments, 20);
$page_links = paginate_links( array(
2007-09-03 23:32:58 +00:00
'base' => add_query_arg( 'apage', '%#%' ),
2007-05-21 12:52:44 +00:00
'format' => '',
2007-03-27 21:20:16 +00:00
'total' => ceil($total / 20),
'current' => $page
));
if ( $page_links )
echo "<p class='pagenav'>$page_links</p>";
2006-11-18 06:52:01 +00:00
2004-02-17 08:35:04 +00:00
if ('view' == $mode) {
2003-10-27 07:09:25 +00:00
if ($comments) {
2007-03-27 21:20:16 +00:00
$offset = $offset + 1;
$start = " start='$offset'";
2004-10-05 07:25:21 +00:00
2007-10-09 22:49:42 +00:00
echo "<ol id='the-comment-list' class='list:comment commentlist' $start>\n";
2004-10-05 07:13:51 +00:00
$i = 0;
2007-03-27 21:20:16 +00:00
foreach ( $comments as $comment ) {
_wp_comment_list_item( $comment->comment_ID, ++$i );
}
echo "</ol>\n\n";
2006-04-19 08:30:56 +00:00
2007-03-27 21:20:16 +00:00
if ( $extra_comments ) : ?>
<div id="extra-comments" style="display:none">
2007-10-09 22:49:42 +00:00
<ol id="the-extra-comment-list" class="list:comment commentlist" style="color:red">
2006-04-19 08:30:56 +00:00
<?php
2007-03-27 21:20:16 +00:00
foreach ( $extra_comments as $comment ) {
get_comment( $comment ); // Cache it
2007-10-09 22:49:42 +00:00
_wp_comment_list_item( $comment->comment_ID, 0 );
2006-04-19 08:30:56 +00:00
}
?>
2007-10-09 22:49:42 +00:00
</ol>
<form action="" method="get" id="get-extra-comments" class="add:the-extra-comment-list:">
<input type="hidden" name="page" value="<?php echo $page; ?>" />
<input type="hidden" name="s" value="<?php echo attribute_escape(@$_GET['s']); ?>" />
<?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?>
2007-03-27 21:20:16 +00:00
</div>
<?php endif; // $extra_comments ?>
2004-10-05 07:25:21 +00:00
2005-08-31 02:39:17 +00:00
<div id="ajax-response"></div>
2004-10-05 07:25:21 +00:00
<?php
2006-03-29 01:51:55 +00:00
} else { //no comments to show
2004-02-17 08:35:04 +00:00
?>
<p>
2006-11-19 07:56:05 +00:00
<strong><?php _e('No comments found.') ?></strong></p>
2006-02-12 07:53:23 +00:00
2004-02-17 08:35:04 +00:00
<?php
} // end if ($comments)
} elseif ('edit' == $mode) {
2004-02-17 10:50:33 +00:00
2004-02-17 08:35:04 +00:00
if ($comments) {
2006-05-02 22:36:06 +00:00
echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
wp_nonce_field('bulk-comments');
2006-05-10 20:35:10 +00:00
echo '<table class="widefat">
<thead>
2004-02-17 08:35:04 +00:00
<tr>
2006-09-27 00:51:17 +00:00
<th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th>
<th scope="col">' . __('Name') . '</th>
<th scope="col">' . __('E-mail') . '</th>
<th scope="col">' . __('IP') . '</th>
<th scope="col">' . __('Comment Excerpt') . '</th>
<th scope="col" colspan="3" style="text-align: center">' . __('Actions') . '</th>
2006-05-10 20:35:10 +00:00
</tr>
2007-10-09 22:49:42 +00:00
</thead>
<tbody id="the-comment-list" class="list:comment">';
2004-02-17 08:35:04 +00:00
foreach ($comments as $comment) {
2007-06-08 00:20:22 +00:00
$post = get_post($comment->comment_post_ID);
$authordata = get_userdata($post->post_author);
2006-03-29 01:51:55 +00:00
$comment_status = wp_get_comment_status($comment->comment_ID);
2004-07-06 18:14:42 +00:00
$class = ('alternate' == $class) ? '' : 'alternate';
2006-03-29 01:51:55 +00:00
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
2004-02-17 08:35:04 +00:00
?>
2006-03-29 01:51:55 +00:00
<tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
2007-05-09 08:12:54 +00:00
<td style="text-align: center"><?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>
2007-10-09 22:49:42 +00:00
<td class="comment-author"><?php comment_author_link() ?></td>
2004-02-17 08:35:04 +00:00
<td><?php comment_author_email_link() ?></td>
2007-08-20 07:00:29 +00:00
<td><a href="edit-comments.php?s=<?php comment_author_IP() ?>&mode=edit"><?php comment_author_IP() ?></a></td>
2004-02-17 08:35:04 +00:00
<td><?php comment_excerpt(); ?></td>
2006-03-29 01:51:55 +00:00
<td>
2007-08-21 00:35:55 +00:00
<?php if ('unapproved' == $comment_status) {
_e('Unapproved');
} else { ?>
2006-03-29 01:51:55 +00:00
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a>
<?php } ?>
</td>
2005-07-17 21:21:50 +00:00
<td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
2006-10-31 06:50:38 +00:00
echo "<a href='comment.php?action=editcomment&c=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>
2005-07-17 21:21:50 +00:00
<td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
2007-10-09 22:49:42 +00: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> ";
2006-03-29 01:51:55 +00:00
} ?></td>
2004-02-17 08:35:04 +00:00
</tr>
2007-09-03 23:32:58 +00:00
<?php
2004-02-17 08:35:04 +00:00
} // end foreach
2007-10-09 22:49:42 +00:00
?></tbody>
</table>
2006-12-06 11:26:27 +00:00
<p class="submit"><input type="submit" name="delete_button" class="delete" value="<?php _e('Delete Checked Comments »') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__("Please select some comments to delete")); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to delete %s comments permanently \n 'Cancel' to stop, 'OK' to delete.")), "' + numchecked + '"); ?>')" />
<input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam »') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php echo js_escape(__("Please select some comments to mark as spam")); ?>'); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to mark %s comments as spam \n 'Cancel' to stop, 'OK' to mark as spam.")), "' + numchecked + '"); ?>')" /></p>
2004-02-17 08:35:04 +00:00
</form>
2006-03-29 01:51:55 +00:00
<div id="ajax-response"></div>
2004-02-17 08:35:04 +00:00
<?php
2003-10-27 07:09:25 +00:00
} else {
2004-02-17 10:50:33 +00:00
?>
<p>
2004-04-23 03:23:05 +00:00
<strong><?php _e('No results found.') ?></strong>
2004-02-17 10:50:33 +00:00
</p>
<?php
2003-10-27 07:09:25 +00:00
} // end if ($comments)
2004-02-17 08:35:04 +00:00
}
2006-11-18 06:52:01 +00:00
2007-03-27 21:20:16 +00:00
if ( $page_links )
echo "<p class='pagenav'>$page_links</p>";
?>
2003-10-27 07:09:25 +00:00
</div>
2005-08-31 02:39:17 +00:00
<?php include('admin-footer.php'); ?>