Customizer: Send JSON success for customize_save and allow response to be filtered.

props westonruter.
fixes #29098.

git-svn-id: https://develop.svn.wordpress.org/trunk@31062 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90)
2015-01-06 21:46:54 +00:00
parent afb8352a70
commit 8bf3003c67
2 changed files with 35 additions and 16 deletions

View File

@@ -628,10 +628,14 @@ final class WP_Customize_Manager {
* @since 3.4.0
*/
public function save() {
if ( ! $this->is_preview() )
die;
if ( ! $this->is_preview() ) {
wp_send_json_error( 'not_preview' );
}
check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce' );
$action = 'save-customize_' . $this->get_stylesheet();
if ( ! check_ajax_referer( $action, 'nonce', false ) ) {
wp_send_json_error( 'invalid_nonce' );
}
// Do we have to switch themes?
if ( ! $this->is_theme_active() ) {
@@ -666,7 +670,18 @@ final class WP_Customize_Manager {
*/
do_action( 'customize_save_after', $this );
die;
/**
* Filter response data for a successful customize_save Ajax request.
*
* This filter does not apply if there was a nonce or authentication failure.
*
* @since 4.2.0
*
* @param array $data
* @param WP_Customize_Manager $this WP_Customize_Manager instance.
*/
$response = apply_filters( 'customize_save_response', array(), $this );
wp_send_json_success( $response );
}
/**