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'] ) ) :
43 foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
44 $comment = (int) $comment;
45 $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
46 $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
47 if ( current_user_can('edit_post', $post_id) ) :
48 wp_set_comment_status($comment, "delete");
52 echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
55 if (isset($_GET['s'])) {
56 $s = $wpdb->escape($_GET['s']);
57 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE
58 (comment_author LIKE '%$s%' OR
59 comment_author_email LIKE '%$s%' OR
60 comment_author_url LIKE ('%$s%') OR
61 comment_author_IP LIKE ('%$s%') OR
62 comment_content LIKE ('%$s%') ) AND
63 comment_approved != 'spam'
64 ORDER BY comment_date DESC");
66 if ( isset($_GET['offset']) )
67 $offset = (int) $_GET['offset'] * 20;
71 $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $offset,20");
73 if ('view' == $mode) {
76 $start = " start='$offset'";
80 echo "<ol id='the-list' class='commentlist' $start>";
82 foreach ($comments as $comment) {
84 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
85 $comment_status = wp_get_comment_status($comment->comment_ID);
86 if ('unapproved' == $comment_status)
87 $class .= ' unapproved';
89 $class .= ' alternate';
90 echo "<li id='comment-$comment->comment_ID' class='$class'>";
92 <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>
94 <?php comment_text() ?>
96 <p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A');
97 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
98 echo " | <a href=\"post.php?action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>";
99 echo " | <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Delete Comment') . "</a> — ";
100 } // end if any comments to show
102 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
103 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID");
104 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
105 ?> <a href="post.php?action=edit&post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post “%s”'), stripslashes($post_title)); ?></a>
107 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
110 <?php } // end foreach ?>
113 <div id="ajax-response"></div>
120 <strong><?php _e('No comments found.') ?></strong></p>
123 } // end if ($comments)
124 } elseif ('edit' == $mode) {
127 echo '<form name="deletecomments" id="deletecomments" action="" method="post">
128 <table width="100%" cellpadding="3" cellspacing="3">
130 <th scope="col">*</th>
131 <th scope="col">' . __('Name') . '</th>
132 <th scope="col">' . __('E-mail') . '</th>
133 <th scope="col">' . __('IP') . '</th>
134 <th scope="col">' . __('Comment Excerpt') . '</th>
135 <th scope="col" colspan="3">' . __('Actions') . '</th>
137 foreach ($comments as $comment) {
138 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
139 $class = ('alternate' == $class) ? '' : 'alternate';
141 <tr class='<?php echo $class; ?>'>
142 <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>
143 <td><?php comment_author_link() ?></td>
144 <td><?php comment_author_email_link() ?></td>
145 <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
146 <td><?php comment_excerpt(); ?></td>
147 <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td>
148 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
149 echo "<a href='post.php?action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>
150 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
151 echo "<a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\" class='delete'>" . __('Delete') . "</a>"; } ?></td>
156 <p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; "><?php _e('Invert Checkbox Selection') ?></a></p>
157 <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>
163 <strong><?php _e('No results found.') ?></strong>
166 } // end if ($comments)
172 <?php include('admin-footer.php'); ?>