FIX: defines an enabled_site_setting

FIX: defines an enabled_site_setting

This will amongst other things prevent to load plugin’s code if the plugin is disabled.

diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index a6c73bf..1396682 100755
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1,5 +1,7 @@
 en:
   site_settings:
+    discourse_adplugin_enabled: Enable the discourse-adplugin.
+
     no_ads_for_personal_messages: "Don't show ads when viewing personal messages"
     no_ads_for_restricted_categories: "Don't show ads in categories that aren't visible to everyone."
     no_ads_for_groups: "Don't show ads to users in these groups."
diff --git a/config/settings.yml b/config/settings.yml
index 131febd..5c3abfd 100755
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -1,4 +1,7 @@
 ad_plugin:
+  discourse_adplugin_enabled:
+    client: true
+    default: true
   no_ads_for_personal_messages:
     client: true
     default: true
diff --git a/plugin.rb b/plugin.rb
index 45df3de..4abb938 100755
--- a/plugin.rb
+++ b/plugin.rb
@@ -10,6 +10,8 @@ register_asset "stylesheets/adplugin.scss"
 
 add_admin_route 'admin.adplugin.house_ads.title', 'houseAds'
 
+enabled_site_setting :discourse_adplugin_enabled
+
 module ::AdPlugin
   def self.plugin_name
     'discourse-adplugin'.freeze

GitHub sha: 75fb2bf8

1 Like