diff -r 34716fd837a4 -r be944660c56a wp/wp-admin/edit.php --- 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( ' ' . __( 'Search results for “%s”' ) . '', get_search_query() ); + echo ''; + printf( + /* translators: %s: Search query. */ + __( 'Search results for: %s' ), + '' . get_search_query() . '' + ); + echo ''; } ?> @@ -419,10 +434,22 @@ $ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] ); $messages[] = '' . __( 'Undo' ) . ''; } + + if ( 'untrashed' === $message && isset( $_REQUEST['ids'] ) ) { + $ids = explode( ',', $_REQUEST['ids'] ); + + if ( 1 === count( $ids ) && current_user_can( 'edit_post', $ids[0] ) ) { + $messages[] = sprintf( + '%2$s', + 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 '
' . join( ' ', $messages ) . '
' . implode( ' ', $messages ) . '