| 1 |
<?php |
|---|
| 2 |
require_once('admin.php'); |
|---|
| 3 |
|
|---|
| 4 |
$title = __('Edit Comments'); |
|---|
| 5 |
$parent_file = 'edit.php'; |
|---|
| 6 |
$list_js = true; |
|---|
| 7 |
|
|---|
| 8 |
require_once('admin-header.php'); |
|---|
| 9 |
if (empty($_GET['mode'])) $mode = 'view'; |
|---|
| 10 |
else $mode = attribute_escape($_GET['mode']); |
|---|
| 11 |
?> |
|---|
| 12 |
|
|---|
| 13 |
<script type="text/javascript"> |
|---|
| 14 |
<!-- |
|---|
| 15 |
function checkAll(form) |
|---|
| 16 |
{ |
|---|
| 17 |
for (i = 0, n = form.elements.length; i < n; i++) { |
|---|
| 18 |
if(form.elements[i].type == "checkbox") { |
|---|
| 19 |
if(form.elements[i].checked == true) |
|---|
| 20 |
form.elements[i].checked = false; |
|---|
| 21 |
else |
|---|
| 22 |
form.elements[i].checked = true; |
|---|
| 23 |
} |
|---|
| 24 |
} |
|---|
| 25 |
} |
|---|
| 26 |
//--> |
|---|
| 27 |
</script> |
|---|
| 28 |
<div class="wrap"> |
|---|
| 29 |
<h2><?php _e('Comments'); ?></h2> |
|---|
| 30 |
<form name="searchform" action="" method="get"> |
|---|
| 31 |
<fieldset> |
|---|
| 32 |
<legend><?php _e('Show Comments That Contain...') ?></legend> |
|---|
| 33 |
<input type="text" name="s" value="<?php if (isset($_GET['s'])) echo attribute_escape($_GET['s']); ?>" size="17" /> |
|---|
| 34 |
<input type="submit" name="submit" value="<?php _e('Search') ?>" /> |
|---|
| 35 |
<input type="hidden" name="mode" value="<?php echo $mode; ?>" /> |
|---|
| 36 |
<?php _e('(Searches within comment text, e-mail, URI, and IP address.)') ?> |
|---|
| 37 |
</fieldset> |
|---|
| 38 |
</form> |
|---|
| 39 |
<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p> |
|---|
| 40 |
<?php |
|---|
| 41 |
if ( !empty( $_POST['delete_comments'] ) ) : |
|---|
| 42 |
check_admin_referer('bulk-comments'); |
|---|
| 43 |
|
|---|
| 44 |
$i = 0; |
|---|
| 45 |
foreach ($_POST['delete_comments'] as $comment) : |
|---|
| 46 |
$comment = (int) $comment; |
|---|
| 47 |
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); |
|---|
| 48 |
$authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); |
|---|
| 49 |
if ( current_user_can('edit_post', $post_id) ) : |
|---|
| 50 |
wp_set_comment_status($comment, "delete"); |
|---|
| 51 |
++$i; |
|---|
| 52 |
endif; |
|---|
| 53 |
endforeach; |
|---|
| 54 |
echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>"; |
|---|
| 55 |
endif; |
|---|
| 56 |
|
|---|
| 57 |
if (isset($_GET['s'])) { |
|---|
| 58 |
$s = $wpdb->escape($_GET['s']); |
|---|
| 59 |
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE |
|---|
| 60 |
(comment_author LIKE '%$s%' OR |
|---|
| 61 |
comment_author_email LIKE '%$s%' OR |
|---|
| 62 |
comment_author_url LIKE ('%$s%') OR |
|---|
| 63 |
comment_author_IP LIKE ('%$s%') OR |
|---|
| 64 |
comment_content LIKE ('%$s%') ) AND |
|---|
| 65 |
comment_approved != 'spam' |
|---|
| 66 |
ORDER BY comment_date DESC"); |
|---|
| 67 |
} else { |
|---|
| 68 |
if ( isset($_GET['offset']) ) |
|---|
| 69 |
$offset = (int) $_GET['offset'] * 20; |
|---|
| 70 |
else |
|---|
| 71 |
$offset = 0; |
|---|
| 72 |
|
|---|
| 73 |
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20"); |
|---|
| 74 |
} |
|---|
| 75 |
if ('view' == $mode) { |
|---|
| 76 |
if ($comments) { |
|---|
| 77 |
if ($offset) |
|---|
| 78 |
$start = " start='$offset'"; |
|---|
| 79 |
else |
|---|
| 80 |
$start = ''; |
|---|
| 81 |
|
|---|
| 82 |
echo "<ol id='the-list' class='commentlist' $start>"; |
|---|
| 83 |
$i = 0; |
|---|
| 84 |
foreach ($comments as $comment) { |
|---|
| 85 |
++$i; $class = ''; |
|---|
| 86 |
$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); |
|---|
| 87 |
$comment_status = wp_get_comment_status($comment->comment_ID); |
|---|
| 88 |
if ('unapproved' == $comment_status) |
|---|
| 89 |
$class .= ' unapproved'; |
|---|
| 90 |
if ($i % 2) |
|---|
| 91 |
$class .= ' alternate'; |
|---|
| 92 |
echo "<li id='comment-$comment->comment_ID' class='$class'>"; |
|---|
| 93 |
?> |
|---|
| 94 |
<p><strong><?php _e('Name:') ?></strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> |
|---|
| 95 |
|
|---|
| 96 |
<?php comment_text() ?> |
|---|
| 97 |
|
|---|
| 98 |
<p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A'); |
|---|
| 99 |
if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
|---|
| 100 |
echo " | <a href=\"post.php?action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>"; |
|---|
| 101 |
echo ' | <a href="' . wp_nonce_url('post.php?action=deletecomment&p=' . $comment->comment_post_ID . '&comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . __("You are about to delete this comment.\\n"Cancel" to stop, "OK" to delete.") . "' );\">" . __('Delete Comment') . '</a> '; |
|---|
| 102 |
} |
|---|
| 103 |
// Get post title |
|---|
| 104 |
if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
|---|
| 105 |
$post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"); |
|---|
| 106 |
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; |
|---|
| 107 |
?> | <a href="post.php?action=edit&post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post “%s”'), stripslashes($post_title)); ?></a> |
|---|
| 108 |
<?php } ?> |
|---|
| 109 |
| <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p> |
|---|
| 110 |
</li> |
|---|
| 111 |
|
|---|
| 112 |
<?php } ?> |
|---|
| 113 |
</ol> |
|---|
| 114 |
|
|---|
| 115 |
<div id="ajax-response"></div> |
|---|
| 116 |
|
|---|
| 117 |
<?php |
|---|
| 118 |
} else { |
|---|
| 119 |
|
|---|
| 120 |
?> |
|---|
| 121 |
<p> |
|---|
| 122 |
<strong><?php _e('No comments found.') ?></strong></p> |
|---|
| 123 |
|
|---|
| 124 |
<?php |
|---|
| 125 |
} |
|---|
| 126 |
} elseif ('edit' == $mode) { |
|---|
| 127 |
|
|---|
| 128 |
if ($comments) { |
|---|
| 129 |
echo '<form name="deletecomments" id="deletecomments" action="" method="post"> '; |
|---|
| 130 |
wp_nonce_field('bulk-comments'); |
|---|
| 131 |
echo '<table width="100%" cellpadding="3" cellspacing="3"> |
|---|
| 132 |
<tr> |
|---|
| 133 |
<th scope="col">*</th> |
|---|
| 134 |
<th scope="col">' . __('Name') . '</th> |
|---|
| 135 |
<th scope="col">' . __('E-mail') . '</th> |
|---|
| 136 |
<th scope="col">' . __('IP') . '</th> |
|---|
| 137 |
<th scope="col">' . __('Comment Excerpt') . '</th> |
|---|
| 138 |
<th scope="col" colspan="3">' . __('Actions') . '</th> |
|---|
| 139 |
</tr>'; |
|---|
| 140 |
foreach ($comments as $comment) { |
|---|
| 141 |
$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); |
|---|
| 142 |
$class = ('alternate' == $class) ? '' : 'alternate'; |
|---|
| 143 |
?> |
|---|
| 144 |
<tr class='<?php echo $class; ?>'> |
|---|
| 145 |
<td><?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> |
|---|
| 146 |
<td><?php comment_author_link() ?></td> |
|---|
| 147 |
<td><?php comment_author_email_link() ?></td> |
|---|
| 148 |
<td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td> |
|---|
| 149 |
<td><?php comment_excerpt(); ?></td> |
|---|
| 150 |
<td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td> |
|---|
| 151 |
<td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
|---|
| 152 |
echo "<a href='post.php?action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> |
|---|
| 153 |
<td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
|---|
| 154 |
echo "<a href=\"" . wp_nonce_url("post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return confirm('" . __("You are about to delete this comment.\\n \'Cancel\' to stop, \'OK\' to delete.") . "')\" class='delete'>" . __('Delete') . "</a>"; } ?></td> |
|---|
| 155 |
</tr> |
|---|
| 156 |
<?php |
|---|
| 157 |
} |
|---|
| 158 |
?></table> |
|---|
| 159 |
<p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; "><?php _e('Invert Checkbox Selection') ?></a></p> |
|---|
| 160 |
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Delete Checked Comments') ?> »" onclick="return confirm('<?php _e("You are about to delete these comments permanently.\\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /> </p> |
|---|
| 161 |
</form> |
|---|
| 162 |
<?php |
|---|
| 163 |
} else { |
|---|
| 164 |
?> |
|---|
| 165 |
<p> |
|---|
| 166 |
<strong><?php _e('No results found.') ?></strong> |
|---|
| 167 |
</p> |
|---|
| 168 |
<?php |
|---|
| 169 |
} |
|---|
| 170 |
} |
|---|
| 171 |
?> |
|---|
| 172 |
|
|---|
| 173 |
</div> |
|---|
| 174 |
|
|---|
| 175 |
<?php include('admin-footer.php'); ?> |
|---|
| 176 |
|
|---|