Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 11743)
+++ wp-includes/post.php	(working copy)
@@ -998,7 +998,7 @@
 
 	$count = $wpdb->get_results( $wpdb->prepare( $query, $type ), ARRAY_A );
 
-	$stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0 );
+	$stats = array( 'publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0, 'deleted' => 0 );
 	foreach( (array) $count as $row_num => $row ) {
 		$stats[$row['post_status']] = $row['num_posts'];
 	}
@@ -1027,12 +1027,13 @@
 	global $wpdb;
 
 	$and = wp_post_mime_type_where( $mime_type );
-	$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 );
+	$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 );
 
 	$stats = array( );
 	foreach( (array) $count as $row ) {
 		$stats[$row['post_mime_type']] = $row['num_posts'];
 	}
+	$stats['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'deleted' $and");
 
 	return (object) $stats;
 }
@@ -1140,10 +1141,17 @@
 	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
 		return $post;
 
-	if ( 'attachment' == $post->post_type )
+	if (($post->post_type == 'post' || $post->post_type == 'page') && get_post_status($postid) != 'deleted') {
+		wp_update_post(array('ID'=>$postid, 'post_status'=>'deleted'));
+		wp_schedule_post_delete($postid);
+		return true;
+	}
+	else if ($post->post_type == 'attachment')
 		return wp_delete_attachment($postid);
 
 	do_action('delete_post', $postid);
+	
+	wp_unschedule_post_delete($postid);
 
 	/** @todo delete for pluggable post taxonomies too */
 	wp_delete_object_term_relationships($postid, array('category', 'post_tag'));
@@ -1205,6 +1213,69 @@
 }
 
 /**
+ * Removes a post or page from the Trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'undelete_post' before deletion
+ * @uses do_action() on 'undeleted_post' after deletion
+ *
+ * @param int $postid Post ID.
+ * @return mixed False on failure
+ */
+function wp_undelete_post($postid = 0) {
+	global $wpdb, $wp_rewrite;
+
+	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
+		return $post;
+
+	do_action('undelete_post', $postid);
+	
+	wp_update_post(array('ID'=>$postid, 'post_status'=>'draft'));
+	
+	wp_unschedule_post_delete($postid);
+
+	do_action('undeleted_post', $postid);
+
+	return $post;
+}
+
+/**
+ * Schedules a post for permanent deletion.
+ * 
+ * @since 2.9.0
+ * 
+ * @param int $post_id Post ID.
+ * @return void
+ */
+function wp_schedule_post_delete($post_id) {
+	$to_delete = get_option('wp_scheduled_delete');
+	if (!is_array($to_delete))
+		$to_delete = array();
+	
+	$to_delete['posts'][$post_id] = time();
+	
+	update_option('wp_scheduled_delete', $to_delete);
+}
+
+/**
+ * Unschedules a post for permanent deletion.
+ * 
+ * @since 2.9.0
+ * 
+ * @param int $post_id Post ID.
+ * @return void
+ */
+function wp_unschedule_post_delete($post_id) {
+	$to_delete = get_option('wp_scheduled_delete');
+	if (!is_array($to_delete))
+		return;
+	
+	unset($to_delete['posts'][$post_id]);
+	
+	update_option('wp_scheduled_delete', $to_delete);
+}
+
+/**
  * Retrieve the list of categories for a post.
  *
  * Compatibility layer for themes and plugins. Also an easy layer of abstraction
@@ -2586,6 +2657,13 @@
 
 	if ( 'attachment' != $post->post_type )
 		return false;
+	elseif (get_post_status($postid) != 'deleted') {
+		$post = wp_get_single_post($postid, ARRAY_A);
+		$post['post_status'] = 'deleted';
+		wp_insert_post($post);
+		wp_schedule_post_delete($postid);
+		return true;
+	}
 
 	$meta = wp_get_attachment_metadata( $postid );
 	$file = get_attached_file( $postid );
@@ -2632,6 +2710,35 @@
 }
 
 /**
+ * Removes an attachment from the Trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'undelete_attachment' before deletion
+ * @uses do_action() on 'undeleted_attachment' after deletion
+ *
+ * @param int $postid Post ID.
+ * @return mixed False on failure
+ */
+function wp_undelete_attachment($postid = 0) {
+	global $wpdb, $wp_rewrite;
+
+	if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
+		return $post;
+
+	do_action('undelete_attachment', $postid);
+	
+	$post = wp_get_single_post($postid, ARRAY_A);
+	$post['post_status'] = 'inherit';
+	wp_insert_post($post);
+	
+	wp_unschedule_post_delete($postid);
+
+	do_action('undeleted_attachment', $postid);
+
+	return $post;
+}
+
+/**
  * Retrieve attachment meta field for attachment ID.
  *
  * @since 2.1.0
Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php	(revision 11743)
+++ wp-includes/comment.php	(working copy)
@@ -694,11 +694,12 @@
 	if ( false !== $count )
 		return $count;
 
-	$where = '';
+	$where = 'WHERE ';
 	if( $post_id > 0 )
-		$where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id );
+		$where .= $wpdb->prepare( "c.comment_post_ID = %d AND ", $post_id );
+	$where .= "p.post_status <> 'deleted'";
 
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
+	$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 );
 
 	$total = 0;
 	$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted');
@@ -1084,7 +1085,7 @@
 }
 
 /**
- * Schedules a comment for destruction in 30 days.
+ * Schedules a comment for permanent deletion.
  * 
  * @since 2.9.0
  * 
@@ -1102,7 +1103,7 @@
 }
 
 /**
- * Unschedules a comment for destruction.
+ * Unschedules a comment for permanent deletion.
  * 
  * @since 2.9.0
  * 
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 11743)
+++ wp-includes/functions.php	(working copy)
@@ -3339,10 +3339,8 @@
 }
 
 /**
- * Permanently deletes comments that have been scheduled for deleting.
- * Will do the same for posts, pages, etc in the future.
+ * Permanently deletes posts, pages, and comments that have been scheduled for deleting.
  * 
- * @access private
  * @since 2.9.0
  *
  * @return void
@@ -3355,14 +3353,20 @@
 	if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) )
 		$to_delete['comments'] = array();
 
-	$delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30);
-	$deletetimestamp = time() - $delete_delay;
+	$delete_days = defined('EMPTY_TRASH_DAYS') ? (int) EMPTY_TRASH_DAYS : 30;
+	$deletetimestamp = time() - (60*60*24*$delete_days);
 	foreach ($to_delete['comments'] as $comment_id => $timestamp) {
 		if ($timestamp < $deletetimestamp) {
 			wp_delete_comment($comment_id);
 			unset($to_delete['comments'][$comment_id]);
 		}
 	}
+	foreach ($to_delete['posts'] as $post_id => $timestamp) {
+		if ($timestamp < $deletetimestamp) {
+			wp_delete_post($post_id);
+			unset($to_delete['posts'][$post_id]);
+		}
+	}
 
 	update_option('wp_scheduled_delete', $to_delete);
 }
Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 11743)
+++ wp-includes/query.php	(working copy)
@@ -2099,6 +2099,8 @@
 				$p_status[] = "$wpdb->posts.post_status = 'private'";
 			if ( in_array( 'publish', $q_status ) )
 				$r_status[] = "$wpdb->posts.post_status = 'publish'";
+			if ( in_array( 'deleted', $q_status ) )
+				$r_status[] = "$wpdb->posts.post_status = 'deleted'";
 
 			if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) {
 				$r_status = array_merge($r_status, $p_status);
Index: wp-admin/edit-comments.php
===================================================================
--- wp-admin/edit-comments.php	(revision 11743)
+++ wp-admin/edit-comments.php	(working copy)
@@ -292,9 +292,9 @@
 if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) {
 	wp_nonce_field('bulk-destroy', '_destroy_nonce');
     if ( 'spam' == $comment_status ) { ?>
-		<input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
+		<input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
 <?php } elseif ( 'deleted' == $comment_status ) { ?>
-		<input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-primary apply" />
+		<input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
 <?php }
 } ?>
 <?php do_action('manage_comments_nav', $comment_status); ?>
@@ -364,7 +364,7 @@
 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
 
 <?php if ( 'spam' == $comment_status ) { ?>
-<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Quarantine'); ?>" class="button-secondary apply" />
+<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
 <?php } elseif ( 'deleted' == $comment_status ) { ?>
 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
 <?php } ?>
Index: wp-admin/wp-admin.css
===================================================================
--- wp-admin/wp-admin.css	(revision 11743)
+++ wp-admin/wp-admin.css	(working copy)
@@ -409,7 +409,8 @@
 }
 
 #doaction,
-#doaction2 {
+#doaction2,
+#post-query-submit {
 	margin-right: 8px;
 }
 
Index: wp-admin/includes/post.php
===================================================================
--- wp-admin/includes/post.php	(revision 11743)
+++ wp-admin/includes/post.php	(working copy)
@@ -795,6 +795,7 @@
 				'pending' => array(_x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')),
 				'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')),
 				'private' => array(_x('Private', 'post'), __('Private posts'), _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')),
+				'deleted' => array(_x('Trash', 'post'), __('Trash posts'), _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>')),
 			);
 
 	$post_stati = apply_filters('post_stati', $post_stati);
Index: wp-admin/includes/dashboard.php
===================================================================
--- wp-admin/includes/dashboard.php	(revision 11743)
+++ wp-admin/includes/dashboard.php	(working copy)
@@ -480,7 +480,7 @@
 	$comments = array();
 	$start = 0;
 
-	while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments ORDER BY comment_date_gmt DESC LIMIT $start, 50" ) ) {
+	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" ) ) {
 
 		foreach ( $possible as $comment ) {
 			if ( count( $comments ) >= 5 )
Index: wp-admin/includes/template.php
===================================================================
--- wp-admin/includes/template.php	(revision 11743)
+++ wp-admin/includes/template.php	(working copy)
@@ -1433,24 +1433,29 @@
 		case 'title':
 			$attributes = 'class="post-title column-title"' . $style;
 		?>
-		<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>
+		<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>
 		<?php
 			if ( 'excerpt' == $mode )
 				the_excerpt();
 
 			$actions = array();
-			if ( current_user_can('edit_post', $post->ID) ) {
-				$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
-				$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
-			}
-			if ( current_user_can('delete_post', $post->ID) ) {
-				$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>";
-			}
-			if ( in_array($post->post_status, array('pending', 'draft')) ) {
-				if ( current_user_can('edit_post', $post->ID) )
-					$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
+			if ( 'deleted' == $post->post_status ) {
+				$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>";
+				$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>";
 			} else {
-				$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+				if ( current_user_can('edit_post', $post->ID) ) {
+					$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
+					$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
+				}
+				if ( current_user_can('delete_post', $post->ID) ) {
+					$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>";
+				}
+				if ( in_array($post->post_status, array('pending', 'draft')) ) {
+					if ( current_user_can('edit_post', $post->ID) )
+						$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
+				} else {
+					$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+				}
 			}
 			$actions = apply_filters('post_row_actions', $actions, $post);
 			$action_count = count($actions);
@@ -1651,21 +1656,28 @@
 		$attributes = 'class="post-title page-title column-title"' . $style;
 		$edit_link = get_edit_post_link( $page->ID );
 		?>
-		<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>
+		<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>
 		<?php
 		$actions = array();
-		if ( current_user_can('edit_page', $page->ID) ) {
-			$actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
-			$actions['inline'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
-		}
-		if ( current_user_can('delete_page', $page->ID) ) {
-			$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>";
-		}
-		if ( in_array($post->post_status, array('pending', 'draft')) ) {
-			if ( current_user_can('edit_page', $page->ID) )
-				$actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
+		if ($post->post_status == 'deleted') {
+			if ( current_user_can('delete_page', $page->ID) ) {
+				$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>";
+				$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>";
+			}
 		} else {
-			$actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+			if ( current_user_can('edit_page', $page->ID) ) {
+				$actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
+				$actions['inline'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
+			}
+			if ( current_user_can('delete_page', $page->ID) ) {
+				$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>";
+			}
+			if ( in_array($post->post_status, array('pending', 'draft')) ) {
+				if ( current_user_can('edit_page', $page->ID) )
+					$actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
+			} else {
+				$actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+			}
 		}
 		$actions = apply_filters('page_row_actions', $actions, $page);
 		$action_count = count($actions);
@@ -1999,64 +2011,65 @@
 	$index = '';
 
 	if ( 'moderated' == $status ) {
-		$approved = "comment_approved = '0'";
+		$approved = "c.comment_approved = '0'";
 		$total = $count->moderated;
 	} elseif ( 'approved' == $status ) {
-		$approved = "comment_approved = '1'";
+		$approved = "c.comment_approved = '1'";
 		$total = $count->approved;
 	} elseif ( 'spam' == $status ) {
-		$approved = "comment_approved = 'spam'";
+		$approved = "c.comment_approved = 'spam'";
 		$total = $count->spam;
 	} elseif ( 'deleted' == $status ) {
-		$approved = "comment_approved = 'deleted'";
+		$approved = "c.comment_approved = 'deleted'";
 		$total = $count->deleted;
 	} else {
-		$approved = "( comment_approved = '0' OR comment_approved = '1' )";
+		$approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )";
 		$total = $count->moderated + $count->approved;
-		$index = 'USE INDEX (comment_date_gmt)';
+		$index = 'USE INDEX (c.comment_date_gmt)';
 	}
 
 	if ( $post ) {
 		$total = '';
-		$post = " AND comment_post_ID = '$post'";
-		$orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
+		$post = " AND c.comment_post_ID = '$post'";
+		$orderby = "ORDER BY c.comment_date_gmt ASC LIMIT $start, $num";
 	} else {
 		$post = '';
-		$orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
+		$orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num";
 	}
 
 	if ( 'comment' == $type )
-		$typesql = "AND comment_type = ''";
+		$typesql = "AND c.comment_type = ''";
 	elseif ( 'pingback' == $type )
-		$typesql = "AND comment_type = 'pingback'";
+		$typesql = "AND c.comment_type = 'pingback'";
 	elseif ( 'trackback' == $type )
-		$typesql = "AND comment_type = 'trackback'";
+		$typesql = "AND c.comment_type = 'trackback'";
 	elseif ( 'pings' == $type )
-		$typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
+		$typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
 	else
 		$typesql = '';
 
 	if ( !empty($type) )
 		$total = '';
 
+	$query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'deleted' ";
 	if ( $s ) {
 		$total = '';
 		$s = $wpdb->escape($s);
-		$query = "FROM $wpdb->comments WHERE
-			(comment_author LIKE '%$s%' OR
-			comment_author_email LIKE '%$s%' OR
-			comment_author_url LIKE ('%$s%') OR
-			comment_author_IP LIKE ('%$s%') OR
-			comment_content LIKE ('%$s%') ) AND
+		$query .= "AND
+			(c.comment_author LIKE '%$s%' OR
+			c.comment_author_email LIKE '%$s%' OR
+			c.comment_author_url LIKE ('%$s%') OR
+			c.comment_author_IP LIKE ('%$s%') OR
+			c.comment_content LIKE ('%$s%') ) AND
 			$approved
 			$typesql";
 	} else {
-		$query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
+		$query .= "AND $approved $post $typesql";
 	}
-
+	
 	$comments = $wpdb->get_results("SELECT * $query $orderby");
 	if ( '' === $total )
-		$total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
+		$total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
 
 	update_comment_cache($comments);
 
@@ -2157,7 +2170,7 @@
 							$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>';
 						} else {
 							$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>';
-							$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';
+							$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Trash') . '</a>';
 						}
 
 						$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php	(revision 11743)
+++ wp-admin/includes/media.php	(working copy)
@@ -1170,11 +1170,9 @@
 	if ( $send )
 		$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
 	if ( $delete )
-		$delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a>";
+		$delete = "<a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>";
 	if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
-		$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete
-		<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>
-		<a href=\"#\" class=\"del-link\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div></td></tr>\n");
+		$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete</td></tr>\n");
 
 	$hidden_fields = array();
 
Index: wp-admin/post.php
===================================================================
--- wp-admin/post.php	(revision 11743)
+++ wp-admin/post.php	(working copy)
@@ -116,6 +116,7 @@
 	$post = get_post($post_ID);
 
 	if ( empty($post->ID) ) wp_die( __('You attempted to edit a post that doesn&#8217;t exist. Perhaps it was deleted?') );
+	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.') );
 
 	if ( 'post' != $post->post_type ) {
 		wp_redirect( get_edit_post_link( $post->ID, 'url' ) );
@@ -206,6 +207,28 @@
 	exit();
 	break;
 
+case 'undelete':
+	$post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
+	check_admin_referer('undelete-post_' . $post_id);
+
+	$post = & get_post($post_id);
+
+	if ( $post->post_type == 'attachment' ) {
+		if ( ! wp_undelete_attachment($post_id) )
+			wp_die( __('Error in undeleting...') );
+	} else {
+		if ( !wp_undelete_post($post_id) )
+			wp_die( __('Error in undeleting...') );
+	}
+
+	$sendback = wp_get_referer();
+	if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('edit.php?undeleted=1');
+	elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
+	else $sendback = add_query_arg('undeleted', 1, $sendback);
+	wp_redirect($sendback);
+	exit();
+	break;
+
 case 'preview':
 	check_admin_referer( 'autosave', 'autosavenonce' );
 
Index: wp-admin/js/common.dev.js
===================================================================
--- wp-admin/js/common.dev.js	(revision 11743)
+++ wp-admin/js/common.dev.js	(working copy)
@@ -154,16 +154,6 @@
 	$('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2');
 	$('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first');
 
-	// show warnings
-	$('#doaction, #doaction2').click(function(){
-		if ( $('select[name="action"]').val() == 'destroy' || $('select[name="action2"]').val() == 'destroy' ) {
-			return showNotice.warn();
-		}
-	});
-	$('#destroy_all, #destroy_all2').click(function(){
-		return showNotice.warn();
-	});
-
 	// screen settings tab
 	$('#show-settings-link').click(function () {
 		if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) {
Index: wp-admin/js/edit-comments.dev.js
===================================================================
--- wp-admin/js/edit-comments.dev.js	(revision 11743)
+++ wp-admin/js/edit-comments.dev.js	(working copy)
@@ -39,7 +39,7 @@
 		settings.data._url = document.location.href;
 
 		if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted)
-			return showNotice.warn() ? settings : false;
+			return settings;
 
 		return settings;
 	};
Index: wp-admin/edit-page-form.php
===================================================================
--- wp-admin/edit-page-form.php	(revision 11743)
+++ wp-admin/edit-page-form.php	(working copy)
@@ -216,7 +216,7 @@
 <div id="delete-action">
 <?php
 if ( ( 'edit' == $action ) && current_user_can('delete_page', $post->ID) ) { ?>
-<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>
+<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>
 <?php } ?>
 </div>
 
Index: wp-admin/edit-attachment-rows.php
===================================================================
--- wp-admin/edit-attachment-rows.php	(revision 11743)
+++ wp-admin/edit-attachment-rows.php	(working copy)
@@ -29,6 +29,8 @@
 $posts_columns = get_column_headers('upload');
 $hidden = get_hidden_columns('upload');
 while (have_posts()) : the_post();
+if ($is_trash && $post->post_status != 'deleted') continue;
+elseif (!$is_trash && $post->post_status == 'deleted') continue;
 $alt = ( 'alternate' == $alt ) ? '' : 'alternate';
 global $current_user;
 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
@@ -60,13 +62,15 @@
 		?>
 		<td <?php echo $attributes ?>><?php
 			if ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) {
+				if ($is_trash) echo $thumb;
+				else {
 ?>
-
 				<a href="media.php?action=edit&amp;attachment_id=<?php the_ID(); ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $att_title)); ?>">
 					<?php echo $thumb; ?>
 				</a>
 
 <?php			}
+			}
 		?></td>
 		<?php
 		// TODO
@@ -74,16 +78,21 @@
 
 	case 'media':
 		?>
-		<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 />
+		<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 />
 		<?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
 		<p>
 		<?php
 		$actions = array();
-		if ( current_user_can('edit_post', $post->ID) )
-			$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
-		if ( current_user_can('delete_post', $post->ID) )
-			$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>";
-		$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+		if ($is_trash && current_user_can('delete_post', $post->ID)) {
+			$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>";
+			$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
+		} else {
+			if (current_user_can('edit_post', $post->ID))
+				$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
+			if (current_user_can('delete_post', $post->ID))
+				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
+			$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
+		}
 		$action_count = count($actions);
 		$i = 0;
 		echo '<div class="row-actions">';
Index: wp-admin/media.php
===================================================================
--- wp-admin/media.php	(revision 11743)
+++ wp-admin/media.php	(working copy)
@@ -58,6 +58,9 @@
 
 	$att = get_post($att_id);
 
+	if ( empty($att->ID) ) wp_die( __('You attempted to edit an attachment that doesn&#8217;t exist. Perhaps it was deleted?') );
+	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.') );
+	
 	add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
 
 	wp_enqueue_script( 'wp-ajax-response' );
Index: wp-admin/upload.php
===================================================================
--- wp-admin/upload.php	(revision 11743)
+++ wp-admin/upload.php	(working copy)
@@ -67,33 +67,52 @@
 		exit;
 	}
 
-} elseif ( isset($_GET['action']) && isset($_GET['media']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
+} elseif ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
 	check_admin_referer('bulk-media');
-	$doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
+	
+	if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
+		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'deleted'" );
+		$doaction = 'delete';
+	} elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['media'])) {
+		$post_ids = $_GET['media'];
+		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
+	} else wp_redirect($_SERVER['HTTP_REFERER']);
+	
+	$location = 'upload.php';
+	if ( $referer = wp_get_referer() ) {
+		if ( false !== strpos($referer, 'upload.php') )
+			$location = $referer;
+	}
 
-	if ( 'delete' == $doaction ) {
-		foreach( (array) $_GET['media'] as $post_id_del ) {
-			$post_del = & get_post($post_id_del);
+	switch ( $doaction ) {
+		case 'delete':
+			foreach( (array) $post_ids as $post_id_del ) {
+				$post_del = & get_post($post_id_del);
+				
+				if ( !current_user_can('delete_post', $post_id_del) )
+					wp_die( __('You are not allowed to delete this post.') );
+	
+				if ( $post_del->post_type == 'attachment' )
+					if ( !wp_delete_attachment($post_id_del) )
+						wp_die( __('Error in deleting...') );
+			}
+			$location = add_query_arg('message', 2, $location);
+			break;
+		case 'undelete':
+			foreach( (array) $post_ids as $post_id ) {
+				$post_del = & get_post($post_id);
 
-			if ( !current_user_can('delete_post', $post_id_del) )
-				wp_die( __('You are not allowed to delete this post.') );
+				if ( $post_del->post_type == 'attachment' )
+					if ( !wp_undelete_attachment($post_id) )
+						wp_die( __('Error in undeleting...') );
+			}
+			$location = add_query_arg('message', 4, $location);
+			break;
+	}
 
-			if ( $post_del->post_type == 'attachment' )
-				if ( ! wp_delete_attachment($post_id_del) )
-					wp_die( __('Error in deleting...') );
-		}
-
-		$location = 'upload.php';
-		if ( $referer = wp_get_referer() ) {
-			if ( false !== strpos($referer, 'upload.php') )
-				$location = $referer;
-		}
-
-		$location = add_query_arg('message', 2, $location);
-		$location = remove_query_arg('posted', $location);
-		wp_redirect($location);
-		exit;
-	}
+	$location = remove_query_arg('posted', $location);
+	wp_redirect($location);
+	exit;
 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
 	 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
 	 exit;
@@ -135,6 +154,8 @@
 	list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
 }
 
+$is_trash = (isset($_GET['status']) && $_GET['status'] == 'deleted');
+
 wp_enqueue_script('media');
 require_once('admin-header.php'); ?>
 
@@ -153,6 +174,7 @@
 $messages[1] = __('Media attachment updated.');
 $messages[2] = __('Media deleted.');
 $messages[3] = __('Error saving media attachment.');
+$messages[4] = __('Media removed from Trash.');
 
 if ( isset($_GET['message']) && (int) $_GET['message'] ) {
 	$message = $messages[$_GET['message']];
@@ -180,13 +202,13 @@
 <?php
 $type_links = array();
 $_num_posts = (array) wp_count_attachments();
-$_total_posts = array_sum( $_num_posts );
+$_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
 $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
 foreach ( $matches as $type => $reals )
 	foreach ( $reals as $real )
 		$num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
 
-$class = empty($_GET['post_mime_type']) && ! isset($_GET['detached']) ? ' class="current"' : '';
+$class = (empty($_GET['post_mime_type']) && !isset($_GET['detached']) && !isset($_GET['status'])) ? ' class="current"' : '';
 $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>';
 foreach ( $post_mime_types as $mime_type => $label ) {
 	$class = '';
@@ -199,8 +221,8 @@
 
 	$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>';
 }
-$class = isset($_GET['detached']) ? ' class="current"' : '';
-$type_links[] = '<li><a href="upload.php?detached=1"' . $class . '>' . __('Unattached') . '</a>';
+$type_links[] = '<li><a href="upload.php?detached=1"' . (isset($_GET['detached']) ? ' class="current"' : '') . '>' . __('Unattached') . '</a>';
+$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>';
 
 echo implode( " |</li>\n", $type_links) . '</li>';
 unset($type_links);
@@ -242,8 +264,12 @@
 <div class="alignleft actions">
 <select name="action" class="select-action">
 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
-<option value="delete"><?php _e('Delete'); ?></option>
-<?php if ( isset($orphans) ) { ?>
+<?php if ($is_trash) { ?>
+<option value="undelete"><?php _e('Remove from Trash'); ?></option>
+<option value="delete"><?php _e('Delete Permanently'); ?></option>
+<?php } else { ?>
+<option value="delete"><?php _e('Move to Trash'); ?></option>
+<?php } if (isset($orphans)) { ?>
 <option value="attach"><?php _e('Attach to a post'); ?></option>
 <?php } ?>
 </select>
@@ -251,7 +277,7 @@
 <?php wp_nonce_field('bulk-media'); ?>
 
 <?php
-if ( ! is_singular() && ! isset($_GET['detached']) ) {
+if ( !is_singular() && !isset($_GET['detached']) && !$is_trash ) {
 	$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";
 
 	$arc_result = $wpdb->get_results( $arc_query );
@@ -286,6 +312,8 @@
 
 <?php if ( isset($_GET['detached']) ) { ?>
 	<input type="submit" id="find_detached" name="find_detached" value="<?php esc_attr_e('Scan for lost attachments'); ?>" class="button-secondary" />
+<?php } elseif ( isset($_GET['status']) && $_GET['status'] == 'deleted' ) { ?>
+	<input type="submit" id="delete_all" name="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
 <?php } ?>
 
 </div>
@@ -341,7 +369,7 @@
 		if ( current_user_can('edit_post', $post->ID) )
 			$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
 		if ( current_user_can('delete_post', $post->ID) )
-			$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>";
+			$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
 		$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
 		if ( current_user_can('edit_post', $post->ID) )
 			$actions['attach'] = '<a href="#the-list" onclick="findPosts.open(\'media[]\',\''.$post->ID.'\');return false;">'.__('Attach').'</a>';
@@ -398,12 +426,20 @@
 <div class="alignleft actions">
 <select name="action2" class="select-action">
 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
-<option value="delete"><?php _e('Delete'); ?></option>
-<?php if ( isset($orphans) ) { ?>
+<?php if ($is_trash) { ?>
+<option value="undelete"><?php _e('Remove from Trash'); ?></option>
+<option value="delete"><?php _e('Delete Permanently'); ?></option>
+<?php } else { ?>
+<option value="delete"><?php _e('Move to Trash'); ?></option>
+<?php } if (isset($orphans)) { ?>
 <option value="attach"><?php _e('Attach to a post'); ?></option>
 <?php } ?>
 </select>
 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+
+<?php if ( isset($_GET['status']) && $_GET['status'] == 'deleted' ) { ?>
+	<input type="submit" id="delete_all2" name="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
+<?php } ?>
 </div>
 
 <br class="clear" />
Index: wp-admin/edit-form-comment.php
===================================================================
--- wp-admin/edit-form-comment.php	(revision 11743)
+++ wp-admin/edit-form-comment.php	(working copy)
@@ -64,7 +64,7 @@
 
 <div id="major-publishing-actions">
 <div id="delete-action">
-<?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"; ?>
+<?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"; ?>
 </div>
 <div id="publishing-action">
 <input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php	(revision 11743)
+++ wp-admin/edit-form-advanced.php	(working copy)
@@ -229,7 +229,7 @@
 <div id="delete-action">
 <?php
 if ( ( 'edit' == $action ) && current_user_can('delete_post', $post->ID) ) { ?>
-<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>
+<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>
 <?php } ?>
 </div>
 
Index: wp-admin/edit.php
===================================================================
--- wp-admin/edit.php	(revision 11743)
+++ wp-admin/edit.php	(working copy)
@@ -18,45 +18,58 @@
 }
 
 // Handle bulk actions
-if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
-	$doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
-
+if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
+	check_admin_referer('bulk-posts');
+	
+	if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
+		$post_status = $wpdb->escape($_GET['post_status']);
+		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = '$post_status'" );
+		$doaction = 'delete';
+	} elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
+		$post_ids = $_GET['post'];
+		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
+	} else wp_redirect($_SERVER['HTTP_REFERER']);
+	
 	switch ( $doaction ) {
 		case 'delete':
-			if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
-				check_admin_referer('bulk-posts');
-				$deleted = 0;
-				foreach( (array) $_GET['post'] as $post_id_del ) {
-					$post_del = & get_post($post_id_del);
+			$deleted = 0;
+			foreach( (array) $post_ids as $post_id_del ) {
+				$post_del = & get_post($post_id_del);
 
-					if ( !current_user_can('delete_post', $post_id_del) )
-						wp_die( __('You are not allowed to delete this post.') );
+				if ( !current_user_can('delete_post', $post_id_del) )
+					wp_die( __('You are not allowed to delete this post.') );
 
-					if ( $post_del->post_type == 'attachment' ) {
-						if ( ! wp_delete_attachment($post_id_del) )
-							wp_die( __('Error in deleting...') );
-					} else {
-						if ( !wp_delete_post($post_id_del) )
-							wp_die( __('Error in deleting...') );
-					}
-					$deleted++;
+				if ( $post_del->post_type == 'attachment' ) {
+					if ( ! wp_delete_attachment($post_id_del) )
+						wp_die( __('Error in deleting...') );
+				} else {
+					if ( !wp_delete_post($post_id_del) )
+						wp_die( __('Error in deleting...') );
 				}
+				$deleted++;
 			}
 			break;
-		case 'edit':
-			if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
-				check_admin_referer('bulk-posts');
+		case 'undelete':
+			$undeleted = 0;
+			foreach( (array) $post_ids as $post_id ) {
+				$post_del = & get_post($post_id);
 
-				if ( -1 == $_GET['_status'] ) {
-					$_GET['post_status'] = null;
-					unset($_GET['_status'], $_GET['post_status']);
-				} else {
-					$_GET['post_status'] = $_GET['_status'];
-				}
-
-				$done = bulk_edit_posts($_GET);
+				if ( !wp_undelete_post($post_id) )
+					wp_die( __('Error in undeleting...') );
+				
+				$undeleted++;
 			}
 			break;
+		case 'edit':
+			if ( -1 == $_GET['_status'] ) {
+				$_GET['post_status'] = null;
+				unset($_GET['_status'], $_GET['post_status']);
+			} else {
+				$_GET['post_status'] = $_GET['_status'];
+			}
+
+			$done = bulk_edit_posts($_GET);
+			break;
 	}
 
 	$sendback = wp_get_referer();
@@ -70,6 +83,8 @@
 	}
 	if ( isset($deleted) )
 		$sendback = add_query_arg('deleted', $deleted, $sendback);
+	elseif ( isset($undeleted) )
+		$sendback = add_query_arg('undeleted', $undeleted, $sendback);
 	wp_redirect($sendback);
 	exit();
 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
@@ -127,6 +142,11 @@
 	unset($_GET['deleted']);
 }
 
+if ( isset($_GET['undeleted']) && (int) $_GET['undeleted'] ) {
+	printf( _n( 'Post returned to Pending.', '%s posts returned to Pending.', $_GET['undeleted'] ), number_format_i18n( $_GET['undeleted'] ) );
+	unset($_GET['undeleted']);
+}
+
 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] );
 ?>
 </p></div>
@@ -139,7 +159,7 @@
 if ( empty($locked_post_status) ) :
 $status_links = array();
 $num_posts = wp_count_posts( 'post', 'readable' );
-$total_posts = array_sum( (array) $num_posts );
+$total_posts = array_sum( (array) $num_posts ) - $num_posts->deleted;
 $class = empty( $_GET['post_status'] ) ? ' class="current"' : '';
 $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>';
 
@@ -190,8 +210,13 @@
 <div class="alignleft actions">
 <select name="action">
 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<?php if ($_GET['post_status'] == 'deleted') { ?>
+<option value="undelete"><?php _e('Return to Pending'); ?></option>
+<option value="delete"><?php _e('Delete Permanently'); ?></option>
+<?php } else { ?>
 <option value="edit"><?php _e('Edit'); ?></option>
-<option value="delete"><?php _e('Delete'); ?></option>
+<option value="delete"><?php _e('Move to Trash'); ?></option>
+<?php } ?>
 </select>
 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
 <?php wp_nonce_field('bulk-posts'); ?>
@@ -235,7 +260,8 @@
 do_action('restrict_manage_posts');
 ?>
 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
-
+<?php } if ($_GET['post_status'] == 'deleted') { ?>
+<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
 <?php } ?>
 </div>
 
@@ -270,10 +296,18 @@
 <div class="alignleft actions">
 <select name="action2">
 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<?php if ($_GET['post_status'] == 'deleted') { ?>
+<option value="undelete"><?php _e('Return to Pending'); ?></option>
+<option value="delete"><?php _e('Delete Permanently'); ?></option>
+<?php } else { ?>
 <option value="edit"><?php _e('Edit'); ?></option>
-<option value="delete"><?php _e('Delete'); ?></option>
+<option value="delete"><?php _e('Move to Trash'); ?></option>
+<?php } ?>
 </select>
 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+<?php if ($_GET['post_status'] == 'deleted') { ?>
+<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
+<?php } ?>
 <br class="clear" />
 </div>
 <br class="clear" />
Index: wp-admin/page.php
===================================================================
--- wp-admin/page.php	(revision 11743)
+++ wp-admin/page.php	(working copy)
@@ -83,6 +83,7 @@
 	$post = get_post_to_edit($page_ID);
 
 	if ( empty($post->ID) ) wp_die( __('You attempted to edit a page that doesn&#8217;t exist. Perhaps it was deleted?') );
+	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.') );
 
 	if ( 'page' != $post->post_type ) {
 		wp_redirect( get_edit_post_link( $post_ID, 'url' ) );
@@ -165,6 +166,28 @@
 	exit();
 	break;
 
+case 'undelete':
+	$post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
+	check_admin_referer('undelete-page_' . $post_id);
+
+	$post = & get_post($post_id);
+
+	if ( $post->post_type == 'attachment' ) {
+		if ( ! wp_undelete_attachment($post_id) )
+			wp_die( __('Error in undeleting...') );
+	} else {
+		if ( !wp_undelete_post($post_id) )
+			wp_die( __('Error in undeleting...') );
+	}
+
+	$sendback = wp_get_referer();
+	if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('edit.php?undeleted=1');
+	elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
+	else $sendback = add_query_arg('undeleted', 1, $sendback);
+	wp_redirect($sendback);
+	exit();
+	break;
+
 case 'preview':
 	check_admin_referer( 'autosave', 'autosavenonce' );
 
Index: wp-admin/edit-pages.php
===================================================================
--- wp-admin/edit-pages.php	(revision 11743)
+++ wp-admin/edit-pages.php	(working copy)
@@ -10,45 +10,58 @@
 require_once('admin.php');
 
 // Handle bulk actions
-if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) {
-	$doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2'];
+if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {
+	check_admin_referer('bulk-pages');
+	
+	if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) {
+		$post_status = $wpdb->escape($_GET['post_status']);
+		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = '$post_status'" );
+		$doaction = 'delete';
+	} elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {
+		$post_ids = $_GET['post'];
+		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
+	} else wp_redirect($_SERVER['HTTP_REFERER']);
 
 	switch ( $doaction ) {
 		case 'delete':
-			if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) {
-				check_admin_referer('bulk-pages');
-				$deleted = 0;
-				foreach( (array) $_GET['post'] as $post_id_del ) {
-					$post_del = & get_post($post_id_del);
+			$deleted = 0;
+			foreach( (array) $post_ids as $post_id_del ) {
+				$post_del = & get_post($post_id_del);
 
-					if ( !current_user_can('delete_page', $post_id_del) )
-						wp_die( __('You are not allowed to delete this page.') );
+				if ( !current_user_can('delete_page', $post_id_del) )
+					wp_die( __('You are not allowed to delete this page.') );
 
-					if ( $post_del->post_type == 'attachment' ) {
-						if ( ! wp_delete_attachment($post_id_del) )
-							wp_die( __('Error in deleting...') );
-					} else {
-						if ( !wp_delete_post($post_id_del) )
-							wp_die( __('Error in deleting...') );
-					}
-					$deleted++;
+				if ( $post_del->post_type == 'attachment' ) {
+					if ( ! wp_delete_attachment($post_id_del) )
+						wp_die( __('Error in deleting...') );
+				} else {
+					if ( !wp_delete_post($post_id_del) )
+						wp_die( __('Error in deleting...') );
 				}
+				$deleted++;
 			}
 			break;
-		case 'edit':
-			if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) {
-				check_admin_referer('bulk-pages');
+		case 'undelete':
+			$undeleted = 0;
+			foreach( (array) $post_ids as $post_id ) {
+				$post_del = & get_post($post_id);
 
-				if ( -1 == $_GET['_status'] ) {
-					$_GET['post_status'] = null;
-					unset($_GET['_status'], $_GET['post_status']);
-				} else {
-					$_GET['post_status'] = $_GET['_status'];
-				}
-
-				$done = bulk_edit_posts($_GET);
+				if ( !wp_undelete_post($post_id) )
+					wp_die( __('Error in undeleting...') );
+				
+				$undeleted++;
 			}
 			break;
+		case 'edit':
+			if ( -1 == $_GET['_status'] ) {
+				$_GET['post_status'] = null;
+				unset($_GET['_status'], $_GET['post_status']);
+			} else {
+				$_GET['post_status'] = $_GET['_status'];
+			}
+
+			$done = bulk_edit_posts($_GET);
+			break;
 	}
 
 	$sendback = wp_get_referer();
@@ -62,6 +75,8 @@
 	}
 	if ( isset($deleted) )
 		$sendback = add_query_arg('deleted', $deleted, $sendback);
+	elseif ( isset($undeleted) )
+		$sendback = add_query_arg('undeleted', $undeleted, $sendback);
 	wp_redirect($sendback);
 	exit();
 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
@@ -79,7 +94,8 @@
 		'future' => array(_x('Scheduled', 'page'), __('Scheduled pages'), _nx_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>', 'page')),
 		'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')),
 		'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')),
-		'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page'))
+		'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')),
+		'deleted' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page'))
 	);
 
 $post_stati = apply_filters('page_stati', $post_stati);
@@ -150,7 +166,7 @@
 if ( empty($locked_post_status) ) :
 $status_links = array();
 $num_posts = wp_count_posts('page', 'readable');
-$total_posts = array_sum( (array) $num_posts );
+$total_posts = array_sum( (array) $num_posts ) - $num_posts->deleted;
 $class = empty($_GET['post_status']) ? ' class="current"' : '';
 $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>';
 foreach ( $post_stati as $status => $label ) {
@@ -212,11 +228,19 @@
 <div class="alignleft actions">
 <select name="action">
 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<?php if ($_GET['post_status'] == 'deleted') { ?>
+<option value="undelete"><?php _e('Return to Pending'); ?></option>
+<option value="delete"><?php _e('Delete Permanently'); ?></option>
+<?php } else { ?>
 <option value="edit"><?php _e('Edit'); ?></option>
-<option value="delete"><?php _e('Delete'); ?></option>
+<option value="delete"><?php _e('Move to Trash'); ?></option>
+<?php } ?>
 </select>
 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
 <?php wp_nonce_field('bulk-pages'); ?>
+<?php if ($_GET['post_status'] == 'deleted') { ?>
+<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
+<?php } ?>
 </div>
 
 <br class="clear" />
@@ -251,10 +275,18 @@
 <div class="alignleft actions">
 <select name="action2">
 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
+<?php if ($_GET['post_status'] == 'deleted') { ?>
+<option value="undelete"><?php _e('Return to Pending'); ?></option>
+<option value="delete"><?php _e('Delete Permanently'); ?></option>
+<?php } else { ?>
 <option value="edit"><?php _e('Edit'); ?></option>
-<option value="delete"><?php _e('Delete'); ?></option>
+<option value="delete"><?php _e('Move to Trash'); ?></option>
+<?php } ?>
 </select>
 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
+<?php if ($_GET['post_status'] == 'deleted') { ?>
+<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
+<?php } ?>
 </div>
 
 <br class="clear" />
