Customize: Keep frontend preview link updated to reflect the current state of previewed URL, active theme, and autosaved state.

See #39896.

Built from https://develop.svn.wordpress.org/trunk@41969


git-svn-id: http://core.svn.wordpress.org/trunk@41803 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-10-23 00:41:47 +00:00
parent 5e7e44aba7
commit 990c6d5a42
3 changed files with 17 additions and 10 deletions

View File

@ -5797,6 +5797,8 @@
api.bind( 'ready', control.updatePreviewLink ); api.bind( 'ready', control.updatePreviewLink );
api.state( 'saved' ).bind( control.updatePreviewLink ); api.state( 'saved' ).bind( control.updatePreviewLink );
api.state( 'changesetStatus' ).bind( control.updatePreviewLink ); api.state( 'changesetStatus' ).bind( control.updatePreviewLink );
api.state( 'activated' ).bind( control.updatePreviewLink );
api.previewer.previewUrl.bind( control.updatePreviewLink );
button.element.on( 'click', function( event ) { button.element.on( 'click', function( event ) {
event.preventDefault(); event.preventDefault();
@ -7586,18 +7588,23 @@
* @return {string} Preview url. * @return {string} Preview url.
*/ */
getFrontendPreviewUrl: function() { getFrontendPreviewUrl: function() {
var previewer = this, var previewer = this, params, urlParser;
a = document.createElement( 'a' ), urlParser = document.createElement( 'a' );
params = {}; urlParser.href = previewer.previewUrl.get();
params = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
if ( api.state( 'changesetStatus' ).get() && 'publish' !== api.state( 'changesetStatus' ).get() ) { if ( api.state( 'changesetStatus' ).get() && 'publish' !== api.state( 'changesetStatus' ).get() ) {
params.customize_changeset_uuid = api.settings.changeset.uuid; params.customize_changeset_uuid = api.settings.changeset.uuid;
} }
if ( ! api.state( 'activated' ).get() ) {
params.customize_theme = api.settings.theme.stylesheet;
}
if ( api.settings.changeset.autosaved || ! api.state( 'saved' ).get() ) {
params.customize_autosaved = 'on';
}
a.href = previewer.previewUrl(); urlParser.search = $.param( params );
a.search = $.param( params ); return urlParser.href;
return a.href;
} }
}); });

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9-beta3-41968'; $wp_version = '4.9-beta3-41969';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.