From db3da0b695cfa139773166db14a79e5e63ab1937 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 14 May 2012 16:45:32 +0000 Subject: [PATCH] Add filters for the default to get_option() and get_site_option(). Provide default overrides in the customizer. Props Otto42. see #20448 git-svn-id: http://core.svn.wordpress.org/trunk@20783 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-setting.php | 4 +++- wp-includes/option.php | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-customize-setting.php b/wp-includes/class-wp-customize-setting.php index dd55d374c4..1e304d9ab4 100644 --- a/wp-includes/class-wp-customize-setting.php +++ b/wp-includes/class-wp-customize-setting.php @@ -68,8 +68,10 @@ class WP_Customize_Setting { case 'option' : if ( empty( $this->id_data[ 'keys' ] ) ) add_filter( 'pre_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) ); - else + else { add_filter( 'option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) ); + add_filter( 'default_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) ); + } break; default : do_action( 'customize_preview_' . $this->id ); diff --git a/wp-includes/option.php b/wp-includes/option.php index 2a25a27a01..6c9a9d067d 100644 --- a/wp-includes/option.php +++ b/wp-includes/option.php @@ -44,6 +44,8 @@ function get_option( $option, $default = false ) { if ( defined( 'WP_SETUP_CONFIG' ) ) return false; + $default = apply_filters( 'default_option_' . $option, $default ); + if ( ! defined( 'WP_INSTALLING' ) ) { // prevent non-existent options from triggering multiple queries $notoptions = wp_cache_get( 'notoptions', 'options' ); @@ -754,6 +756,8 @@ function get_site_option( $option, $default = false, $use_cache = true ) { if ( false !== $pre ) return $pre; + $default = apply_filters( 'default_site_option_' . $option, $default ); + if ( !is_multisite() ) { $value = get_option($option, $default); } else {