diff --git a/wp-admin/js/theme.dev.js b/wp-admin/js/theme.dev.js index 2110feb81..ede9274bd 100644 --- a/wp-admin/js/theme.dev.js +++ b/wp-admin/js/theme.dev.js @@ -18,6 +18,35 @@ jQuery( function($) { }); }); +/** + * Theme Customizer + * + * Ensures the themes page is refreshed if the customizer switches the theme. + */ +jQuery( function($) { + var Loader, activated; + + if ( typeof wp === 'undefined' || ! wp.customize || ! ( Loader = wp.customize.Loader ) ) + return; + + // Strip the current URL of its query string and hash, add activated query string. + activated = window.location.href.replace(/[#?].*$/, '') + '?activated=true'; + + // When an instance of the customizer is loaded... + Loader.bind( 'open', function() { + + // If the customizer triggers a theme switched event, + // load the activated page when the customizer is closed. + Loader.messenger.bind( 'switched', function() { + + Loader.unbind( 'close', Loader.overlay.hide ); + Loader.bind( 'close', function() { + window.location = activated; + }); + }); + }); +}); + /** * Theme Install * diff --git a/wp-includes/class-wp-customize.php b/wp-includes/class-wp-customize.php index ffae10619..9eb280ff3 100644 --- a/wp-includes/class-wp-customize.php +++ b/wp-includes/class-wp-customize.php @@ -144,6 +144,15 @@ final class WP_Customize { do_action( 'stop_previewing_theme', $this ); } + /** + * Checks if the current theme is active. + * + * @since 3.4.0 + */ + public function is_current_theme_active() { + return $this->get_stylesheet() == $this->original_stylesheet; + } + /** * Register styles/scripts and initialize the preview of each setting * diff --git a/wp-includes/customize-controls.php b/wp-includes/customize-controls.php index 225382997..0fd9b030d 100644 --- a/wp-includes/customize-controls.php +++ b/wp-includes/customize-controls.php @@ -76,7 +76,7 @@ do_action( 'customize_controls_print_scripts' );