Make WordPress Core


Ignore:
Timestamp:
07/30/2009 01:39:34 PM (15 years ago)
Author:
azaozz
Message:

Trash status updates for posts, pages, comments and attachments, props caesarsgrunt, see #4529

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-comments.php

    r11741 r11749  
    1515$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
    1616
    17 if ( isset($_REQUEST['doaction']) ||  isset($_REQUEST['doaction2']) || isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2']) ) {
     17if ( isset($_REQUEST['doaction']) ||  isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
    1818    check_admin_referer('bulk-comments');
    1919   
    20     if ((isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
     20    if ((isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
    2121        $comment_status = $wpdb->escape($_REQUEST['comment_status']);
    2222        $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']);
    2323        $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';
     24        $doaction = 'delete';
    2525    } elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) {
    2626        $comment_ids = $_REQUEST['delete_comments'];
     
    2828    } else wp_redirect($_SERVER['HTTP_REFERER']);
    2929   
    30     $approved = $unapproved = $spammed = $deleted = $destroyed = 0;
     30    $approved = $unapproved = $spammed = $trashed = $untrashed = $deleted = 0;
    3131   
    3232    foreach ($comment_ids as $comment_id) { // Check the permissions on each
     
    4949                $spammed++;
    5050                break;
     51            case 'trash' :
     52                wp_trash_comment($comment_id);
     53                $trashed++;
     54                break;
     55            case 'untrash' :
     56                wp_untrash_comment($comment_id);
     57                $untrashed++;
     58                break;
    5159            case 'delete' :
    52                 wp_set_comment_status($comment_id, 'delete');
     60                wp_delete_comment($comment_id);
    5361                $deleted++;
    5462                break;
    55             case 'destroy' :
    56                 wp_set_comment_status($comment_id, 'delete');
    57                 $destroyed++;
    58                 break;
    5963        }
    6064    }
    6165
    62     $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&deleted=' . $deleted . '&destroyed=' . $destroyed;
     66    $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&trashed=' . $trashed . '&untrashed=' . $untrashed . '&deleted=' . $deleted;
    6367    if ( $post_id )
    6468        $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
     
    8791
    8892$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
    89 if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'deleted')) )
     93if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) )
    9094    $comment_status = 'all';
    9195
     
    103107
    104108<?php
    105 if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['destroyed'] ) || isset( $_GET['spam'] ) ) {
    106     $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
    107     $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
    108     $destroyed = isset( $_GET['destroyed'] ) ? (int) $_GET['destroyed'] : 0;
    109     $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0;
    110 
    111     if ( $approved > 0 || $deleted > 0 || $destroyed > 0 || $spam > 0 ) {
     109if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spam']) ) {
     110    $approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0;
     111    $deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0;
     112    $trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0;
     113    $untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0;
     114    $spam = isset($_GET['spam']) ? (int) $_GET['spam'] : 0;
     115
     116    if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spam > 0 ) {
    112117        echo '<div id="moderated" class="updated fade"><p>';
    113118
     
    120125            echo '<br />';
    121126        }
     127        if ( $trashed > 0 ) {
     128            printf( _n( '%s comment moved to the trash', '%s comments moved to the trash', $trashed ), $trashed );
     129            echo '<br />';
     130        }
     131        if ( $untrashed > 0 ) {
     132            printf( _n( '%s comment removed from the trash', '%s comments removed from the trash', $untrashed ), $untrashed );
     133            echo '<br />';
     134        }
    122135        if ( $deleted > 0 ) {
    123             printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
    124             echo '<br />';
    125         }
    126         if ( $destroyed > 0 ) {
    127             printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed );
     136            printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
    128137            echo '<br />';
    129138        }
     
    146155        'approved' => _n_noop('Approved', 'Approved'), // singular not used
    147156        '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>')
     157        'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')
    149158    );
    150159$link = 'edit-comments.php';
     
    257266<option value="markspam"><?php _e('Mark as Spam'); ?></option>
    258267<?php endif; ?>
    259 <?php if ( 'deleted' == $comment_status ): ?>
    260 <option value="unapprove"><?php _e('Return to Pending'); ?></option>
    261 <?php endif; ?>
    262 <?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
    263 <option value="destroy"><?php _e('Delete Permanently'); ?></option>
     268<?php if ( 'trash' == $comment_status ): ?>
     269<option value="untrash"><?php _e('Restore'); ?></option>
     270<?php endif; ?>
     271<?php if ( 'trash' == $comment_status || 'spam' == $comment_status ): ?>
     272<option value="delete"><?php _e('Delete Permanently'); ?></option>
    264273<?php else: ?>
    265 <option value="delete"><?php _e('Move to Trash'); ?></option>
     274<option value="trash"><?php _e('Move to Trash'); ?></option>
    266275<?php endif; ?>
    267276</select>
     
    290299<?php }
    291300
    292 if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) {
     301if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_can ('moderate_comments') ) {
    293302    wp_nonce_field('bulk-destroy', '_destroy_nonce');
    294303    if ( 'spam' == $comment_status ) { ?>
    295         <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
    296 <?php } elseif ( 'deleted' == $comment_status ) { ?>
    297         <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-primary apply" />
     304        <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
     305<?php } elseif ( 'trash' == $comment_status ) { ?>
     306        <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    298307<?php }
    299308} ?>
     
    353362<option value="markspam"><?php _e('Mark as Spam'); ?></option>
    354363<?php endif; ?>
    355 <?php if ( 'deleted' == $comment_status ): ?>
    356 <option value="unapprove"><?php _e('Return to Pending'); ?></option>
    357 <?php endif; ?>
    358 <?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
    359 <option value="destroy"><?php _e('Delete Permanently'); ?></option>
     364<?php if ( 'trash' == $comment_status ): ?>
     365<option value="untrash"><?php _e('Restore'); ?></option>
     366<?php endif; ?>
     367<?php if ( 'trash' == $comment_status || 'spam' == $comment_status ): ?>
     368<option value="delete"><?php _e('Delete Permanently'); ?></option>
    360369<?php else: ?>
    361 <option value="delete"><?php _e('Move to Trash'); ?></option>
     370<option value="trash"><?php _e('Move to Trash'); ?></option>
    362371<?php endif; ?>
    363372</select>
     
    365374
    366375<?php if ( 'spam' == $comment_status ) { ?>
    367 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Quarantine'); ?>" class="button-secondary apply" />
    368 <?php } elseif ( 'deleted' == $comment_status ) { ?>
    369 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
     376<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
     377<?php } elseif ( 'trash' == $comment_status ) { ?>
     378<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    370379<?php } ?>
    371380<?php do_action('manage_comments_nav', $comment_status); ?>
Note: See TracChangeset for help on using the changeset viewer.