File tree Expand file tree Collapse file tree 2 files changed +18
-20
lines changed Expand file tree Collapse file tree 2 files changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -264,23 +264,18 @@ public static function refresh_htaccess() {
264
264
* @param string $value Setting value.
265
265
*/
266
266
public static function update_setting ( $ key , $ value ) {
267
- $ settings = \ZeroSpam \Core \Settings::get_settings ();
268
- $ new_settings = array ();
269
-
270
- if ( ! isset ( $ settings [ $ key ] ) ) {
267
+ $ settings = \ZeroSpam \Core \Settings::get_settings ();
268
+ if ( empty ( $ settings [ $ key ] ) ) {
271
269
self ::log ( $ key . ' is not a valid setting key. ' );
272
270
return false ;
273
271
}
274
272
275
- foreach ( $ settings as $ k => $ array ) {
276
- if ( $ key === $ k ) {
277
- $ new_settings [ $ k ] = $ value ;
278
- } else {
279
- $ new_settings [ $ k ] = isset ( $ array ['value ' ] ) ? $ array ['value ' ] : false ;
280
- }
281
- }
273
+ $ module = $ settings [ $ key ]['module ' ];
274
+ $ module_settings = get_option ( "zero-spam- $ module " );
275
+
276
+ $ module_settings [ $ key ] = $ value ;
282
277
283
- update_option ( ' wpzerospam ' , $ new_settings , true );
278
+ update_option ( " zero-spam- $ module " , $ module_settings , true );
284
279
285
280
return true ;
286
281
}
Original file line number Diff line number Diff line change @@ -17,17 +17,20 @@ public function autoconfigure() {
17
17
* Outputs settings
18
18
*/
19
19
public function settings () {
20
- $ zerospam_settings = \ZeroSpam \Core \Settings::get_settings ();
21
- $ settings = array ();
20
+ $ modules = \ZeroSpam \Core \Settings::get_settings_by_module ();
21
+ $ settings = array ();
22
22
23
- foreach ( $ zerospam_settings as $ key => $ setting ) {
24
- $ settings [] = array (
25
- 'setting ' => $ key ,
26
- 'value ' => isset ( $ setting ['value ' ] ) ? $ setting ['value ' ] : false ,
27
- );
23
+ foreach ( $ modules as $ module => $ module_settings ) {
24
+ foreach ( $ module_settings as $ key => $ setting ) {
25
+ $ settings [] = array (
26
+ 'module ' => $ module ,
27
+ 'setting ' => $ key ,
28
+ 'value ' => isset ( $ setting ['value ' ] ) ? $ setting ['value ' ] : false ,
29
+ );
30
+ }
28
31
}
29
32
30
- $ fields = array ( 'setting ' , 'value ' );
33
+ $ fields = array ( 'module ' , ' setting ' , 'value ' );
31
34
WP_CLI \Utils \format_items ( 'table ' , $ settings , $ fields );
32
35
}
33
36
You can’t perform that action at this time.
0 commit comments