diff options
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php')
-rw-r--r-- | plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php index ca8e1ec3..3a20ea80 100644 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php +++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-site-settings-endpoint.php @@ -263,7 +263,7 @@ class WPCOM_JSON_API_Site_Settings_Endpoint extends WPCOM_JSON_API_Endpoint { */ protected function get_cast_option_value_or_null( $option_name, $cast_callable ) { $option_value = get_option( $option_name, null ); - if ( is_null( $option_value ) ) { + if ( $option_value === null ) { return $option_value; } @@ -416,6 +416,12 @@ class WPCOM_JSON_API_Site_Settings_Endpoint extends WPCOM_JSON_API_Endpoint { 'date_format' => get_option( 'date_format' ), 'time_format' => get_option( 'time_format' ), 'start_of_week' => get_option( 'start_of_week' ), + 'woocommerce_onboarding_profile' => (array) get_option( 'woocommerce_onboarding_profile', array() ), + 'woocommerce_store_address' => (string) get_option( 'woocommerce_store_address' ), + 'woocommerce_store_address_2' => (string) get_option( 'woocommerce_store_address_2' ), + 'woocommerce_store_city' => (string) get_option( 'woocommerce_store_city' ), + 'woocommerce_default_country' => (string) get_option( 'woocommerce_default_country' ), + 'woocommerce_store_postcode' => (string) get_option( 'woocommerce_store_postcode' ), 'jetpack_testimonial' => (bool) get_option( 'jetpack_testimonial', '0' ), 'jetpack_testimonial_posts_per_page' => (int) get_option( 'jetpack_testimonial_posts_per_page', '10' ), 'jetpack_portfolio' => (bool) get_option( 'jetpack_portfolio', '0' ), @@ -567,7 +573,7 @@ class WPCOM_JSON_API_Site_Settings_Endpoint extends WPCOM_JSON_API_Endpoint { $coerce_value = ( $value ) ? 'open' : 'closed'; if ( update_option( $key, $coerce_value ) ) { $updated[ $key ] = $value; - }; + } break; case 'jetpack_protect_whitelist': if ( function_exists( 'jetpack_protect_save_whitelist' ) ) { @@ -751,6 +757,33 @@ class WPCOM_JSON_API_Site_Settings_Endpoint extends WPCOM_JSON_API_Endpoint { } break; + case 'woocommerce_onboarding_profile': + // Allow boolean values but sanitize_text_field everything else. + $sanitized_value = (array) $value; + array_walk_recursive( + $sanitized_value, + function ( &$value ) { + if ( ! is_bool( $value ) ) { + $value = sanitize_text_field( $value ); + } + } + ); + if ( update_option( $key, $sanitized_value ) ) { + $updated[ $key ] = $sanitized_value; + } + break; + + case 'woocommerce_store_address': + case 'woocommerce_store_address_2': + case 'woocommerce_store_city': + case 'woocommerce_default_country': + case 'woocommerce_store_postcode': + $sanitized_value = sanitize_text_field( $value ); + if ( update_option( $key, $sanitized_value ) ) { + $updated[ $key ] = $sanitized_value; + } + break; + case 'date_format': case 'time_format': // settings are stored as strings. |