@@ -22,7 +22,7 @@ protected function onBoot(): void
2222 #[\Override]
2323 public function onActivation (): void
2424 {
25- $ this ->registerOptions ();
25+ $ this ->addOptions ();
2626 }
2727
2828 #[\Override]
@@ -52,9 +52,17 @@ public function onInit(): void
5252 * to preload them on each page and avoid
5353 * extra database queries.
5454 */
55- protected function registerOptions (): void
55+ protected function addOptions (): void
5656 {
57- foreach (SettingName::cases () as $ name ) {
57+ // Add options with default values
58+ add_option (SettingName::ENABLED , '1 ' , null , true );
59+
60+ // Autoload the option introduced in a previous release.
61+ update_option (SettingName::CUSTOM_DOMAIN , get_option (SettingName::CUSTOM_DOMAIN ), true );
62+
63+ // Add all remaining options
64+ $ optionNames = array_diff (SettingName::cases (), [SettingName::ENABLED ]);
65+ foreach ($ optionNames as $ name ) {
5866 add_option ($ name , null , null , true );
5967 }
6068 }
@@ -94,8 +102,7 @@ protected function defineAdminPage(): void
94102 ->docs ('https://docs.simpleanalytics.com/bypass-ad-blockers ' );
95103
96104 $ tab ->checkbox (SettingName::ENABLED , 'Enabled ' )
97- ->description ('Enable or disable Simple Analytics on your website. ' )
98- ->default (true );
105+ ->description ('Enable or disable Simple Analytics on your website. ' );
99106 })
100107 ->tab ('Ignore Rules ' , function (Tab $ tab ) {
101108 $ tab ->icon (get_icon ('eye-slash ' ));
@@ -130,8 +137,7 @@ protected function defineAdminPage(): void
130137 ->docs ('https://docs.simpleanalytics.com/trigger-custom-page-views#use-custom-collection-anyway ' );
131138
132139 $ tab ->checkbox (SettingName::NOSCRIPT , 'Support no JavaScript mode ' )
133- ->description ('Collect analytics from visitors with disabled or no JavaScript. ' )
134- ->default (false );
140+ ->description ('Collect analytics from visitors with disabled or no JavaScript. ' );
135141
136142 $ tab ->input (SettingName::ONLOAD_CALLBACK , 'Onload Callback ' )
137143 ->description ('JavaScript function to call when the script is loaded. ' )
0 commit comments