Make WordPress Core


Ignore:
Timestamp:
10/11/2017 05:41:14 AM (7 years ago)
Author:
westonruter
Message:

Customize: Introduce WP_Customize_Manager::trash_changeset_post() to reduce duplication and ensure proper changeset trashing logic.

Trashing a changeset via wp_trash_post() does not have the desired result since it mutates post_content (via Kses) and the post_name (even though it is a UUID).

Props dlh.
See #39896, #42030.
Fixes #42175.

File:
1 edited

Legend:

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

    r41732 r41824  
    29102910     */
    29112911    if ( ! wp_revisions_enabled( $changeset_post ) ) {
    2912         $post = $changeset_post;
    2913         $post_id = $changeset_post->ID;
    2914 
    2915         /*
    2916          * The following re-formulates the logic from wp_trash_post() as done in
    2917          * wp_publish_post(). The reason for bypassing wp_trash_post() is that it
    2918          * will mutate the post_content and the post_name when they should be
    2919          * untouched.
    2920          */
    2921         if ( ! EMPTY_TRASH_DAYS ) {
    2922             wp_delete_post( $post_id, true );
    2923         } else {
    2924             /** This action is documented in wp-includes/post.php */
    2925             do_action( 'wp_trash_post', $post_id );
    2926 
    2927             add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status );
    2928             add_post_meta( $post_id, '_wp_trash_meta_time', time() );
    2929 
    2930             $old_status = $post->post_status;
    2931             $new_status = 'trash';
    2932             $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) );
    2933             clean_post_cache( $post->ID );
    2934 
    2935             $post->post_status = $new_status;
    2936             wp_transition_post_status( $new_status, $old_status, $post );
    2937 
    2938             /** This action is documented in wp-includes/post.php */
    2939             do_action( 'edit_post', $post->ID, $post );
    2940 
    2941             /** This action is documented in wp-includes/post.php */
    2942             do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
    2943 
    2944             /** This action is documented in wp-includes/post.php */
    2945             do_action( 'save_post', $post->ID, $post, true );
    2946 
    2947             /** This action is documented in wp-includes/post.php */
    2948             do_action( 'wp_insert_post', $post->ID, $post, true );
    2949 
    2950             /** This action is documented in wp-includes/post.php */
    2951             do_action( 'trashed_post', $post_id );
    2952         }
     2912        $wp_customize->trash_changeset_post( $changeset_post->ID );
    29532913    }
    29542914}
Note: See TracChangeset for help on using the changeset viewer.