Changeset 11731 for trunk/wp-admin/edit-comments.php
- Timestamp:
- 07/21/2009 03:11:12 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/edit-comments.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-comments.php
r11660 r11731 15 15 $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; 16 16 17 if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) { 18 check_admin_referer('bulk-spam-delete', '_spam_nonce'); 19 20 $delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] ); 21 if ( current_user_can('moderate_comments')) { 22 $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" ); 23 } else { 24 $deleted_spam = 0; 25 } 26 $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam; 27 if ( $post_id ) 28 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); 29 wp_redirect( $redirect_to ); 30 } elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) { 17 if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2']) ) { 31 18 check_admin_referer('bulk-comments'); 32 $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; 33 34 $deleted = $approved = $unapproved = $spammed = 0; 35 foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each 36 $comment_id = (int) $comment_id; 19 20 if ((isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) { 21 $comment_status = $wpdb->escape($_REQUEST['comment_status']); 22 $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']); 23 $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" ); 24 $doaction = 'destroy'; 25 } elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) { 26 $comment_ids = $_REQUEST['delete_comments']; 27 $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2']; 28 } else wp_redirect($_SERVER['HTTP_REFERER']); 29 30 $approved = $unapproved = $spammed = $deleted = $destroyed = 0; 31 32 foreach ($comment_ids as $comment_id) { // Check the permissions on each 37 33 $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); 38 34 … … 41 37 42 38 switch( $doaction ) { 39 case 'approve' : 40 wp_set_comment_status($comment_id, 'approve'); 41 $approved++; 42 break; 43 case 'unapprove' : 44 wp_set_comment_status($comment_id, 'hold'); 45 $unapproved++; 46 break; 43 47 case 'markspam' : 44 48 wp_set_comment_status($comment_id, 'spam'); … … 49 53 $deleted++; 50 54 break; 51 case 'approve' : 52 wp_set_comment_status($comment_id, 'approve'); 53 $approved++; 54 break; 55 case 'unapprove' : 56 wp_set_comment_status($comment_id, 'hold'); 57 $unapproved++; 58 break; 59 } 60 endforeach; 61 62 $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved; 55 case 'destroy' : 56 wp_set_comment_status($comment_id, 'delete'); 57 $destroyed++; 58 break; 59 } 60 } 61 62 $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&deleted=' . $deleted . '&destroyed=' . $destroyed; 63 63 if ( $post_id ) 64 64 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); … … 87 87 88 88 $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; 89 if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam' )) )89 if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'deleted')) ) 90 90 $comment_status = 'all'; 91 91 … … 103 103 104 104 <?php 105 if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET[' spam'] ) ) {105 if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['destroyed'] ) || isset( $_GET['spam'] ) ) { 106 106 $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; 107 107 $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; 108 $destroyed = isset( $_GET['destroyed'] ) ? (int) $_GET['destroyed'] : 0; 108 109 $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0; 109 110 110 if ( $approved > 0 || $deleted > 0 || $ spam > 0 ) {111 if ( $approved > 0 || $deleted > 0 || $destroyed > 0 || $spam > 0 ) { 111 112 echo '<div id="moderated" class="updated fade"><p>'; 112 113 … … 115 116 echo '<br />'; 116 117 } 117 118 if ( $spam > 0 ) { 119 printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); 120 echo '<br />'; 121 } 118 122 if ( $deleted > 0 ) { 119 123 printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); 120 124 echo '<br />'; 121 125 } 122 123 if ( $spam > 0 ) { 124 printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam ); 126 if ( $destroyed > 0 ) { 127 printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed ); 125 128 echo '<br />'; 126 129 } … … 140 143 $stati = array( 141 144 'all' => _n_noop('All', 'All'), // singular not used 142 'moderated' => _n_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'),145 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'), 143 146 'approved' => _n_noop('Approved', 'Approved'), // singular not used 144 'spam' => _n_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)') 147 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'), 148 'deleted' => _n_noop('Trash <span class="count">(<span class="deleted-count">%s</span>)</span>', 'Trash <span class="count">(<span class="deleted-count">%s</span>)</span>') 145 149 ); 146 150 $link = 'edit-comments.php'; … … 247 251 <option value="unapprove"><?php _e('Unapprove'); ?></option> 248 252 <?php endif; ?> 249 <?php if ( 'a ll' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>253 <?php if ( 'approved' != $comment_status ): ?> 250 254 <option value="approve"><?php _e('Approve'); ?></option> 251 255 <?php endif; ?> … … 253 257 <option value="markspam"><?php _e('Mark as Spam'); ?></option> 254 258 <?php endif; ?> 259 <?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?> 260 <option value="destroy"><?php _e('Delete Permanently'); ?></option> 261 <?php else: ?> 255 262 <option value="delete"><?php _e('Delete'); ?></option> 263 <?php endif; ?> 256 264 </select> 257 265 <input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> … … 279 287 <?php } 280 288 281 if ( 'spam' == $comment_status ) {282 wp_nonce_field('bulk- spam-delete', '_spam_nonce');289 if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { 290 wp_nonce_field('bulk-destroy', '_destroy_nonce'); 283 291 if ( current_user_can ('moderate_comments')) { ?> 284 <input type="submit" name="de lete_all_spam" value="<?php esc_attr_e('Delete All Spam'); ?>" class="button-secondary apply" />285 <?php }292 <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" /> 293 <?php } 286 294 } ?> 287 295 <?php do_action('manage_comments_nav', $comment_status); ?> … … 334 342 <option value="unapprove"><?php _e('Unapprove'); ?></option> 335 343 <?php endif; ?> 336 <?php if ( 'a ll' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>344 <?php if ( 'approved' != $comment_status ): ?> 337 345 <option value="approve"><?php _e('Approve'); ?></option> 338 346 <?php endif; ?> … … 340 348 <option value="markspam"><?php _e('Mark as Spam'); ?></option> 341 349 <?php endif; ?> 350 <?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?> 351 <option value="destroy"><?php _e('Delete Permanently'); ?></option> 352 <?php else: ?> 342 353 <option value="delete"><?php _e('Delete'); ?></option> 354 <?php endif; ?> 343 355 </select> 344 356 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> 345 357 346 <?php if ( 'spam' == $comment_status ) { ?>347 <input type="submit" name="de lete_all_spam2" value="<?php esc_attr_e('Delete All Spam'); ?>" class="button-secondary apply" />358 <?php if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { ?> 359 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" /> 348 360 <?php } ?> 349 361 <?php do_action('manage_comments_nav', $comment_status); ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)