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:
parent
2b6e2d287a
commit
db3da0b695
|
@ -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 );
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue