From a397b8f6bb7e98146914802abdaa461bcde482d0 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 7 Nov 2017 04:16:11 +0000 Subject: [PATCH] Customize: Fix logic inversion in [42113] which prevented themes from being installed in Customizer. Also fix PHP notice related to parent themes and WordPress.org theme query results. Props dd32, obenland, celloexpressions, westonruter, atachibana for testing. See #42406, #37661. Fixes #42442. git-svn-id: https://develop.svn.wordpress.org/trunk@42122 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 7 +++++-- src/wp-includes/class-wp-customize-manager.php | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 2d13952a42..5ff47c4998 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -3202,7 +3202,7 @@ } // Prevent loading a non-active theme preview when there is a drafted/scheduled changeset. - if ( panel.canSwitchTheme( slug ) ) { + if ( ! panel.canSwitchTheme( slug ) ) { deferred.reject({ errorCode: 'theme_switch_unavailable' }); @@ -3299,7 +3299,10 @@ // Prevent loading a non-active theme preview when there is a drafted/scheduled changeset. if ( ! panel.canSwitchTheme( themeId ) ) { - return deferred.reject().promise(); + deferred.reject({ + errorCode: 'theme_switch_unavailable' + }); + return deferred.promise(); } urlParser = document.createElement( 'a' ); diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 607349b04a..bb4aafb0b7 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -5446,7 +5446,12 @@ final class WP_Customize_Manager { $theme->id = $theme->slug; $theme->screenshot = array( $theme->screenshot_url ); $theme->authorAndUri = $theme->author; - $theme->parent = ( $theme->slug === $theme->template ) ? false : $theme->template; // The .org API does not seem to return the parent in a documented way; however, this check should yield a similar result in most cases. + // The .org API can return the full parent theme details if passed the 'parent' arg, or if passed the 'template' option it'll return that in the event it's a child theme. + if ( isset( $theme->parent ) ) { + $theme->parent = $theme->parent['slug']; + } else { + $theme->parent = false; + } unset( $theme->slug ); unset( $theme->screenshot_url ); unset( $theme->author );