diff --git a/admin/partials/nginx-helper-general-options.php b/admin/partials/nginx-helper-general-options.php index ef1423d..a91eb53 100644 --- a/admin/partials/nginx-helper-general-options.php +++ b/admin/partials/nginx-helper-general-options.php @@ -59,17 +59,24 @@ $nginx_helper_admin->nginx_helper_default_settings() ); - $site_options = get_site_option( 'rt_wp_nginx_helper_options', array() ); + $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 ) { + 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 ] ) ) { + // Uncheck checkbox fields whose default value is `1` but user has unchecked. + if ( 1 === $default_setting_value && isset( $site_options[ $default_setting_field ] ) && empty( $all_inputs[ $default_setting_field ] ) ) { - $nginx_settings[ $default_setting_field ] = 0; + $nginx_settings[ $default_setting_field ] = 0; - } - } + } + + // Populate the setting field with default value when it is empty. + if ( '' === $nginx_settings[ $default_setting_field ] ) { + + $nginx_settings[ $default_setting_field ] = $default_setting_value; + + } + } if ( ( ! is_numeric( $nginx_settings['log_filesize'] ) ) || ( empty( $nginx_settings['log_filesize'] ) ) ) { $error_log_filesize = __( 'Log file size must be a number.', 'nginx-helper' );