From 87a8377de20e757ef6fedeac311cc2b2a1eb097d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 3 Jan 2024 16:22:20 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@57238 git-svn-id: http://core.svn.wordpress.org/trunk@56744 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 13 +++++++------ wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index 24f82510bd..d12eea0e5f 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -3079,25 +3079,26 @@ final class WP_Customize_Manager { return false; } + $previous_status = $post->post_status; + /** This filter is documented in wp-includes/post.php */ - $check = apply_filters( 'pre_trash_post', null, $post ); + $check = apply_filters( 'pre_trash_post', null, $post, $previous_status ); if ( null !== $check ) { return $check; } /** This action is documented in wp-includes/post.php */ - do_action( 'wp_trash_post', $post_id ); + do_action( 'wp_trash_post', $post_id, $previous_status ); - add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status ); + add_post_meta( $post_id, '_wp_trash_meta_status', $previous_status ); add_post_meta( $post_id, '_wp_trash_meta_time', time() ); - $old_status = $post->post_status; $new_status = 'trash'; $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) ); clean_post_cache( $post->ID ); $post->post_status = $new_status; - wp_transition_post_status( $new_status, $old_status, $post ); + wp_transition_post_status( $new_status, $previous_status, $post ); /** This action is documented in wp-includes/post.php */ do_action( "edit_post_{$post->post_type}", $post->ID, $post ); @@ -3119,7 +3120,7 @@ final class WP_Customize_Manager { wp_trash_post_comments( $post_id ); /** This action is documented in wp-includes/post.php */ - do_action( 'trashed_post', $post_id ); + do_action( 'trashed_post', $post_id, $previous_status ); return $post; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 9b5db7d27f..ec1c105666 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57237'; +$wp_version = '6.5-alpha-57238'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.