@@ -80,24 +80,28 @@ public static function settings(): array
8080 type: SettingType::Boolean,
8181 default: false ,
8282 section: 'rollbar_wp_general ' ,
83+ alwaysSave: true ,
8384 ),
8485 'server_side_access_token ' => new Setting (
8586 id: 'server_side_access_token ' ,
8687 type: SettingType::Text,
8788 default: '' ,
8889 section: 'rollbar_wp_general ' ,
90+ alwaysSave: true ,
8991 ),
9092 'js_logging_enabled ' => new Setting (
9193 id: 'js_logging_enabled ' ,
9294 type: SettingType::Boolean,
9395 default: false ,
9496 section: 'rollbar_wp_general ' ,
97+ alwaysSave: true ,
9598 ),
9699 'client_side_access_token ' => new Setting (
97100 id: 'client_side_access_token ' ,
98101 type: SettingType::Text,
99102 default: '' ,
100103 section: 'rollbar_wp_general ' ,
104+ alwaysSave: true ,
101105 ),
102106 'environment ' => new Setting (
103107 id: 'environment ' ,
@@ -108,6 +112,7 @@ public static function settings(): array
108112 'precendence over the default value.</strong></p> ' ,
109113 default: 'production ' ,
110114 section: 'rollbar_wp_general ' ,
115+ alwaysSave: true ,
111116 ),
112117 'included_errno ' => new Setting (
113118 id: 'included_errno ' ,
@@ -127,6 +132,7 @@ public static function settings(): array
127132 E_ALL => 'Absolutely everything (E_ALL) ' ,
128133 ],
129134 section: 'rollbar_wp_general ' ,
135+ alwaysSave: true ,
130136 ),
131137 'agent_log_location ' => new Setting (
132138 id: 'agent_log_location ' ,
@@ -450,6 +456,11 @@ public static function preUpdate(array $settings): array
450456
451457 // Don't store default values in the database, so future updates to default values in the SDK get propagated.
452458 foreach ($ settings as $ setting_name => $ setting_value ) {
459+ // Always save settings that are marked as alwaysSave.
460+ $ settingConfig = self ::settings ()[$ setting_name ] ?? null ;
461+ if (null !== $ settingConfig && $ settingConfig ->alwaysSave ) {
462+ continue ;
463+ }
453464 // Loose comparison to allow for boolean values to be set to 0 or 1 and integers to be strings, which is how
454465 // they are posted via HTTP.
455466 if ($ setting_value == Plugin::getInstance ()->settingsInstance ()->getDefaultOption ($ setting_name )) {
@@ -501,15 +512,15 @@ public function set(string $name, mixed $value): void
501512 */
502513 public function saveSettings (array $ settings ): void
503514 {
504- $ option = get_option (' rollbar_wp ' );
515+ $ option = get_option (self :: OPTIONS_KEY );
505516
506517 $ option = array_merge ($ option , $ settings );
507518
508519 foreach ($ settings as $ setting => $ value ) {
509520 $ this ->settings [$ setting ] = $ value ;
510521 }
511522
512- update_option (' rollbar_wp ' , $ option );
523+ update_option (self :: OPTIONS_KEY , $ option );
513524 }
514525
515526 /**
@@ -678,8 +689,8 @@ public static function normalizeSettings(array $options): array
678689 $ options = array_intersect_key ($ options , array_flip (self ::listOptions ()));
679690
680691 foreach (self ::settings () as $ key => $ setting ) {
681- // 'access_token' and 'enabled' are different in WordPress plugin
682- // look for 'server_side_access_token' and 'php_logging_enabled' above
692+ // 'access_token' and 'enabled' are different in the WordPress plugin look for 'server_side_access_token'
693+ // and 'php_logging_enabled' above.
683694 if (in_array ($ key , ['access_token ' , 'enabled ' ])) {
684695 continue ;
685696 }
0 commit comments