From e2b25e6159abf8a86f02c3b9173bc20fa11a266e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 22 Jan 2018 19:09:16 +0000 Subject: [PATCH] Customize: Let default status for Customizer be `draft` if user does not have capability to `publish`. Amends [41626]. Props sayedwp, westonruter. See #30937. Fixes #42686. git-svn-id: https://develop.svn.wordpress.org/trunk@42543 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index c7b5905f43..5afcd783bd 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -7904,7 +7904,7 @@ previewerAlive = state.instance( 'previewerAlive' ), editShortcutVisibility = state.instance( 'editShortcutVisibility' ), changesetLocked = state.instance( 'changesetLocked' ), - populateChangesetUuidParam; + populateChangesetUuidParam, defaultSelectedChangesetStatus; state.bind( 'change', function() { var canSave; @@ -7938,9 +7938,7 @@ } else { saveBtn.val( api.l10n.schedule ); } - } else if ( ! api.settings.changeset.currentUserCanPublish ) { - selectedChangesetStatus( 'draft' ); - } else { + } else if ( api.settings.changeset.currentUserCanPublish ) { saveBtn.val( api.l10n.publish ); } closeBtn.find( '.screen-reader-text' ).text( api.l10n.cancel ); @@ -7962,12 +7960,14 @@ return status; }; + defaultSelectedChangesetStatus = api.settings.changeset.currentUserCanPublish ? 'publish' : 'draft'; + // Set default states. changesetStatus( api.settings.changeset.status ); changesetLocked( Boolean( api.settings.changeset.lockUser ) ); changesetDate( api.settings.changeset.publishDate ); selectedChangesetDate( api.settings.changeset.publishDate ); - selectedChangesetStatus( '' === api.settings.changeset.status || 'auto-draft' === api.settings.changeset.status ? 'publish' : api.settings.changeset.status ); + selectedChangesetStatus( '' === api.settings.changeset.status || 'auto-draft' === api.settings.changeset.status ? defaultSelectedChangesetStatus : api.settings.changeset.status ); selectedChangesetStatus.link( changesetStatus ); // Ensure that direct updates to status on server via wp.customizer.previewer.save() will update selection. saved( true ); if ( '' === changesetStatus() ) { // Handle case for loading starter content.