From d0268ece09788c48d226fa5fbee416c0717b0d2c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 13 Jun 2020 14:24:30 +0000 Subject: [PATCH] Themes: Ensure the theme slug is set before checking if the theme is installed or active. This fixes an issue with every installed theme being marked as active on Themes screen. The slug is set on Add Themes screen, but not on Themes. Follow-up to [47924]. Props BackuPs, mukesh27, SergeyBiryukov. Fixes #50381. See #50334. git-svn-id: https://develop.svn.wordpress.org/trunk@48037 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/theme.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 2115037671..a7481053b4 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -28,14 +28,16 @@ themes.Model = Backbone.Model.extend({ initialize: function() { var description; - // If the theme is already installed, set an attribute. - if ( _.indexOf( themes.data.installedThemes, this.get( 'slug' ) ) !== -1 ) { - this.set({ installed: true }); - } + if ( this.get( 'slug' ) ) { + // If the theme is already installed, set an attribute. + if ( _.indexOf( themes.data.installedThemes, this.get( 'slug' ) ) !== -1 ) { + this.set({ installed: true }); + } - // If the theme is active, set an attribute. - if ( themes.data.activeTheme === this.get( 'slug' ) ) { - this.set({ active: true }); + // If the theme is active, set an attribute. + if ( themes.data.activeTheme === this.get( 'slug' ) ) { + this.set({ active: true }); + } } // Set the attributes.