Skip to content

Commit

Permalink
refactor: updates default options handling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathan-Amaankhan committed Apr 1, 2024
1 parent 01424b0 commit 5d779c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion admin/class-nginx-helper-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function nginx_helper_default_settings() {
'purge_page_on_mod' => 1,
'purge_page_on_new_comment' => 1,
'purge_page_on_deleted_comment' => 1,
'purge_feeds' => 0,
'purge_feeds' => 1,
'redis_hostname' => '127.0.0.1',
'redis_port' => '6379',
'redis_prefix' => 'nginx-cache:',
Expand Down
12 changes: 12 additions & 0 deletions admin/partials/nginx-helper-general-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
$nginx_helper_admin->nginx_helper_default_settings()
);

$site_options = get_site_option( 'rt_wp_nginx_helper_options', array() );

// Uncheck checkbox fields whose default value is `1` but user has unchecked.
foreach ( $nginx_helper_admin->nginx_helper_default_settings() as $default_setting_field => $default_setting_value ) {

if ( 1 === $default_setting_value && isset( $site_options[ $default_setting_field ] ) && empty( $all_inputs[ $default_setting_field ] ) ) {

$nginx_settings[ $default_setting_field ] = 0;

}
}

if ( ( ! is_numeric( $nginx_settings['log_filesize'] ) ) || ( empty( $nginx_settings['log_filesize'] ) ) ) {
$error_log_filesize = __( 'Log file size must be a number.', 'nginx-helper' );
unset( $nginx_settings['log_filesize'] );
Expand Down

0 comments on commit 5d779c4

Please sign in to comment.