$data =
apply_filters( 'customize_changeset_save_data',
$data,
$filter_context );
// Switch theme if publishing changes now.
if ( 'publish' ===
$args['status'
] && !
$this->
is_theme_active() ) { // Temporarily stop previewing the theme to allow switch_themes() to operate properly.
$this->
stop_previewing_theme();
switch_theme( $this->
get_stylesheet() );
update_option( 'theme_switched_via_customizer', true
);
$this->
start_previewing_theme();
} // Gather the data for wp_insert_post()/wp_update_post().
$post_array = array
( // JSON_UNESCAPED_SLASHES is only to improve readability as slashes needn't be escaped in storage.
'post_content' =>
wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT
),
);
if ( $args['title'
] ) { $post_array['post_title'
] =
$args['title'
];
}