New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trac 30937: Implement Customize Changesets (née Transactions aka Snapshots) #161

Closed
wants to merge 203 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+35 −4
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Eliminate AYS during theme switch if changeset UUID can appear in the…

… URL
  • Loading branch information...
westonruter committed Oct 2, 2016
commit 8b8e0256de199fc18d37fb4866df1cff5730c925
@@ -1318,6 +1318,23 @@
}
},
/**
* Get the url to preview a given theme switch.
*
* @param {string} themeId Theme ID.
* @returns {string} Customize URL.
*/
getThemePreviewUrl: function( themeId ) {
var urlParser = document.createElement( 'a' );
urlParser.href = location.href;
urlParser.search = urlParser.search.replace( /(\?|&)theme=[^&]+(&|$)/, '$1' );
if ( urlParser.search.length > 1 ) {
urlParser.search += '&';
}
urlParser.search += 'theme=' + themeId;

This comment has been minimized.

@westonruter

westonruter Oct 11, 2016

Contributor

This should be modified to make use of jQuery.param() and wp.customize.utils.parseQueryString()

@westonruter

westonruter Oct 11, 2016

Contributor

This should be modified to make use of jQuery.param() and wp.customize.utils.parseQueryString()

return urlParser.href;
},
/**
* Render & show the theme details for a given theme model.
*
@@ -1335,6 +1352,7 @@
$( 'body' ).addClass( 'modal-open' );
section.containFocus( section.overlay );
section.updateLimits();
section.overlay.find( '.inactive-theme > a' ).prop( 'href', section.getThemePreviewUrl( theme.id ) );
callback();
},
@@ -2972,6 +2990,8 @@
// Bind details view trigger.
control.container.on( 'click keydown touchend', '.theme', function( event ) {
var previewUrl;
if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
return;
}
@@ -2986,10 +3006,15 @@
return;
}
var previewUrl = $( this ).data( 'previewUrl' );
previewUrl = api.ThemesSection.prototype.getThemePreviewUrl( control.params.theme.id );
$( '.wp-full-overlay' ).addClass( 'customize-loading' );
// Remove AYS if the changes can persist via the changeset UUID in the URL.
if ( history.replaceState && 0 === api.state( 'processing' ).get() ) {
$( window ).off( 'beforeunload.customize-confirm' );
}
window.parent.location = previewUrl;
});
@@ -4388,7 +4413,7 @@
});
// Prompt user with AYS dialog if leaving the Customizer with unsaved changes
$( window ).on( 'beforeunload', function () {
$( window ).on( 'beforeunload.customize-confirm', function () {
if ( ! api.state( 'saved' )() ) {
setTimeout( function() {
overlay.removeClass( 'customize-loading' );
View
@@ -2077,12 +2077,13 @@ function check_theme_switched() {
*/
function _wp_customize_include() {
$is_customize_admin_page = ( is_admin() && 'customize.php' == basename( $_SERVER['PHP_SELF'] ) );
$should_include = (
( isset( $_REQUEST['wp_customize'] ) && 'on' == $_REQUEST['wp_customize'] )
||
! empty( $_REQUEST['customize_changeset_uuid'] )
||
( is_admin() && 'customize.php' == basename( $_SERVER['PHP_SELF'] ) )
$is_customize_admin_page
);
if ( ! $should_include ) {
@@ -2092,10 +2093,15 @@ function _wp_customize_include() {
$theme = null;
$changeset_uuid = null;
$messenger_channel = null;
// @todo Also allow just changeset_uuid on customize.php admin page.
if ( ! empty( $_REQUEST['customize_changeset_uuid'] ) ) {
$changeset_uuid = sanitize_key( wp_unslash( $_REQUEST['customize_changeset_uuid'] ) );
}
if ( isset( $_REQUEST['customize_theme'] ) ) {
if ( $is_customize_admin_page && isset( $_REQUEST['theme'] ) ) {
$theme = wp_unslash( $_REQUEST['theme'] );
} elseif ( isset( $_REQUEST['customize_theme'] ) ) {
$theme = wp_unslash( $_REQUEST['customize_theme'] );
}
if ( isset( $_REQUEST['customize_messenger_channel'] ) ) {
ProTip! Use n and p to navigate between commits in a pull request.