2 require_once('admin.php');
4 $title = __('Edit Comments');
5 $parent_file = 'edit.php';
8 require_once('admin-header.php');
9 if (empty($_GET['mode'])) $mode = 'view';
10 else $mode = wp_specialchars($_GET['mode'], 1);
13 <script type="text/javascript">
15 function checkAll(form)
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;
22 form.elements[i].checked = true;
29 <h2><?php _e('Comments'); ?></h2>
30 <form name="searchform" action="" method="get">
32 <legend><?php _e('Show Comments That Contain...') ?></legend>
33 <input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" 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.)') ?>
39 <p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
41 if ( !empty( $_POST['delete_comments'] ) ) :
42 check_admin_referer('bulk-comments');
45 foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
46 $comment = (int) $comment;
47 $post_id = $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");
54 echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
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");
68 if ( isset($_GET['offset']) )
69 $offset = (int) $_GET['offset'] * 20;
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");
75 if ('view' == $mode) {
78 $start = " start='$offset'";
82 echo "<ol id='the-list' class='commentlist' $start>";
84 foreach ($comments as $comment) {
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';
91 $class .= ' alternate';
92 echo "<li id='comment-$comment->comment_ID' class='$class'>";
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>
96 <?php comment_text() ?>
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 } // end if any comments to show
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>
109 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
112 <?php } // end foreach ?>
115 <div id="ajax-response"></div>
122 <strong><?php _e('No comments found.') ?></strong></p>
125 } // end if ($comments)
126 } elseif ('edit' == $mode) {
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">
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>
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';
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>
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>
166 <strong><?php _e('No results found.') ?></strong>
169 } // end if ($comments)
175 <?php include('admin-footer.php'); ?>