wp/wp-admin/edit.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-admin/edit.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/edit.php	Wed Sep 21 18:19:35 2022 +0200
@@ -80,6 +80,8 @@
 		$sendback = admin_url( $post_new_file );
 	}
 
+	$post_ids = array();
+
 	if ( 'delete_all' === $doaction ) {
 		// Prepare for deletion of all posts with a specified post status (i.e. Empty Trash).
 		$post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] );
@@ -96,7 +98,7 @@
 		$post_ids = array_map( 'intval', $_REQUEST['post'] );
 	}
 
-	if ( ! isset( $post_ids ) ) {
+	if ( empty( $post_ids ) ) {
 		wp_redirect( $sendback );
 		exit;
 	}
@@ -126,7 +128,7 @@
 			$sendback = add_query_arg(
 				array(
 					'trashed' => $trashed,
-					'ids'     => join( ',', $post_ids ),
+					'ids'     => implode( ',', $post_ids ),
 					'locked'  => $locked,
 				),
 				$sendback
@@ -134,6 +136,11 @@
 			break;
 		case 'untrash':
 			$untrashed = 0;
+
+			if ( isset( $_GET['doaction'] ) && ( 'undo' === $_GET['doaction'] ) ) {
+				add_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 );
+			}
+
 			foreach ( (array) $post_ids as $post_id ) {
 				if ( ! current_user_can( 'delete_post', $post_id ) ) {
 					wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
@@ -146,6 +153,9 @@
 				$untrashed++;
 			}
 			$sendback = add_query_arg( 'untrashed', $untrashed, $sendback );
+
+			remove_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 );
+
 			break;
 		case 'delete':
 			$deleted = 0;
@@ -398,8 +408,13 @@
 }
 
 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
-	/* translators: %s: Search query. */
-	printf( ' <span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', get_search_query() );
+	echo '<span class="subtitle">';
+	printf(
+		/* translators: %s: Search query. */
+		__( 'Search results for: %s' ),
+		'<strong>' . get_search_query() . '</strong>'
+	);
+	echo '</span>';
 }
 ?>
 
@@ -419,10 +434,22 @@
 		$ids        = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] );
 		$messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", 'bulk-posts' ) ) . '">' . __( 'Undo' ) . '</a>';
 	}
+
+	if ( 'untrashed' === $message && isset( $_REQUEST['ids'] ) ) {
+		$ids = explode( ',', $_REQUEST['ids'] );
+
+		if ( 1 === count( $ids ) && current_user_can( 'edit_post', $ids[0] ) ) {
+			$messages[] = sprintf(
+				'<a href="%1$s">%2$s</a>',
+				esc_url( get_edit_post_link( $ids[0] ) ),
+				esc_html( get_post_type_object( get_post_type( $ids[0] ) )->labels->edit_item )
+			);
+		}
+	}
 }
 
 if ( $messages ) {
-	echo '<div id="message" class="updated notice is-dismissible"><p>' . join( ' ', $messages ) . '</p></div>';
+	echo '<div id="message" class="updated notice is-dismissible"><p>' . implode( ' ', $messages ) . '</p></div>';
 }
 unset( $messages );
 
@@ -457,7 +484,7 @@
 ?>
 
 <div id="ajax-response"></div>
-<br class="clear" />
+<div class="clear"></div>
 </div>
 
 <?php