mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Posts, Post Types: Switch to restoring posts to draft status by default when they are untrashed.
This allows for edits to be made to a restored post before it goes live again. This also prevents scheduled posts being published unexpectedly if they are untrashed after their originally scheduled date. The old behaviour of restoring untrashed posts to their original status can be reinstated using the `wp_untrash_post_set_previous_status()` helper function. Also fixes an issue where the incorrect post ID gets passed to hooks if no post ID is passed to the function. Props harrym, bananastalktome, jaredcobb, chriscct7, melchoyce, johnbillion, pankajmohale Fixes #23022 git-svn-id: https://develop.svn.wordpress.org/trunk@49125 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -134,6 +134,11 @@ if ( $doaction ) {
|
||||
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 +151,9 @@ if ( $doaction ) {
|
||||
$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;
|
||||
@@ -419,6 +427,18 @@ foreach ( $bulk_counts as $message => $count ) {
|
||||
$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 ) {
|
||||
|
||||
Reference in New Issue
Block a user