Code review comments.

Code review comments.

diff --git a/app/assets/javascripts/discourse/app/lib/theme-selector.js b/app/assets/javascripts/discourse/app/lib/theme-selector.js
index 32326b4..fdc4cb9 100644
--- a/app/assets/javascripts/discourse/app/lib/theme-selector.js
+++ b/app/assets/javascripts/discourse/app/lib/theme-selector.js
@@ -2,7 +2,7 @@ import cookie, { removeCookie } from "discourse/lib/cookie";
 import I18n from "I18n";
 import deprecated from "discourse-common/lib/deprecated";
 
-const keySelector = "meta[name=discourse_theme_ids]";
+const keySelector = "meta[name=discourse_theme_id]";
 
 export function currentThemeKey() {
   // eslint-disable-next-line no-console
diff --git a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js
index 7c78d2d..18f7b80 100644
--- a/app/assets/javascripts/discourse/lib/bootstrap-json/index.js
+++ b/app/assets/javascripts/discourse/lib/bootstrap-json/index.js
@@ -34,9 +34,9 @@ function head(buffer, bootstrap) {
     buffer.push(`<meta name="csrf-param" content="authenticity_token">`);
     buffer.push(`<meta name="csrf-token" content="${bootstrap.csrf_token}">`);
   }
-  if (bootstrap.theme_ids) {
+  if (bootstrap.theme_id) {
     buffer.push(
-      `<meta name="discourse_theme_ids" content="${bootstrap.theme_ids}">`
+      `<meta name="discourse_theme_id" content="${bootstrap.theme_id}">`
     );
   }
 
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
index 6869f9f..312fd2a 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-interface-test.js
@@ -100,7 +100,7 @@ acceptance("User Preferences - Interface", function (needs) {
 
   test("shows no default option for light scheme when theme's color scheme is user selectable", async function (assert) {
     let meta = document.createElement("meta");
-    meta.name = "discourse_theme_ids";
+    meta.name = "discourse_theme_id";
     meta.content = "2";
     document.getElementsByTagName("head")[0].appendChild(meta);
 
@@ -128,7 +128,7 @@ acceptance("User Preferences - Interface", function (needs) {
     await selectKit(".light-color-scheme .select-kit").expand();
     assert.equal(count(".light-color-scheme .select-kit .select-kit-row"), 2);
 
-    document.querySelector("meta[name='discourse_theme_ids']").remove();
+    document.querySelector("meta[name='discourse_theme_id']").remove();
   });
 });
 
diff --git a/app/controllers/bootstrap_controller.rb b/app/controllers/bootstrap_controller.rb
index 5bb4dc6..7840dca 100644
--- a/app/controllers/bootstrap_controller.rb
+++ b/app/controllers/bootstrap_controller.rb
@@ -51,7 +51,7 @@ class BootstrapController < ApplicationController
     ).map { |f| script_asset_path(f) }
 
     bootstrap = {
-      theme_ids: [theme_id],
+      theme_id: theme_id,
       title: SiteSetting.title,
       current_homepage: current_homepage,
       locale_script: locale,
diff --git a/app/controllers/stylesheets_controller.rb b/app/controllers/stylesheets_controller.rb
index 427f2b9..df53cf5 100644
--- a/app/controllers/stylesheets_controller.rb
+++ b/app/controllers/stylesheets_controller.rb
@@ -47,7 +47,7 @@ class StylesheetsController < ApplicationController
         theme_id =
           if target.include?("theme")
             split_target, theme_id = target.split(/_(-?[0-9]+)/)
-            Theme.where(id: theme_id).pluck_first(:id) if theme_id.present?
+            theme_id if theme_id.present? && Theme.exists?(id: theme_id)
           else
             split_target, color_scheme_id = target.split(/_(-?[0-9]+)/)
             Theme.where(color_scheme_id: color_scheme_id).pluck_first(:id)
diff --git a/app/models/theme.rb b/app/models/theme.rb
index ad5f63b..fe71405 100644
--- a/app/models/theme.rb
+++ b/app/models/theme.rb
@@ -203,6 +203,7 @@ class Theme < ActiveRecord::Base
 
   def self.transform_ids(id)
     return [] if id.blank?
+    id = id.to_i
 
     get_set_cache "transformed_ids_#{id}" do
       all_ids =
@@ -297,8 +298,7 @@ class Theme < ActiveRecord::Base
   end
 
   def self.lookup_modifier(theme_ids, modifier_name)
-    theme_ids = [theme_ids] unless Array === theme_ids
-    theme_ids = transform_ids(theme_ids)
+    theme_ids = [theme_ids] unless theme_ids.is_a?(Array)
 
     get_set_cache("#{theme_ids.join(",")}:modifier:#{modifier_name}:#{Theme.compiler_version}") do
       ThemeModifierSet.resolve_modifier_for_themes(theme_ids, modifier_name)
@@ -350,7 +350,7 @@ class Theme < ActiveRecord::Base
   end
 
   def self.refresh_message_for_targets(targets, theme_ids)
-    theme_ids = [theme_ids] unless theme_ids === Array
+    theme_ids = [theme_ids] unless theme_ids.is_a?(Array)
 
     targets.each_with_object([]) do |target, data|
       theme_ids.each do |theme_id|
diff --git a/app/views/common/_discourse_publish_stylesheet.html.erb b/app/views/common/_discourse_publish_stylesheet.html.erb
index 90fe9a9..ae48d98 100644
--- a/app/views/common/_discourse_publish_stylesheet.html.erb
+++ b/app/views/common/_discourse_publish_stylesheet.html.erb
@@ -1,4 +1,4 @@
-<%= discourse_stylesheet_link_tag 'publish', theme_ids: nil %>
+<%= discourse_stylesheet_link_tag 'publish', theme_id: nil %>
 
 <%- if rtl? %>
   <%= discourse_stylesheet_link_tag(mobile_view? ? :publish_mobile_rtl : :publish_mobile_rtl) %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 47159a6..b5ec502 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -5,7 +5,7 @@
     <meta charset="utf-8">
     <title><%= content_for?(:title) ? yield(:title) : SiteSetting.title %></title>
     <meta name="description" content="<%= @description_meta || SiteSetting.site_description %>">
-    <meta name="discourse_theme_ids" content="<%= theme_id %>">
+    <meta name="discourse_theme_id" content="<%= theme_id %>">
     <meta name="discourse_current_homepage" content="<%= current_homepage %>">
     <%= render partial: "layouts/head" %>
     <%= discourse_csrf_tags %>
@@ -90,6 +90,9 @@
 
     <%- unless customization_disabled? %>
       <%= theme_lookup("header") %>
+    <%- end %>
+
+    <%- if allow_plugins? %>
       <%= build_plugin_html 'server:header' %>
     <%- end %>
 
@@ -115,6 +118,9 @@
     <%- unless customization_disabled? %>
       <%= theme_lookup("body_tag") %>
     <%- end %>
-    <%= build_plugin_html 'server:before-body-close' %>
+
+    <%- if allow_plugins? %>
+      <%= build_plugin_html 'server:before-body-close' %>
+    <%- end %>
   </body>
 </html>
diff --git a/app/views/layouts/embed.html.erb b/app/views/layouts/embed.html.erb
index 42b70d0..90711df 100644
--- a/app/views/layouts/embed.html.erb
+++ b/app/views/layouts/embed.html.erb
@@ -3,7 +3,7 @@
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, viewport-fit=cover">
-    <%= discourse_stylesheet_link_tag 'embed', theme_ids: nil %>
+    <%= discourse_stylesheet_link_tag 'embed', theme_id: nil %>
     <%- unless customization_disabled? %>
       <%= discourse_stylesheet_link_tag  :embedded_theme %>
     <%- end %>
diff --git a/app/views/layouts/finish_installation.html.erb b/app/views/layouts/finish_installation.html.erb
index 22c2b04..4cff210 100644
--- a/app/views/layouts/finish_installation.html.erb
+++ b/app/views/layouts/finish_installation.html.erb
@@ -1,6 +1,6 @@
 <html>
   <head>
-    <%= discourse_stylesheet_link_tag 'wizard', theme_ids: nil %>
+    <%= discourse_stylesheet_link_tag 'wizard', theme_id: nil %>
     <%= discourse_color_scheme_stylesheets %>
 
     <%= render partial: "layouts/head" %>
diff --git a/app/views/layouts/no_ember.html.erb b/app/views/layouts/no_ember.html.erb

[... diff too long, it was truncated ...]

GitHub sha: 44aa46ca05939cc986ae8e42b24b6101f49e8b5a

This commit appears in #13397 which was approved by OsamaSayegh and davidtaylorhq. It was merged by tgxworld.

Oops I forgot to squash the commits. My bad.