<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[41667] trunk: Customize: Add infrastructure for trashing/reverting of unpublished changes; introduce full-screen `OverlayNotification` for trashing and theme install/preview.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/41667">41667</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/41667","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-10-02 03:36:18 +0000 (Mon, 02 Oct 2017)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Customize: Add infrastructure for trashing/reverting of unpublished changes; introduce full-screen `OverlayNotification` for trashing and theme install/preview.
* Introduce a new `wp.customize.previewer.trash()` JS API to trash the current changeset, along with logic to `WP_Customize_Manager` to handle deleting changeset drafts.
* Add `trashing` to `wp.customize.state` which is then used to update the UI.
* UI for trashing is pending design feedback. One possibility is to add a new trash button to Publish Settings section that invokes `wp.customize.previewer.trash()`.
* Improve logic for managing the visibility and disabled states for publish buttons.
* Prevent attempting `requestChangesetUpdate` while processing and bump processing while doing `save`.
* Update `changeset_date` state only if sent in save response.
* Merge `ThemesSection#loadThemePreview()` into `ThemesPanel#loadThemePreview()`.
* Remove unused `autosaved` state.
* Start autosaving and prompting at beforeunload after a change first happens. This is key for theme previews since even if a user did not make any changes, there were still dirty settings which would get stored in an auto-draft unexpectedly.
* Allow `Notification` to accept additional `classes` to be added to `container`.
* Introduce `OverlayNotification` and use for theme installing, previewing, and trashing. Such overlay notifications take over the entire window.
Props westonruter, celloexpressions.
See <a href="https://core.trac.wordpress.org/ticket/37661">#37661</a>, <a href="https://core.trac.wordpress.org/ticket/39896">#39896</a>, <a href="https://core.trac.wordpress.org/ticket/21666">#21666</a>, <a href="https://core.trac.wordpress.org/ticket/35210">#35210</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsscustomizecontrolscss">trunk/src/wp-admin/css/customize-controls.css</a></li>
<li><a href="#trunksrcwpadmincssthemescss">trunk/src/wp-admin/css/themes.css</a></li>
<li><a href="#trunksrcwpadminjscustomizecontrolsjs">trunk/src/wp-admin/js/customize-controls.js</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizemanagerphp">trunk/src/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#trunksrcwpincludescustomizeclasswpcustomizethemespanelphp">trunk/src/wp-includes/customize/class-wp-customize-themes-panel.php</a></li>
<li><a href="#trunksrcwpincludesjscustomizebasejs">trunk/src/wp-includes/js/customize-base.js</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
<li><a href="#trunktestsphpunittestsajaxCustomizeManagerphp">trunk/tests/phpunit/tests/ajax/CustomizeManager.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsscustomizecontrolscss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/customize-controls.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/customize-controls.css 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/src/wp-admin/css/customize-controls.css 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -29,11 +29,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> margin-top: 9px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+body:not(.ready) #customize-save-button-wrapper .save {
+ visibility: hidden;
+}
</ins><span class="cx" style="display: block; padding: 0 10px"> #customize-save-button-wrapper .save {
</span><span class="cx" style="display: block; padding: 0 10px"> float: left;
</span><span class="cx" style="display: block; padding: 0 10px"> border-radius: 3px;
</span><span class="cx" style="display: block; padding: 0 10px"> box-shadow: none; /* @todo Adjust box shadow based on the disable states of paired button. */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- display: none; /* Shown when ready. */
</del><span class="cx" style="display: block; padding: 0 10px"> margin-top: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> #customize-save-button-wrapper .save.has-next-sibling {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,18 +108,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> font-size: 14px;
</span><span class="cx" style="display: block; padding: 0 10px"> width: 30px;
</span><span class="cx" style="display: block; padding: 0 10px"> float: left;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- display: none; /* Shown when ready. */
</del><span class="cx" style="display: block; padding: 0 10px"> -webkit-transform: none;
</span><span class="cx" style="display: block; padding: 0 10px"> transform: none;
</span><span class="cx" style="display: block; padding: 0 10px"> margin-top: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+body:not(.ready) #publish-settings,
+body.trashing #customize-save-button-wrapper .save,
+body.trashing #publish-settings {
+ display: none;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #customize-header-actions .spinner {
</span><span class="cx" style="display: block; padding: 0 10px"> margin-top: 13px;
</span><span class="cx" style="display: block; padding: 0 10px"> margin-right: 4px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.saving #customize-header-actions .spinner {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.saving #customize-header-actions .spinner,
+.trashing #customize-header-actions .spinner {
</ins><span class="cx" style="display: block; padding: 0 10px"> visibility: visible;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,6 +155,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> padding-right: 12px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#customize-control-trash_changeset {
+ margin-top: 20px;
+}
+#customize-control-trash_changeset button {
+ position: relative;
+ padding-left: 24px;
+ display: inline-block;
+}
+#customize-control-trash_changeset button:before {
+ content: "\f182";
+ font: normal 22px dashicons;
+ text-decoration: none;
+ position: absolute;
+ left: 0;
+ top: -2px;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> #customize-controls .date-input:invalid {
</span><span class="cx" style="display: block; padding: 0 10px"> border-color: red;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1126,6 +1151,43 @@
</span><span class="cx" style="display: block; padding: 0 10px"> margin-top: 1px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+@-webkit-keyframes customize-fade-in {
+ 0% { opacity: 0; }
+ 100% { opacity: 1; }
+}
+
+@keyframes customize-fade-in {
+ 0% { opacity: 0; }
+ 100% { opacity: 1; }
+}
+
+#customize-controls .notice.notification-overlay,
+#customize-controls #customize-notifications-area .notice.notification-overlay {
+ margin: 0;
+ border-left: 0; /* @todo Appropriate styles could be added for notice-error, notice-warning, notice-success, etc */
+}
+
+#customize-controls .customize-control-notifications-container.has-overlay-notifications {
+ -webkit-animation: customize-fade-in 0.5s;
+ animation: customize-fade-in 0.5s;
+ z-index: 30;
+}
+
+/* Note: Styles for this are also defined in themes.css */
+#customize-controls #customize-notifications-area .notice.notification-overlay .notification-message {
+ clear: both;
+ color: #191e23;
+ font-size: 18px;
+ font-style: normal;
+ margin: 0;
+ padding: 2em 0;
+ text-align: center;
+ width: 100%;
+ display: block;
+ top: 50%;
+ position: relative;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /* Style for custom settings */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1550,40 +1612,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Themes
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-@-webkit-keyframes customize-reload {
- 0% { opacity: 0; }
- 100% { opacity: 1; }
-}
-
-@keyframes customize-reload {
- 0% { opacity: 0; }
- 100% { opacity: 1; }
-}
-
-.wp-customizer .customize-loading #customize-themes-loading-container {
- display: block;
- -webkit-animation: customize-reload .5s; /* Can't use `transition` because `display` changes here. */
- animation: customize-reload .5s;
-}
-
-.customize-loading #customize-themes-loading-container span {
- clear: both;
- color: #191e23;
- font-size: 18px;
- font-style: normal;
- margin: 0;
- padding: 2em 0;
- text-align: center;
- width: 100%;
- display: block;
- top: 50%;
- position: relative;
-}
-
-.customize-loading #customize-themes-loading-container .customize-loading-text {
- display: none;
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> #customize-theme-controls .control-panel-themes {
</span><span class="cx" style="display: block; padding: 0 10px"> border-bottom: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1673,8 +1701,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> transition: .18s bottom ease-in-out;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.in-themes-panel:not(.animating) #customize-header-actions .save,
-.in-themes-panel:not(.animating) #customize-header-actions #publish-settings,
</del><span class="cx" style="display: block; padding: 0 10px"> .in-themes-panel:not(.animating) #customize-header-actions .spinner,
</span><span class="cx" style="display: block; padding: 0 10px"> .in-themes-panel:not(.animating) #customize-header-actions .customize-controls-preview-toggle,
</span><span class="cx" style="display: block; padding: 0 10px"> .in-themes-panel:not(.animating) #customize-preview,
</span></span></pre></div>
<a id="trunksrcwpadmincssthemescss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/themes.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/themes.css 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/src/wp-admin/css/themes.css 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1707,8 +1707,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #customize-container,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#customize-themes-loading-container {
- display: none;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#customize-controls .notice.notification-overlay {
</ins><span class="cx" style="display: block; padding: 0 10px"> background: #eee;
</span><span class="cx" style="display: block; padding: 0 10px"> z-index: 500000;
</span><span class="cx" style="display: block; padding: 0 10px"> position: fixed;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1719,10 +1718,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> right: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> height: 100%;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#customize-container {
+ display: none;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* Make the Customizer and Theme installer overlays the only available content. */
</span><span class="cx" style="display: block; padding: 0 10px"> #customize-container,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-#customize-themes-loading-container,
</del><span class="cx" style="display: block; padding: 0 10px"> .theme-install-overlay {
</span><span class="cx" style="display: block; padding: 0 10px"> visibility: visible;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1827,7 +1828,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #customize-preview.wp-full-overlay-main:before,
</span><span class="cx" style="display: block; padding: 0 10px"> .customize-loading #customize-container:before,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.customize-loading #customize-themes-loading-container:before,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+#customize-controls .notice.notification-overlay.notification-loading:before,
</ins><span class="cx" style="display: block; padding: 0 10px"> .theme-install-overlay .wp-full-overlay-main:before {
</span><span class="cx" style="display: block; padding: 0 10px"> content: "";
</span><span class="cx" style="display: block; padding: 0 10px"> display: block;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1865,7 +1866,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> #customize-preview.wp-full-overlay-main:before,
</span><span class="cx" style="display: block; padding: 0 10px"> .customize-loading #customize-container:before,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- .customize-loading #customize-themes-loading-container:before,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ #customize-controls .notice.notification-overlay.notification-loading:before,
</ins><span class="cx" style="display: block; padding: 0 10px"> .theme-install-overlay .wp-full-overlay-main:before {
</span><span class="cx" style="display: block; padding: 0 10px"> background-image: url(../images/spinner-2x.gif);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminjscustomizecontrolsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/js/customize-controls.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/js/customize-controls.js 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/src/wp-admin/js/customize-controls.js 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,6 +3,41 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var Container, focus, normalizedTransitionendEventName, api = wp.customize;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * A notification that is displayed in a full-screen overlay.
+ *
+ * @since 4.9.0
+ * @class
+ * @augments wp.customize.Notification
+ */
+ api.OverlayNotification = api.Notification.extend({
+
+ /**
+ * Whether the notification should show a loading spinner.
+ *
+ * @since 4.9.0
+ * @var {boolean}
+ */
+ loading: false,
+
+ /**
+ * Initialize.
+ *
+ * @since 4.9.0
+ *
+ * @param {string} code - Code.
+ * @param {object} params - Params.
+ */
+ initialize: function( code, params ) {
+ var notification = this;
+ api.Notification.prototype.initialize.call( notification, code, params );
+ notification.classes += ' notification-overlay';
+ if ( notification.loading ) {
+ notification.classes += ' notification-loading';
+ }
+ }
+ });
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * A collection of observable notifications.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,7 +180,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> render: function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var collection = this,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- notifications,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ notifications, hadOverlayNotification = false, hasOverlayNotification,
</ins><span class="cx" style="display: block; padding: 0 10px"> previousNotificationsByCode = {},
</span><span class="cx" style="display: block; padding: 0 10px"> listElement;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -178,12 +213,30 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add all notifications in the sorted order.
</span><span class="cx" style="display: block; padding: 0 10px"> _.each( notifications, function( notification ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var notificationContainer;
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( wp.a11y && ( ! previousNotificationsByCode[ notification.code ] || ! _.isEqual( notification.message, previousNotificationsByCode[ notification.code ].message ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp.a11y.speak( notification.message, 'assertive' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- listElement.append( $( notification.render() ) ); // @todo Consider slideDown() as enhancement.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ notificationContainer = $( notification.render() );
+ listElement.append( notificationContainer ); // @todo Consider slideDown() as enhancement.
+
+ // @todo Constraing focus in notificationContainer if notification.extended( api.OverlayNotification ).
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ hasOverlayNotification = Boolean( _.find( notifications, function( notification ) {
+ return notification.extended( api.OverlayNotification );
+ } ) );
+ if ( collection.previousNotifications ) {
+ hadOverlayNotification = Boolean( _.find( collection.previousNotifications, function( notification ) {
+ return notification.extended( api.OverlayNotification );
+ } ) );
+ }
+
+ if ( hasOverlayNotification !== hadOverlayNotification ) {
+ $( document.body ).toggleClass( 'customize-loading', hasOverlayNotification );
+ collection.container.toggleClass( 'has-overlay-notifications', hasOverlayNotification );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> collection.previousNotifications = notifications;
</span><span class="cx" style="display: block; padding: 0 10px"> collection.previousContainer = collection.container;
</span><span class="cx" style="display: block; padding: 0 10px"> collection.trigger( 'rendered' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -368,6 +421,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var deferred, request, submittedChanges = {}, data, submittedArgs;
</span><span class="cx" style="display: block; padding: 0 10px"> deferred = new $.Deferred();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Prevent attempting changeset update while request is being made.
+ if ( 0 !== api.state( 'processing' ).get() ) {
+ deferred.reject( 'already_processing' );
+ return deferred.promise();
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> submittedArgs = _.extend( {
</span><span class="cx" style="display: block; padding: 0 10px"> title: null,
</span><span class="cx" style="display: block; padding: 0 10px"> date: null,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1572,12 +1631,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Preview installed themes.
</span><span class="cx" style="display: block; padding: 0 10px"> section.container.on( 'click', '.theme-actions .preview-theme', function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var themeId = $( this ).data( 'slug' );
-
- $( '.wp-full-overlay' ).addClass( 'customize-loading' );
- api.panel( 'themes' ).loadThemePreview( themeId ).fail( function() {
- $( '.wp-full-overlay' ).removeClass( 'customize-loading' );
- } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.panel( 'themes' ).loadThemePreview( $( this ).data( 'slug' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Theme navigation in details view.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1763,7 +1817,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Parameters for every API query. Additional params are set in PHP.
</span><span class="cx" style="display: block; padding: 0 10px"> page = Math.ceil( section.loaded / 100 ) + 1;
</span><span class="cx" style="display: block; padding: 0 10px"> params = {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'switch-themes-nonce': api.settings.nonce['switch-themes'],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'nonce': api.settings.nonce.switch_themes,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'wp_customize': 'on',
</span><span class="cx" style="display: block; padding: 0 10px"> 'theme_action': section.params.action,
</span><span class="cx" style="display: block; padding: 0 10px"> 'customized_theme': api.settings.theme.stylesheet,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1780,7 +1834,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> section.headContainer.closest( '.wp-full-overlay' ).addClass( 'loading' );
</span><span class="cx" style="display: block; padding: 0 10px"> section.loading = true;
</span><span class="cx" style="display: block; padding: 0 10px"> section.container.find( '.no-themes' ).hide();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- request = wp.ajax.post( 'customize-load-themes', params );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ request = wp.ajax.post( 'customize_load_themes', params );
</ins><span class="cx" style="display: block; padding: 0 10px"> request.done(function( data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var themes = data.themes, themeControl, newThemeControls;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2213,58 +2267,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @deprecated
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param {string} themeId Theme ID.
</span><span class="cx" style="display: block; padding: 0 10px"> * @returns {jQuery.promise} Promise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> loadThemePreview: function( themeId ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var deferred = $.Deferred(), onceProcessingComplete, overlay, urlParser;
-
- urlParser = document.createElement( 'a' );
- urlParser.href = location.href;
- urlParser.search = $.param( _.extend(
- api.utils.parseQueryString( urlParser.search.substr( 1 ) ),
- {
- theme: themeId,
- changeset_uuid: api.settings.changeset.uuid
- }
- ) );
-
- overlay = $( '.wp-full-overlay' );
- overlay.addClass( 'customize-loading' );
-
- onceProcessingComplete = function() {
- var request;
- if ( api.state( 'processing' ).get() > 0 ) {
- return;
- }
-
- api.state( 'processing' ).unbind( onceProcessingComplete );
-
- request = api.requestChangesetUpdate( {}, { autosave: true } );
- request.done( function() {
- $( window ).off( 'beforeunload.customize-confirm' );
-
- // Include autosaved param to load autosave revision without prompting user to restore it.
- if ( ! api.state( 'saved' ).get() ) {
- urlParser.search += '&customize_autosaved=on';
- }
-
- top.location.href = urlParser.href;
- deferred.resolve();
- } );
- request.fail( function() {
- overlay.removeClass( 'customize-loading' );
- deferred.reject();
- } );
- };
-
- if ( 0 === api.state( 'processing' ).get() ) {
- onceProcessingComplete();
- } else {
- api.state( 'processing' ).bind( onceProcessingComplete );
- }
-
- return deferred.promise();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return api.ThemesPanel.prototype.loadThemePreview.call( this, themeId );
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2844,10 +2852,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( document ).one( 'wp-theme-install-success', function( event, response ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var theme = false, customizeId, themeControl;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( preview ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.notifications.remove( 'theme_installing' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- panel.loadThemePreview( slug ).fail( function() {
- $( '.wp-full-overlay' ).removeClass( 'customize-loading' );
- } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ panel.loadThemePreview( slug );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> api.control.each( function( control ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2899,8 +2906,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Also preview the theme as the event is triggered on Install & Preview.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $( event.target ).hasClass( 'preview' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> preview = true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $( '.wp-full-overlay' ).addClass( 'customize-loading' );
- wp.a11y.speak( $( '#customize-themes-loading-container .customize-loading-text-installing-theme' ).text() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ api.notifications.add( 'theme_installing', new api.OverlayNotification( 'theme_installing', {
+ message: api.l10n.themeDownloading,
+ type: 'info',
+ loading: true
+ } ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2913,24 +2924,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @returns {jQuery.promise} Promise.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> loadThemePreview: function( themeId ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var deferred = $.Deferred(), onceProcessingComplete, overlay, urlParser;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var deferred = $.Deferred(), onceProcessingComplete, urlParser, queryParams;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> urlParser = document.createElement( 'a' );
</span><span class="cx" style="display: block; padding: 0 10px"> urlParser.href = location.href;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- urlParser.search = $.param( _.extend(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ queryParams = _.extend(
</ins><span class="cx" style="display: block; padding: 0 10px"> api.utils.parseQueryString( urlParser.search.substr( 1 ) ),
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> theme: themeId,
</span><span class="cx" style="display: block; padding: 0 10px"> changeset_uuid: api.settings.changeset.uuid
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Include autosaved param to load autosave revision without prompting user to restore it.
+ if ( ! api.state( 'saved' ).get() ) {
+ queryParams.customize_autosaved = 'on';
+ }
+
+ urlParser.search = $.param( queryParams );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Update loading message. Everything else is handled by reloading the page.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $( '#customize-themes-loading-container span' ).hide();
- $( '#customize-themes-loading-container .customize-loading-text' ).css( 'display', 'block' );
- wp.a11y.speak( $( '#customize-themes-loading-container .customize-loading-text' ).text() );
- overlay = $( '.wp-full-overlay' );
- overlay.addClass( 'customize-loading' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.notifications.add( 'theme_previewing', new api.OverlayNotification( 'theme_previewing', {
+ message: api.l10n.themePreviewWait,
+ type: 'info',
+ loading: true
+ } ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> onceProcessingComplete = function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var request;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2940,14 +2958,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> api.state( 'processing' ).unbind( onceProcessingComplete );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- request = api.requestChangesetUpdate();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ request = api.requestChangesetUpdate( {}, { autosave: true } );
</ins><span class="cx" style="display: block; padding: 0 10px"> request.done( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> deferred.resolve();
</span><span class="cx" style="display: block; padding: 0 10px"> $( window ).off( 'beforeunload.customize-confirm' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- window.location.href = urlParser.href;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ window.location.href = urlParser.href; // @todo Use location.replace()?
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> request.fail( function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- overlay.removeClass( 'customize-loading' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // @todo Show notification regarding failure.
+ api.notifications.remove( 'theme_previewing' );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> deferred.reject();
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6230,8 +6251,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> api.state = new api.Values();
</span><span class="cx" style="display: block; padding: 0 10px"> _.each( [
</span><span class="cx" style="display: block; padding: 0 10px"> 'saved',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'autosaved',
</del><span class="cx" style="display: block; padding: 0 10px"> 'saving',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'trashing',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'activated',
</span><span class="cx" style="display: block; padding: 0 10px"> 'processing',
</span><span class="cx" style="display: block; padding: 0 10px"> 'paneVisible',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6279,8 +6300,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> publishSettingsBtn = $( '#publish-settings' ),
</span><span class="cx" style="display: block; padding: 0 10px"> footerActions = $( '#customize-footer-actions' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- saveBtn.show();
-
</del><span class="cx" style="display: block; padding: 0 10px"> api.section( 'publish_settings', function( section ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var updateButtonsState, previewLinkControl, previewLinkControlId = 'changeset_preview_link', updateSectionActive, isSectionActive;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6301,9 +6320,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return {boolean} Is section active.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> isSectionActive = function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! api.state( 'activated' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! api.state( 'activated' ).get() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( api.state( 'trashing' ).get() || 'trash' === api.state( 'changesetStatus' ).get() ) {
+ return false;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( '' === api.state( 'changesetStatus' ).get() && api.state( 'saved' ).get() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6316,6 +6338,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> section.active.set( isSectionActive() );
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px"> api.state( 'activated' ).bind( updateSectionActive );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.state( 'trashing' ).bind( updateSectionActive );
</ins><span class="cx" style="display: block; padding: 0 10px"> api.state( 'saved' ).bind( updateSectionActive );
</span><span class="cx" style="display: block; padding: 0 10px"> api.state( 'changesetStatus' ).bind( updateSectionActive );
</span><span class="cx" style="display: block; padding: 0 10px"> updateSectionActive();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6551,15 +6574,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * due to dependencies on other settings.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> request = wp.ajax.post( 'customize_save', query );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.state( 'processing' ).set( api.state( 'processing' ).get() + 1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Disable save button during the save request.
- saveBtn.prop( 'disabled', true );
-
</del><span class="cx" style="display: block; padding: 0 10px"> api.trigger( 'save', request );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> request.always( function () {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.state( 'processing' ).set( api.state( 'processing' ).get() - 1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> api.state( 'saving' ).set( false );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- saveBtn.prop( 'disabled', false );
</del><span class="cx" style="display: block; padding: 0 10px"> api.unbind( 'change', captureSettingModifiedDuringSave );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6636,7 +6657,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> previewer.send( 'saved', response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> api.state( 'changesetStatus' ).set( response.changeset_status );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- api.state( 'changesetDate' ).set( response.changeset_date );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( response.changeset_date ) {
+ api.state( 'changesetDate' ).set( response.changeset_date );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'publish' === response.changeset_status ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6694,6 +6717,74 @@
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Trash the current changes.
+ *
+ * Revert the Customizer to it's previously-published state.
+ *
+ * @since 4.9.0
+ *
+ * @returns {jQuery.promise} Promise.
+ */
+ trash: function trash() {
+ var request, success, fail;
+
+ api.state( 'trashing' ).set( true );
+ api.state( 'processing' ).set( api.state( 'processing' ).get() + 1 );
+
+ request = wp.ajax.post( 'customize_trash', {
+ customize_changeset_uuid: api.settings.changeset.uuid,
+ nonce: api.settings.nonce.trash
+ } );
+ api.notifications.add( 'changeset_trashing', new api.OverlayNotification( 'changeset_trashing', {
+ type: 'info',
+ message: api.l10n.revertingChanges,
+ loading: true
+ } ) );
+
+ success = function() {
+ var urlParser = document.createElement( 'a' ), queryParams;
+
+ api.state( 'changesetStatus' ).set( 'trash' );
+ api.each( function( setting ) {
+ setting._dirty = false;
+ } );
+ api.state( 'saved' ).set( true );
+
+ // Go back to Customizer without changeset.
+ urlParser.href = location.href;
+ queryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
+ delete queryParams.changeset_uuid;
+ urlParser.search = $.param( queryParams );
+ location.replace( urlParser.href );
+ };
+
+ fail = function( code, message ) {
+ var notificationCode = code || 'unknown_error';
+ api.state( 'processing' ).set( api.state( 'processing' ).get() - 1 );
+ api.state( 'trashing' ).set( false );
+ api.notifications.remove( 'changeset_trashing' );
+ api.notifications.add( notificationCode, new api.Notification( notificationCode, {
+ message: message || api.l10n.unknownError,
+ dismissible: true,
+ type: 'error'
+ } ) );
+ };
+
+ request.done( function( response ) {
+ success( response.message );
+ } );
+
+ request.fail( function( response ) {
+ var code = response.code || 'trashing_failed';
+ if ( response.success || 'non_existent_changeset' === code || 'changeset_already_trashed' === code ) {
+ success( response.message );
+ } else {
+ fail( code, response.message );
+ }
+ } );
+ },
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Builds the front preview url with the current state of customizer.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6842,6 +6933,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> (function( state ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var saved = state.instance( 'saved' ),
</span><span class="cx" style="display: block; padding: 0 10px"> saving = state.instance( 'saving' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ trashing = state.instance( 'trashing' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> activated = state.instance( 'activated' ),
</span><span class="cx" style="display: block; padding: 0 10px"> processing = state.instance( 'processing' ),
</span><span class="cx" style="display: block; padding: 0 10px"> paneVisible = state.instance( 'paneVisible' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6863,7 +6955,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! activated() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> saveBtn.val( api.l10n.activate );
</span><span class="cx" style="display: block; padding: 0 10px"> closeBtn.find( '.screen-reader-text' ).text( api.l10n.cancel );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- publishSettingsBtn.prop( 'disabled', false );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } else if ( '' === changesetStatus.get() && saved() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( api.settings.changeset.currentUserCanPublish ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6871,7 +6962,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> saveBtn.val( api.l10n.saved );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- publishSettingsBtn.prop( 'disabled', true );
</del><span class="cx" style="display: block; padding: 0 10px"> closeBtn.find( '.screen-reader-text' ).text( api.l10n.close );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6899,14 +6989,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> saveBtn.val( api.l10n.publish );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> closeBtn.find( '.screen-reader-text' ).text( api.l10n.cancel );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- publishSettingsBtn.prop( 'disabled', false );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * Save (publish) button should be enabled if saving is not currently happening,
</span><span class="cx" style="display: block; padding: 0 10px"> * and if the theme is not active or the changeset exists but is not published.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- canSave = ! saving() && ( ! activated() || ! saved() || ( changesetStatus() !== selectedChangesetStatus() && '' !== changesetStatus() ) || ( 'future' === selectedChangesetStatus() && changesetDate.get() !== selectedChangesetDate.get() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ canSave = ! saving() && ! trashing() && ( ! activated() || ! saved() || ( changesetStatus() !== selectedChangesetStatus() && '' !== changesetStatus() ) || ( 'future' === selectedChangesetStatus() && changesetDate.get() !== selectedChangesetDate.get() ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> saveBtn.prop( 'disabled', ! canSave );
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6958,6 +7047,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> saving.bind( function( isSaving ) {
</span><span class="cx" style="display: block; padding: 0 10px"> body.toggleClass( 'saving', isSaving );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ trashing.bind( function( isTrashing ) {
+ body.toggleClass( 'trashing', isTrashing );
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> api.bind( 'saved', function( response ) {
</span><span class="cx" style="display: block; padding: 0 10px"> state('saved').set( true );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7028,7 +7120,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Show changeset UUID in URL when in branching mode and there is a saved changeset.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( api.settings.changeset.branching ) {
</span><span class="cx" style="display: block; padding: 0 10px"> changesetStatus.bind( function( newStatus ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- populateChangesetUuidParam( '' !== newStatus && 'publish' !== newStatus );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ populateChangesetUuidParam( '' !== newStatus && 'publish' !== newStatus && 'trash' !== newStatus );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }( api.state ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7105,7 +7197,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Handle dismissal of notice.
</span><span class="cx" style="display: block; padding: 0 10px"> li.find( '.notice-dismiss' ).on( 'click', function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp.ajax.post( 'dismiss_customize_changeset_autosave', {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp.ajax.post( 'customize_dismiss_autosave', {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_customize: 'on',
</span><span class="cx" style="display: block; padding: 0 10px"> customize_theme: api.settings.theme.stylesheet,
</span><span class="cx" style="display: block; padding: 0 10px"> customize_changeset_uuid: api.settings.changeset.uuid,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7532,16 +7624,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> isInsideIframe = true;
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Prompt user with AYS dialog if leaving the Customizer with unsaved changes
- $( window ).on( 'beforeunload.customize-confirm', function() {
- if ( ! isCleanState() ) {
- setTimeout( function() {
- overlay.removeClass( 'customize-loading' );
- }, 1 );
- return api.l10n.saveAlert;
- }
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function startPromptingBeforeUnload() {
+ api.unbind( 'change', startPromptingBeforeUnload );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Prompt user with AYS dialog if leaving the Customizer with unsaved changes
+ $( window ).on( 'beforeunload.customize-confirm', function() {
+ if ( ! isCleanState() ) {
+ setTimeout( function() {
+ overlay.removeClass( 'customize-loading' );
+ }, 1 );
+ return api.l10n.saveAlert;
+ }
+ });
+ }
+ api.bind( 'change', startPromptingBeforeUnload );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> closeBtn.on( 'click.customize-controls-close', function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var clearedToClose = $.Deferred();
</span><span class="cx" style="display: block; padding: 0 10px"> event.preventDefault();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7566,7 +7663,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '' === api.state( 'changesetStatus' ).get() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> clearedToClose.resolve();
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp.ajax.send( 'dismiss_customize_changeset_autosave', {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp.ajax.send( 'customize_dismiss_autosave', {
</ins><span class="cx" style="display: block; padding: 0 10px"> timeout: 500, // Don't wait too long.
</span><span class="cx" style="display: block; padding: 0 10px"> data: {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_customize: 'on',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7987,9 +8084,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Autosave changeset.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ( function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function startAutosaving() {
</ins><span class="cx" style="display: block; padding: 0 10px"> var timeoutId, updateChangesetWithReschedule, scheduleChangesetUpdate, updatePending = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ api.unbind( 'change', startAutosaving ); // Ensure startAutosaving only fires once.
+
</ins><span class="cx" style="display: block; padding: 0 10px"> api.state( 'saved' ).bind( function( isSaved ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isSaved && ! api.settings.changeset.autosaved ) {
</span><span class="cx" style="display: block; padding: 0 10px"> api.settings.changeset.autosaved = true; // Once a change is made then autosaving kicks in.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8040,7 +8139,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $( window ).on( 'beforeunload.wp-customize-changeset-update', function() {
</span><span class="cx" style="display: block; padding: 0 10px"> updateChangesetWithReschedule();
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } ());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
+ api.bind( 'change', startAutosaving );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure TinyMCE dialogs appear above Customizer UI.
</span><span class="cx" style="display: block; padding: 0 10px"> $( document ).one( 'wp-before-tinymce-init', function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8049,6 +8149,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ body.addClass( 'ready' );
</ins><span class="cx" style="display: block; padding: 0 10px"> api.trigger( 'ready' );
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-customize-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-manager.php 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/src/wp-includes/class-wp-customize-manager.php 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -374,10 +374,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> remove_action( 'admin_init', '_maybe_update_plugins' );
</span><span class="cx" style="display: block; padding: 0 10px"> remove_action( 'admin_init', '_maybe_update_themes' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
- add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) );
- add_action( 'wp_ajax_customize-load-themes', array( $this, 'load_themes_ajax' ) );
- add_action( 'wp_ajax_dismiss_customize_changeset_autosave', array( $this, 'handle_dismiss_changeset_autosave_request' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
+ add_action( 'wp_ajax_customize_trash', array( $this, 'handle_changeset_trash_request' ) );
+ add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) );
+ add_action( 'wp_ajax_customize_load_themes', array( $this, 'handle_load_themes_request' ) );
+ add_action( 'wp_ajax_customize_dismiss_autosave', array( $this, 'handle_dismiss_autosave_request' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'customize_register', array( $this, 'register_controls' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2830,6 +2831,65 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Handle request to trash a changeset.
+ *
+ * @since 4.9.0
+ */
+ public function handle_changeset_trash_request() {
+ if ( ! is_user_logged_in() ) {
+ wp_send_json_error( 'unauthenticated' );
+ }
+
+ if ( ! $this->is_preview() ) {
+ wp_send_json_error( 'not_preview' );
+ }
+
+ if ( ! check_ajax_referer( 'trash_customize_changeset', 'nonce', false ) ) {
+ wp_send_json_error( array(
+ 'code' => 'invalid_nonce',
+ 'message' => __( 'There was an authentication problem. Please reload and try again.' ),
+ ) );
+ }
+
+ $changeset_post_id = $this->changeset_post_id();
+
+ if ( ! $changeset_post_id ) {
+ wp_send_json_error( array(
+ 'message' => __( 'No changes saved yet, so there is nothing to trash.' ),
+ 'code' => 'non_existent_changeset',
+ ) );
+ return;
+ }
+
+ if ( $changeset_post_id && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) {
+ wp_send_json_error( array(
+ 'code' => 'changeset_trash_unauthorized',
+ 'message' => __( 'Unable to trash changes.' ),
+ ) );
+ }
+
+ if ( 'trash' === get_post_status( $changeset_post_id ) ) {
+ wp_send_json_error( array(
+ 'message' => __( 'Changes have already been trashed.' ),
+ 'code' => 'changeset_already_trashed',
+ ) );
+ return;
+ }
+
+ $r = wp_trash_post( $changeset_post_id );
+ if ( ! ( $r instanceof WP_Post ) ) {
+ wp_send_json_error( array(
+ 'code' => 'changeset_trash_failure',
+ 'message' => __( 'Unable to trash changes.' ),
+ ) );
+ }
+
+ wp_send_json_success( array(
+ 'message' => __( 'Changes trashed successfully.' ),
+ ) );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Re-map 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * There is essentially a "meta meta" cap in play here, where 'edit_post' meta cap maps to
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3102,12 +3162,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function handle_dismiss_changeset_autosave_request() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function handle_dismiss_autosave_request() {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->is_preview() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( 'not_preview', 400 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! check_ajax_referer( 'dismiss_customize_changeset_autosave', 'nonce', false ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! check_ajax_referer( 'customize_dismiss_autosave', 'nonce', false ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_send_json_error( 'invalid_nonce', 403 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3543,8 +3603,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script type="text/html" id="tmpl-customize-notification">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
- {{{ data.message || data.code }}}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} {{ data.classes || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
+ <div class="notification-message">{{{ data.message || data.code }}}</div>
</ins><span class="cx" style="display: block; padding: 0 10px"> <# if ( data.dismissible ) { #>
</span><span class="cx" style="display: block; padding: 0 10px"> <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php _e( 'Dismiss' ); ?></span></button>
</span><span class="cx" style="display: block; padding: 0 10px"> <# } #>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3576,6 +3636,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </label>
</span><span class="cx" style="display: block; padding: 0 10px"> </div>
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script type="text/html" id="tmpl-customize-trash-changeset-control">
+ <button type="button" class="button-link button-link-delete"><?php _e( 'Trash unpublished changes' ); ?></button>
+ </script>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3901,8 +3964,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $nonces = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'switch-themes' => wp_create_nonce( 'switch-themes' ),
- 'dismiss_autosave' => wp_create_nonce( 'dismiss_customize_changeset_autosave' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'switch_themes' => wp_create_nonce( 'switch_themes' ),
+ 'dismiss_autosave' => wp_create_nonce( 'customize_dismiss_autosave' ),
+ 'trash' => wp_create_nonce( 'trash_customize_changeset' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4159,6 +4223,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->add_control( 'changeset_status', array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'section' => 'publish_settings',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'priority' => 10,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'settings' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'radio',
</span><span class="cx" style="display: block; padding: 0 10px"> 'label' => __( 'Action' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4173,6 +4238,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->add_control( new WP_Customize_Date_Time_Control( $this, 'changeset_scheduled_date', array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'section' => 'publish_settings',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'priority' => 20,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'settings' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'date_time',
</span><span class="cx" style="display: block; padding: 0 10px"> 'min_year' => date( 'Y' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4723,8 +4789,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function load_themes_ajax() {
- check_ajax_referer( 'switch-themes', 'switch-themes-nonce' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function handle_load_themes_request() {
+ check_ajax_referer( 'switch_themes', 'nonce' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! current_user_can( 'switch_themes' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( -1 );
</span></span></pre></div>
<a id="trunksrcwpincludescustomizeclasswpcustomizethemespanelphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/customize/class-wp-customize-themes-panel.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/customize/class-wp-customize-themes-panel.php 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/src/wp-includes/customize/class-wp-customize-themes-panel.php 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -89,10 +89,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <# } #>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </li>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <li id="customize-themes-loading-container">
- <span class="customize-loading-text-installing-theme"><?php _e( 'Downloading your new theme…' ); ?></span>
- <span class="customize-loading-text"><?php _e( 'Setting up your live preview. This may take a bit.' ); ?></span>
- </li><?php // Used as a full-screen overlay transition after clicking to preview a theme. ?>
</del><span class="cx" style="display: block; padding: 0 10px"> <li class="customize-themes-full-container-container">
</span><span class="cx" style="display: block; padding: 0 10px"> <ul class="customize-themes-full-container">
</span><span class="cx" style="display: block; padding: 0 10px"> <li class="customize-themes-notifications"></li>
</span></span></pre></div>
<a id="trunksrcwpincludesjscustomizebasejs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/customize-base.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/customize-base.js 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/src/wp-includes/js/customize-base.js 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -810,6 +810,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> templateId: 'customize-notification',
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Additional class names to add to the notification container.
+ *
+ * @since 4.9.0
+ * @var {string}
+ */
+ classes: '',
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Initialize notification.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -821,6 +829,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {string} [params.setting] - Related setting ID.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {Function} [params.template] - Function for rendering template. If not provided, this will come from templateId.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {string} [params.templateId] - ID for template to render the notification.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {string} [params.classes] - Additional class names to add to the notification container.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param {boolean} [params.dismissible] - Whether the notification can be dismissed.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> initialize: function( code, params ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -834,7 +843,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> data: null,
</span><span class="cx" style="display: block; padding: 0 10px"> setting: null,
</span><span class="cx" style="display: block; padding: 0 10px"> template: null,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- dismissible: false
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ dismissible: false,
+ classes: ''
</ins><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> params
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/src/wp-includes/script-loader.php 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -571,6 +571,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'expandSidebar' => _x( 'Show Controls', 'label for hide controls button without length constraints' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'untitledBlogName' => __( '(Untitled)' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'serverSaveError' => __( 'Failed connecting to the server. Please try saving again.' ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'themeDownloading' => __( 'Downloading your new theme…' ),
+ 'themePreviewWait' => __( 'Setting up your live preview. This may take a bit.' ),
+ 'revertingChanges' => __( 'Reverting unpublished changes…' ),
+ 'trashConfirm' => __( 'Are you sure you would like to discard your unpublished changes?' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> /* translators: %s: URL to the Customizer to load the autosaved version */
</span><span class="cx" style="display: block; padding: 0 10px"> 'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'videoHeaderNotice' => __( 'This theme doesn\'t support video headers on this page. Navigate to the front page or another page that supports video headers.' ),
</span></span></pre></div>
<a id="trunktestsphpunittestsajaxCustomizeManagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/ajax/CustomizeManager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/ajax/CustomizeManager.php 2017-10-02 03:19:17 UTC (rev 41666)
+++ trunk/tests/phpunit/tests/ajax/CustomizeManager.php 2017-10-02 03:36:18 UTC (rev 41667)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -443,23 +443,93 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Test request for trashing a changeset.
+ *
+ * @ticket 39896
+ * @covers WP_Customize_Manager::handle_changeset_trash_request()
+ */
+ public function test_handle_changeset_trash_request() {
+ $uuid = wp_generate_uuid4();
+ $wp_customize = $this->set_up_valid_state( $uuid );
+
+ $this->make_ajax_call( 'customize_trash' );
+ $this->assertFalse( $this->_last_response_parsed['success'] );
+ $this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data']['code'] );
+
+ $nonce = wp_create_nonce( 'trash_customize_changeset' );
+ $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
+ $this->make_ajax_call( 'customize_trash' );
+ $this->assertFalse( $this->_last_response_parsed['success'] );
+ $this->assertEquals( 'non_existent_changeset', $this->_last_response_parsed['data']['code'] );
+
+ $wp_customize->register_controls(); // And settings too.
+ $wp_customize->set_post_value( 'blogname', 'HELLO' );
+ $wp_customize->save_changeset_post( array(
+ 'status' => 'save',
+ ) );
+
+ add_filter( 'map_meta_cap', array( $this, 'return_do_not_allow' ) );
+ $this->make_ajax_call( 'customize_trash' );
+ $this->assertFalse( $this->_last_response_parsed['success'] );
+ $this->assertEquals( 'changeset_trash_unauthorized', $this->_last_response_parsed['data']['code'] );
+ remove_filter( 'map_meta_cap', array( $this, 'return_do_not_allow' ) );
+
+ wp_update_post( array(
+ 'ID' => $wp_customize->changeset_post_id(),
+ 'post_status' => 'trash',
+ ) );
+ $this->make_ajax_call( 'customize_trash' );
+ $this->assertFalse( $this->_last_response_parsed['success'] );
+ $this->assertEquals( 'changeset_already_trashed', $this->_last_response_parsed['data']['code'] );
+
+ wp_update_post( array(
+ 'ID' => $wp_customize->changeset_post_id(),
+ 'post_status' => 'draft',
+ ) );
+
+ $wp_trash_post_count = did_action( 'wp_trash_post' );
+ add_filter( 'pre_trash_post', '__return_false' );
+ $this->make_ajax_call( 'customize_trash' );
+ $this->assertFalse( $this->_last_response_parsed['success'] );
+ $this->assertEquals( 'changeset_trash_failure', $this->_last_response_parsed['data']['code'] );
+ remove_filter( 'pre_trash_post', '__return_false' );
+ $this->assertEquals( $wp_trash_post_count, did_action( 'wp_trash_post' ) );
+
+ $wp_trash_post_count = did_action( 'wp_trash_post' );
+ $this->assertEquals( 'draft', get_post_status( $wp_customize->changeset_post_id() ) );
+ $this->make_ajax_call( 'customize_trash' );
+ $this->assertTrue( $this->_last_response_parsed['success'] );
+ $this->assertEquals( 'trash', get_post_status( $wp_customize->changeset_post_id() ) );
+ $this->assertEquals( $wp_trash_post_count + 1, did_action( 'wp_trash_post' ) );
+ }
+
+ /**
+ * Return caps array containing 'do_not_allow'.
+ *
+ * @return array Caps.
+ */
+ public function return_do_not_allow() {
+ return array( 'do_not_allow' );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Test request for dismissing autosave changesets.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 39896
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers WP_Customize_Manager::handle_dismiss_changeset_autosave_request()
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @covers WP_Customize_Manager::handle_dismiss_autosave_request()
</ins><span class="cx" style="display: block; padding: 0 10px"> * @covers WP_Customize_Manager::dismiss_user_auto_draft_changesets()
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_handle_dismiss_changeset_autosave_request() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_handle_dismiss_autosave_request() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $uuid = wp_generate_uuid4();
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_customize = $this->set_up_valid_state( $uuid );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->make_ajax_call( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->make_ajax_call( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $this->_last_response_parsed['success'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $nonce = wp_create_nonce( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $nonce = wp_create_nonce( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->make_ajax_call( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->make_ajax_call( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $this->_last_response_parsed['success'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -489,7 +559,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( array_merge( $user_auto_draft_ids, $other_user_auto_draft_ids ) as $post_id ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( (bool) get_post_meta( $post_id, '_customize_restore_dismissed', true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->make_ajax_call( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->make_ajax_call( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $this->_last_response_parsed['success'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'auto_draft_dismissed', $this->_last_response_parsed['data'] );
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $user_auto_draft_ids as $post_id ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -502,7 +572,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Subsequent test results in none dismissed.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->make_ajax_call( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->make_ajax_call( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $this->_last_response_parsed['success'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -520,7 +590,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'Foo', get_post( $wp_customize->changeset_post_id() )->post_content );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Since no autosave yet, confirm no action.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->make_ajax_call( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->make_ajax_call( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $this->_last_response_parsed['success'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -540,13 +610,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertContains( 'Bar', $autosave_revision->post_content );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Confirm autosave gets deleted.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->make_ajax_call( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->make_ajax_call( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $this->_last_response_parsed['success'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'autosave_revision_deleted', $this->_last_response_parsed['data'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( wp_get_post_autosave( $wp_customize->changeset_post_id() ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Since no autosave yet, confirm no action.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->make_ajax_call( 'dismiss_customize_changeset_autosave' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->make_ajax_call( 'customize_dismiss_autosave' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $this->_last_response_parsed['success'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>