Make WordPress Core


Ignore:
Timestamp:
11/09/2016 05:44:14 AM (8 years ago)
Author:
westonruter
Message:

Customize: Prevent post_content and post_name from being modified when trashing customize_changeset posts.

See #30937.
Fixes #38719.

File:
1 edited

Legend:

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

    r39165 r39180  
    25502550 */
    25512551function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_post ) {
    2552     global $wp_customize;
     2552    global $wp_customize, $wpdb;
    25532553
    25542554    $is_publishing_changeset = (
     
    26012601     */
    26022602    if ( ! wp_revisions_enabled( $changeset_post ) ) {
    2603         wp_trash_post( $changeset_post->ID );
     2603        $post = $changeset_post;
     2604        $post_id = $changeset_post->ID;
     2605
     2606        /*
     2607         * The following re-formulates the logic from wp_trash_post() as done in
     2608         * wp_publish_post(). The reason for bypassing wp_trash_post() is that it
     2609         * will mutate the the post_content and the post_name when they should be
     2610         * untouched.
     2611         */
     2612        if ( ! EMPTY_TRASH_DAYS ) {
     2613            wp_delete_post( $post_id, true );
     2614        } else {
     2615            /** This action is documented in wp-includes/post.php */
     2616            do_action( 'wp_trash_post', $post_id );
     2617
     2618            add_post_meta( $post_id, '_wp_trash_meta_status', $post->post_status );
     2619            add_post_meta( $post_id, '_wp_trash_meta_time', time() );
     2620
     2621            $old_status = $post->post_status;
     2622            $new_status = 'trash';
     2623            $wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) );
     2624            clean_post_cache( $post->ID );
     2625
     2626            $post->post_status = $new_status;
     2627            wp_transition_post_status( $new_status, $old_status, $post );
     2628
     2629            /** This action is documented in wp-includes/post.php */
     2630            do_action( 'edit_post', $post->ID, $post );
     2631
     2632            /** This action is documented in wp-includes/post.php */
     2633            do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
     2634
     2635            /** This action is documented in wp-includes/post.php */
     2636            do_action( 'save_post', $post->ID, $post, true );
     2637
     2638            /** This action is documented in wp-includes/post.php */
     2639            do_action( 'wp_insert_post', $post->ID, $post, true );
     2640
     2641            /** This action is documented in wp-includes/post.php */
     2642            do_action( 'trashed_post', $post_id );
     2643        }
    26042644    }
    26052645}
Note: See TracChangeset for help on using the changeset viewer.