Customize: Introduce drafting and scheduling for Customizer changesets.
* Incorporates code from the Customize Snapshots and Customize Posts feature plugins.
* Adds a new Publish Settings section for managing the changeset status, scheduled date, and frontend preview link.
* Updates Publish button to reflect the status selected in the Publish Settings (including Save Draft and Schedule).
* Deactivates the Themes section when a non-publish status selected, and deactivates the Publish Settings section when previewing a theme switch.
* Introduces an `outer` section type (`wp.customize.OuterSection` in JS) for the Publish Settings section to use and for available widgets and available nav menu panels to use in the future. These sections can be expanded while other sections are expanded.
* Introduces `WP_Customize_Date_Time_Control` in PHP and `wp.customize.DateTimeControl` in JS for managing a date/time value.
* Keeps track of scheduled time and proactively publish from the client when the time arrives, as opposed to waiting for WP Cron.
* Auto-publishes a scheduled changeset when attempting to access one that missed its schedule.
* Starts a new changeset if attempting to save a changeset that was previously publish.
* Adds `force` arg to `requestChangesetUpdate()` to force an update request even when there are no pending changes.
* Adds utils methods for `getCurrentTimestamp` and `getRemainingTime`.
* Adds new state values for `selectedChangesetStatus`, `changesetDate`, `selectedChangesetDate`.
* Fixes logic for when to short-circuit check to close Customizer when there are unsaved changes.
* Adds getter methods for `autosaved` and `branching` parameters, with the latter applying the `customize_changeset_branching` filter.
* Call to `establish_loaded_changeset` on the fly when `changeset_uuid()` is called if no changeset UUID was specififed.
* De-duplicates logic for dismissing auto-draft changesets.
* Includes unit tests.
Builds on [41597].
Props sayedwp, westonruter, melchoyce, JoshuaWold, folletto, stubgo, karmatosed, dlh, paaljoachim, afercia, johnregan3, utkarshpatel, valendesigns.
See #30937.
Fixes #39896, #28721, #39275.
Built from https://develop.svn.wordpress.org/trunk@41626
git-svn-id: http://core.svn.wordpress.org/trunk@41461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-27 18:25:46 -04:00
|
|
|
!function(a,b){var c,d=wp.customize,e={};!function(a){var c;a.replaceState&&(c=function(a){var c,e,f;return c=document.createElement("a"),c.href=a,e=d.utils.parseQueryString(location.search.substr(1)),f=d.utils.parseQueryString(c.search.substr(1)),f.customize_changeset_uuid=e.customize_changeset_uuid,d.settings.changeset.autosaved&&(f.customize_autosaved="on"),e.customize_theme&&(f.customize_theme=e.customize_theme),e.customize_messenger_channel&&(f.customize_messenger_channel=e.customize_messenger_channel),c.search=b.param(f),c.href},a.replaceState=function(b){return function(d,f,g){return e=d,b.call(a,d,f,"string"==typeof g&&g.length>0?c(g):g)}}(a.replaceState),a.pushState=function(b){return function(d,f,g){return e=d,b.call(a,d,f,"string"==typeof g&&g.length>0?c(g):g)}}(a.pushState),window.addEventListener("popstate",function(a){e=a.state}))}(history),c=function(a,b,c){var d;return function(){var e=arguments;c=c||this,clearTimeout(d),d=setTimeout(function(){d=null,a.apply(c,e)},b)}},d.Preview=d.Messenger.extend({initialize:function(a,e){var f=this,g=document.createElement("a");d.Messenger.prototype.initialize.call(f,a,e),g.href=f.origin(),f.add("scheme",g.protocol.replace(/:$/,"")),f.body=b(document.body),f.window=b(window),d.settings.channel&&(f.body.on("click.preview","a",function(a){f.handleLinkClick(a)}),f.body.on("submit.preview","form",function(a){f.handleFormSubmit(a)}),f.window.on("scroll.preview",c(function(){f.send("scroll",f.window.scrollTop())},200)),f.bind("scroll",function(a){f.window.scrollTop(a)}))},handleLinkClick:function(a){var c,e,f=this;if(c=b(a.target).closest("a"),!_.isUndefined(c.attr("href"))&&(e="#"===c.attr("href").substr(0,1),!e&&/^https?:$/.test(c.prop("protocol")))){if(!d.isLinkPreviewable(c[0]))return wp.a11y.speak(d.settings.l10n.linkUnpreviewable),void a.preventDefault();a.preventDefault(),a.shiftKey||f.send("url",c.prop("href"))}},handleFormSubmit:function(a){var c,e,f=this;return c=document.createElement("a"),e=b(a.target),c.href=e.prop("action"),"GET"===e.prop("method").toUpperCase()&&d.isLinkPreviewable(c)?(a.isDefaultPrevented()||(c.search.length>1&&(c.search+="&"),c.search+=e.serialize(),f.send("url",c.href)),void a.preventDefault()):(wp.a11y.speak(d.settings.l10n.formUnpreviewable),void a.preventDefault())}}),d.addLinkPreviewing=function(){var a="a[href], area";b(document.body).find(a).each(function(){d.prepareLinkPreview(this)}),"undefined"!=typeof MutationObserver?(d.mutationObserver=new MutationObserver(function(c){_.each(c,function(c){b(c.target).find(a).each(function(){d.prepareLinkPreview(this)})})}),d.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0})):b(document.documentElement).on("click focus mouseover",a,function(){d.prepareLinkPreview(this)})},d.isLinkPreviewable=function(a,b){var c,e,f,g;return f=_.extend({},{allowAdminAjax:!1},b||{}),"javascript:"===a.protocol||("https:"===a.protocol||"http:"===a.protocol)&&(g=a.host.replace(/:(80|443)$/,""),e=document.createElement("a"),c=!_.isUndefined(_.find(d.settings.url.allowed,function(b){return e.href=b,e.protocol===a.protocol&&e.host.replace(/:(80|443)$/,"")===g&&0===a.pathname.indexOf(e.pathname.replace(/\/$/,""))})),!!c&&(!/\/wp-(login|signup)\.php$/.test(a.pathname)&&(/\/wp-admin\/admin-ajax\.php$/.test(a.pathname)?f.allowAdminAjax:!/\/wp-(admin|includes|content)(\/|$)/.test(a.pathname))))},d.prepareLinkPreview=function(a){var c,e=b(a);if(!e.closest("#wpadminbar").length&&"#"!==e.attr("href").substr(0,1)&&/^https?:$/.test(a.protocol)&&(d.settings.channel&&"https"===d.preview.scheme.get()&&"http:"===a.protocol&&-1!==d.settings.url.allowedHosts.indexOf(a.host)&&(a.protocol="https:"),!e.hasClass("wp-playlist-caption"))){if(!d.isLinkPreviewable(a))return void(d.settings.channel&&e.addClass("customize-unpreviewable"));e.removeClass("customize-unpreviewable"),c=d.utils.parseQueryString(a.search.substring(1)),c.customize_changeset_uuid=d.settings.changeset.uuid,d.settings.changeset.autosaved&&(c.customize_autosaved="on"),d.settings.theme.active||(c.customize_theme=d.settings.theme.stylesheet),d.setti
|