Make WordPress Core

Changeset 11749


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

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

Location:
trunk
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r11731 r11749  
    182182switch ( $action = $_POST['action'] ) :
    183183case 'delete-comment' : // On success, die with time() instead of 1
    184         check_ajax_referer( "delete-comment_$id" );
    185184        if ( !$comment = get_comment( $id ) )
    186185                die( (string) time() );
    … …  
    188187                die('-1');
    189188
    190         if ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
     189        if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
     190                check_ajax_referer( "trash-comment_$id" );
     191                if ( 'trash' == wp_get_comment_status( $comment->comment_ID ) )
     192                        die( (string) time() );
     193                $r = wp_trash_comment( $comment->comment_ID );
     194        } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
     195                check_ajax_referer( "untrash-comment_$id" );
     196                $r = wp_untrash_comment( $comment->comment_ID );
     197        } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
     198                check_ajax_referer( "delete-comment_$id" );
    191199                if ( 'spam' == wp_get_comment_status( $comment->comment_ID ) )
    192200                        die( (string) time() );
    193201                $r = wp_set_comment_status( $comment->comment_ID, 'spam' );
    194202        } else {
    195                 $r = wp_set_comment_status( $comment->comment_ID, 'delete' );
     203                check_ajax_referer( "delete-comment_$id" );
     204                $r = wp_delete_comment( $comment->comment_ID );
    196205        }
    197206        if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
  • trunk/wp-admin/comment.php

    r11731 r11749  
    4545                comment_footer_die( __('You are not allowed to edit comments on this post.') );
    4646
    47         if ( 'deleted' == $comment->comment_status )
    48                 comment_footer_die( __('This comment has been deleted. Please move it out of the Trash if you want to edit it.') );
     47        if ( 'trash' == $comment->comment_status )
     48                comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') );
    4949       
    5050        $comment = get_comment_to_edit( $comment_id );
    … …  
    167167        break;
    168168
     169case 'trashcomment' :
     170case 'untrashcomment' :
     171        $comment_id = absint( $_REQUEST['c'] );
     172        $noredir = isset($_REQUEST['noredir']);
     173       
     174        if (!$comment = get_comment($comment_id))
     175                comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'edit-comments.php') );
     176        if (!current_user_can('edit_post', $comment->comment_post_ID ))
     177                comment_footer_die( __('You are not allowed to edit comments on this post.') );
     178       
     179        if ($action == 'trashcomment') {
     180                check_admin_referer( 'trash-comment_' . $comment_id );
     181                wp_trash_comment($comment_id);
     182        }
     183        else {
     184                check_admin_referer( 'untrash-comment_' . $comment_id );
     185                wp_untrash_comment($comment_id);
     186        }
     187       
     188        if ('' != wp_get_referer() && false == $noredir && false === strpos(wp_get_referer(), 'comment.php' ))
     189                wp_redirect( wp_get_referer() );
     190        else if ('' != wp_get_original_referer() && false == $noredir)
     191                wp_redirect(wp_get_original_referer());
     192        else
     193                wp_redirect(admin_url('edit-comments.php'));
     194
     195        die;
     196        break;
     197
    169198case 'unapprovecomment' :
    170199        $comment_id = absint( $_GET['c'] );
  • trunk/wp-admin/edit-attachment-rows.php

    r11380 r11749  
    2929$posts_columns = get_column_headers('upload');
    3030$hidden = get_hidden_columns('upload');
    31 while (have_posts()) : the_post();
     31
     32while ( have_posts() ) : the_post();
     33
     34if ( $is_trash && $post->post_status != 'trash' )
     35        continue;
     36elseif ( !$is_trash && $post->post_status == 'trash' )
     37        continue;
     38
    3239$alt = ( 'alternate' == $alt ) ? '' : 'alternate';
    3340global $current_user;
    3441$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
    3542$att_title = _draft_or_post_title();
    36 
    3743?>
    3844        <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
    … …  
    6167                <td <?php echo $attributes ?>><?php
    6268                        if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
    63 ?>
    64 
     69                                if ( $is_trash ) echo $thumb;
     70                                else {
     71?>
    6572                                <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>">
    6673                                        <?php echo $thumb; ?>
    … …  
    6875
    6976<?php                   }
     77                        }
    7078                ?></td>
    7179                <?php
    … …  
    7583        case 'media':
    7684                ?>
    77                 <td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>"><?php echo $att_title; ?></a></strong><br />
     85                <td <?php echo $attributes ?>><strong><?php if ( $is_trash ) echo $att_title; else { ?><a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>"><?php echo $att_title; ?></a><?php } ?></strong><br />
    7886                <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
    7987                <p>
    8088                <?php
    8189                $actions = array();
    82                 if ( current_user_can('edit_post', $post->ID) )
    83                         $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
    84                 if ( current_user_can('delete_post', $post->ID) )
    85                         $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
    86                 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     90                if ( $is_trash && current_user_can('delete_post', $post->ID) ) {
     91                        $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
     92                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
     93                } else {
     94                        if ( current_user_can('edit_post', $post->ID) )
     95                                $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
     96                        if ( current_user_can('delete_post', $post->ID) )
     97                                $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
     98                        $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     99                }
    87100                $action_count = count($actions);
    88101                $i = 0;
  • 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); ?>
  • trunk/wp-admin/edit-form-advanced.php

    r11383 r11749  
    230230<?php
    231231if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?>
    232 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
     232<a class="submitdelete deletion" href="<?php echo wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID); ?>"><?php _e('Move to Trash'); ?></a>
    233233<?php } ?>
    234234</div>
  • trunk/wp-admin/edit-form-comment.php

    r11739 r11749  
    6565<div id="major-publishing-actions">
    6666<div id="delete-action">
    67 <?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=deletecomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . esc_js(__("You are about to delete this comment. \n  'Cancel' to stop, 'OK' to delete.")) . "') ){return true;}return false;\">" . __('Delete') . "</a>\n"; ?>
     67<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=deletecomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . __('Move to Trash') . "</a>\n"; ?>
    6868</div>
    6969<div id="publishing-action">
  • trunk/wp-admin/edit-page-form.php

    r11383 r11749  
    217217<?php
    218218if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?>
    219 <a class="submitdelete deletion" href="<?php echo wp_nonce_url("page.php?action=delete&amp;post=$post->ID", 'delete-page_' . $post->ID); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
     219<a class="submitdelete deletion" href="<?php echo wp_nonce_url("page.php?action=trash&amp;post=$post->ID", 'trash-page_' . $post->ID); ?>"><?php _e('Move to Trash'); ?></a>
    220220<?php } ?>
    221221</div>
  • trunk/wp-admin/edit-pages.php

    r11743 r11749  
    1111
    1212// Handle bulk actions
    13 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
    14         $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
     13if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
     14        check_admin_referer('bulk-pages');
     15       
     16        if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
     17                $post_status = $wpdb->escape($_GET['post_status']);
     18                $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = '$post_status'" );
     19                $doaction = 'delete';
     20        } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
     21                $post_ids = $_GET['post'];
     22                $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
     23        } else wp_redirect($_SERVER['HTTP_REFERER']);
    1524
    1625        switch ( $doaction ) {
     26                case 'trash':
     27                        $trashed = 0;
     28                        foreach( (array) $post_ids as $post_id ) {
     29                                if ( !current_user_can('delete_page', $post_id) )
     30                                        wp_die( __('You are not allowed to move this page to the trash.') );
     31
     32                                if ( !wp_trash_post($post_id) )
     33                                        wp_die( __('Error in moving to trash...') );
     34                               
     35                                $trashed++;
     36                        }
     37                        break;
     38                case 'untrash':
     39                        $untrashed = 0;
     40                        foreach( (array) $post_ids as $post_id ) {
     41                                if ( !current_user_can('delete_page', $post_id) )
     42                                        wp_die( __('You are not allowed to remove this page from the trash.') );
     43
     44                                if ( !wp_untrash_post($post_id) )
     45                                        wp_die( __('Error in removing from trash...') );
     46                               
     47                                $untrashed++;
     48                        }
     49                        break;
    1750                case 'delete':
    18                         if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
    19                                 check_admin_referer('bulk-pages');
    20                                 $deleted = 0;
    21                                 foreach( (array) $_GET['post'] as $post_id_del ) {
    22                                         $post_del = & get_post($post_id_del);
    23 
    24                                         if ( !current_user_can('delete_page', $post_id_del) )
    25                                                 wp_die( __('You are not allowed to delete this page.') );
    26 
    27                                         if ( $post_del->post_type == 'attachment' ) {
    28                                                 if ( ! wp_delete_attachment($post_id_del) )
    29                                                         wp_die( __('Error in deleting...') );
    30                                         } else {
    31                                                 if ( !wp_delete_post($post_id_del) )
    32                                                         wp_die( __('Error in deleting...') );
    33                                         }
    34                                         $deleted++;
     51                        $deleted = 0;
     52                        foreach( (array) $post_ids as $post_id_del ) {
     53                                $post_del = & get_post($post_id_del);
     54
     55                                if ( !current_user_can('delete_page', $post_id_del) )
     56                                        wp_die( __('You are not allowed to delete this page.') );
     57
     58                                if ( $post_del->post_type == 'attachment' ) {
     59                                        if ( ! wp_delete_attachment($post_id_del) )
     60                                                wp_die( __('Error in deleting...') );
     61                                } else {
     62                                        if ( !wp_delete_post($post_id_del) )
     63                                                wp_die( __('Error in deleting...') );
    3564                                }
     65                                $deleted++;
    3666                        }
    3767                        break;
    3868                case 'edit':
    39                         if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
    40                                 check_admin_referer('bulk-pages');
    41 
    42                                 if ( -1 == $_GET['_status'] ) {
    43                                         $_GET['post_status'] = null;
    44                                         unset($_GET['_status'], $_GET['post_status']);
    45                                 } else {
    46                                         $_GET['post_status'] = $_GET['_status'];
    47                                 }
    48 
    49                                 $done = bulk_edit_posts($_GET);
     69                        if ( -1 == $_GET['_status'] ) {
     70                                $_GET['post_status'] = null;
     71                                unset($_GET['_status'], $_GET['post_status']);
     72                        } else {
     73                                $_GET['post_status'] = $_GET['_status'];
    5074                        }
     75
     76                        $done = bulk_edit_posts($_GET);
    5177                        break;
    5278        }
    … …  
    6389        if ( isset($deleted) )
    6490                $sendback = add_query_arg('deleted', $deleted, $sendback);
     91        elseif ( isset($trashed) )
     92                $sendback = add_query_arg('trashed', $trashed, $sendback);
     93        elseif ( isset($untrashed) )
     94                $sendback = add_query_arg('untrashed', $untrashed, $sendback);
    6595        wp_redirect($sendback);
    6696        exit();
    … …  
    80110                'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')),
    81111                'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')),
    82                 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page'))
     112                'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')),
     113                'trash' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page'))
    83114        );
    84115
    … …  
    112143</h2>
    113144
    114 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
     145<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
    115146<div id="message" class="updated fade"><p>
    116147<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
    … …  
    118149        unset($_GET['updated']);
    119150}
    120 
    121151if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) {
    122152        printf( _n( '%s page not updated, invalid parent page specified.', '%s pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) );
    123153        unset($_GET['skipped']);
    124154}
    125 
    126155if ( isset($_GET['locked']) && (int) $_GET['locked'] ) {
    127156        printf( _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) );
    128157        unset($_GET['locked']);
    129158}
    130 
    131159if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
    132         printf( _n( 'Page deleted.', '%s pages deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
     160        printf( _n( 'Page permanently deleted.', '%s pages permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
    133161        unset($_GET['deleted']);
    134162}
    135 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
     163if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
     164        printf( _n( 'Page moved to the trash.', '%s pages moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
     165        unset($_GET['trashed']);
     166}
     167if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
     168        printf( _n( 'Page removed from the trash.', '%s pages removed from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
     169        unset($_GET['untrashed']);
     170}
     171$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] );
    136172?>
    137173</p></div>
    … …  
    151187$status_links = array();
    152188$num_posts = wp_count_posts('page', 'readable');
    153 $total_posts = array_sum( (array) $num_posts );
     189$total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
    154190$class = empty($_GET['post_status']) ? ' class="current"' : '';
    155191$status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'pages' ), number_format_i18n( $total_posts ) ) . '</a>';
    … …  
    213249<select name="action">
    214250<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
     251<?php if ($_GET['post_status'] == 'trash') { ?>
     252<option value="untrash"><?php _e('Restore'); ?></option>
     253<option value="delete"><?php _e('Delete Permanently'); ?></option>
     254<?php } else { ?>
    215255<option value="edit"><?php _e('Edit'); ?></option>
    216 <option value="delete"><?php _e('Delete'); ?></option>
     256<option value="trash"><?php _e('Move to Trash'); ?></option>
     257<?php } ?>
    217258</select>
    218259<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
    219260<?php wp_nonce_field('bulk-pages'); ?>
     261<?php if ($_GET['post_status'] == 'trash') { ?>
     262<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
     263<?php } ?>
    220264</div>
    221265
    … …  
    252296<select name="action2">
    253297<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
     298<?php if ($_GET['post_status'] == 'trash') { ?>
     299<option value="untrash"><?php _e('Restore'); ?></option>
     300<option value="delete"><?php _e('Delete Permanently'); ?></option>
     301<?php } else { ?>
    254302<option value="edit"><?php _e('Edit'); ?></option>
    255 <option value="delete"><?php _e('Delete'); ?></option>
     303<option value="trash"><?php _e('Move to Trash'); ?></option>
     304<?php } ?>
    256305</select>
    257306<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
     307<?php if ($_GET['post_status'] == 'trash') { ?>
     308<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
     309<?php } ?>
    258310</div>
    259311
  • trunk/wp-admin/edit.php

    r11743 r11749  
    1919
    2020// Handle bulk actions
    21 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
    22         $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
    23 
     21if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
     22        check_admin_referer('bulk-posts');
     23       
     24        if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
     25                $post_status = $wpdb->escape($_GET['post_status']);
     26                $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = '$post_status'" );
     27                $doaction = 'delete';
     28        } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
     29                $post_ids = $_GET['post'];
     30                $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
     31        } else wp_redirect($_SERVER['HTTP_REFERER']);
     32       
    2433        switch ( $doaction ) {
     34                case 'trash':
     35                        $trashed = 0;
     36                        foreach( (array) $post_ids as $post_id ) {
     37                                $post_del = & get_post($post_id);
     38
     39                                if ( !current_user_can('delete_post', $post_id_del) )
     40                                        wp_die( __('You are not allowed to move this post to the trash.') );
     41
     42                                if ( !wp_trash_post($post_id) )
     43                                        wp_die( __('Error in moving to trash...') );
     44                               
     45                                $trashed++;
     46                        }
     47                        break;
     48                case 'untrash':
     49                        $untrashed = 0;
     50                        foreach( (array) $post_ids as $post_id ) {
     51                                $post_del = & get_post($post_id);
     52
     53                                if ( !current_user_can('delete_post', $post_id_del) )
     54                                        wp_die( __('You are not allowed to remove this post from the trash.') );
     55
     56                                if ( !wp_untrash_post($post_id) )
     57                                        wp_die( __('Error in removing from trash...') );
     58                               
     59                                $untrashed++;
     60                        }
     61                        break;
    2562                case 'delete':
    26                         if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
    27                                 check_admin_referer('bulk-posts');
    28                                 $deleted = 0;
    29                                 foreach( (array) $_GET['post'] as $post_id_del ) {
    30                                         $post_del = & get_post($post_id_del);
    31 
    32                                         if ( !current_user_can('delete_post', $post_id_del) )
    33                                                 wp_die( __('You are not allowed to delete this post.') );
    34 
    35                                         if ( $post_del->post_type == 'attachment' ) {
    36                                                 if ( ! wp_delete_attachment($post_id_del) )
    37                                                         wp_die( __('Error in deleting...') );
    38                                         } else {
    39                                                 if ( !wp_delete_post($post_id_del) )
    40                                                         wp_die( __('Error in deleting...') );
    41                                         }
    42                                         $deleted++;
     63                        $deleted = 0;
     64                        foreach( (array) $post_ids as $post_id_del ) {
     65                                $post_del = & get_post($post_id_del);
     66
     67                                if ( !current_user_can('delete_post', $post_id_del) )
     68                                        wp_die( __('You are not allowed to delete this post.') );
     69
     70                                if ( $post_del->post_type == 'attachment' ) {
     71                                        if ( ! wp_delete_attachment($post_id_del) )
     72                                                wp_die( __('Error in deleting...') );
     73                                } else {
     74                                        if ( !wp_delete_post($post_id_del) )
     75                                                wp_die( __('Error in deleting...') );
    4376                                }
     77                                $deleted++;
    4478                        }
    4579                        break;
    4680                case 'edit':
    47                         if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
    48                                 check_admin_referer('bulk-posts');
    49 
    50                                 if ( -1 == $_GET['_status'] ) {
    51                                         $_GET['post_status'] = null;
    52                                         unset($_GET['_status'], $_GET['post_status']);
    53                                 } else {
    54                                         $_GET['post_status'] = $_GET['_status'];
    55                                 }
    56 
    57                                 $done = bulk_edit_posts($_GET);
     81                        if ( -1 == $_GET['_status'] ) {
     82                                $_GET['post_status'] = null;
     83                                unset($_GET['_status'], $_GET['post_status']);
     84                        } else {
     85                                $_GET['post_status'] = $_GET['_status'];
    5886                        }
     87
     88                        $done = bulk_edit_posts($_GET);
    5989                        break;
    6090        }
    … …  
    71101        if ( isset($deleted) )
    72102                $sendback = add_query_arg('deleted', $deleted, $sendback);
     103        elseif ( isset($trashed) )
     104                $sendback = add_query_arg('trashed', $trashed, $sendback);
     105        elseif ( isset($untrashed) )
     106                $sendback = add_query_arg('untrashed', $untrashed, $sendback);
    73107        wp_redirect($sendback);
    74108        exit();
    … …  
    108142endif; ?>
    109143
    110 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>
     144<?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?>
    111145<div id="message" class="updated fade"><p>
    112146<?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) {
    … …  
    124158
    125159if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) {
    126         printf( _n( 'Post deleted.', '%s posts deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
     160        printf( _n( 'Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );
    127161        unset($_GET['deleted']);
     162}
     163
     164if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
     165        printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
     166        unset($_GET['deleted']);
     167}
     168
     169if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
     170        printf( _n( 'Post removed from the trash.', '%s posts removed from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) );
     171        unset($_GET['undeleted']);
    128172}
    129173
    … …  
    140184$status_links = array();
    141185$num_posts = wp_count_posts( 'post', 'readable' );
    142 $total_posts = array_sum( (array) $num_posts );
     186$total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
    143187$class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
    144188$status_links[] = "<li><a href='edit.php' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
    … …  
    191235<select name="action">
    192236<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
     237<?php if ($_GET['post_status'] == 'trash') { ?>
     238<option value="untrash"><?php _e('Restore'); ?></option>
     239<option value="delete"><?php _e('Delete Permanently'); ?></option>
     240<?php } else { ?>
    193241<option value="edit"><?php _e('Edit'); ?></option>
    194 <option value="delete"><?php _e('Delete'); ?></option>
     242<option value="trash"><?php _e('Move to Trash'); ?></option>
     243<?php } ?>
    195244</select>
    196245<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
    … …  
    236285?>
    237286<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
    238 
     287<?php } if ( $_GET['post_status'] == 'trash' ) { ?>
     288<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    239289<?php } ?>
    240290</div>
    … …  
    271321<select name="action2">
    272322<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
     323<?php if ( $_GET['post_status'] == 'trash' ) { ?>
     324<option value="untrash"><?php _e('Restore'); ?></option>
     325<option value="delete"><?php _e('Delete Permanently'); ?></option>
     326<?php } else { ?>
    273327<option value="edit"><?php _e('Edit'); ?></option>
    274 <option value="delete"><?php _e('Delete'); ?></option>
     328<option value="trash"><?php _e('Move to Trash'); ?></option>
     329<?php } ?>
    275330</select>
    276331<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
     332<?php if ( $_GET['post_status'] == 'trash' ) { ?>
     333<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
     334<?php } ?>
    277335<br class="clear" />
    278336</div>
  • trunk/wp-admin/includes/dashboard.php

    r11741 r11749  
    481481        $start = 0;
    482482
    483         while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
     483        while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {
    484484
    485485                foreach ( $possible as $comment ) {
  • trunk/wp-admin/includes/media.php

    r11704 r11749  
    11671167        );
    11681168
    1169         $delete_href = wp_nonce_url("post.php?action=delete-post&amp;post=$attachment_id", 'delete-post_' . $attachment_id);
     1169        $delete_href = wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'delete-post_' . $attachment_id);
    11701170        if ( $send )
    11711171                $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
    11721172        if ( $delete )
    1173                 $delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a>";
     1173                $delete = "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>";
    11741174        if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
    1175                 $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete
    1176                 <div id=\"del_attachment_$attachment_id\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Continue') . "</a>
    1177                 <a href=\"#\" class=\"del-link\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div></td></tr>\n");
     1175                $form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete</td></tr>\n");
    11781176
    11791177        $hidden_fields = array();
  • trunk/wp-admin/includes/post.php

    r11534 r11749  
    796796                                'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')),
    797797                                'private' => array(_x('Private', 'post'), __('Private posts'), _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')),
     798                                'trash' => array(_x('Trash', 'post'), __('Trash posts'), _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>')),
    798799                        );
    799800
    … …  
    859860        $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
    860861        $q['post_type'] = 'attachment';
    861         $q['post_status'] = 'any';
     862        $q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : 'any';
    862863        $media_per_page = get_user_option('upload_per_page');
    863864        if ( empty($media_per_page) )
  • trunk/wp-admin/includes/template.php

    r11748 r11749  
    14341434                        $attributes = 'class="post-title column-title"' . $style;
    14351435                ?>
    1436                 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
     1436                <td <?php echo $attributes ?>><strong><?php if ( current_user_can('edit_post', $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
    14371437                <?php
    14381438                        if ( 'excerpt' == $mode )
    … …  
    14401440
    14411441                        $actions = array();
    1442                         if ( current_user_can('edit_post', $post->ID) ) {
    1443                                 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
    1444                                 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
    1445                         }
    1446                         if ( current_user_can('delete_post', $post->ID) ) {
    1447                                 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
    1448                         }
    1449                         if ( in_array($post->post_status, array('pending', 'draft')) ) {
    1450                                 if ( current_user_can('edit_post', $post->ID) )
    1451                                         $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
     1442                        if ( 'trash' == $post->post_status && current_user_can('delete_post', $post->ID) ) {
     1443                                $actions['untrash'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
     1444                                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
    14521445                        } else {
    1453                                 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     1446                                if ( current_user_can('edit_post', $post->ID) ) {
     1447                                        $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
     1448                                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
     1449                                }
     1450                                if ( current_user_can('delete_post', $post->ID) ) {
     1451                                        $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
     1452                                }
     1453                                if ( in_array($post->post_status, array('pending', 'draft')) ) {
     1454                                        if ( current_user_can('edit_post', $post->ID) )
     1455                                                $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
     1456                                } else {
     1457                                        $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     1458                                }
    14541459                        }
    14551460                        $actions = apply_filters('post_row_actions', $actions, $post);
    … …  
    16521657                $edit_link = get_edit_post_link( $page->ID );
    16531658                ?>
    1654                 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_page', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong>
     1659                <td <?php echo $attributes ?>><strong><?php if ( current_user_can('edit_page', $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong>
    16551660                <?php
    16561661                $actions = array();
    1657                 if ( current_user_can('edit_page', $page->ID) ) {
    1658                         $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
    1659                         $actions['inline'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
    1660                 }
    1661                 if ( current_user_can('delete_page', $page->ID) ) {
    1662                         $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
    1663                 }
    1664                 if ( in_array($post->post_status, array('pending', 'draft')) ) {
    1665                         if ( current_user_can('edit_page', $page->ID) )
    1666                                 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
     1662                if ($post->post_status == 'trash' && current_user_can('delete_page', $page->ID)) {
     1663                        $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=untrash&amp;post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>";
     1664                        $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
    16671665                } else {
    1668                         $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     1666                        if ( current_user_can('edit_page', $page->ID) ) {
     1667                                $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
     1668                                $actions['inline'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
     1669                        }
     1670                        if ( current_user_can('delete_page', $page->ID) ) {
     1671                                $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . wp_nonce_url("page.php?action=trash&amp;post=$page->ID", 'trash-page_' . $page->ID) . "'>" . __('Trash') . "</a>";
     1672                        }
     1673                        if ( in_array($post->post_status, array('pending', 'draft')) ) {
     1674                                if ( current_user_can('edit_page', $page->ID) )
     1675                                        $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
     1676                        } else {
     1677                                $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
     1678                        }
    16691679                }
    16701680                $actions = apply_filters('page_row_actions', $actions, $page);
    … …  
    19821992 * @since unknown
    19831993 *
    1984  * @param string $status Comment status (approved, spam, deleted, etc)
     1994 * @param string $status Comment status (approved, spam, trash, etc)
    19851995 * @param string $s Term to search for
    19861996 * @param int $start Offset to start at for pagination
    … …  
    20002010
    20012011        if ( 'moderated' == $status ) {
    2002                 $approved = "comment_approved = '0'";
     2012                $approved = "c.comment_approved = '0'";
    20032013                $total = $count->moderated;
    20042014        } elseif ( 'approved' == $status ) {
    2005                 $approved = "comment_approved = '1'";
     2015                $approved = "c.comment_approved = '1'";
    20062016                $total = $count->approved;
    20072017        } elseif ( 'spam' == $status ) {
    2008                 $approved = "comment_approved = 'spam'";
     2018                $approved = "c.comment_approved = 'spam'";
    20092019                $total = $count->spam;
    2010         } elseif ( 'deleted' == $status ) {
    2011                 $approved = "comment_approved = 'deleted'";
    2012                 $total = $count->deleted;
     2020        } elseif ( 'trash' == $status ) {
     2021                $approved = "c.comment_approved = 'trash'";
     2022                $total = $count->trash;
    20132023        } else {
    2014                 $approved = "( comment_approved = '0' OR comment_approved = '1' )";
     2024                $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )";
    20152025                $total = $count->moderated + $count->approved;
    2016                 $index = 'USE INDEX (comment_date_gmt)';
     2026                $index = 'USE INDEX (c.comment_date_gmt)';
    20172027        }
    20182028
    20192029        if ( $post ) {
    20202030                $total = '';
    2021                 $post = " AND comment_post_ID = '$post'";
    2022                 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
     2031                $post = " AND c.comment_post_ID = '$post'";
     2032                $orderby = "ORDER BY c.comment_date_gmt ASC LIMIT $start, $num";
    20232033        } else {
    20242034                $post = '';
    2025                 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
     2035                $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num";
    20262036        }
    20272037
    20282038        if ( 'comment' == $type )
    2029                 $typesql = "AND comment_type = ''";
     2039                $typesql = "AND c.comment_type = ''";
    20302040        elseif ( 'pings' == $type )
    2031                 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
     2041                $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
    20322042        elseif ( !empty($type) )
    2033                 $typesql = $wpdb->prepare("AND comment_type = %s", $type);
     2043                $typesql = $wpdb->prepare("AND c.comment_type = %s", $type);
    20342044        else
    20352045                $typesql = '';
    … …  
    20382048                $total = '';
    20392049
     2050        $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ";
    20402051        if ( $s ) {
    20412052                $total = '';
    20422053                $s = $wpdb->escape($s);
    2043                 $query = "FROM $wpdb->comments WHERE
    2044                         (comment_author LIKE '%$s%' OR
    2045                         comment_author_email LIKE '%$s%' OR
    2046                         comment_author_url LIKE ('%$s%') OR
    2047                         comment_author_IP LIKE ('%$s%') OR
    2048                         comment_content LIKE ('%$s%') ) AND
     2054                $query .= "AND
     2055                        (c.comment_author LIKE '%$s%' OR
     2056                        c.comment_author_email LIKE '%$s%' OR
     2057                        c.comment_author_url LIKE ('%$s%') OR
     2058                        c.comment_author_IP LIKE ('%$s%') OR
     2059                        c.comment_content LIKE ('%$s%') ) AND
    20492060                        $approved
    20502061                        $typesql";
    20512062        } else {
    2052                 $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
    2053         }
    2054 
     2063                $query .= "AND $approved $post $typesql";
     2064        }
     2065       
    20552066        $comments = $wpdb->get_results("SELECT * $query $orderby");
    20562067        if ( '' === $total )
    2057                 $total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
     2068                $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
    20582069
    20592070        update_comment_cache($comments);
    … …  
    20962107        $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
    20972108        $spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
     2109        $trash_url = esc_url( wp_nonce_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID", "trash-comment_$comment->comment_ID" ) );
     2110        $untrash_url = esc_url( wp_nonce_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID", "untrash-comment_$comment->comment_ID" ) );
    20982111
    20992112        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
    … …  
    21352148
    21362149                                if ( $user_can ) {
    2137                                         if ( 'deleted' == $the_comment_status ) {
    2138                                                 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . __( 'Return this comment to Unapproved status' ) . "'>" . __( 'Return to Pending' ) . '</a>';
    2139                                                 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::deleted=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
     2150                                        if ( 'trash' == $the_comment_status ) {
     2151                                                $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID::untrash=1 vim-t vim-destructive''>" . __( 'Restore' ) . '</a>';
     2152                                                $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
    21402153                                        } else {
    21412154                                                $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
    … …  
    21532166
    21542167                                                if ( 'spam' == $the_comment_status ) {
    2155                                                         $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::deleted=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
     2168                                                        $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
    21562169                                                } else {
    21572170                                                        $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
    2158                                                         $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';
     2171                                                        $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-t vim-destructive'>" . __('Trash') . '</a>';
    21592172                                                }
    21602173
    … …  
    21772190                                                if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
    21782191                                                        $action .= ' hide-if-no-js';
     2192                                                elseif ($action == 'untrash' && $the_comment_status == 'trash') {
     2193                                                        $trash_meta = get_option('wp_trash_meta');
     2194                                                        if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id]['status'])) {
     2195                                                                if ($trash_meta['comments'][$comment_id]['status'] == '1')
     2196                                                                        $action .= ' approve';
     2197                                                                else
     2198                                                                        $action .= ' unapprove';
     2199                                                        }
     2200                                                }
    21792201
    21802202                                                echo "<span class='$action'>$sep$link</span>";
  • trunk/wp-admin/js/common.dev.js

    r11731 r11749  
    155155        $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
    156156
    157         // show warnings
    158         $('#doaction, #doaction2').click(function(){
    159                 if ( $('select[name="action"]').val() == 'destroy' || $('select[name="action2"]').val() == 'destroy' ) {
    160                         return showNotice.warn();
    161                 }
    162         });
    163         $('#destroy_all, #destroy_all2').click(function(){
    164                 return showNotice.warn();
    165         });
    166 
    167157        // screen settings tab
    168158        $('#show-settings-link').click(function () {
  • trunk/wp-admin/js/common.js

    r11731 r11749  
    1 var showNotice,adminMenu,columns,validateForm;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});this.favorites();a("a.separator").click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=d.parent().offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a("body").scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").change(function(){a(this).removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#doaction, #doaction2").click(function(){if(d('select[name="action"]').val()=="destroy"||d('select[name="action2"]').val()=="destroy"){return showNotice.warn()}});d("#destroy_all, #destroy_all2").click(function(){return showNotice.warn()});d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).parents("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead :checkbox, tfoot :checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).parents("form:first").find("table tbody:visible").find(".check-column :checkbox").attr("checked",function(){if(d(this).parents("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).parents("form:first").find("table thead:visible, table tfoot:visible").find(".check-column :checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})});d("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");d("div.default-password-nag").hide();return false})});jQuery(document).ready(function(b){var a=b(".turbo-nag");if(!a.length||("undefined"!=typeof(google)&&google.gears)){return}if("undefined"!=typeof GearsFactory){return}else{try{if(("undefined"!=typeof window.ActiveXObject&&ActiveXObject("Gears.Factory"))||("undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"])){return}}catch(c){}}a.show()});
     1var showNotice,adminMenu,columns,validateForm;(function(a){adminMenu={init:function(){a("#adminmenu div.wp-menu-toggle").each(function(){if(a(this).siblings(".wp-submenu").length){a(this).click(function(){adminMenu.toggle(a(this).siblings(".wp-submenu"))})}else{a(this).hide()}});this.favorites();a("a.separator").click(function(){if(a("body").hasClass("folded")){adminMenu.fold(1);deleteUserSetting("mfold")}else{adminMenu.fold();setUserSetting("mfold","f")}return false});if(a("body").hasClass("folded")){this.fold()}this.restoreMenuState()},restoreMenuState:function(){a("#adminmenu li.wp-has-submenu").each(function(c,d){var b=getUserSetting("m"+c);if(a(d).hasClass("wp-has-current-submenu")){return true}if("o"==b){a(d).addClass("wp-menu-open")}else{if("c"==b){a(d).removeClass("wp-menu-open")}}})},toggle:function(b){b.slideToggle(150,function(){b.css("display","")}).parent().toggleClass("wp-menu-open");a("#adminmenu li.wp-has-submenu").each(function(d,f){var c=a(f).hasClass("wp-menu-open")?"o":"c";setUserSetting("m"+d,c)});return false},fold:function(b){if(b){a("body").removeClass("folded");a("#adminmenu li.wp-has-submenu").unbind()}else{a("body").addClass("folded");a("#adminmenu li.wp-has-submenu").hoverIntent({over:function(j){var d,c,g,k,i;d=a(this).find(".wp-submenu");c=d.parent().offset().top+d.height()+1;g=a("#wpwrap").height();k=60+c-g;i=a(window).height()+a("body").scrollTop()-15;if(i<(c-k)){k=c-i}if(k>1){d.css({marginTop:"-"+k+"px"})}else{if(d.css("marginTop")){d.css({marginTop:""})}}d.addClass("sub-open")},out:function(){a(this).find(".wp-submenu").removeClass("sub-open").css({marginTop:""})},timeout:220,sensitivity:8,interval:100})}},favorites:function(){a("#favorite-inside").width(a("#favorite-actions").width()-4);a("#favorite-toggle, #favorite-inside").bind("mouseenter",function(){a("#favorite-inside").removeClass("slideUp").addClass("slideDown");setTimeout(function(){if(a("#favorite-inside").hasClass("slideDown")){a("#favorite-inside").slideDown(100);a("#favorite-first").addClass("slide-down")}},200)});a("#favorite-toggle, #favorite-inside").bind("mouseleave",function(){a("#favorite-inside").removeClass("slideDown").addClass("slideUp");setTimeout(function(){if(a("#favorite-inside").hasClass("slideUp")){a("#favorite-inside").slideUp(100,function(){a("#favorite-first").removeClass("slide-down")})}},300)})}};a(document).ready(function(){adminMenu.init()});columns={init:function(){a(".hide-column-tog").click(function(){var c=a(this).val(),b=a(this).attr("checked");if(b){a(".column-"+c).show()}else{a(".column-"+c).hide()}columns.save_manage_columns_state()})},save_manage_columns_state:function(){var b=a(".manage-column").filter(":hidden").map(function(){return this.id}).get().join(",");a.post(ajaxurl,{action:"hidden-columns",hidden:b,screenoptionnonce:a("#screenoptionnonce").val(),page:pagenow})}};a(document).ready(function(){columns.init()});validateForm=function(b){return !a(b).find(".form-required").filter(function(){return a("input:visible",this).val()==""}).addClass("form-invalid").change(function(){a(this).removeClass("form-invalid")}).size()}})(jQuery);showNotice={warn:function(){var a=commonL10n.warnDelete||"";if(confirm(a)){return true}return false},note:function(a){alert(a)}};jQuery(document).ready(function(d){var f=false,a,e,c,b;d(".fade").animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300).animate({backgroundColor:"#ffffe0"},300).animate({backgroundColor:"#fffbcc"},300);d("div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error").addClass("below-h2");d("div.updated, div.error").not(".below-h2").insertAfter("div.wrap h2:first");d("#show-settings-link").click(function(){if(!d("#screen-options-wrap").hasClass("screen-options-open")){d("#contextual-help-link-wrap").css("visibility","hidden")}d("#screen-options-wrap").slideToggle("fast",function(){if(d(this).hasClass("screen-options-open")){d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#contextual-help-link-wrap").css("visibility","");d(this).removeClass("screen-options-open")}else{d("#show-settings-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("screen-options-open")}});return false});d("#contextual-help-link").click(function(){if(!d("#contextual-help-wrap").hasClass("contextual-help-open")){d("#screen-options-link-wrap").css("visibility","hidden")}d("#contextual-help-wrap").slideToggle("fast",function(){if(d(this).hasClass("contextual-help-open")){d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right.gif")'});d("#screen-options-link-wrap").css("visibility","");d(this).removeClass("contextual-help-open")}else{d("#contextual-help-link").css({backgroundImage:'url("images/screen-options-right-up.gif")'});d(this).addClass("contextual-help-open")}});return false});d("#contextual-help-link-wrap, #screen-options-link-wrap").show();d("table:visible tbody .check-column :checkbox").click(function(g){if("undefined"==g.shiftKey){return true}if(g.shiftKey){if(!f){return true}a=d(f).parents("form:first").find(":checkbox");e=a.index(f);c=a.index(this);b=d(this).attr("checked");if(0<e&&0<c&&e!=c){a.slice(e,c).attr("checked",function(){if(d(this).parents("tr").is(":visible")){return b?"checked":""}return""})}}f=this;return true});d("thead :checkbox, tfoot :checkbox").click(function(i){var j=d(this).attr("checked"),h="undefined"==typeof toggleWithKeyboard?false:toggleWithKeyboard,g=i.shiftKey||h;d(this).parents("form:first").find("table tbody:visible").find(".check-column :checkbox").attr("checked",function(){if(d(this).parents("tr").is(":hidden")){return""}if(g){return d(this).attr("checked")?"":"checked"}else{if(j){return"checked"}}return""});d(this).parents("form:first").find("table thead:visible, table tfoot:visible").find(".check-column :checkbox").attr("checked",function(){if(g){return""}else{if(j){return"checked"}}return""})});d("#default-password-nag-no").click(function(){setUserSetting("default_password_nag","hide");d("div.default-password-nag").hide();return false})});jQuery(document).ready(function(b){var a=b(".turbo-nag");if(!a.length||("undefined"!=typeof(google)&&google.gears)){return}if("undefined"!=typeof GearsFactory){return}else{try{if(("undefined"!=typeof window.ActiveXObject&&ActiveXObject("Gears.Factory"))||("undefined"!=typeof navigator.mimeTypes&&navigator.mimeTypes["application/x-googlegears"])){return}}catch(c){}}a.show()});
  • trunk/wp-admin/js/edit-comments.dev.js

    r11731 r11749  
    3939                settings.data._url = document.location.href;
    4040
    41                 if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted)
    42                         return showNotice.warn() ? settings : false;
    43 
    4441                return settings;
    4542        };
    … …  
    10299                });
    103100
    104                 $('span.deleted-count').each( function() {
     101                $('span.trash-count').each( function() {
    105102                        var a = $(this), n;
    106103                        n = a.html().replace(/[ ,.]+/g, '');
    107104                        n = parseInt(n,10);
    108105                        if ( isNaN(n) ) return;
    109                         if ( $(settings.target).parents( 'span.delete' ).size() && $('#' + settings.element).is('.deleted,.spam') ) { // we destroyed a deleted or spam comment
    110                                 n--;
    111                         } else if ( $(settings.target).parents( 'span.delete' ).size() ) { // we deleted a comment
    112                                 n++;
    113                         } else if ( $('#' + settings.element).is('.deleted') ) { // we approved or spammed a deleted comment
    114                                 n--;
     106                        if ( $(settings.target).parents( 'span.trash' ).size() ) { // we trashed a comment
     107                                n = n + 1;
     108                        } else if ( $('#' + settings.element).is('.trash') ) { // we deleted or untrashed a trash comment
     109                                n = n - 1;
    115110                        }
    116111                        if ( n < 0 ) { n = 0; }
  • trunk/wp-admin/js/edit-comments.js

    r11731 r11749  
    1 var theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var g,i,h,f=0,c,e,d,b;g=a('#comments-form .tablenav :input[name="_total"]');i=a('#comments-form .tablenav :input[name="_per_page"]');h=a('#comments-form .tablenav :input[name="_page"]');c=function(k,j){var l=a("#"+j.element);if(l.is(".unapproved")){l.find("div.comment_status").html("0")}else{l.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}o=o+(a("#"+j.element).is("."+j.dimClass)?1:-1);if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href;if("undefined"!=showNotice&&j.data.action&&j.data.action=="delete-comment"&&j.data.deleted){return showNotice.warn()?j:false}return j};d=function(j,k,l){if(k<f){return}g.val(j.toString());if(l){f=k}a("span.total-type-count").each(function(){var m=a(this),o;o=g.val().toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.deleted-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.delete").size()&&a("#"+j.element).is(".deleted,.spam")){o--}else{if(a(j.target).parents("span.delete").size()){o++}else{if(a("#"+j.element).is(".deleted")){o--}}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f<j.parsed.responses[0].supplemental.time){d(j.parsed.responses[0].supplemental.total,j.parsed.responses[0].supplemental.time,true);if(a.trim(j.parsed.responses[0].supplemental.pageLinks)){a(".tablenav-pages").find(".page-numbers").remove().end().append(a(j.parsed.responses[0].supplemental.pageLinks))}else{if("undefined"!=typeof j.parsed.responses[0].supplemental.pageLinks){a(".tablenav-pages").find(".page-numbers").remove()}}}else{var k=parseInt(g.val(),10);if(k--<0){k=0}d(k,l,false)}if(theExtraList.size()==0||theExtraList.children().size()==0){return}theList.get(0).wpList.add(theExtraList.children(":eq(0)").remove().clone());a("#get-extra-comments").submit()};theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"});theList=a("#the-comment-list").wpList({alt:"",delBefore:e,dimAfter:c,delAfter:b,addColor:"none"})};commentReply={init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()});a("a.save",b).click(function(){return commentReply.send()});a("input#author, input#author-email, input#author-url",b).keypress(function(c){if(c.which==13){commentReply.send();c.preventDefault();return false}});a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20<j){window.scroll(0,j-h+35)}else{if(l-20<m){window.scroll(0,l-35)}}a("#replycontent").focus().keyup(function(n){if(n.which==27){commentReply.revert()}})},600);return false},send:function(){var b={};a("#replysubmit .waiting").show();a("#replyrow input").each(function(){b[a(this).attr("name")]=a(this).val()});b.content=a("#replycontent").val();b.id=b.comment_post_ID;b.comments_listing=this.comments_listing;a.ajax({type:"POST",url:wpListL10n.url,data:b,success:function(c){commentReply.show(c)},error:function(c){commentReply.error(c)}});return false},show:function(b){var e,g,f,d;if(typeof(b)=="string"){this.error({responseText:b});return false}e=wpAjax.parseAjaxResponse(b);if(e.errors){this.error({responseText:wpAjax.broken});return false}if("edit-comment"==this.act){a(this.o).remove()}e=e.responses[0];g=e.data;a(g).hide();a("#replyrow").after(g);this.o=f="#comment-"+e.id;this.revert();this.addEvents(a(f));d=a(f).hasClass("unapproved")?"#ffffe0":"#fff";a(f).animate({backgroundColor:"#CCEEBB"},600).animate({backgroundColor:d},600);a.fn.wpList.process(a(f))},error:function(b){var c=b.statusText;a("#replysubmit .waiting").hide();if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a("span.delete a.delete").click(function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("#comments-form thead #cb input:checkbox").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery);
     1var theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var g,i,h,f=0,c,e,d,b;g=a('#comments-form .tablenav :input[name="_total"]');i=a('#comments-form .tablenav :input[name="_per_page"]');h=a('#comments-form .tablenav :input[name="_page"]');c=function(k,j){var l=a("#"+j.element);if(l.is(".unapproved")){l.find("div.comment_status").html("0")}else{l.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}o=o+(a("#"+j.element).is("."+j.dimClass)?1:-1);if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};e=function(j){j.data._total=g.val();j.data._per_page=i.val();j.data._page=h.val();j.data._url=document.location.href;return j};d=function(j,k,l){if(k<f){return}g.val(j.toString());if(l){f=k}a("span.total-type-count").each(function(){var m=a(this),o;o=g.val().toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)})};b=function(l,j){a("span.pending-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a("#"+j.element).is(".unapproved")){o=o-1}else{if(a(j.target).parents("span.unapprove").size()){o=o+1}}if(o<0){o=0}m.parents("#awaiting-mod")[0==o?"addClass":"removeClass"]("count-0");o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.spam-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.spam").size()){o=o+1}else{if(a("#"+j.element).is(".spam")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});a("span.trash-count").each(function(){var m=a(this),o;o=m.html().replace(/[ ,.]+/g,"");o=parseInt(o,10);if(isNaN(o)){return}if(a(j.target).parents("span.trash").size()){o=o+1}else{if(a("#"+j.element).is(".trash")){o=o-1}}if(o<0){o=0}o=o.toString();if(o.length>3){o=o.substr(0,o.length-3)+" "+o.substr(-3)}m.html(o)});if(("object"==typeof l)&&f<j.parsed.responses[0].supplemental.time){d(j.parsed.responses[0].supplemental.total,j.parsed.responses[0].supplemental.time,true);if(a.trim(j.parsed.responses[0].supplemental.pageLinks)){a(".tablenav-pages").find(".page-numbers").remove().end().append(a(j.parsed.responses[0].supplemental.pageLinks))}else{if("undefined"!=typeof j.parsed.responses[0].supplemental.pageLinks){a(".tablenav-pages").find(".page-numbers").remove()}}}else{var k=parseInt(g.val(),10);if(k--<0){k=0}d(k,l,false)}if(theExtraList.size()==0||theExtraList.children().size()==0){return}theList.get(0).wpList.add(theExtraList.children(":eq(0)").remove().clone());a("#get-extra-comments").submit()};theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"});theList=a("#the-comment-list").wpList({alt:"",delBefore:e,dimAfter:c,delAfter:b,addColor:"none"})};commentReply={init:function(){var b=a("#replyrow");a("a.cancel",b).click(function(){return commentReply.revert()});a("a.save",b).click(function(){return commentReply.send()});a("input#author, input#author-email, input#author-url",b).keypress(function(c){if(c.which==13){commentReply.send();c.preventDefault();return false}});a("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())});a("#doaction, #doaction2, #post-query-submit").click(function(c){if(a("#the-comment-list #replyrow").length>0){commentReply.close()}});this.comments_listing=a('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(b){b.each(function(){a(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(a(this).parent())})})},toggle:function(b){if(a(b).css("display")!="none"){a(b).find("a.vim-q").click()}},revert:function(){if(a("#the-comment-list #replyrow").length<1){return false}a("#replyrow").fadeOut("fast",function(){commentReply.close()});return false},close:function(){a(this.o).fadeIn("fast").css("backgroundColor","");a("#com-reply").append(a("#replyrow"));a("#replycontent").val("");a("#edithead input").val("");a("#replysubmit .error").html("").hide();a("#replysubmit .waiting").hide();if(a.browser.msie){a("#replycontainer, #replycontent").css("height","120px")}else{a("#replycontainer").resizable("destroy").css("height","120px")}},open:function(i,g,c){var e=this,d,b,f;e.close();e.o="#comment-"+i;a("#replyrow td").attr("colspan",a(".widefat thead th:visible").length);d=a("#replyrow"),rowData=a("#inline-"+i);b=e.act=(c=="edit")?"edit-comment":"replyto-comment";a("#action",d).val(b);a("#comment_post_ID",d).val(g);a("#comment_ID",d).val(i);if(c=="edit"){a("#author",d).val(a("div.author",rowData).text());a("#author-email",d).val(a("div.author-email",rowData).text());a("#author-url",d).val(a("div.author-url",rowData).text());a("#status",d).val(a("div.comment_status",rowData).text());a("#replycontent",d).val(a("textarea.comment",rowData).val());a("#edithead, #savebtn",d).show();a("#replyhead, #replybtn",d).hide();f=a(e.o).height();if(f>220){if(a.browser.msie){a("#replycontainer, #replycontent",d).height(f-105)}else{a("#replycontainer",d).height(f-105)}}a(e.o).after(d.hide()).fadeOut("fast",function(){a("#replyrow").fadeIn("fast")})}else{a("#edithead, #savebtn",d).hide();a("#replyhead, #replybtn",d).show();a(e.o).after(d);a("#replyrow").hide().fadeIn("fast")}if(!a.browser.msie){a("#replycontainer").resizable({handles:"s",axis:"y",minHeight:80,stop:function(){a("#replycontainer").width("auto")}})}setTimeout(function(){var l,j,m,h,k;l=a("#replyrow").offset().top;j=l+a("#replyrow").height();m=window.pageYOffset||document.documentElement.scrollTop;h=document.documentElement.clientHeight||self.innerHeight||0;k=m+h;if(k-20<j){window.scroll(0,j-h+35)}else{if(l-20<m){window.scroll(0,l-35)}}a("#replycontent").focus().keyup(function(n){if(n.which==27){commentReply.revert()}})},600);return false},send:function(){var b={};a("#replysubmit .waiting").show();a("#replyrow input").each(function(){b[a(this).attr("name")]=a(this).val()});b.content=a("#replycontent").val();b.id=b.comment_post_ID;b.comments_listing=this.comments_listing;a.ajax({type:"POST",url:wpListL10n.url,data:b,success:function(c){commentReply.show(c)},error:function(c){commentReply.error(c)}});return false},show:function(b){var e,g,f,d;if(typeof(b)=="string"){this.error({responseText:b});return false}e=wpAjax.parseAjaxResponse(b);if(e.errors){this.error({responseText:wpAjax.broken});return false}if("edit-comment"==this.act){a(this.o).remove()}e=e.responses[0];g=e.data;a(g).hide();a("#replyrow").after(g);this.o=f="#comment-"+e.id;this.revert();this.addEvents(a(f));d=a(f).hasClass("unapproved")?"#ffffe0":"#fff";a(f).animate({backgroundColor:"#CCEEBB"},600).animate({backgroundColor:d},600);a.fn.wpList.process(a(f))},error:function(b){var c=b.statusText;a("#replysubmit .waiting").hide();if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#replysubmit .error").html(c).show()}}};a(document).ready(function(){var e,b,c,d;setCommentsList();commentReply.init();a("span.delete a.delete").click(function(){return false});if(typeof QTags!="undefined"){ed_reply=new QTags("ed_reply","replycontent","replycontainer","more")}if(typeof a.table_hotkeys!="undefined"){e=function(f){return function(){var h,g;h="next"==f?"first":"last";g=a("."+f+".page-numbers");if(g.length){window.location=g[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+h+"=1"}}};b=function(g,f){window.location=a("span.edit a",f).attr("href")};c=function(){toggleWithKeyboard=true;a("#comments-form thead #cb input:checkbox").click().attr("checked","");toggleWithKeyboard=false};d=function(f){return function(h,g){a("option[value="+f+"]").attr("selected","selected");a("form#comments-form")[0].submit()}};a.table_hotkeys(a("table.widefat"),["a","u","s","d","r","q",["e",b],["shift+a",d("approve")],["shift+s",d("markspam")],["shift+d",d("delete")],["shift+x",c],["shift+u",d("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:e("prev"),next_page_link_cb:e("next")})}})})(jQuery);
  • trunk/wp-admin/media.php

    r11383 r11749  
    5959        $att = get_post($att_id);
    6060
     61        if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn&#8217;t exist. Perhaps it was deleted?') );
     62        if ( $att->post_status == 'trash' ) wp_die( __('You can&#8217;t edit this attachment because it is in the Trash. Please move it out of the Trash and try again.') );
     63       
    6164        add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
    6265
  • trunk/wp-admin/page.php

    r11380 r11749  
    8484
    8585        if ( empty($post->ID) ) wp_die( __('You attempted to edit a page that doesn&#8217;t exist. Perhaps it was deleted?') );
     86        if ( $post->post_status == 'trash' ) wp_die( __('You can&#8217;t edit this page because it is in the Trash. Please move it out of the Trash and try again.') );
    8687
    8788        if ( 'page' != $post->post_type ) {
    … …  
    141142        break;
    142143
     144case 'trash':
     145        $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     146        check_admin_referer('trash-page_' . $post_id);
     147
     148        $post = & get_post($post_id);
     149
     150        if ( !current_user_can('delete_page', $page_id) )
     151                wp_die( __('You are not allowed to move this page to the trash.') );
     152
     153        if ( !wp_trash_post($post_id) )
     154                wp_die( __('Error in removing from trash...') );
     155
     156        $sendback = wp_get_referer();
     157        if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?trashed=1');
     158        elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     159        else $sendback = add_query_arg('trashed', 1, $sendback);
     160        wp_redirect($sendback);
     161        exit();
     162        break;
     163
     164case 'untrash':
     165        $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     166        check_admin_referer('untrash-page_' . $post_id);
     167
     168        $post = & get_post($post_id);
     169
     170        if ( !current_user_can('delete_page', $page_id) )
     171                wp_die( __('You are not allowed to remove this page form the trash.') );
     172
     173        if ( !wp_untrash_post($post_id) )
     174                wp_die( __('Error in removing from trash...') );
     175
     176        $sendback = wp_get_referer();
     177        if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit-pages.php?untrashed=1');
     178        elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     179        else $sendback = add_query_arg('untrashed', 1, $sendback);
     180        wp_redirect($sendback);
     181        exit();
     182        break;
     183
    143184case 'delete':
    144185        $page_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
  • trunk/wp-admin/post.php

    r11380 r11749  
    117117
    118118        if ( empty($post->ID) ) wp_die( __('You attempted to edit a post that doesn&#8217;t exist. Perhaps it was deleted?') );
     119        if ( $post->post_status == 'trash' ) wp_die( __('You can&#8217;t edit this post because it is in the Trash. Please move it out of the Trash and try again.') );
    119120
    120121        if ( 'post' != $post->post_type ) {
    … …  
    182183        break;
    183184
     185case 'trash':
     186        $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     187        check_admin_referer('trash-post_' . $post_id);
     188
     189        $post = & get_post($post_id);
     190
     191        if ( !current_user_can('delete_post', $post_id) )
     192                wp_die( __('You are not allowed to move this post to the trash.') );
     193
     194        if ( ! wp_trash_post($post_id) )
     195                wp_die( __('Error in moving to trash...') );
     196
     197        $sendback = wp_get_referer();
     198        if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?trashed=1');
     199        elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     200        else $sendback = add_query_arg('trashed', 1, $sendback);
     201        wp_redirect($sendback);
     202        exit();
     203        break;
     204
     205case 'untrash':
     206        $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     207        check_admin_referer('untrash-post_' . $post_id);
     208
     209        $post = & get_post($post_id);
     210
     211        if ( !current_user_can('delete_post', $post_id) )
     212                wp_die( __('You are not allowed to remove this post from the trash.') );
     213
     214        if ( ! wp_untrash_post($post_id) )
     215                wp_die( __('Error in removing from trash...') );
     216
     217        $sendback = wp_get_referer();
     218        if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?untrashed=1');
     219        elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
     220        else $sendback = add_query_arg('untrashed', 1, $sendback);
     221        wp_redirect($sendback);
     222        exit();
     223        break;
     224
    184225case 'delete':
    185226        $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
  • trunk/wp-admin/upload.php

    r11715 r11749  
    6868        }
    6969
    70 } elseif ( isset($_GET['action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
     70} elseif ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
    7171        check_admin_referer('bulk-media');
    72         $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
    73 
    74         if ( 'delete' == $doaction ) {
    75                 foreach( (array) $_GET['media'] as $post_id_del ) {
    76                         $post_del = & get_post($post_id_del);
    77 
    78                         if ( !current_user_can('delete_post', $post_id_del) )
    79                                 wp_die( __('You are not allowed to delete this post.') );
    80 
    81                         if ( $post_del->post_type == 'attachment' )
    82                                 if ( ! wp_delete_attachment($post_id_del) )
     72       
     73        if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
     74                $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
     75                $doaction = 'delete';
     76        } elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['media']) ) {
     77                $post_ids = $_GET['media'];
     78                $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
     79        } else
     80                wp_redirect($_SERVER['HTTP_REFERER']);
     81       
     82        $location = 'upload.php';
     83        if ( $referer = wp_get_referer() ) {
     84                if ( false !== strpos($referer, 'upload.php') )
     85                        $location = $referer;
     86        }
     87
     88        switch ( $doaction ) {
     89                case 'trash':
     90                        foreach( (array) $post_ids as $post_id ) {
     91                                if ( !current_user_can('delete_post', $post_id) )
     92                                        wp_die( __('You are not allowed to move this post to the trash.') );
     93                               
     94                                if ( !wp_trash_post($post_id) )
     95                                        wp_die( __('Error in moving to trash...') );
     96                        }
     97                        $location = add_query_arg('message', 4, $location);
     98                        break;
     99                case 'untrash':
     100                        foreach( (array) $post_ids as $post_id ) {
     101                                if ( !current_user_can('delete_post', $post_id) )
     102                                        wp_die( __('You are not allowed to remove this post from the trash.') );
     103                               
     104                                if ( !wp_untrash_post($post_id) )
     105                                        wp_die( __('Error in restoring from trash...') );
     106                        }
     107                        $location = add_query_arg('message', 5, $location);
     108                        break;
     109                case 'delete':
     110                        foreach( (array) $post_ids as $post_id_del ) {
     111                                if ( !current_user_can('delete_post', $post_id_del) )
     112                                        wp_die( __('You are not allowed to delete this post.') );
     113       
     114                                if ( !wp_delete_attachment($post_id_del) )
    83115                                        wp_die( __('Error in deleting...') );
    84                 }
    85 
    86                 $location = 'upload.php';
    87                 if ( $referer = wp_get_referer() ) {
    88                         if ( false !== strpos($referer, 'upload.php') )
    89                                 $location = $referer;
    90                 }
    91 
    92                 $location = add_query_arg('message', 2, $location);
    93                 $location = remove_query_arg('posted', $location);
    94                 wp_redirect($location);
    95                 exit;
    96         }
     116                        }
     117                        $location = add_query_arg('message', 2, $location);
     118                        break;
     119        }
     120
     121        $location = remove_query_arg('posted', $location);
     122        wp_redirect($location);
     123        exit;
    97124} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
    98125         wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
    … …  
    116143        } else {
    117144                $start = ( $_GET['paged'] - 1 ) * 25;
    118                 $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent < 1 LIMIT $start, 25" );
     145                $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT $start, 25" );
    119146                $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
    120147        }
    … …  
    136163}
    137164
     165$is_trash = ( isset($_GET['status']) && $_GET['status'] == 'trash' );
     166
    138167wp_enqueue_script('media');
    139168require_once('admin-header.php'); ?>
    … …  
    154183$messages[2] = __('Media deleted.');
    155184$messages[3] = __('Error saving media attachment.');
     185$messages[4] = __('Media moved to Trash.');
     186$messages[5] = __('Media removed from Trash.');
    156187
    157188if ( isset($_GET['message']) && (int) $_GET['message'] ) {
    … …  
    181212$type_links = array();
    182213$_num_posts = (array) wp_count_attachments();
    183 $_total_posts = array_sum( $_num_posts );
     214$_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
    184215$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
    185216foreach ( $matches as $type => $reals )
    … …  
    187218                $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
    188219
    189 $class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';
     220$class = ( empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status']) ) ? ' class="current"' : '';
    190221$type_links[] = "<li><a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>';
    191222foreach ( $post_mime_types as $mime_type => $label ) {
    … …  
    200231        $type_links[] = "<li><a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
    201232}
    202 $class = isset($_GET['detached']) ? ' class="current"' : '';
    203 $type_links[] = '<li><a href="upload.php?detached=1"' . $class . '>' . __('Unattached') . '</a>';
     233$type_links[] = '<li><a href="upload.php?detached=1"' . ( isset($_GET['detached']) ? ' class="current"' : '' ) . '>' . __('Unattached') . '</a>';
     234$type_links[] = '<li><a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>';
    204235
    205236echo implode( " |</li>\n", $type_links) . '</li>';
    … …  
    243274<select name="action" class="select-action">
    244275<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
    245 <option value="delete"><?php _e('Delete'); ?></option>
    246 <?php if ( isset($orphans) ) { ?>
     276<?php if ( $is_trash ) { ?>
     277<option value="untrash"><?php _e('Restore'); ?></option>
     278<option value="delete"><?php _e('Delete Permanently'); ?></option>
     279<?php } else { ?>
     280<option value="trash"><?php _e('Move to Trash'); ?></option>
     281<?php } if ( isset($orphans) ) { ?>
    247282<option value="attach"><?php _e('Attach to a post'); ?></option>
    248283<?php } ?>
    … …  
    252287
    253288<?php
    254 if ( ! is_singular() && ! isset($_GET['detached']) ) {
     289if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) {
    255290        $arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
    256291
    … …  
    287322<?php if ( isset($_GET['detached']) ) { ?>
    288323        <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
     324<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>
     325        <input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    289326<?php } ?>
    290327
    … …  
    342379                        $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
    343380                if ( current_user_can('delete_post', $post->ID) )
    344                         $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this attachment '%s'\n  'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
     381                        $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
    345382                $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
    346383                if ( current_user_can('edit_post', $post->ID) )
    … …  
    399436<select name="action2" class="select-action">
    400437<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
    401 <option value="delete"><?php _e('Delete'); ?></option>
    402 <?php if ( isset($orphans) ) { ?>
     438<?php if ($is_trash) { ?>
     439<option value="untrash"><?php _e('Restore'); ?></option>
     440<option value="delete"><?php _e('Delete Permanently'); ?></option>
     441<?php } else { ?>
     442<option value="trash"><?php _e('Move to Trash'); ?></option>
     443<?php } if (isset($orphans)) { ?>
    403444<option value="attach"><?php _e('Attach to a post'); ?></option>
    404445<?php } ?>
    405446</select>
    406447<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
     448
     449<?php if ( isset($_GET['status']) && $_GET['status'] == 'trash' ) { ?>
     450        <input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
     451<?php } ?>
    407452</div>
    408453
  • trunk/wp-admin/wp-admin.css

    r11731 r11749  
    410410
    411411#doaction,
    412 #doaction2 {
     412#doaction2,
     413#post-query-submit {
    413414        margin-right: 8px;
    414415}
    … …  
    445446}
    446447
    447 .unapproved .approve, .spam .approve, .deleted .approve {
     448.unapproved .approve,
     449.spam .approve,
     450.trash .approve {
    448451        display: inline;
    449452}
  • trunk/wp-app.php

    r11416 r11749  
    12321232                header('Content-Type: text/plain');
    12331233                status_header('204');
    1234                 echo "Deleted.";
     1234                echo "Moved to Trash.";
    12351235                exit;
    12361236        }
  • trunk/wp-includes/comment.php

    r11741 r11749  
    209209        elseif ( 'spam' == $status )
    210210                $approved = "comment_approved = 'spam'";
    211         elseif ( 'deleted' == $status )
    212                 $approved = "comment_approved = 'deleted'";
     211        elseif ( 'trash' == $status )
     212                $approved = "comment_approved = 'trash'";
    213213        else
    214214                $approved = "( comment_approved = '0' OR comment_approved = '1' )";
    … …  
    695695                return $count;
    696696
    697         $where = '';
     697        $where = 'WHERE ';
    698698        if( $post_id > 0 )
    699                 $where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id );
    700 
    701         $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
     699                $where .= $wpdb->prepare( "c.comment_post_ID = %d AND ", $post_id );
     700        $where .= "p.post_status <> 'trash'";
     701
     702        $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} c LEFT JOIN {$wpdb->posts} p ON c.comment_post_ID = p.ID {$where} GROUP BY comment_approved", ARRAY_A );
    702703
    703704        $total = 0;
    704         $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted');
     705        $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash');
    705706        $known_types = array_keys( $approved );
    706707        foreach( (array) $count as $row_num => $row ) {
    … …  
    738739 */
    739740function wp_delete_comment($comment_id) {
    740         if (wp_get_comment_status($comment_id) != 'deleted' && wp_get_comment_status($comment_id) != 'spam')
    741                 return wp_set_comment_status($comment_id, 'delete');
     741        global $wpdb;
     742        if (!$comment = get_comment($comment_id))
     743                return false;
     744
     745        if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0)
     746                return wp_trash_comment($comment_id);
    742747       
    743         global $wpdb;
    744748        do_action('delete_comment', $comment_id);
    745749       
    746         wp_unschedule_comment_delete($comment_id);
    747 
    748         $comment = get_comment($comment_id);
     750        $trash_meta = get_option('wp_trash_meta');
     751        if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) {
     752                unset($trash_meta['comments'][$comment_id]);
     753                update_option('wp_trash_meta', $trash_meta);
     754        }
    749755
    750756        if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
    … …  
    770776
    771777/**
     778 * Moves a comment to the Trash
     779 *
     780 * @since 2.9.0
     781 * @uses do_action() on 'trash_comment' before trashing
     782 * @uses do_action() on 'trashed_comment' after trashing
     783 *
     784 * @param int $comment_id Comment ID.
     785 * @return mixed False on failure
     786 */
     787function wp_trash_comment($comment_id = 0) {
     788        if (EMPTY_TRASH_DAYS == 0)
     789                return wp_delete_comment($comment_id);
     790
     791        if (!$comment = get_comment($comment_id))
     792                return false;
     793
     794        do_action('trash_comment', $comment_id);
     795
     796        $trash_meta = get_option('wp_trash_meta', array());
     797        $trash_meta['comments'][$comment_id]['status'] = $comment->comment_approved;
     798        $trash_meta['comments'][$comment_id]['time'] = time();
     799        update_option('wp_trash_meta', $trash_meta);
     800
     801        wp_set_comment_status($comment_id, 'trash');
     802
     803        do_action('trashed_comment', $comment_id);
     804
     805        return true;
     806}
     807
     808/**
     809 * Removes a comment from the Trash
     810 *
     811 * @since 2.9.0
     812 * @uses do_action() on 'untrash_comment' before undeletion
     813 * @uses do_action() on 'untrashed_comment' after undeletion
     814 *
     815 * @param int $comment_id Comment ID.
     816 * @return mixed False on failure
     817 */
     818function wp_untrash_comment($comment_id = 0) {
     819        do_action('untrash_comment', $comment_id);
     820
     821        $comment = array('comment_ID'=>$comment_id, 'comment_approved'=>'0');
     822
     823        $trash_meta = get_option('wp_trash_meta');
     824        if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) {
     825                $comment['comment_approved'] = $trash_meta['comments'][$comment_id]['status'];
     826                unset($trash_meta['comments'][$comment_id]);
     827                update_option('wp_trash_meta', $trash_meta);
     828        }
     829
     830        wp_update_comment($comment);
     831
     832        do_action('untrashed_comment', $comment_id);
     833
     834        return true;
     835}
     836
     837/**
    772838 * The status of a comment by ID.
    773839 *
    … …  
    775841 *
    776842 * @param int $comment_id Comment ID
    777  * @return string|bool Status might be 'deleted', 'approved', 'unapproved', 'spam'. False on failure.
     843 * @return string|bool Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
    778844 */
    779845function wp_get_comment_status($comment_id) {
    … …  
    785851
    786852        if ( $approved == NULL )
    787                 return 'deleted';
     853                return false;
    788854        elseif ( $approved == '1' )
    789855                return 'approved';
    … …  
    792858        elseif ( $approved == 'spam' )
    793859                return 'spam';
    794         elseif ( $approved == 'deleted' )
    795                 return 'deleted';
     860        elseif ( $approved == 'trash' )
     861                return 'trash';
    796862        else
    797863                return false;
    … …  
    10381104function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
    10391105        global $wpdb;
    1040         wp_unschedule_comment_delete($comment_id);
    1041        
     1106               
    10421107        $status = '0';
    10431108        switch ( $comment_status ) {
    … …  
    10551120                        $status = 'spam';
    10561121                        break;
    1057                 case 'delete':
    1058                         if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam')
    1059                                 return wp_delete_comment($comment_id);
    1060                         $status = 'deleted';
    1061                         wp_schedule_comment_delete($comment_id);
     1122                case 'trash':
     1123                        $status = 'trash';
    10621124                        break;
    10631125                default:
    … …  
    10821144
    10831145        return true;
    1084 }
    1085 
    1086 /**
    1087  * Schedules a comment for destruction in 30 days.
    1088  *
    1089  * @since 2.9.0
    1090  *
    1091  * @param int $comment_id Comment ID.
    1092  * @return void
    1093  */
    1094 function wp_schedule_comment_delete($comment_id) {
    1095         $to_delete = get_option('wp_scheduled_delete');
    1096         if ( !is_array($to_delete) )
    1097                 $to_delete = array();
    1098        
    1099         $to_delete['comments'][$comment_id] = time();
    1100        
    1101         update_option('wp_scheduled_delete', $to_delete);
    1102 }
    1103 
    1104 /**
    1105  * Unschedules a comment for destruction.
    1106  *
    1107  * @since 2.9.0
    1108  *
    1109  * @param int $comment_id Comment ID.
    1110  * @return void
    1111  */
    1112 function wp_unschedule_comment_delete($comment_id) {
    1113         $to_delete = get_option('wp_scheduled_delete');
    1114         if ( !is_array($to_delete) )
    1115                 return;
    1116        
    1117         unset($to_delete['comments'][$comment_id]);
    1118        
    1119         update_option('wp_scheduled_delete', $to_delete);
    11201146}
    11211147
  • trunk/wp-includes/functions.php

    r11741 r11749  
    33403340
    33413341/**
    3342  * Permanently deletes comments that have been scheduled for deleting.
    3343  * Will do the same for posts, pages, etc in the future.
     3342 * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
    33443343 *
    3345  * @access private
    33463344 * @since 2.9.0
    33473345 *
    … …  
    33493347 */
    33503348function wp_scheduled_delete() {
    3351         $to_delete = get_option('wp_scheduled_delete');
    3352         if (!is_array($to_delete))
     3349        $trash_meta = get_option('wp_trash_meta');
     3350        if ( !is_array($trash_meta) )
    33533351                return;
    33543352
    3355         if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) )
    3356                 $to_delete['comments'] = array();
    3357 
    3358         $delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30);
    3359         $deletetimestamp = time() - $delete_delay;
    3360         foreach ($to_delete['comments'] as $comment_id => $timestamp) {
    3361                 if ($timestamp < $deletetimestamp) {
    3362                         wp_delete_comment($comment_id);
    3363                         unset($to_delete['comments'][$comment_id]);
     3353        $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
     3354
     3355        foreach ( $trash_meta['comments'] as $id => $meta ) {
     3356                if ( $meta['time'] < $delete_timestamp ) {
     3357                        wp_delete_comment($id);
     3358                        unset($trash_meta['comments'][$id]);
    33643359                }
    33653360        }
     3361        foreach ( $trash_meta['posts'] as $id => $meta ) {
     3362                if ( $meta['time'] < $delete_timestamp ) {
     3363                        wp_delete_post($id);
     3364                        unset($to_delete['posts'][$id]);
     3365                }
     3366        }
    33663367
    33673368        update_option('wp_scheduled_delete', $to_delete);
  • trunk/wp-includes/post.php

    r11734 r11749  
    999999        $count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
    10001000
    1001         $stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0 );
     1001        $stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0, 'trash' => 0 );
    10021002        foreach( (array) $count as $row_num => $row ) {
    10031003                $stats[$row['post_status']] = $row['num_posts'];
    … …  
    10281028
    10291029        $and = wp_post_mime_type_where( $mime_type );
    1030         $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' $and GROUP BY post_mime_type", ARRAY_A );
     1030        $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A );
    10311031
    10321032        $stats = array( );
    … …  
    10341034                $stats[$row['post_mime_type']] = $row['num_posts'];
    10351035        }
     1036        $stats['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and");
    10361037
    10371038        return (object) $stats;
    … …  
    11411142                return $post;
    11421143
    1143         if ( 'attachment' == $post->post_type )
     1144        if ( ($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'trash' && EMPTY_TRASH_DAYS > 0 )
     1145                return wp_trash_post($postid);
     1146               
     1147        if ( $post->post_type == 'attachment' )
    11441148                return wp_delete_attachment($postid);
    11451149
    11461150        do_action('delete_post', $postid);
     1151       
     1152        $trash_meta = get_option('wp_trash_meta');
     1153        if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) {
     1154                unset($trash_meta['posts'][$postid]);
     1155                update_option('wp_trash_meta', $trash_meta);
     1156        }
    11471157
    11481158        /** @todo delete for pluggable post taxonomies too */
    … …  
    12011211
    12021212        do_action('deleted_post', $postid);
     1213
     1214        return $post;
     1215}
     1216
     1217/**
     1218 * Moves a post or page to the Trash
     1219 *
     1220 * @since 2.9.0
     1221 * @uses do_action() on 'trash_post' before trashing
     1222 * @uses do_action() on 'trashed_post' after trashing
     1223 *
     1224 * @param int $postid Post ID.
     1225 * @return mixed False on failure
     1226 */
     1227function wp_trash_post($postid = 0) {
     1228        if ( EMPTY_TRASH_DAYS == 0 )
     1229                return wp_delete_post($postid);
     1230
     1231        if ( !$post = wp_get_single_post($postid, ARRAY_A) )
     1232                return $post;
     1233
     1234        do_action('trash_post', $postid);
     1235
     1236        $trash_meta = get_option('wp_trash_meta');
     1237        if ( !is_array($trash_meta) )
     1238                $trash_meta = array();
     1239        $trash_meta['posts'][$postid]['status'] = $post['post_status'];
     1240        $trash_meta['posts'][$postid]['time'] = time();
     1241        update_option('wp_trash_meta', $trash_meta);
     1242
     1243        $post['post_status'] = 'trash';
     1244        wp_insert_post($post);
     1245
     1246        do_action('trashed_post', $postid);
     1247
     1248        return $post;
     1249}
     1250
     1251/**
     1252 * Removes a post or page from the Trash
     1253 *
     1254 * @since 2.9.0
     1255 * @uses do_action() on 'untrash_post' before undeletion
     1256 * @uses do_action() on 'untrashed_post' after undeletion
     1257 *
     1258 * @param int $postid Post ID.
     1259 * @return mixed False on failure
     1260 */
     1261function wp_untrash_post($postid = 0) {
     1262        if (!$post = wp_get_single_post($postid, ARRAY_A))
     1263                return $post;
     1264
     1265        do_action('untrash_post', $postid);
     1266       
     1267        $post['post_status'] = 'draft';
     1268       
     1269        $trash_meta = get_option('wp_trash_meta');
     1270        if (is_array($trash_meta) && isset($trash_meta['posts'][$postid])) {
     1271                $post['post_status'] = $trash_meta['posts'][$postid]['status'];
     1272                unset($trash_meta['posts'][$postid]);
     1273                update_option('wp_trash_meta', $trash_meta);
     1274        }
     1275       
     1276        wp_insert_post($post);
     1277       
     1278        do_action('untrashed_post', $postid);
    12031279
    12041280        return $post;
    … …  
    25872663        if ( 'attachment' != $post->post_type )
    25882664                return false;
     2665       
     2666        if ( 'trash' != $post->post_status )
     2667                return wp_trash_post($postid);
     2668
     2669        $trash_meta = get_option('wp_trash_meta');
     2670        if ( is_array($trash_meta) && isset($trash_meta['posts'][$postid]) ) {
     2671                unset($trash_meta['posts'][$postid]);
     2672                update_option('wp_trash_meta', $trash_meta);
     2673        }
    25892674
    25902675        $meta = wp_get_attachment_metadata( $postid );
  • trunk/wp-includes/query.php

    r11606 r11749  
    21002100                        if ( in_array( 'publish', $q_status ) )
    21012101                                $r_status[] = "$wpdb->posts.post_status = 'publish'";
     2102                        if ( in_array( 'trash', $q_status ) )
     2103                                $r_status[] = "$wpdb->posts.post_status = 'trash'";
    21022104
    21032105                        if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) {
  • trunk/wp-includes/script-loader.php

    r11742 r11749  
    6161        $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
    6262
    63         $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090720' );
     63        $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090730' );
    6464        $scripts->add_data( 'common', 'group', 1 );
    6565        $scripts->localize( 'common', 'commonL10n', array(
    … …  
    205205                        'dismiss' => __('Dismiss'),
    206206                        'crunching' => __('Crunching&hellip;'),
    207                         'deleted' => __('Deleted'),
     207                        'deleted' => __('Moved to Trash'),
    208208                        'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};'
    209209        ) );
    … …  
    249249                $scripts->add_data( 'user-profile', 'group', 1 );
    250250
    251                 $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090720' );
     251                $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090730' );
    252252                $scripts->add_data( 'admin-comments', 'group', 1 );
    253253                $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
  • trunk/wp-settings.php

    r11702 r11749  
    535535        define( 'AUTOSAVE_INTERVAL', 60 );
    536536
     537/**
     538 * It is possible to define this in wp-config.php
     539 * @since 2.9.0
     540 */
     541if ( !defined( 'EMPTY_TRASH_DAYS' ) )
     542        define( 'EMPTY_TRASH_DAYS', 30 );
    537543
    538544require (ABSPATH . WPINC . '/vars.php');
Note: See TracChangeset for help on using the changeset viewer.