Customize: Ensure state query params persist in preview through calls to `history.pushState()` & `history.replaceState()`.
Allow history to be manipulated before DOM ready by sourcing state params from the current URL instead of from the `wp.customize.settings` object, since they will be the same anyway. This fixes a JS error since `wp.customize.settings` is not defined before DOM ready. Amends [38810]. See #30937. Fixes #38592. Built from https://develop.svn.wordpress.org/trunk@39060 git-svn-id: http://core.svn.wordpress.org/trunk@39002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4356a28b52
commit
1c45ae618c
|
@ -29,20 +29,21 @@
|
|||
* @returns {string} URL with customized state.
|
||||
*/
|
||||
injectUrlWithState = function( url ) {
|
||||
var urlParser, queryParams;
|
||||
var urlParser, oldQueryParams, newQueryParams;
|
||||
urlParser = document.createElement( 'a' );
|
||||
urlParser.href = url;
|
||||
queryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
|
||||
oldQueryParams = api.utils.parseQueryString( location.search.substr( 1 ) );
|
||||
newQueryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
|
||||
|
||||
queryParams.customize_changeset_uuid = api.settings.changeset.uuid;
|
||||
if ( ! api.settings.theme.active ) {
|
||||
queryParams.customize_theme = api.settings.theme.stylesheet;
|
||||
newQueryParams.customize_changeset_uuid = oldQueryParams.customize_changeset_uuid;
|
||||
if ( oldQueryParams.customize_theme ) {
|
||||
newQueryParams.customize_theme = oldQueryParams.customize_theme;
|
||||
}
|
||||
if ( api.settings.theme.channel ) {
|
||||
queryParams.customize_messenger_channel = api.settings.channel;
|
||||
if ( oldQueryParams.customize_messenger_channel ) {
|
||||
newQueryParams.customize_messenger_channel = oldQueryParams.customize_messenger_channel;
|
||||
}
|
||||
urlParser.search = $.param( queryParams );
|
||||
return url;
|
||||
urlParser.search = $.param( newQueryParams );
|
||||
return urlParser.href;
|
||||
};
|
||||
|
||||
history.replaceState = ( function( nativeReplaceState ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-beta1-39059';
|
||||
$wp_version = '4.7-beta1-39060';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue