Changeset 9028 for trunk/wp-admin/edit-comments.php
- Timestamp:
- 09/29/2008 09:26:21 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-comments.php
r9023 r9028 17 17 if ( isset( $_POST['delete_all_spam'] ) ) { 18 18 check_admin_referer('bulk-spam-delete'); 19 19 20 20 $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'" ); 21 21 wp_redirect('edit-comments.php?deleted=' . (int) $deleted_spam); 22 22 } 23 23 24 if ( !empty( $_REQUEST['delete_comments'] ) && isset($_REQUEST['action']) ) {24 if ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) { 25 25 check_admin_referer('bulk-comments'); 26 27 $comments_deleted = $comments_approved = $comments_unapproved = $comments_spammed = 0; 28 foreach ($_REQUEST['delete_comments'] as $comment) : // Check the permissions on each 29 $comment = (int) $comment; 30 $post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment) ); 26 $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; 27 28 $deleted = $approved = $unapproved = $spammed = 0; 29 foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each 30 $comment_id = (int) $comment_id; 31 $post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); 32 31 33 if ( !current_user_can('edit_post', $post_id) ) 32 34 continue; 33 if ( $_REQUEST['action'] == 'markspam' ) { 34 wp_set_comment_status($comment, 'spam'); 35 $comments_spammed++; 36 } elseif ( $_REQUEST['action'] == 'delete' ) { 37 wp_set_comment_status($comment, 'delete'); 38 $comments_deleted++; 39 } elseif ( $_REQUEST['action'] == 'approve' ) { 40 wp_set_comment_status($comment, 'approve'); 41 $comments_approved++; 42 } elseif ( $_REQUEST['action'] == 'unapprove' ) { 43 wp_set_comment_status($comment, 'hold'); 44 $comments_unapproved++; 35 36 switch( $doaction ) { 37 case 'markspam' : 38 wp_set_comment_status($comment_id, 'spam'); 39 $spammed++; 40 break; 41 case 'delete' : 42 wp_set_comment_status($comment_id, 'delete'); 43 $deleted++; 44 break; 45 case 'approve' : 46 wp_set_comment_status($comment_id, 'approve'); 47 $approved++; 48 break; 49 case 'unapprove' : 50 wp_set_comment_status($comment_id, 'hold'); 51 $unapproved++; 52 break; 45 53 } 46 54 endforeach; 47 $redirect_to = basename( __FILE__ ) . '?deleted=' . $comments_deleted . '&approved=' . $comments_approved . '&spam=' . $comments_spammed . '&unapproved=' . $comments_unapproved; 55 56 $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved; 48 57 if ( isset($_REQUEST['apage']) ) 49 58 $redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to ); … … 55 64 $redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to); 56 65 wp_redirect( $redirect_to ); 57 } elseif ( !empty($_GET['_wp_http_referer']) ) {58 wp_redirect( remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));66 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 67 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 59 68 exit; 60 69 } … … 112 121 } 113 122 ?> 123 114 124 <div class="wrap"> 115 125 … … 144 154 145 155 <?php 146 147 156 $comments_per_page = apply_filters('comments_per_page', 20, $comment_status); 148 157 … … 181 190 <div class="alignleft"> 182 191 <select name="action"> 183 <option value=" " selected="selected"><?php _e('Actions') ?></option>192 <option value="-1" selected="selected"><?php _e('Actions') ?></option> 184 193 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?> 185 194 <option value="unapprove"><?php _e('Unapprove'); ?></option> … … 199 208 <?php } 200 209 201 if ( 'spam' == $comment_status ) { 210 if ( 'spam' == $comment_status ) { 202 211 wp_nonce_field('bulk-spam-delete'); ?> 203 212 <input type="submit" name="delete_all_spam" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" /> … … 211 220 212 221 <br class="clear" /> 213 <?php 214 if ($comments) { 215 ?> 222 223 <?php if ( $comments ) { ?> 216 224 <table class="widefat"> 217 225 <thead> … … 220 228 </tr> 221 229 </thead> 230 231 <tfoot> 232 <tr> 233 <?php print_column_headers('comment', false); ?> 234 </tr> 235 </tfoot> 236 222 237 <tbody id="the-comment-list" class="list:comment"> 223 238 <?php … … 233 248 </tbody> 234 249 </table> 250 251 <div class="tablenav"> 252 <?php 253 if ( $page_links ) 254 echo "<div class='tablenav-pages'>$page_links</div>"; 255 ?> 256 257 <div class="alignleft"> 258 <select name="action2"> 259 <option value="-1" selected="selected"><?php _e('Actions') ?></option> 260 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?> 261 <option value="unapprove"><?php _e('Unapprove'); ?></option> 262 <?php endif; ?> 263 <?php if ( empty($comment_status) || 'moderated' == $comment_status ): ?> 264 <option value="approve"><?php _e('Approve'); ?></option> 265 <?php endif; ?> 266 <?php if ( 'spam' != $comment_status ): ?> 267 <option value="markspam"><?php _e('Mark as Spam'); ?></option> 268 <?php endif; ?> 269 <option value="delete"><?php _e('Delete'); ?></option> 270 </select> 271 <input type="submit" name="doaction2" id="doaction2" value="<?php _e('Apply'); ?>" class="button-secondary apply" /> 272 273 <?php if ( 'spam' == $comment_status ) { ?> 274 <input type="submit" name="delete_all_spam2" value="<?php _e('Delete All Spam'); ?>" class="button-secondary apply" /> 275 <?php } ?> 276 <?php do_action('manage_comments_nav', $comment_status); ?> 277 </div> 278 279 <br class="clear" /> 280 </div> 235 281 236 282 </form> … … 252 298 </p> 253 299 <?php 254 } else 300 } else { 255 301 ?> 256 302 <p> … … 260 306 } 261 307 ?> 262 <div class="tablenav">263 <?php264 if ( $page_links )265 echo "<div class='tablenav-pages'>$page_links</div>";266 ?>267 <br class="clear" />268 </div>269 308 270 309 </div>
Note: See TracChangeset
for help on using the changeset viewer.