From 43a5d7110e275f7898bcf17024de38b23ec1ce5c Mon Sep 17 00:00:00 2001 From: Jonathan Daggerhart Date: Mon, 28 Sep 2015 21:47:36 -0400 Subject: [PATCH] allow for very-granular default settings so that updates can make use of default values --- includes/wp-option-settings.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/wp-option-settings.php b/includes/wp-option-settings.php index 82739cc..e290e90 100644 --- a/includes/wp-option-settings.php +++ b/includes/wp-option-settings.php @@ -16,11 +16,16 @@ class WP_Option_Settings { /** * @param $option_name * @param array $default_settings + * @param bool|TRUE $granular_defaults */ - function __construct( $option_name, $default_settings = array() ){ + function __construct( $option_name, $default_settings = array(), $granular_defaults = true ){ $this->option_name = $option_name; $this->default_settings = $default_settings; $this->values = get_option( $this->option_name, $this->default_settings ); + + if ( $granular_defaults ) { + $this->values = array_replace_recursive( $this->default_settings, $this->values ); + } } function __get( $key ){