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
This commit is contained in:
Sergey Biryukov 2020-06-13 14:24:30 +00:00
parent a0742854fa
commit d0268ece09

View File

@ -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.