Skip to content

Commit 5d779c4

Browse files
refactor: updates default options handling logic
1 parent 01424b0 commit 5d779c4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

admin/class-nginx-helper-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function nginx_helper_default_settings() {
272272
'purge_page_on_mod' => 1,
273273
'purge_page_on_new_comment' => 1,
274274
'purge_page_on_deleted_comment' => 1,
275-
'purge_feeds' => 0,
275+
'purge_feeds' => 1,
276276
'redis_hostname' => '127.0.0.1',
277277
'redis_port' => '6379',
278278
'redis_prefix' => 'nginx-cache:',

admin/partials/nginx-helper-general-options.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
$nginx_helper_admin->nginx_helper_default_settings()
6060
);
6161

62+
$site_options = get_site_option( 'rt_wp_nginx_helper_options', array() );
63+
64+
// Uncheck checkbox fields whose default value is `1` but user has unchecked.
65+
foreach ( $nginx_helper_admin->nginx_helper_default_settings() as $default_setting_field => $default_setting_value ) {
66+
67+
if ( 1 === $default_setting_value && isset( $site_options[ $default_setting_field ] ) && empty( $all_inputs[ $default_setting_field ] ) ) {
68+
69+
$nginx_settings[ $default_setting_field ] = 0;
70+
71+
}
72+
}
73+
6274
if ( ( ! is_numeric( $nginx_settings['log_filesize'] ) ) || ( empty( $nginx_settings['log_filesize'] ) ) ) {
6375
$error_log_filesize = __( 'Log file size must be a number.', 'nginx-helper' );
6476
unset( $nginx_settings['log_filesize'] );

0 commit comments

Comments
 (0)