Skip to content

Commit

Permalink
Posts/Post Types: Display the correct message when post status is fil…
Browse files Browse the repository at this point in the history
…tered on save.

This prevents the display of an inaccurate message when the `wp_insert_post_data` filter is used to change the status of a post while saving. This bug was only present when using the Classic Editor.

The previous code incorrectly assumed that a filter would never change a post’s status to `draft`, resulting in a “Post published.” message instead of “Post draft updated.”.

Props freibergergarcia, sirzooro, hakre, blepoxp, scribu, kawauso.
Fixes #11207.

git-svn-id: https://develop.svn.wordpress.org/trunk@58406 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
desrosj committed Jun 13, 2024
1 parent dbb3261 commit 986e464
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/wp-admin/includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -2181,19 +2181,19 @@ function redirect_post( $post_id = '' ) {
if ( isset( $_POST['save'] ) || isset( $_POST['publish'] ) ) {
$status = get_post_status( $post_id );

if ( isset( $_POST['publish'] ) ) {
switch ( $status ) {
case 'pending':
$message = 8;
break;
case 'future':
$message = 9;
break;
default:
$message = 6;
}
} else {
$message = 'draft' === $status ? 10 : 1;
switch ( $status ) {
case 'pending':
$message = 8;
break;
case 'future':
$message = 9;
break;
case 'draft':
$message = 10;
break;
default:
$message = isset( $_POST['publish'] ) ? 6 : 1;
break;
}

$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
Expand Down

0 comments on commit 986e464

Please sign in to comment.