diff --git a/wp-admin/js/customize-controls.dev.js b/wp-admin/js/customize-controls.dev.js index 24d647011f..4e54c1866c 100644 --- a/wp-admin/js/customize-controls.dev.js +++ b/wp-admin/js/customize-controls.dev.js @@ -694,11 +694,6 @@ api.state = state; }()); - api.bind( 'activated', function() { - if ( api.settings.url.activated ) - window.location = api.settings.url.activated; - }); - // Temporary accordion code. $('.customize-section-title').click( function( event ) { var clicked = $( this ).parents( '.customize-section' ); @@ -738,10 +733,17 @@ }); // Pass events through to the parent. - $.each([ 'saved', 'activated' ], function( i, id ) { - api.bind( id, function() { - parent.send( id ); - }); + api.bind( 'saved', function() { + parent.send( 'saved' ); + }); + + // When activated, let the loader handle redirecting the page. + // If no loader exists, redirect the page ourselves (if a url exists). + api.bind( 'activated', function() { + if ( parent.targetWindow() ) + parent.send( 'activated', api.settings.url.activated ); + else if ( api.settings.url.activated ) + window.location = api.settings.url.activated; }); // Initialize the connection with the parent frame. diff --git a/wp-includes/js/customize-base.dev.js b/wp-includes/js/customize-base.dev.js index 588efafc15..d643f65066 100644 --- a/wp-includes/js/customize-base.dev.js +++ b/wp-includes/js/customize-base.dev.js @@ -547,7 +547,7 @@ if ( typeof wp === 'undefined' ) send: function( id, data ) { var message; - data = typeof data === 'undefined' ? {} : data; + data = typeof data === 'undefined' ? null : data; if ( ! this.url() || ! this.targetWindow() ) return; diff --git a/wp-includes/js/customize-loader.dev.js b/wp-includes/js/customize-loader.dev.js index 403708fc68..01cec6aca3 100644 --- a/wp-includes/js/customize-loader.dev.js +++ b/wp-includes/js/customize-loader.dev.js @@ -98,6 +98,11 @@ if ( typeof wp === 'undefined' ) Loader.close(); }); + this.messenger.bind( 'activated', function( location ) { + if ( location ) + window.location = location; + }); + hash = src.split('?')[1]; // Ensure we don't call pushState if the user hit the forward button.