WordPress.org

Make WordPress Core

Ticket #4529: delete-post.4.diff

File delete-post.4.diff, 59.6 KB (added by caesarsgrunt, 5 years ago)

Adds trash for Media and fixes/tweaks many other things...

  • wp-includes/post.php

     
    998998 
    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, 'deleted' => 0 ); 
    10021002        foreach( (array) $count as $row_num => $row ) { 
    10031003                $stats[$row['post_status']] = $row['num_posts']; 
    10041004        } 
     
    10271027        global $wpdb; 
    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 != 'deleted' $and GROUP BY post_mime_type", ARRAY_A ); 
    10311031 
    10321032        $stats = array( ); 
    10331033        foreach( (array) $count as $row ) { 
    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 = 'deleted' $and"); 
    10361037 
    10371038        return (object) $stats; 
    10381039} 
     
    11401141        if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) 
    11411142                return $post; 
    11421143 
    1143         if ( 'attachment' == $post->post_type ) 
     1144        if (($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'deleted') { 
     1145                wp_update_post(array('ID'=>$postid, 'post_status'=>'deleted')); 
     1146                wp_schedule_post_delete($postid); 
     1147                return true; 
     1148        } 
     1149        else if ($post->post_type == 'attachment') 
    11441150                return wp_delete_attachment($postid); 
    11451151 
    11461152        do_action('delete_post', $postid); 
     1153         
     1154        wp_unschedule_post_delete($postid); 
    11471155 
    11481156        /** @todo delete for pluggable post taxonomies too */ 
    11491157        wp_delete_object_term_relationships($postid, array('category', 'post_tag')); 
     
    12051213} 
    12061214 
    12071215/** 
     1216 * Removes a post or page from the Trash 
     1217 * 
     1218 * @since 2.9.0 
     1219 * @uses do_action() on 'undelete_post' before deletion 
     1220 * @uses do_action() on 'undeleted_post' after deletion 
     1221 * 
     1222 * @param int $postid Post ID. 
     1223 * @return mixed False on failure 
     1224 */ 
     1225function wp_undelete_post($postid = 0) { 
     1226        global $wpdb, $wp_rewrite; 
     1227 
     1228        if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) 
     1229                return $post; 
     1230 
     1231        do_action('undelete_post', $postid); 
     1232         
     1233        wp_update_post(array('ID'=>$postid, 'post_status'=>'draft')); 
     1234         
     1235        wp_unschedule_post_delete($postid); 
     1236 
     1237        do_action('undeleted_post', $postid); 
     1238 
     1239        return $post; 
     1240} 
     1241 
     1242/** 
     1243 * Schedules a post for permanent deletion. 
     1244 *  
     1245 * @since 2.9.0 
     1246 *  
     1247 * @param int $post_id Post ID. 
     1248 * @return void 
     1249 */ 
     1250function wp_schedule_post_delete($post_id) { 
     1251        $to_delete = get_option('wp_scheduled_delete'); 
     1252        if (!is_array($to_delete)) 
     1253                $to_delete = array(); 
     1254         
     1255        $to_delete['posts'][$post_id] = time(); 
     1256         
     1257        update_option('wp_scheduled_delete', $to_delete); 
     1258} 
     1259 
     1260/** 
     1261 * Unschedules a post for permanent deletion. 
     1262 *  
     1263 * @since 2.9.0 
     1264 *  
     1265 * @param int $post_id Post ID. 
     1266 * @return void 
     1267 */ 
     1268function wp_unschedule_post_delete($post_id) { 
     1269        $to_delete = get_option('wp_scheduled_delete'); 
     1270        if (!is_array($to_delete)) 
     1271                return; 
     1272         
     1273        unset($to_delete['posts'][$post_id]); 
     1274         
     1275        update_option('wp_scheduled_delete', $to_delete); 
     1276} 
     1277 
     1278/** 
    12081279 * Retrieve the list of categories for a post. 
    12091280 * 
    12101281 * Compatibility layer for themes and plugins. Also an easy layer of abstraction 
     
    25862657 
    25872658        if ( 'attachment' != $post->post_type ) 
    25882659                return false; 
     2660        elseif (get_post_status($postid) != 'deleted') { 
     2661                $post = wp_get_single_post($postid, ARRAY_A); 
     2662                $post['post_status'] = 'deleted'; 
     2663                wp_insert_post($post); 
     2664                wp_schedule_post_delete($postid); 
     2665                return true; 
     2666        } 
    25892667 
    25902668        $meta = wp_get_attachment_metadata( $postid ); 
    25912669        $file = get_attached_file( $postid ); 
     
    26322710} 
    26332711 
    26342712/** 
     2713 * Removes an attachment from the Trash 
     2714 * 
     2715 * @since 2.9.0 
     2716 * @uses do_action() on 'undelete_attachment' before deletion 
     2717 * @uses do_action() on 'undeleted_attachment' after deletion 
     2718 * 
     2719 * @param int $postid Post ID. 
     2720 * @return mixed False on failure 
     2721 */ 
     2722function wp_undelete_attachment($postid = 0) { 
     2723        global $wpdb, $wp_rewrite; 
     2724 
     2725        if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) ) 
     2726                return $post; 
     2727 
     2728        do_action('undelete_attachment', $postid); 
     2729         
     2730        $post = wp_get_single_post($postid, ARRAY_A); 
     2731        $post['post_status'] = 'inherit'; 
     2732        wp_insert_post($post); 
     2733         
     2734        wp_unschedule_post_delete($postid); 
     2735 
     2736        do_action('undeleted_attachment', $postid); 
     2737 
     2738        return $post; 
     2739} 
     2740 
     2741/** 
    26352742 * Retrieve attachment meta field for attachment ID. 
    26362743 * 
    26372744 * @since 2.1.0 
  • wp-includes/comment.php

     
    694694        if ( false !== $count ) 
    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 ); 
     699                $where .= $wpdb->prepare( "c.comment_post_ID = %d AND ", $post_id ); 
     700        $where .= "p.post_status <> 'deleted'"; 
    700701 
    701         $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); 
     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; 
    704705        $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted'); 
     
    10841085} 
    10851086 
    10861087/** 
    1087  * Schedules a comment for destruction in 30 days. 
     1088 * Schedules a comment for permanent deletion. 
    10881089 *  
    10891090 * @since 2.9.0 
    10901091 *  
     
    11021103} 
    11031104 
    11041105/** 
    1105  * Unschedules a comment for destruction. 
     1106 * Unschedules a comment for permanent deletion. 
    11061107 *  
    11071108 * @since 2.9.0 
    11081109 *  
  • wp-includes/functions.php

     
    33393339} 
    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, and comments that have been scheduled for deleting. 
    33443343 *  
    3345  * @access private 
    33463344 * @since 2.9.0 
    33473345 * 
    33483346 * @return void 
     
    33553353        if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) ) 
    33563354                $to_delete['comments'] = array(); 
    33573355 
    3358         $delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30); 
    3359         $deletetimestamp = time() - $delete_delay; 
     3356        $delete_days = defined('EMPTY_TRASH_DAYS') ? (int) EMPTY_TRASH_DAYS : 30; 
     3357        $deletetimestamp = time() - (60*60*24*$delete_days); 
    33603358        foreach ($to_delete['comments'] as $comment_id => $timestamp) { 
    33613359                if ($timestamp < $deletetimestamp) { 
    33623360                        wp_delete_comment($comment_id); 
    33633361                        unset($to_delete['comments'][$comment_id]); 
    33643362                } 
    33653363        } 
     3364        foreach ($to_delete['posts'] as $post_id => $timestamp) { 
     3365                if ($timestamp < $deletetimestamp) { 
     3366                        wp_delete_post($post_id); 
     3367                        unset($to_delete['posts'][$post_id]); 
     3368                } 
     3369        } 
    33663370 
    33673371        update_option('wp_scheduled_delete', $to_delete); 
    33683372} 
  • wp-includes/query.php

     
    20992099                                $p_status[] = "$wpdb->posts.post_status = 'private'"; 
    21002100                        if ( in_array( 'publish', $q_status ) ) 
    21012101                                $r_status[] = "$wpdb->posts.post_status = 'publish'"; 
     2102                        if ( in_array( 'deleted', $q_status ) ) 
     2103                                $r_status[] = "$wpdb->posts.post_status = 'deleted'"; 
    21022104 
    21032105                        if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { 
    21042106                                $r_status = array_merge($r_status, $p_status); 
  • wp-admin/edit-comments.php

     
    292292if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) { 
    293293        wp_nonce_field('bulk-destroy', '_destroy_nonce'); 
    294294    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" /> 
     295                <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 
    296296<?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" /> 
     297                <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
    298298<?php } 
    299299} ?> 
    300300<?php do_action('manage_comments_nav', $comment_status); ?> 
     
    364364<input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> 
    365365 
    366366<?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" /> 
     367<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" /> 
    368368<?php } elseif ( 'deleted' == $comment_status ) { ?> 
    369369<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
    370370<?php } ?> 
  • wp-admin/wp-admin.css

     
    409409} 
    410410 
    411411#doaction, 
    412 #doaction2 { 
     412#doaction2, 
     413#post-query-submit { 
    413414        margin-right: 8px; 
    414415} 
    415416 
  • wp-admin/includes/post.php

     
    795795                                'pending' => array(_x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')), 
    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                                'deleted' => array(_x('Trash', 'post'), __('Trash posts'), _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>')), 
    798799                        ); 
    799800 
    800801        $post_stati = apply_filters('post_stati', $post_stati); 
  • wp-admin/includes/dashboard.php

     
    480480        $comments = array(); 
    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 != 'deleted' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { 
    484484 
    485485                foreach ( $possible as $comment ) { 
    486486                        if ( count( $comments ) >= 5 ) 
  • wp-admin/includes/template.php

     
    14331433                case 'title': 
    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 != 'deleted' ) { ?><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 ) 
    14391439                                the_excerpt(); 
    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 ( 'deleted' == $post->post_status ) { 
     1443                                $actions['undelete'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=undelete&amp;post=$post->ID", 'undelete-post_' . $post->ID) . "'>" . __('Return to Drafts') . "</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['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-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); 
    14561461                        $action_count = count($actions); 
     
    16511656                $attributes = 'class="post-title page-title column-title"' . $style; 
    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 != 'deleted' ) { ?><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 == 'deleted') { 
     1663                        if ( current_user_can('delete_page', $page->ID) ) { 
     1664                                $actions['undelete'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=undelete&amp;post=$page->ID", 'undelete-page_' . $page->ID) . "'>" . __('Return to Drafts') . "</a>"; 
     1665                                $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>"; 
     1666                        } 
    16671667                } else { 
    1668                         $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 
     1668                        if ( current_user_can('edit_page', $page->ID) ) { 
     1669                                $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>'; 
     1670                                $actions['inline'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>'; 
     1671                        } 
     1672                        if ( current_user_can('delete_page', $page->ID) ) { 
     1673                                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Trash') . "</a>"; 
     1674                        } 
     1675                        if ( in_array($post->post_status, array('pending', 'draft')) ) { 
     1676                                if ( current_user_can('edit_page', $page->ID) ) 
     1677                                        $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; 
     1678                        } else { 
     1679                                $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 
     1680                        } 
    16691681                } 
    16701682                $actions = apply_filters('page_row_actions', $actions, $page); 
    16711683                $action_count = count($actions); 
     
    19992011        $index = ''; 
    20002012 
    20012013        if ( 'moderated' == $status ) { 
    2002                 $approved = "comment_approved = '0'"; 
     2014                $approved = "c.comment_approved = '0'"; 
    20032015                $total = $count->moderated; 
    20042016        } elseif ( 'approved' == $status ) { 
    2005                 $approved = "comment_approved = '1'"; 
     2017                $approved = "c.comment_approved = '1'"; 
    20062018                $total = $count->approved; 
    20072019        } elseif ( 'spam' == $status ) { 
    2008                 $approved = "comment_approved = 'spam'"; 
     2020                $approved = "c.comment_approved = 'spam'"; 
    20092021                $total = $count->spam; 
    20102022        } elseif ( 'deleted' == $status ) { 
    2011                 $approved = "comment_approved = 'deleted'"; 
     2023                $approved = "c.comment_approved = 'deleted'"; 
    20122024                $total = $count->deleted; 
    20132025        } else { 
    2014                 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 
     2026                $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )"; 
    20152027                $total = $count->moderated + $count->approved; 
    2016                 $index = 'USE INDEX (comment_date_gmt)'; 
     2028                $index = 'USE INDEX (c.comment_date_gmt)'; 
    20172029        } 
    20182030 
    20192031        if ( $post ) { 
    20202032                $total = ''; 
    2021                 $post = " AND comment_post_ID = '$post'"; 
    2022                 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num"; 
     2033                $post = " AND c.comment_post_ID = '$post'"; 
     2034                $orderby = "ORDER BY c.comment_date_gmt ASC LIMIT $start, $num"; 
    20232035        } else { 
    20242036                $post = ''; 
    2025                 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num"; 
     2037                $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num"; 
    20262038        } 
    20272039 
    20282040        if ( 'comment' == $type ) 
    2029                 $typesql = "AND comment_type = ''"; 
     2041                $typesql = "AND c.comment_type = ''"; 
    20302042        elseif ( 'pingback' == $type ) 
    2031                 $typesql = "AND comment_type = 'pingback'"; 
     2043                $typesql = "AND c.comment_type = 'pingback'"; 
    20322044        elseif ( 'trackback' == $type ) 
    2033                 $typesql = "AND comment_type = 'trackback'"; 
     2045                $typesql = "AND c.comment_type = 'trackback'"; 
    20342046        elseif ( 'pings' == $type ) 
    2035                 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )"; 
     2047                $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )"; 
    20362048        else 
    20372049                $typesql = ''; 
    20382050 
    20392051        if ( !empty($type) ) 
    20402052                $total = ''; 
    20412053 
     2054        $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'deleted' "; 
    20422055        if ( $s ) { 
    20432056                $total = ''; 
    20442057                $s = $wpdb->escape($s); 
    2045                 $query = "FROM $wpdb->comments WHERE 
    2046                         (comment_author LIKE '%$s%' OR 
    2047                         comment_author_email LIKE '%$s%' OR 
    2048                         comment_author_url LIKE ('%$s%') OR 
    2049                         comment_author_IP LIKE ('%$s%') OR 
    2050                         comment_content LIKE ('%$s%') ) AND 
     2058                $query .= "AND 
     2059                        (c.comment_author LIKE '%$s%' OR 
     2060                        c.comment_author_email LIKE '%$s%' OR 
     2061                        c.comment_author_url LIKE ('%$s%') OR 
     2062                        c.comment_author_IP LIKE ('%$s%') OR 
     2063                        c.comment_content LIKE ('%$s%') ) AND 
    20512064                        $approved 
    20522065                        $typesql"; 
    20532066        } else { 
    2054                 $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql"; 
     2067                $query .= "AND $approved $post $typesql"; 
    20552068        } 
    2056  
     2069         
    20572070        $comments = $wpdb->get_results("SELECT * $query $orderby"); 
    20582071        if ( '' === $total ) 
    2059                 $total = $wpdb->get_var("SELECT COUNT(comment_ID) $query"); 
     2072                $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query"); 
    20602073 
    20612074        update_comment_cache($comments); 
    20622075 
     
    21572170                                                        $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>'; 
    21582171                                                } else { 
    21592172                                                        $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>'; 
    2160                                                         $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>'; 
     2173                                                        $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Trash') . '</a>'; 
    21612174                                                } 
    21622175 
    21632176                                                $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; 
  • wp-admin/includes/media.php

     
    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(); 
    11801178 
  • wp-admin/post.php

     
    116116        $post = get_post($post_ID); 
    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 == 'deleted' ) 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 ) { 
    121122                wp_redirect( get_edit_post_link( $post->ID, 'url' ) ); 
     
    206207        exit(); 
    207208        break; 
    208209 
     210case 'undelete': 
     211        $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']); 
     212        check_admin_referer('undelete-post_' . $post_id); 
     213 
     214        $post = & get_post($post_id); 
     215 
     216        if ( $post->post_type == 'attachment' ) { 
     217                if ( ! wp_undelete_attachment($post_id) ) 
     218                        wp_die( __('Error in undeleting...') ); 
     219        } else { 
     220                if ( !wp_undelete_post($post_id) ) 
     221                        wp_die( __('Error in undeleting...') ); 
     222        } 
     223 
     224        $sendback = wp_get_referer(); 
     225        if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?undeleted=1'); 
     226        elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 
     227        else $sendback = add_query_arg('undeleted', 1, $sendback); 
     228        wp_redirect($sendback); 
     229        exit(); 
     230        break; 
     231 
    209232case 'preview': 
    210233        check_admin_referer( 'autosave', 'autosavenonce' ); 
    211234 
  • wp-admin/js/common.dev.js

     
    154154        $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); 
    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 () { 
    169159                if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) { 
  • wp-admin/js/edit-comments.dev.js

     
    3939                settings.data._url = document.location.href; 
    4040 
    4141                if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted) 
    42                         return showNotice.warn() ? settings : false; 
     42                        return settings; 
    4343 
    4444                return settings; 
    4545        }; 
  • wp-admin/edit-page-form.php

     
    216216<div id="delete-action"> 
    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=delete&amp;post=$post->ID", 'delete-page_' . $post->ID); ?>"><?php _e('Move to Trash'); ?></a> 
    220220<?php } ?> 
    221221</div> 
    222222 
  • wp-admin/edit-attachment-rows.php

     
    2929$posts_columns = get_column_headers('upload'); 
    3030$hidden = get_hidden_columns('upload'); 
    3131while (have_posts()) : the_post(); 
     32if ($is_trash && $post->post_status != 'deleted') continue; 
     33elseif (!$is_trash && $post->post_status == 'deleted') continue; 
    3234$alt = ( 'alternate' == $alt ) ? '' : 'alternate'; 
    3335global $current_user; 
    3436$post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); 
     
    6062                ?> 
    6163                <td <?php echo $attributes ?>><?php 
    6264                        if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) { 
     65                                if ($is_trash) echo $thumb; 
     66                                else { 
    6367?> 
    64  
    6568                                <a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>"> 
    6669                                        <?php echo $thumb; ?> 
    6770                                </a> 
    6871 
    6972<?php                   } 
     73                        } 
    7074                ?></td> 
    7175                <?php 
    7276                // TODO 
     
    7478 
    7579        case 'media': 
    7680                ?> 
    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 /> 
     81                <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 /> 
    7882                <?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?> 
    7983                <p> 
    8084                <?php 
    8185                $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>'; 
     86                if ($is_trash && current_user_can('delete_post', $post->ID)) { 
     87                        $actions['undelete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=undelete&amp;post=$post->ID", 'undelete-post_' . $post->ID) . "'>" . __('Remove from Trash') . "</a>"; 
     88                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; 
     89                } else { 
     90                        if (current_user_can('edit_post', $post->ID)) 
     91                                $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 
     92                        if (current_user_can('delete_post', $post->ID)) 
     93                                $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 
     94                        $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 
     95                } 
    8796                $action_count = count($actions); 
    8897                $i = 0; 
    8998                echo '<div class="row-actions">'; 
  • wp-admin/media.php

     
    5858 
    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 == 'deleted' ) 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 
    6366        wp_enqueue_script( 'wp-ajax-response' ); 
  • wp-admin/upload.php

     
    6767                exit; 
    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']; 
     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 = 'deleted'" ); 
     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 wp_redirect($_SERVER['HTTP_REFERER']); 
     80         
     81        $location = 'upload.php'; 
     82        if ( $referer = wp_get_referer() ) { 
     83                if ( false !== strpos($referer, 'upload.php') ) 
     84                        $location = $referer; 
     85        } 
    7386 
    74         if ( 'delete' == $doaction ) { 
    75                 foreach( (array) $_GET['media'] as $post_id_del ) { 
    76                         $post_del = & get_post($post_id_del); 
     87        switch ( $doaction ) { 
     88                case 'delete': 
     89                        foreach( (array) $post_ids as $post_id_del ) { 
     90                                $post_del = & get_post($post_id_del); 
     91                                 
     92                                if ( !current_user_can('delete_post', $post_id_del) ) 
     93                                        wp_die( __('You are not allowed to delete this post.') ); 
     94         
     95                                if ( $post_del->post_type == 'attachment' ) 
     96                                        if ( !wp_delete_attachment($post_id_del) ) 
     97                                                wp_die( __('Error in deleting...') ); 
     98                        } 
     99                        $location = add_query_arg('message', 2, $location); 
     100                        break; 
     101                case 'undelete': 
     102                        foreach( (array) $post_ids as $post_id ) { 
     103                                $post_del = & get_post($post_id); 
    77104 
    78                         if ( !current_user_can('delete_post', $post_id_del) ) 
    79                                 wp_die( __('You are not allowed to delete this post.') ); 
     105                                if ( $post_del->post_type == 'attachment' ) 
     106                                        if ( !wp_undelete_attachment($post_id) ) 
     107                                                wp_die( __('Error in undeleting...') ); 
     108                        } 
     109                        $location = add_query_arg('message', 4, $location); 
     110                        break; 
     111        } 
    80112 
    81                         if ( $post_del->post_type == 'attachment' ) 
    82                                 if ( ! wp_delete_attachment($post_id_del) ) 
    83                                         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         } 
     113        $location = remove_query_arg('posted', $location); 
     114        wp_redirect($location); 
     115        exit; 
    97116} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 
    98117         wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 
    99118         exit; 
     
    135154        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 
    136155} 
    137156 
     157$is_trash = (isset($_GET['status']) && $_GET['status'] == 'deleted'); 
     158 
    138159wp_enqueue_script('media'); 
    139160require_once('admin-header.php'); ?> 
    140161 
     
    153174$messages[1] = __('Media attachment updated.'); 
    154175$messages[2] = __('Media deleted.'); 
    155176$messages[3] = __('Error saving media attachment.'); 
     177$messages[4] = __('Media removed from Trash.'); 
    156178 
    157179if ( isset($_GET['message']) && (int) $_GET['message'] ) { 
    158180        $message = $messages[$_GET['message']]; 
     
    180202<?php 
    181203$type_links = array(); 
    182204$_num_posts = (array) wp_count_attachments(); 
    183 $_total_posts = array_sum( $_num_posts ); 
     205$_total_posts = array_sum($_num_posts) - $_num_posts['trash']; 
    184206$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 
    185207foreach ( $matches as $type => $reals ) 
    186208        foreach ( $reals as $real ) 
    187209                $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; 
    188210 
    189 $class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : ''; 
     211$class = (empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status'])) ? ' class="current"' : ''; 
    190212$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>'; 
    191213foreach ( $post_mime_types as $mime_type => $label ) { 
    192214        $class = ''; 
     
    199221 
    200222        $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>'; 
    201223} 
    202 $class = isset($_GET['detached']) ? ' class="current"' : ''; 
    203 $type_links[] = '<li><a href="upload.php?detached=1"' . $class . '>' . __('Unattached') . '</a>'; 
     224$type_links[] = '<li><a href="upload.php?detached=1"' . (isset($_GET['detached']) ? ' class="current"' : '') . '>' . __('Unattached') . '</a>'; 
     225$type_links[] = '<li><a href="upload.php?status=deleted"' . ((isset($_GET['status']) && $_GET['status'] == 'deleted') ? ' 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>'; 
    204226 
    205227echo implode( " |</li>\n", $type_links) . '</li>'; 
    206228unset($type_links); 
     
    242264<div class="alignleft actions"> 
    243265<select name="action" class="select-action"> 
    244266<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 
    245 <option value="delete"><?php _e('Delete'); ?></option> 
    246 <?php if ( isset($orphans) ) { ?> 
     267<?php if ($is_trash) { ?> 
     268<option value="undelete"><?php _e('Remove from Trash'); ?></option> 
     269<option value="delete"><?php _e('Delete Permanently'); ?></option> 
     270<?php } else { ?> 
     271<option value="delete"><?php _e('Move to Trash'); ?></option> 
     272<?php } if (isset($orphans)) { ?> 
    247273<option value="attach"><?php _e('Attach to a post'); ?></option> 
    248274<?php } ?> 
    249275</select> 
     
    251277<?php wp_nonce_field('bulk-media'); ?> 
    252278 
    253279<?php 
    254 if ( ! is_singular() && ! isset($_GET['detached']) ) { 
     280if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) { 
    255281        $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"; 
    256282 
    257283        $arc_result = $wpdb->get_results( $arc_query ); 
     
    286312 
    287313<?php if ( isset($_GET['detached']) ) { ?> 
    288314        <input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" /> 
     315<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'deleted' ) { ?> 
     316        <input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
    289317<?php } ?> 
    290318 
    291319</div> 
     
    341369                if ( current_user_can('edit_post', $post->ID) ) 
    342370                        $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>'; 
    343371                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>"; 
     372                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; 
    345373                $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>'; 
    346374                if ( current_user_can('edit_post', $post->ID) ) 
    347375                        $actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;">'.__('Attach').'</a>'; 
     
    398426<div class="alignleft actions"> 
    399427<select name="action2" class="select-action"> 
    400428<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 
    401 <option value="delete"><?php _e('Delete'); ?></option> 
    402 <?php if ( isset($orphans) ) { ?> 
     429<?php if ($is_trash) { ?> 
     430<option value="undelete"><?php _e('Remove from Trash'); ?></option> 
     431<option value="delete"><?php _e('Delete Permanently'); ?></option> 
     432<?php } else { ?> 
     433<option value="delete"><?php _e('Move to Trash'); ?></option> 
     434<?php } if (isset($orphans)) { ?> 
    403435<option value="attach"><?php _e('Attach to a post'); ?></option> 
    404436<?php } ?> 
    405437</select> 
    406438<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 
     439 
     440<?php if ( isset($_GET['status']) && $_GET['status'] == 'deleted' ) { ?> 
     441        <input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
     442<?php } ?> 
    407443</div> 
    408444 
    409445<br class="clear" /> 
  • wp-admin/edit-form-comment.php

     
    6464 
    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"> 
    7070<input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" /> 
  • wp-admin/edit-form-advanced.php

     
    229229<div id="delete-action"> 
    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=delete&amp;post=$post->ID", 'delete-post_' . $post->ID); ?>"><?php _e('Move to Trash'); ?></a> 
    233233<?php } ?> 
    234234</div> 
    235235 
  • wp-admin/edit.php

     
    1818} 
    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 ) { 
    2534                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); 
     35                        $deleted = 0; 
     36                        foreach( (array) $post_ids as $post_id_del ) { 
     37                                $post_del = & get_post($post_id_del); 
    3138 
    32                                         if ( !current_user_can('delete_post', $post_id_del) ) 
    33                                                 wp_die( __('You are not allowed to delete this post.') ); 
     39                                if ( !current_user_can('delete_post', $post_id_del) ) 
     40                                        wp_die( __('You are not allowed to delete this post.') ); 
    3441 
    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++; 
     42                                if ( $post_del->post_type == 'attachment' ) { 
     43                                        if ( ! wp_delete_attachment($post_id_del) ) 
     44                                                wp_die( __('Error in deleting...') ); 
     45                                } else { 
     46                                        if ( !wp_delete_post($post_id_del) ) 
     47                                                wp_die( __('Error in deleting...') ); 
    4348                                } 
     49                                $deleted++; 
    4450                        } 
    4551                        break; 
    46                 case 'edit': 
    47                         if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 
    48                                 check_admin_referer('bulk-posts'); 
     52                case 'undelete': 
     53                        $undeleted = 0; 
     54                        foreach( (array) $post_ids as $post_id ) { 
     55                                $post_del = & get_post($post_id); 
    4956 
    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); 
     57                                if ( !wp_undelete_post($post_id) ) 
     58                                        wp_die( __('Error in undeleting...') ); 
     59                                 
     60                                $undeleted++; 
    5861                        } 
    5962                        break; 
     63                case 'edit': 
     64                        if ( -1 == $_GET['_status'] ) { 
     65                                $_GET['post_status'] = null; 
     66                                unset($_GET['_status'], $_GET['post_status']); 
     67                        } else { 
     68                                $_GET['post_status'] = $_GET['_status']; 
     69                        } 
     70 
     71                        $done = bulk_edit_posts($_GET); 
     72                        break; 
    6073        } 
    6174 
    6275        $sendback = wp_get_referer(); 
     
    7083        } 
    7184        if ( isset($deleted) ) 
    7285                $sendback = add_query_arg('deleted', $deleted, $sendback); 
     86        elseif ( isset($undeleted) ) 
     87                $sendback = add_query_arg('undeleted', $undeleted, $sendback); 
    7388        wp_redirect($sendback); 
    7489        exit(); 
    7590} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 
     
    127142        unset($_GET['deleted']); 
    128143} 
    129144 
     145if ( isset($_GET['undeleted']) && (int) $_GET['undeleted'] ) { 
     146        printf( _n( 'Post returned to Pending.', '%s posts returned to Pending.', $_GET['undeleted'] ), number_format_i18n( $_GET['undeleted'] ) ); 
     147        unset($_GET['undeleted']); 
     148} 
     149 
    130150$_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] ); 
    131151?> 
    132152</p></div> 
     
    139159if ( empty($locked_post_status) ) : 
    140160$status_links = array(); 
    141161$num_posts = wp_count_posts( 'post', 'readable' ); 
    142 $total_posts = array_sum( (array) $num_posts ); 
     162$total_posts = array_sum( (array) $num_posts ) - $num_posts->deleted; 
    143163$class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; 
    144164$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>'; 
    145165 
     
    190210<div class="alignleft actions"> 
    191211<select name="action"> 
    192212<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 
     213<?php if ($_GET['post_status'] == 'deleted') { ?> 
     214<option value="undelete"><?php _e('Return to Pending'); ?></option> 
     215<option value="delete"><?php _e('Delete Permanently'); ?></option> 
     216<?php } else { ?> 
    193217<option value="edit"><?php _e('Edit'); ?></option> 
    194 <option value="delete"><?php _e('Delete'); ?></option> 
     218<option value="delete"><?php _e('Move to Trash'); ?></option> 
     219<?php } ?> 
    195220</select> 
    196221<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 
    197222<?php wp_nonce_field('bulk-posts'); ?> 
     
    235260do_action('restrict_manage_posts'); 
    236261?> 
    237262<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> 
    238  
     263<?php } if ($_GET['post_status'] == 'deleted') { ?> 
     264<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
    239265<?php } ?> 
    240266</div> 
    241267 
     
    270296<div class="alignleft actions"> 
    271297<select name="action2"> 
    272298<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 
     299<?php if ($_GET['post_status'] == 'deleted') { ?> 
     300<option value="undelete"><?php _e('Return to Pending'); ?></option> 
     301<option value="delete"><?php _e('Delete Permanently'); ?></option> 
     302<?php } else { ?> 
    273303<option value="edit"><?php _e('Edit'); ?></option> 
    274 <option value="delete"><?php _e('Delete'); ?></option> 
     304<option value="delete"><?php _e('Move to Trash'); ?></option> 
     305<?php } ?> 
    275306</select> 
    276307<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 
     308<?php if ($_GET['post_status'] == 'deleted') { ?> 
     309<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
     310<?php } ?> 
    277311<br class="clear" /> 
    278312</div> 
    279313<br class="clear" /> 
  • wp-admin/page.php

     
    8383        $post = get_post_to_edit($page_ID); 
    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 == 'deleted' ) 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 ) { 
    8889                wp_redirect( get_edit_post_link( $post_ID, 'url' ) ); 
     
    165166        exit(); 
    166167        break; 
    167168 
     169case 'undelete': 
     170        $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']); 
     171        check_admin_referer('undelete-page_' . $post_id); 
     172 
     173        $post = & get_post($post_id); 
     174 
     175        if ( $post->post_type == 'attachment' ) { 
     176                if ( ! wp_undelete_attachment($post_id) ) 
     177                        wp_die( __('Error in undeleting...') ); 
     178        } else { 
     179                if ( !wp_undelete_post($post_id) ) 
     180                        wp_die( __('Error in undeleting...') ); 
     181        } 
     182 
     183        $sendback = wp_get_referer(); 
     184        if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit.php?undeleted=1'); 
     185        elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 
     186        else $sendback = add_query_arg('undeleted', 1, $sendback); 
     187        wp_redirect($sendback); 
     188        exit(); 
     189        break; 
     190 
    168191case 'preview': 
    169192        check_admin_referer( 'autosave', 'autosavenonce' ); 
    170193 
  • wp-admin/edit-pages.php

     
    1010require_once('admin.php'); 
    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 ) { 
    1726                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); 
     27                        $deleted = 0; 
     28                        foreach( (array) $post_ids as $post_id_del ) { 
     29                                $post_del = & get_post($post_id_del); 
    2330 
    24                                         if ( !current_user_can('delete_page', $post_id_del) ) 
    25                                                 wp_die( __('You are not allowed to delete this page.') ); 
     31                                if ( !current_user_can('delete_page', $post_id_del) ) 
     32                                        wp_die( __('You are not allowed to delete this page.') ); 
    2633 
    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++; 
     34                                if ( $post_del->post_type == 'attachment' ) { 
     35                                        if ( ! wp_delete_attachment($post_id_del) ) 
     36                                                wp_die( __('Error in deleting...') ); 
     37                                } else { 
     38                                        if ( !wp_delete_post($post_id_del) ) 
     39                                                wp_die( __('Error in deleting...') ); 
    3540                                } 
     41                                $deleted++; 
    3642                        } 
    3743                        break; 
    38                 case 'edit': 
    39                         if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 
    40                                 check_admin_referer('bulk-pages'); 
     44                case 'undelete': 
     45                        $undeleted = 0; 
     46                        foreach( (array) $post_ids as $post_id ) { 
     47                                $post_del = & get_post($post_id); 
    4148 
    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); 
     49                                if ( !wp_undelete_post($post_id) ) 
     50                                        wp_die( __('Error in undeleting...') ); 
     51                                 
     52                                $undeleted++; 
    5053                        } 
    5154                        break; 
     55                case 'edit': 
     56                        if ( -1 == $_GET['_status'] ) { 
     57                                $_GET['post_status'] = null; 
     58                                unset($_GET['_status'], $_GET['post_status']); 
     59                        } else { 
     60                                $_GET['post_status'] = $_GET['_status']; 
     61                        } 
     62 
     63                        $done = bulk_edit_posts($_GET); 
     64                        break; 
    5265        } 
    5366 
    5467        $sendback = wp_get_referer(); 
     
    6275        } 
    6376        if ( isset($deleted) ) 
    6477                $sendback = add_query_arg('deleted', $deleted, $sendback); 
     78        elseif ( isset($undeleted) ) 
     79                $sendback = add_query_arg('undeleted', $undeleted, $sendback); 
    6580        wp_redirect($sendback); 
    6681        exit(); 
    6782} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) { 
     
    7994                'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')), 
    8095                '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')), 
    8196                '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')) 
     97                'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')), 
     98                'deleted' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page')) 
    8399        ); 
    84100 
    85101$post_stati = apply_filters('page_stati', $post_stati); 
     
    150166if ( empty($locked_post_status) ) : 
    151167$status_links = array(); 
    152168$num_posts = wp_count_posts('page', 'readable'); 
    153 $total_posts = array_sum( (array) $num_posts ); 
     169$total_posts = array_sum( (array) $num_posts ) - $num_posts->deleted; 
    154170$class = empty($_GET['post_status']) ? ' class="current"' : ''; 
    155171$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>'; 
    156172foreach ( $post_stati as $status => $label ) { 
     
    212228<div class="alignleft actions"> 
    213229<select name="action"> 
    214230<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 
     231<?php if ($_GET['post_status'] == 'deleted') { ?> 
     232<option value="undelete"><?php _e('Return to Pending'); ?></option> 
     233<option value="delete"><?php _e('Delete Permanently'); ?></option> 
     234<?php } else { ?> 
    215235<option value="edit"><?php _e('Edit'); ?></option> 
    216 <option value="delete"><?php _e('Delete'); ?></option> 
     236<option value="delete"><?php _e('Move to Trash'); ?></option> 
     237<?php } ?> 
    217238</select> 
    218239<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 
    219240<?php wp_nonce_field('bulk-pages'); ?> 
     241<?php if ($_GET['post_status'] == 'deleted') { ?> 
     242<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
     243<?php } ?> 
    220244</div> 
    221245 
    222246<br class="clear" /> 
     
    251275<div class="alignleft actions"> 
    252276<select name="action2"> 
    253277<option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 
     278<?php if ($_GET['post_status'] == 'deleted') { ?> 
     279<option value="undelete"><?php _e('Return to Pending'); ?></option> 
     280<option value="delete"><?php _e('Delete Permanently'); ?></option> 
     281<?php } else { ?> 
    254282<option value="edit"><?php _e('Edit'); ?></option> 
    255 <option value="delete"><?php _e('Delete'); ?></option> 
     283<option value="delete"><?php _e('Move to Trash'); ?></option> 
     284<?php } ?> 
    256285</select> 
    257286<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 
     287<?php if ($_GET['post_status'] == 'deleted') { ?> 
     288<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 
     289<?php } ?> 
    258290</div> 
    259291 
    260292<br class="clear" />