add_filter( 'wp_insert_post_data', array
( $this, 'preserve_insert_changeset_post_content'
), 5, 3
);
if ( $changeset_post_id ) { if ( $args['autosave'
] && 'auto-draft' !==
get_post_status( $changeset_post_id ) ) { // See _wp_translate_postdata() for why this is required as it will use the edit_post meta capability.
add_filter( 'map_meta_cap', array
( $this, 'grant_edit_post_capability_for_changeset'
), 10, 4
);
$post_array['post_ID'
] =
$post_array['ID'
];
$post_array['post_type'
] = 'customize_changeset';
$r =
wp_create_post_autosave( wp_slash( $post_array ) );
remove_filter( 'map_meta_cap', array
( $this, 'grant_edit_post_capability_for_changeset'
), 10
);
} else { $post_array['edit_date'
] = true; // Prevent date clearing.
$r =
wp_update_post( wp_slash( $post_array ), true
);
// Delete autosave revision for user when the changeset is updated.
if ( !
empty( $args['user_id'
] ) ) { $autosave_draft =
wp_get_post_autosave( $changeset_post_id,
$args['user_id'
] );
if ( $autosave_draft ) {