mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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:
@@ -1945,7 +1945,6 @@
|
||||
save: function() {
|
||||
var self = this,
|
||||
query = $.extend( this.query(), {
|
||||
action: 'customize_save',
|
||||
nonce: this.nonce.save
|
||||
} ),
|
||||
processing = api.state( 'processing' ),
|
||||
@@ -1955,7 +1954,7 @@
|
||||
body.addClass( 'saving' );
|
||||
|
||||
submit = function () {
|
||||
var request = $.post( api.settings.url.ajax, query );
|
||||
var request = wp.ajax.post( 'customize_save', query );
|
||||
|
||||
api.trigger( 'save', request );
|
||||
|
||||
@@ -1963,28 +1962,33 @@
|
||||
body.removeClass( 'saving' );
|
||||
} );
|
||||
|
||||
request.done( function( response ) {
|
||||
// Check if the user is logged out.
|
||||
request.fail( function ( response ) {
|
||||
if ( '0' === response ) {
|
||||
response = 'not_logged_in';
|
||||
} else if ( '-1' === response ) {
|
||||
// Back-compat in case any other check_ajax_referer() call is dying
|
||||
response = 'invalid_nonce';
|
||||
}
|
||||
|
||||
if ( 'invalid_nonce' === response ) {
|
||||
self.cheatin();
|
||||
} else if ( 'not_logged_in' === response ) {
|
||||
self.preview.iframe.hide();
|
||||
self.login().done( function() {
|
||||
self.save();
|
||||
self.preview.iframe.show();
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for cheaters.
|
||||
if ( '-1' === response ) {
|
||||
self.cheatin();
|
||||
return;
|
||||
}
|
||||
api.trigger( 'error', response );
|
||||
} );
|
||||
|
||||
request.done( function( response ) {
|
||||
// Clear setting dirty states
|
||||
api.each( function ( value ) {
|
||||
value._dirty = false;
|
||||
} );
|
||||
api.trigger( 'saved' );
|
||||
|
||||
api.trigger( 'saved', response );
|
||||
} );
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user