Make WordPress Core

Changeset 58406


Ignore:
Timestamp:
06/13/2024 02:44:45 PM (5 weeks ago)
Author:
desrosj
Message:

Posts/Post Types: Display the correct message when post status is filtered 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r58360 r58406  
    21822182        $status = get_post_status( $post_id );
    21832183
    2184         if ( isset( $_POST['publish'] ) ) {
    2185             switch ( $status ) {
    2186                 case 'pending':
    2187                     $message = 8;
    2188                     break;
    2189                 case 'future':
    2190                     $message = 9;
    2191                     break;
    2192                 default:
    2193                     $message = 6;
    2194             }
    2195         } else {
    2196             $message = 'draft' === $status ? 10 : 1;
     2184        switch ( $status ) {
     2185            case 'pending':
     2186                $message = 8;
     2187                break;
     2188            case 'future':
     2189                $message = 9;
     2190                break;
     2191            case 'draft':
     2192                $message = 10;
     2193                break;
     2194            default:
     2195                $message = isset( $_POST['publish'] ) ? 6 : 1;
     2196                break;
    21972197        }
    21982198
Note: See TracChangeset for help on using the changeset viewer.