diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index a6ff9ce..46b04c7 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -282,7 +282,29 @@ public function nginx_helper_default_settings() { ); } - + + public function store_default_options() { + $options = get_site_option( 'rt_wp_nginx_helper_options', array() ); + $default_settings = $this->nginx_helper_default_settings(); + + $removable_default_settings = array( + 'redis_port', + 'redis_prefix', + 'redis_hostname', + 'redis_database', + 'redis_unix_socket' + ); + + // Remove all the keys that are not to be stored by default. + foreach ( $removable_default_settings as $removable_key ) { + unset( $default_settings[ $removable_key ] ); + } + + $diffed_options = wp_parse_args( $options, $default_settings ); + + add_site_option( 'rt_wp_nginx_helper_options', $diffed_options ); + } + /** * Get settings. * diff --git a/includes/class-nginx-helper-activator.php b/includes/class-nginx-helper-activator.php index ec17992..1b672cd 100644 --- a/includes/class-nginx-helper-activator.php +++ b/includes/class-nginx-helper-activator.php @@ -57,6 +57,10 @@ public static function activate() { $role->add_cap( 'Nginx Helper | Purge cache' ); wp_schedule_event( time(), 'daily', 'rt_wp_nginx_helper_check_log_file_size_daily' ); + + if( method_exists( $nginx_helper_admin, 'store_default_options' ) ) { + $nginx_helper_admin->store_default_options(); + } }