mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 21:00:21 +00:00
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:
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user