Index: wp-admin/post.php
===================================================================
--- wp-admin/post.php	(revision 12114)
+++ wp-admin/post.php	(working copy)
@@ -196,11 +196,11 @@
 	if ( ! wp_trash_post($post_id) )
 		wp_die( __('Error in moving to trash...') );
 
-	$sendback = wp_get_referer();
+	$sendback = remove_query_arg(array('trashed','untrashed','deleted','ids'), wp_get_referer());
 	if ( strpos($sendback, 'post.php') !== false || strpos($sendback, 'post-new.php') !== false )
-		$sendback = admin_url('edit.php?trashed=1');
+		$sendback = admin_url('edit.php?trashed=1&ids='.$post_id);
 	else
-		$sendback = add_query_arg('trashed', 1, $sendback);
+		$sendback = add_query_arg(array('trashed' => 1, ids => $post_id), $sendback);
 
 	wp_redirect($sendback);
 	exit();
Index: wp-admin/upload.php
===================================================================
--- wp-admin/upload.php	(revision 12114)
+++ wp-admin/upload.php	(working copy)
@@ -73,8 +73,8 @@
 	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 = 'trash'" );
 		$doaction = 'delete';
-	} elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['media']) ) {
-		$post_ids = $_GET['media'];
+	} elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && (isset($_GET['media']) || isset($_GET['ids'])) ) {
+		$post_ids = isset($_GET['media']) ? $_GET['media'] : explode(',', $_GET['ids']);
 		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
 	} else
 		wp_redirect($_SERVER['HTTP_REFERER']);
@@ -82,7 +82,7 @@
 	$location = 'upload.php';
 	if ( $referer = wp_get_referer() ) {
 		if ( false !== strpos($referer, 'upload.php') )
-			$location = $referer;
+			$location = remove_query_arg(array('trashed','untrashed','deleted','message','ids'), $referer);
 	}
 
 	switch ( $doaction ) {
@@ -94,7 +94,7 @@
 				if ( !wp_trash_post($post_id) )
 					wp_die( __('Error in moving to trash...') );
 			}
-			$location = add_query_arg('message', 4, $location);
+			$location = add_query_arg(array('message' => 4, 'ids' => join(',', $post_ids)), $location);
 			break;
 		case 'untrash':
 			foreach( (array) $post_ids as $post_id ) {
@@ -202,7 +202,7 @@
 $messages[1] = __('Media attachment updated.');
 $messages[2] = __('Media permanently deleted.');
 $messages[3] = __('Error saving media attachment.');
-$messages[4] = __('Media moved to the trash.') . ' <a href="' . admin_url('upload.php?status=trash') . '">' . __('View trash') . '</a> ';
+$messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.$_GET['ids'], "bulk-media" ) ) . '">' . __('Undo?') . '</a>';
 $messages[5] = __('Media restored from the trash.');
 
 if ( isset($_GET['message']) && (int) $_GET['message'] ) {
Index: wp-admin/edit.php
===================================================================
--- wp-admin/edit.php	(revision 12114)
+++ wp-admin/edit.php	(working copy)
@@ -23,7 +23,7 @@
 // Handle bulk actions
 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
 	check_admin_referer('bulk-posts');
-	$sendback = wp_get_referer();
+	$sendback = remove_query_arg(array('trashed','untrashed','deleted','ids'), wp_get_referer());
 
 	if ( strpos($sendback, 'post.php') !== false )
 		$sendback = admin_url('post-new.php');
@@ -32,8 +32,8 @@
 		$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
 		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = %s", $post_status ) );
 		$doaction = 'delete';
-	} elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post']) ) {
-		$post_ids = array_map( 'intval', (array) $_GET['post'] );
+	} elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && (isset($_GET['post']) || isset($_GET['ids'])) ) {
+		$post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
 		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
 	} else {
 		wp_redirect( admin_url('edit.php') );
@@ -51,7 +51,7 @@
 
 				$trashed++;
 			}
-			$sendback = add_query_arg('trashed', $trashed, $sendback);
+			$sendback = add_query_arg(array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback);
 			break;
 		case 'untrash':
 			$untrashed = 0;
@@ -167,7 +167,8 @@
 
 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
 	printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
-	echo ' <a href="' . admin_url('edit.php?post_status=trash') . '">' . __('View trash') . '</a> ';
+	$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
+	echo ' <a href="' . esc_url( wp_nonce_url( "edit.php?doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo?') . '</a><br />';
 	unset($_GET['trashed']);
 }
 
Index: wp-admin/page.php
===================================================================
--- wp-admin/page.php	(revision 12114)
+++ wp-admin/page.php	(working copy)
@@ -156,11 +156,11 @@
 	if ( !wp_trash_post($post_id) )
 		wp_die( __('Error in moving to trash...') );
 
-	$sendback = wp_get_referer();
+	$sendback = remove_query_arg(array('trashed','untrashed','deleted','ids'), wp_get_referer());
 	if ( strpos($sendback, 'page.php') !== false || strpos($sendback, 'page-new.php') !== false )
-		$sendback = admin_url('edit-pages.php?trashed=1');
+		$sendback = admin_url('edit-pages.php?trashed=1&ids='.$post_id);
 	else
-		$sendback = add_query_arg('trashed', 1, $sendback);
+		$sendback = add_query_arg(array('trashed' => 1, ids => $post_id), $sendback);
 
 	wp_redirect($sendback);
 	exit();
Index: wp-admin/edit-pages.php
===================================================================
--- wp-admin/edit-pages.php	(revision 12114)
+++ wp-admin/edit-pages.php	(working copy)
@@ -15,7 +15,7 @@
 // Handle bulk actions
 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) {
 	check_admin_referer('bulk-pages');
-	$sendback = wp_get_referer();
+	$sendback = remove_query_arg(array('trashed','untrashed','deleted','ids'), wp_get_referer());
 
 	if ( strpos($sendback, 'page.php') !== false )
 		$sendback = admin_url('page-new.php');
@@ -24,8 +24,8 @@
 		$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']);
 		$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = %s", $post_status ) );
 		$doaction = 'delete';
-	} elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post']) ) {
-		$post_ids = array_map( 'intval', (array) $_GET['post'] );
+	} elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && (isset($_GET['post']) || isset($_GET['ids'])) ) {
+		$post_ids = isset($_GET['post']) ? array_map( 'intval', (array) $_GET['post'] ) : explode(',', $_GET['ids']);
 		$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
 	} else {
 		wp_redirect( admin_url('edit-pages.php') );
@@ -43,7 +43,7 @@
 
 				$trashed++;
 			}
-			$sendback = add_query_arg('trashed', $trashed, $sendback);
+			$sendback = add_query_arg(array('trashed' => $trashed, 'ids' => join(',', $post_ids)), $sendback);
 			break;
 		case 'untrash':
 			$untrashed = 0;
@@ -163,7 +163,8 @@
 }
 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) {
 	printf( _n( 'Page moved to the trash.', '%s pages moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) );
-	echo ' <a href="' . admin_url('edit-pages.php?post_status=trash') . '">' . __('View trash') . '</a> ';
+	$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
+	echo ' <a href="' . esc_url( wp_nonce_url( "edit-pages.php?doaction=undo&action=untrash&ids=$ids", "bulk-pages" ) ) . '">' . __('Undo?') . '</a><br />';
 	unset($_GET['trashed']);
 }
 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) {
