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
This commit is contained in:
ryan 2012-05-14 16:45:32 +00:00
parent 2b6e2d287a
commit db3da0b695
2 changed files with 7 additions and 1 deletions

View File

@ -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 );

View File

@ -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 {