Call filters for default option values only as needed to reduce number of filter calls. Props Ott042. see #20448

git-svn-id: https://develop.svn.wordpress.org/trunk@20784 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2012-05-14 17:00:13 +00:00
parent 7e4b88ad24
commit 8dfae17319
2 changed files with 81 additions and 74 deletions
+6 -9
View File
@@ -44,13 +44,11 @@ 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' );
if ( isset( $notoptions[$option] ) )
return $default;
return apply_filters( 'default_option_' . $option, $default );
$alloptions = wp_load_alloptions();
@@ -69,7 +67,7 @@ function get_option( $option, $default = false ) {
} else { // option does not exist, so we must cache its non-existence
$notoptions[$option] = true;
wp_cache_set( 'notoptions', $notoptions, 'options' );
return $default;
return apply_filters( 'default_option_' . $option, $default );
}
}
}
@@ -80,7 +78,7 @@ function get_option( $option, $default = false ) {
if ( is_object( $row ) )
$value = $row->option_value;
else
return $default;
return apply_filters( 'default_option_' . $option, $default );
}
// If home is not set use siteurl.
@@ -756,9 +754,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() ) {
if ( ! is_multisite() ) {
$default = apply_filters( 'default_site_option_' . $option, $default );
$value = get_option($option, $default);
} else {
$cache_key = "{$wpdb->siteid}:$option";
@@ -774,7 +771,7 @@ function get_site_option( $option, $default = false, $use_cache = true ) {
$value = maybe_unserialize( $value );
wp_cache_set( $cache_key, $value, 'site-options' );
} else {
$value = $default;
$value = apply_filters( 'default_site_option_' . $option, $default );
}
}
}