From f65c46cc50ed9665f352a3a19159a03259b92141 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 22 Jan 2018 06:14:10 +0000 Subject: [PATCH] Customize: Prevent showing SFTP theme installation notification in multisite when user cannot install themes. Props flixos90. See #37661, #42184. Fixes #42674. git-svn-id: https://develop.svn.wordpress.org/trunk@42536 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 6 +++--- src/wp-includes/class-wp-customize-manager.php | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index d9db2e600a..c7b5905f43 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -2567,7 +2567,7 @@ // Temporary special function since supplying SFTP credentials does not work yet. See #42184. function disableInstallButtons() { - return disableSwitchButtons() || true === api.settings.theme._filesystemCredentialsNeeded; + return disableSwitchButtons() || false === api.settings.theme._canInstall || true === api.settings.theme._filesystemCredentialsNeeded; } section.overlay.find( 'button.preview, button.preview-theme' ).toggleClass( 'disabled', disableSwitchButtons() ); @@ -3064,7 +3064,7 @@ api.Panel.prototype.attachEvents.apply( panel ); // Temporary since supplying SFTP credentials does not work yet. See #42184 - if ( api.settings.theme._filesystemCredentialsNeeded ) { + if ( api.settings.theme._canInstall && api.settings.theme._filesystemCredentialsNeeded ) { panel.notifications.add( new api.Notification( 'theme_install_unavailable', { message: api.l10n.themeInstallUnavailable, type: 'info', @@ -5092,7 +5092,7 @@ // Temporary special function since supplying SFTP credentials does not work yet. See #42184. function disableInstallButtons() { - return disableSwitchButtons() || true === api.settings.theme._filesystemCredentialsNeeded; + return disableSwitchButtons() || false === api.settings.theme._canInstall || true === api.settings.theme._filesystemCredentialsNeeded; } function updateButtons() { control.container.find( 'button.preview, button.preview-theme' ).toggleClass( 'disabled', disableSwitchButtons() ); diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index fe22d87a06..c453fc0841 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -4702,8 +4702,9 @@ final class WP_Customize_Manager { 'previewFrameSensitivity' => 2000, ), 'theme' => array( - 'stylesheet' => $this->get_stylesheet(), - 'active' => $this->is_theme_active(), + 'stylesheet' => $this->get_stylesheet(), + 'active' => $this->is_theme_active(), + '_canInstall' => current_user_can( 'install_themes' ), ), 'url' => array( 'preview' => esc_url_raw( $this->get_preview_url() ),