Edit File by line
/home/barbar84/public_h.../wp-inclu.../js
File: customize-preview.js
/*
[0] Fix | Delete
* Script run inside a Customizer preview frame.
[1] Fix | Delete
*
[2] Fix | Delete
* @output wp-includes/js/customize-preview.js
[3] Fix | Delete
*/
[4] Fix | Delete
(function( exports, $ ){
[5] Fix | Delete
var api = wp.customize,
[6] Fix | Delete
debounce,
[7] Fix | Delete
currentHistoryState = {};
[8] Fix | Delete
[9] Fix | Delete
/*
[10] Fix | Delete
* Capture the state that is passed into history.replaceState() and history.pushState()
[11] Fix | Delete
* and also which is returned in the popstate event so that when the changeset_uuid
[12] Fix | Delete
* gets updated when transitioning to a new changeset there the current state will
[13] Fix | Delete
* be supplied in the call to history.replaceState().
[14] Fix | Delete
*/
[15] Fix | Delete
( function( history ) {
[16] Fix | Delete
var injectUrlWithState;
[17] Fix | Delete
[18] Fix | Delete
if ( ! history.replaceState ) {
[19] Fix | Delete
return;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Amend the supplied URL with the customized state.
[24] Fix | Delete
*
[25] Fix | Delete
* @since 4.7.0
[26] Fix | Delete
* @access private
[27] Fix | Delete
*
[28] Fix | Delete
* @param {string} url URL.
[29] Fix | Delete
* @return {string} URL with customized state.
[30] Fix | Delete
*/
[31] Fix | Delete
injectUrlWithState = function( url ) {
[32] Fix | Delete
var urlParser, oldQueryParams, newQueryParams;
[33] Fix | Delete
urlParser = document.createElement( 'a' );
[34] Fix | Delete
urlParser.href = url;
[35] Fix | Delete
oldQueryParams = api.utils.parseQueryString( location.search.substr( 1 ) );
[36] Fix | Delete
newQueryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
[37] Fix | Delete
[38] Fix | Delete
newQueryParams.customize_changeset_uuid = oldQueryParams.customize_changeset_uuid;
[39] Fix | Delete
if ( oldQueryParams.customize_autosaved ) {
[40] Fix | Delete
newQueryParams.customize_autosaved = 'on';
[41] Fix | Delete
}
[42] Fix | Delete
if ( oldQueryParams.customize_theme ) {
[43] Fix | Delete
newQueryParams.customize_theme = oldQueryParams.customize_theme;
[44] Fix | Delete
}
[45] Fix | Delete
if ( oldQueryParams.customize_messenger_channel ) {
[46] Fix | Delete
newQueryParams.customize_messenger_channel = oldQueryParams.customize_messenger_channel;
[47] Fix | Delete
}
[48] Fix | Delete
urlParser.search = $.param( newQueryParams );
[49] Fix | Delete
return urlParser.href;
[50] Fix | Delete
};
[51] Fix | Delete
[52] Fix | Delete
history.replaceState = ( function( nativeReplaceState ) {
[53] Fix | Delete
return function historyReplaceState( data, title, url ) {
[54] Fix | Delete
currentHistoryState = data;
[55] Fix | Delete
return nativeReplaceState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url );
[56] Fix | Delete
};
[57] Fix | Delete
} )( history.replaceState );
[58] Fix | Delete
[59] Fix | Delete
history.pushState = ( function( nativePushState ) {
[60] Fix | Delete
return function historyPushState( data, title, url ) {
[61] Fix | Delete
currentHistoryState = data;
[62] Fix | Delete
return nativePushState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url );
[63] Fix | Delete
};
[64] Fix | Delete
} )( history.pushState );
[65] Fix | Delete
[66] Fix | Delete
window.addEventListener( 'popstate', function( event ) {
[67] Fix | Delete
currentHistoryState = event.state;
[68] Fix | Delete
} );
[69] Fix | Delete
[70] Fix | Delete
}( history ) );
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Returns a debounced version of the function.
[74] Fix | Delete
*
[75] Fix | Delete
* @todo Require Underscore.js for this file and retire this.
[76] Fix | Delete
*/
[77] Fix | Delete
debounce = function( fn, delay, context ) {
[78] Fix | Delete
var timeout;
[79] Fix | Delete
return function() {
[80] Fix | Delete
var args = arguments;
[81] Fix | Delete
[82] Fix | Delete
context = context || this;
[83] Fix | Delete
[84] Fix | Delete
clearTimeout( timeout );
[85] Fix | Delete
timeout = setTimeout( function() {
[86] Fix | Delete
timeout = null;
[87] Fix | Delete
fn.apply( context, args );
[88] Fix | Delete
}, delay );
[89] Fix | Delete
};
[90] Fix | Delete
};
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* @memberOf wp.customize
[94] Fix | Delete
* @alias wp.customize.Preview
[95] Fix | Delete
*
[96] Fix | Delete
* @constructor
[97] Fix | Delete
* @augments wp.customize.Messenger
[98] Fix | Delete
* @augments wp.customize.Class
[99] Fix | Delete
* @mixes wp.customize.Events
[100] Fix | Delete
*/
[101] Fix | Delete
api.Preview = api.Messenger.extend(/** @lends wp.customize.Preview.prototype */{
[102] Fix | Delete
/**
[103] Fix | Delete
* @param {Object} params - Parameters to configure the messenger.
[104] Fix | Delete
* @param {Object} options - Extend any instance parameter or method with this object.
[105] Fix | Delete
*/
[106] Fix | Delete
initialize: function( params, options ) {
[107] Fix | Delete
var preview = this, urlParser = document.createElement( 'a' );
[108] Fix | Delete
[109] Fix | Delete
api.Messenger.prototype.initialize.call( preview, params, options );
[110] Fix | Delete
[111] Fix | Delete
urlParser.href = preview.origin();
[112] Fix | Delete
preview.add( 'scheme', urlParser.protocol.replace( /:$/, '' ) );
[113] Fix | Delete
[114] Fix | Delete
preview.body = $( document.body );
[115] Fix | Delete
preview.window = $( window );
[116] Fix | Delete
[117] Fix | Delete
if ( api.settings.channel ) {
[118] Fix | Delete
[119] Fix | Delete
// If in an iframe, then intercept the link clicks and form submissions.
[120] Fix | Delete
preview.body.on( 'click.preview', 'a', function( event ) {
[121] Fix | Delete
preview.handleLinkClick( event );
[122] Fix | Delete
} );
[123] Fix | Delete
preview.body.on( 'submit.preview', 'form', function( event ) {
[124] Fix | Delete
preview.handleFormSubmit( event );
[125] Fix | Delete
} );
[126] Fix | Delete
[127] Fix | Delete
preview.window.on( 'scroll.preview', debounce( function() {
[128] Fix | Delete
preview.send( 'scroll', preview.window.scrollTop() );
[129] Fix | Delete
}, 200 ) );
[130] Fix | Delete
[131] Fix | Delete
preview.bind( 'scroll', function( distance ) {
[132] Fix | Delete
preview.window.scrollTop( distance );
[133] Fix | Delete
});
[134] Fix | Delete
}
[135] Fix | Delete
},
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Handle link clicks in preview.
[139] Fix | Delete
*
[140] Fix | Delete
* @since 4.7.0
[141] Fix | Delete
* @access public
[142] Fix | Delete
*
[143] Fix | Delete
* @param {jQuery.Event} event Event.
[144] Fix | Delete
*/
[145] Fix | Delete
handleLinkClick: function( event ) {
[146] Fix | Delete
var preview = this, link, isInternalJumpLink;
[147] Fix | Delete
link = $( event.target ).closest( 'a' );
[148] Fix | Delete
[149] Fix | Delete
// No-op if the anchor is not a link.
[150] Fix | Delete
if ( _.isUndefined( link.attr( 'href' ) ) ) {
[151] Fix | Delete
return;
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
// Allow internal jump links and JS links to behave normally without preventing default.
[155] Fix | Delete
isInternalJumpLink = ( '#' === link.attr( 'href' ).substr( 0, 1 ) );
[156] Fix | Delete
if ( isInternalJumpLink || ! /^https?:$/.test( link.prop( 'protocol' ) ) ) {
[157] Fix | Delete
return;
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
// If the link is not previewable, prevent the browser from navigating to it.
[161] Fix | Delete
if ( ! api.isLinkPreviewable( link[0] ) ) {
[162] Fix | Delete
wp.a11y.speak( api.settings.l10n.linkUnpreviewable );
[163] Fix | Delete
event.preventDefault();
[164] Fix | Delete
return;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
// Prevent initiating navigating from click and instead rely on sending url message to pane.
[168] Fix | Delete
event.preventDefault();
[169] Fix | Delete
[170] Fix | Delete
/*
[171] Fix | Delete
* Note the shift key is checked so shift+click on widgets or
[172] Fix | Delete
* nav menu items can just result on focusing on the corresponding
[173] Fix | Delete
* control instead of also navigating to the URL linked to.
[174] Fix | Delete
*/
[175] Fix | Delete
if ( event.shiftKey ) {
[176] Fix | Delete
return;
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
// Note: It's not relevant to send scroll because sending url message will have the same effect.
[180] Fix | Delete
preview.send( 'url', link.prop( 'href' ) );
[181] Fix | Delete
},
[182] Fix | Delete
[183] Fix | Delete
/**
[184] Fix | Delete
* Handle form submit.
[185] Fix | Delete
*
[186] Fix | Delete
* @since 4.7.0
[187] Fix | Delete
* @access public
[188] Fix | Delete
*
[189] Fix | Delete
* @param {jQuery.Event} event Event.
[190] Fix | Delete
*/
[191] Fix | Delete
handleFormSubmit: function( event ) {
[192] Fix | Delete
var preview = this, urlParser, form;
[193] Fix | Delete
urlParser = document.createElement( 'a' );
[194] Fix | Delete
form = $( event.target );
[195] Fix | Delete
urlParser.href = form.prop( 'action' );
[196] Fix | Delete
[197] Fix | Delete
// If the link is not previewable, prevent the browser from navigating to it.
[198] Fix | Delete
if ( 'GET' !== form.prop( 'method' ).toUpperCase() || ! api.isLinkPreviewable( urlParser ) ) {
[199] Fix | Delete
wp.a11y.speak( api.settings.l10n.formUnpreviewable );
[200] Fix | Delete
event.preventDefault();
[201] Fix | Delete
return;
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
/*
[205] Fix | Delete
* If the default wasn't prevented already (in which case the form
[206] Fix | Delete
* submission is already being handled by JS), and if it has a GET
[207] Fix | Delete
* request method, then take the serialized form data and add it as
[208] Fix | Delete
* a query string to the action URL and send this in a url message
[209] Fix | Delete
* to the customizer pane so that it will be loaded. If the form's
[210] Fix | Delete
* action points to a non-previewable URL, the customizer pane's
[211] Fix | Delete
* previewUrl setter will reject it so that the form submission is
[212] Fix | Delete
* a no-op, which is the same behavior as when clicking a link to an
[213] Fix | Delete
* external site in the preview.
[214] Fix | Delete
*/
[215] Fix | Delete
if ( ! event.isDefaultPrevented() ) {
[216] Fix | Delete
if ( urlParser.search.length > 1 ) {
[217] Fix | Delete
urlParser.search += '&';
[218] Fix | Delete
}
[219] Fix | Delete
urlParser.search += form.serialize();
[220] Fix | Delete
preview.send( 'url', urlParser.href );
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
// Prevent default since navigation should be done via sending url message or via JS submit handler.
[224] Fix | Delete
event.preventDefault();
[225] Fix | Delete
}
[226] Fix | Delete
});
[227] Fix | Delete
[228] Fix | Delete
/**
[229] Fix | Delete
* Inject the changeset UUID into links in the document.
[230] Fix | Delete
*
[231] Fix | Delete
* @since 4.7.0
[232] Fix | Delete
* @access protected
[233] Fix | Delete
* @access private
[234] Fix | Delete
*
[235] Fix | Delete
* @return {void}
[236] Fix | Delete
*/
[237] Fix | Delete
api.addLinkPreviewing = function addLinkPreviewing() {
[238] Fix | Delete
var linkSelectors = 'a[href], area[href]';
[239] Fix | Delete
[240] Fix | Delete
// Inject links into initial document.
[241] Fix | Delete
$( document.body ).find( linkSelectors ).each( function() {
[242] Fix | Delete
api.prepareLinkPreview( this );
[243] Fix | Delete
} );
[244] Fix | Delete
[245] Fix | Delete
// Inject links for new elements added to the page.
[246] Fix | Delete
if ( 'undefined' !== typeof MutationObserver ) {
[247] Fix | Delete
api.mutationObserver = new MutationObserver( function( mutations ) {
[248] Fix | Delete
_.each( mutations, function( mutation ) {
[249] Fix | Delete
$( mutation.target ).find( linkSelectors ).each( function() {
[250] Fix | Delete
api.prepareLinkPreview( this );
[251] Fix | Delete
} );
[252] Fix | Delete
} );
[253] Fix | Delete
} );
[254] Fix | Delete
api.mutationObserver.observe( document.documentElement, {
[255] Fix | Delete
childList: true,
[256] Fix | Delete
subtree: true
[257] Fix | Delete
} );
[258] Fix | Delete
} else {
[259] Fix | Delete
[260] Fix | Delete
// If mutation observers aren't available, fallback to just-in-time injection.
[261] Fix | Delete
$( document.documentElement ).on( 'click focus mouseover', linkSelectors, function() {
[262] Fix | Delete
api.prepareLinkPreview( this );
[263] Fix | Delete
} );
[264] Fix | Delete
}
[265] Fix | Delete
};
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Should the supplied link is previewable.
[269] Fix | Delete
*
[270] Fix | Delete
* @since 4.7.0
[271] Fix | Delete
* @access public
[272] Fix | Delete
*
[273] Fix | Delete
* @param {HTMLAnchorElement|HTMLAreaElement} element Link element.
[274] Fix | Delete
* @param {string} element.search Query string.
[275] Fix | Delete
* @param {string} element.pathname Path.
[276] Fix | Delete
* @param {string} element.host Host.
[277] Fix | Delete
* @param {Object} [options]
[278] Fix | Delete
* @param {Object} [options.allowAdminAjax=false] Allow admin-ajax.php requests.
[279] Fix | Delete
* @return {boolean} Is appropriate for changeset link.
[280] Fix | Delete
*/
[281] Fix | Delete
api.isLinkPreviewable = function isLinkPreviewable( element, options ) {
[282] Fix | Delete
var matchesAllowedUrl, parsedAllowedUrl, args, elementHost;
[283] Fix | Delete
[284] Fix | Delete
args = _.extend( {}, { allowAdminAjax: false }, options || {} );
[285] Fix | Delete
[286] Fix | Delete
if ( 'javascript:' === element.protocol ) { // jshint ignore:line
[287] Fix | Delete
return true;
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
// Only web URLs can be previewed.
[291] Fix | Delete
if ( 'https:' !== element.protocol && 'http:' !== element.protocol ) {
[292] Fix | Delete
return false;
[293] Fix | Delete
}
[294] Fix | Delete
[295] Fix | Delete
elementHost = element.host.replace( /:(80|443)$/, '' );
[296] Fix | Delete
parsedAllowedUrl = document.createElement( 'a' );
[297] Fix | Delete
matchesAllowedUrl = ! _.isUndefined( _.find( api.settings.url.allowed, function( allowedUrl ) {
[298] Fix | Delete
parsedAllowedUrl.href = allowedUrl;
[299] Fix | Delete
return parsedAllowedUrl.protocol === element.protocol && parsedAllowedUrl.host.replace( /:(80|443)$/, '' ) === elementHost && 0 === element.pathname.indexOf( parsedAllowedUrl.pathname.replace( /\/$/, '' ) );
[300] Fix | Delete
} ) );
[301] Fix | Delete
if ( ! matchesAllowedUrl ) {
[302] Fix | Delete
return false;
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
// Skip wp login and signup pages.
[306] Fix | Delete
if ( /\/wp-(login|signup)\.php$/.test( element.pathname ) ) {
[307] Fix | Delete
return false;
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
// Allow links to admin ajax as faux frontend URLs.
[311] Fix | Delete
if ( /\/wp-admin\/admin-ajax\.php$/.test( element.pathname ) ) {
[312] Fix | Delete
return args.allowAdminAjax;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
// Disallow links to admin, includes, and content.
[316] Fix | Delete
if ( /\/wp-(admin|includes|content)(\/|$)/.test( element.pathname ) ) {
[317] Fix | Delete
return false;
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
return true;
[321] Fix | Delete
};
[322] Fix | Delete
[323] Fix | Delete
/**
[324] Fix | Delete
* Inject the customize_changeset_uuid query param into links on the frontend.
[325] Fix | Delete
*
[326] Fix | Delete
* @since 4.7.0
[327] Fix | Delete
* @access protected
[328] Fix | Delete
*
[329] Fix | Delete
* @param {HTMLAnchorElement|HTMLAreaElement} element Link element.
[330] Fix | Delete
* @param {string} element.search Query string.
[331] Fix | Delete
* @param {string} element.host Host.
[332] Fix | Delete
* @param {string} element.protocol Protocol.
[333] Fix | Delete
* @return {void}
[334] Fix | Delete
*/
[335] Fix | Delete
api.prepareLinkPreview = function prepareLinkPreview( element ) {
[336] Fix | Delete
var queryParams, $element = $( element );
[337] Fix | Delete
[338] Fix | Delete
// Skip elements with no href attribute. Check first to avoid more expensive checks down the road.
[339] Fix | Delete
if ( ! element.hasAttribute( 'href' ) ) {
[340] Fix | Delete
return;
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
// Skip links in admin bar.
[344] Fix | Delete
if ( $element.closest( '#wpadminbar' ).length ) {
[345] Fix | Delete
return;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
// Ignore links with href="#", href="#id", or non-HTTP protocols (e.g. javascript: and mailto:).
[349] Fix | Delete
if ( '#' === $element.attr( 'href' ).substr( 0, 1 ) || ! /^https?:$/.test( element.protocol ) ) {
[350] Fix | Delete
return;
[351] Fix | Delete
}
[352] Fix | Delete
[353] Fix | Delete
// Make sure links in preview use HTTPS if parent frame uses HTTPS.
[354] Fix | Delete
if ( api.settings.channel && 'https' === api.preview.scheme.get() && 'http:' === element.protocol && -1 !== api.settings.url.allowedHosts.indexOf( element.host ) ) {
[355] Fix | Delete
element.protocol = 'https:';
[356] Fix | Delete
}
[357] Fix | Delete
[358] Fix | Delete
// Ignore links with class wp-playlist-caption.
[359] Fix | Delete
if ( $element.hasClass( 'wp-playlist-caption' ) ) {
[360] Fix | Delete
return;
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
if ( ! api.isLinkPreviewable( element ) ) {
[364] Fix | Delete
[365] Fix | Delete
// Style link as unpreviewable only if previewing in iframe; if previewing on frontend, links will be allowed to work normally.
[366] Fix | Delete
if ( api.settings.channel ) {
[367] Fix | Delete
$element.addClass( 'customize-unpreviewable' );
[368] Fix | Delete
}
[369] Fix | Delete
return;
[370] Fix | Delete
}
[371] Fix | Delete
$element.removeClass( 'customize-unpreviewable' );
[372] Fix | Delete
[373] Fix | Delete
queryParams = api.utils.parseQueryString( element.search.substring( 1 ) );
[374] Fix | Delete
queryParams.customize_changeset_uuid = api.settings.changeset.uuid;
[375] Fix | Delete
if ( api.settings.changeset.autosaved ) {
[376] Fix | Delete
queryParams.customize_autosaved = 'on';
[377] Fix | Delete
}
[378] Fix | Delete
if ( ! api.settings.theme.active ) {
[379] Fix | Delete
queryParams.customize_theme = api.settings.theme.stylesheet;
[380] Fix | Delete
}
[381] Fix | Delete
if ( api.settings.channel ) {
[382] Fix | Delete
queryParams.customize_messenger_channel = api.settings.channel;
[383] Fix | Delete
}
[384] Fix | Delete
element.search = $.param( queryParams );
[385] Fix | Delete
};
[386] Fix | Delete
[387] Fix | Delete
/**
[388] Fix | Delete
* Inject the changeset UUID into Ajax requests.
[389] Fix | Delete
*
[390] Fix | Delete
* @since 4.7.0
[391] Fix | Delete
* @access protected
[392] Fix | Delete
*
[393] Fix | Delete
* @return {void}
[394] Fix | Delete
*/
[395] Fix | Delete
api.addRequestPreviewing = function addRequestPreviewing() {
[396] Fix | Delete
[397] Fix | Delete
/**
[398] Fix | Delete
* Rewrite Ajax requests to inject customizer state.
[399] Fix | Delete
*
[400] Fix | Delete
* @param {Object} options Options.
[401] Fix | Delete
* @param {string} options.type Type.
[402] Fix | Delete
* @param {string} options.url URL.
[403] Fix | Delete
* @param {Object} originalOptions Original options.
[404] Fix | Delete
* @param {XMLHttpRequest} xhr XHR.
[405] Fix | Delete
* @return {void}
[406] Fix | Delete
*/
[407] Fix | Delete
var prefilterAjax = function( options, originalOptions, xhr ) {
[408] Fix | Delete
var urlParser, queryParams, requestMethod, dirtyValues = {};
[409] Fix | Delete
urlParser = document.createElement( 'a' );
[410] Fix | Delete
urlParser.href = options.url;
[411] Fix | Delete
[412] Fix | Delete
// Abort if the request is not for this site.
[413] Fix | Delete
if ( ! api.isLinkPreviewable( urlParser, { allowAdminAjax: true } ) ) {
[414] Fix | Delete
return;
[415] Fix | Delete
}
[416] Fix | Delete
queryParams = api.utils.parseQueryString( urlParser.search.substring( 1 ) );
[417] Fix | Delete
[418] Fix | Delete
// Note that _dirty flag will be cleared with changeset updates.
[419] Fix | Delete
api.each( function( setting ) {
[420] Fix | Delete
if ( setting._dirty ) {
[421] Fix | Delete
dirtyValues[ setting.id ] = setting.get();
[422] Fix | Delete
}
[423] Fix | Delete
} );
[424] Fix | Delete
[425] Fix | Delete
if ( ! _.isEmpty( dirtyValues ) ) {
[426] Fix | Delete
requestMethod = options.type.toUpperCase();
[427] Fix | Delete
[428] Fix | Delete
// Override underlying request method to ensure unsaved changes to changeset can be included (force Backbone.emulateHTTP).
[429] Fix | Delete
if ( 'POST' !== requestMethod ) {
[430] Fix | Delete
xhr.setRequestHeader( 'X-HTTP-Method-Override', requestMethod );
[431] Fix | Delete
queryParams._method = requestMethod;
[432] Fix | Delete
options.type = 'POST';
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
// Amend the post data with the customized values.
[436] Fix | Delete
if ( options.data ) {
[437] Fix | Delete
options.data += '&';
[438] Fix | Delete
} else {
[439] Fix | Delete
options.data = '';
[440] Fix | Delete
}
[441] Fix | Delete
options.data += $.param( {
[442] Fix | Delete
customized: JSON.stringify( dirtyValues )
[443] Fix | Delete
} );
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
// Include customized state query params in URL.
[447] Fix | Delete
queryParams.customize_changeset_uuid = api.settings.changeset.uuid;
[448] Fix | Delete
if ( api.settings.changeset.autosaved ) {
[449] Fix | Delete
queryParams.customize_autosaved = 'on';
[450] Fix | Delete
}
[451] Fix | Delete
if ( ! api.settings.theme.active ) {
[452] Fix | Delete
queryParams.customize_theme = api.settings.theme.stylesheet;
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
// Ensure preview nonce is included with every customized request, to allow post data to be read.
[456] Fix | Delete
queryParams.customize_preview_nonce = api.settings.nonce.preview;
[457] Fix | Delete
[458] Fix | Delete
urlParser.search = $.param( queryParams );
[459] Fix | Delete
options.url = urlParser.href;
[460] Fix | Delete
};
[461] Fix | Delete
[462] Fix | Delete
$.ajaxPrefilter( prefilterAjax );
[463] Fix | Delete
};
[464] Fix | Delete
[465] Fix | Delete
/**
[466] Fix | Delete
* Inject changeset UUID into forms, allowing preview to persist through submissions.
[467] Fix | Delete
*
[468] Fix | Delete
* @since 4.7.0
[469] Fix | Delete
* @access protected
[470] Fix | Delete
*
[471] Fix | Delete
* @return {void}
[472] Fix | Delete
*/
[473] Fix | Delete
api.addFormPreviewing = function addFormPreviewing() {
[474] Fix | Delete
[475] Fix | Delete
// Inject inputs for forms in initial document.
[476] Fix | Delete
$( document.body ).find( 'form' ).each( function() {
[477] Fix | Delete
api.prepareFormPreview( this );
[478] Fix | Delete
} );
[479] Fix | Delete
[480] Fix | Delete
// Inject inputs for new forms added to the page.
[481] Fix | Delete
if ( 'undefined' !== typeof MutationObserver ) {
[482] Fix | Delete
api.mutationObserver = new MutationObserver( function( mutations ) {
[483] Fix | Delete
_.each( mutations, function( mutation ) {
[484] Fix | Delete
$( mutation.target ).find( 'form' ).each( function() {
[485] Fix | Delete
api.prepareFormPreview( this );
[486] Fix | Delete
} );
[487] Fix | Delete
} );
[488] Fix | Delete
} );
[489] Fix | Delete
api.mutationObserver.observe( document.documentElement, {
[490] Fix | Delete
childList: true,
[491] Fix | Delete
subtree: true
[492] Fix | Delete
} );
[493] Fix | Delete
}
[494] Fix | Delete
};
[495] Fix | Delete
[496] Fix | Delete
/**
[497] Fix | Delete
* Inject changeset into form inputs.
[498] Fix | Delete
*
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function