Changes in trunk/wp-admin/edit-comments.php [3422:4267]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-comments.php
r3422 r4267 4 4 $title = __('Edit Comments'); 5 5 $parent_file = 'edit.php'; 6 $list_js = true;6 wp_enqueue_script( 'admin-comments' ); 7 7 8 8 require_once('admin-header.php'); … … 24 24 } 25 25 } 26 27 function getNumChecked(form) 28 { 29 var num = 0; 30 for (i = 0, n = form.elements.length; i < n; i++) { 31 if(form.elements[i].type == "checkbox") { 32 if(form.elements[i].checked == true) 33 num++; 34 } 35 } 36 return num; 37 } 26 38 //--> 27 39 </script> 28 40 <div class="wrap"> 29 41 <h2><?php _e('Comments'); ?></h2> 30 <form name="searchform" action="" method="get" >42 <form name="searchform" action="" method="get" id="editcomments"> 31 43 <fieldset> 32 44 <legend><?php _e('Show Comments That Contain...') ?></legend> … … 34 46 <input type="submit" name="submit" value="<?php _e('Search') ?>" /> 35 47 <input type="hidden" name="mode" value="<?php echo $mode; ?>" /> 36 <?php _e('(Searches within comment text, e-mail, UR I, and IP address.)') ?>48 <?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?> 37 49 </fieldset> 38 50 </form> … … 40 52 <?php 41 53 if ( !empty( $_POST['delete_comments'] ) ) : 54 check_admin_referer('bulk-comments'); 55 42 56 $i = 0; 43 57 foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each 44 58 $comment = (int) $comment; 45 59 $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"); 60 // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); 61 if ( current_user_can('edit_post', $post_id) ) { 62 if ( !empty( $_POST['spam_button'] ) ) 63 wp_set_comment_status($comment, 'spam'); 64 else 65 wp_set_comment_status($comment, 'delete'); 49 66 ++$i; 50 endif;67 } 51 68 endforeach; 52 echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>"; 69 echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>'; 70 if ( !empty( $_POST['spam_button'] ) ) 71 printf(__('%s comments marked as spam.'), $i); 72 else 73 printf(__('%s comments deleted.'), $i); 74 echo '</p></div>'; 53 75 endif; 54 76 … … 78 100 $start = ''; 79 101 80 echo "<ol id='the- list' class='commentlist' $start>";102 echo "<ol id='the-comment-list' class='commentlist' $start>"; 81 103 $i = 0; 82 104 foreach ($comments as $comment) { … … 89 111 $class .= ' alternate'; 90 112 echo "<li id='comment-$comment->comment_ID' class='$class'>"; 91 ?> 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> 93 94 <?php comment_text() ?> 95 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 101 // Get post title 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> 106 <?php } ?> 107 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p> 113 ?> 114 <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> 115 116 <?php comment_text() ?> 117 118 <p><?php comment_date('M j, g:i A'); ?> — [ 119 <?php 120 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 121 echo " <a href='comment.php?action=editcomment&comment=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 122 echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&comment=' . $comment->comment_ID, 'delete-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."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; 123 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 124 echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; 125 echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; 126 } 127 echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&delete_type=spam&p=" . $comment->comment_post_ID . "&comment=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by "%s".\\n"Cancel" to stop, "OK" to mark as spam."), js_escape( $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; 128 } 129 $post = get_post($comment->comment_post_ID); 130 $post_title = wp_specialchars( $post->post_title, 'double' ); 131 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; 132 ?> 133 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p> 108 134 </li> 109 135 110 <?php } // end foreach ?>136 <?php } // end foreach($comment) ?> 111 137 </ol> 112 138 … … 114 140 115 141 <?php 116 } else { 142 } else { //no comments to show 117 143 118 144 ?> 119 145 <p> 120 146 <strong><?php _e('No comments found.') ?></strong></p> 121 147 122 148 <?php 123 149 } // end if ($comments) … … 125 151 126 152 if ($comments) { 127 echo '<form name="deletecomments" id="deletecomments" action="" method="post"> 128 <table width="100%" cellpadding="3" cellspacing="3"> 153 echo '<form name="deletecomments" id="deletecomments" action="" method="post"> '; 154 wp_nonce_field('bulk-comments'); 155 echo '<table class="widefat"> 156 <thead> 129 157 <tr> 130 <th scope="col" >*</th>158 <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th> 131 159 <th scope="col">' . __('Name') . '</th> 132 160 <th scope="col">' . __('E-mail') . '</th> 133 161 <th scope="col">' . __('IP') . '</th> 134 162 <th scope="col">' . __('Comment Excerpt') . '</th> 135 <th scope="col" colspan="3">' . __('Actions') . '</th> 136 </tr>'; 163 <th scope="col" colspan="3" style="text-align: center">' . __('Actions') . '</th> 164 </tr> 165 </thead>'; 137 166 foreach ($comments as $comment) { 138 167 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 168 $comment_status = wp_get_comment_status($comment->comment_ID); 139 169 $class = ('alternate' == $class) ? '' : 'alternate'; 140 ?> 141 <tr class='<?php echo $class; ?>'> 170 $class .= ('unapproved' == $comment_status) ? ' unapproved' : ''; 171 ?> 172 <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> 142 173 <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 174 <td><?php comment_author_link() ?></td> … … 145 176 <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td> 146 177 <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> 178 <td> 179 <?php if ('unapproved' == $comment_status) { ?> 180 (Unapproved) 181 <?php } else { ?> 182 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a> 183 <?php } ?> 184 </td> 148 185 <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>186 echo "<a href='comment.php?action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> 150 187 <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> 188 echo "<a href=\"comment.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."), js_escape( $comment->comment_author )) . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> "; 189 } ?></td> 152 190 </tr> 153 191 <?php 154 192 } // end foreach 155 193 ?></table> 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>194 <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 _e("Please select some comments to delete"); ?>'); return false } return confirm('<?php printf(__("You are about to delete %s comments permanently \\n \'Cancel\' to stop, \'OK\' to delete."), "' + numchecked + '"); ?>')" /> 195 <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam »') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p> 158 196 </form> 197 <div id="ajax-response"></div> 159 198 <?php 160 199 } else {
Note: See TracChangeset
for help on using the changeset viewer.