Make WordPress Core

Changeset 57238


Ignore:
Timestamp:
01/03/2024 04:20:02 PM (11 months ago)
Author:
SergeyBiryukov
Message:

Customize: Pass the previous status to post trash hooks when trashing a changeset.

This ensures that the correct number of arguments is passed to post trash hooks in WP_Customize_Manager::trash_changeset_post(), which bypasses wp_trash_post().

Follow-up to [56043].

Props joelcj91, mukesh27.
Fixes #60183.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r56749 r57238  
    30803080        }
    30813081
     3082        $previous_status = $post->post_status;
     3083
    30823084        /** This filter is documented in wp-includes/post.php */
    3083         $check = apply_filters( 'pre_trash_post', null, $post );
     3085        $check = apply_filters( 'pre_trash_post', null, $post, $previous_status );
    30843086        if ( null !== $check ) {
    30853087            return $check;
     
    30873089
    30883090        /** This action is documented in wp-includes/post.php */
    3089         do_action( 'wp_trash_post', $post_id );
    3090 
    3091         add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status );
     3091        do_action( 'wp_trash_post', $post_id, $previous_status );
     3092
     3093        add_post_meta( $post_id, '_wp_trash_meta_status', $previous_status );
    30923094        add_post_meta( $post_id, '_wp_trash_meta_time', time() );
    30933095
    3094         $old_status = $post->post_status;
    30953096        $new_status = 'trash';
    30963097        $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) );
     
    30983099
    30993100        $post->post_status = $new_status;
    3100         wp_transition_post_status( $new_status, $old_status, $post );
     3101        wp_transition_post_status( $new_status, $previous_status, $post );
    31013102
    31023103        /** This action is documented in wp-includes/post.php */
     
    31203121
    31213122        /** This action is documented in wp-includes/post.php */
    3122         do_action( 'trashed_post', $post_id );
     3123        do_action( 'trashed_post', $post_id, $previous_status );
    31233124
    31243125        return $post;
Note: See TracChangeset for help on using the changeset viewer.