consistency & simplicity in get_option(), see #12140
git-svn-id: https://develop.svn.wordpress.org/trunk@14515 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0d826fa206
commit
74a627a09d
|
@ -310,42 +310,41 @@ function get_option( $option, $default = false ) {
|
|||
if ( defined( 'WP_SETUP_CONFIG' ) )
|
||||
return false;
|
||||
|
||||
// prevent non-existent options from triggering multiple queries
|
||||
if ( defined( 'WP_INSTALLING' ) && is_multisite() ) {
|
||||
$notoptions = array();
|
||||
} else {
|
||||
if ( ! defined( 'WP_INSTALLING' ) ) {
|
||||
// prevent non-existent options from triggering multiple queries
|
||||
$notoptions = wp_cache_get( 'notoptions', 'options' );
|
||||
if ( isset( $notoptions[$option] ) )
|
||||
return $default;
|
||||
}
|
||||
|
||||
if ( ! defined( 'WP_INSTALLING' ) ) {
|
||||
$alloptions = wp_load_alloptions();
|
||||
}
|
||||
|
||||
if ( isset( $alloptions[$option] ) ) {
|
||||
$value = $alloptions[$option];
|
||||
} else {
|
||||
$value = wp_cache_get( $option, 'options' );
|
||||
if ( isset( $alloptions[$option] ) ) {
|
||||
$value = $alloptions[$option];
|
||||
} else {
|
||||
$value = wp_cache_get( $option, 'options' );
|
||||
|
||||
if ( false === $value ) {
|
||||
if ( defined( 'WP_INSTALLING' ) )
|
||||
$suppress = $wpdb->suppress_errors();
|
||||
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
|
||||
if ( defined( 'WP_INSTALLING' ) )
|
||||
$wpdb->suppress_errors( $suppress );
|
||||
if ( false === $value ) {
|
||||
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
|
||||
|
||||
// Has to be get_row instead of get_var because of funkiness with 0, false, null values
|
||||
if ( is_object( $row ) ) {
|
||||
$value = $row->option_value;
|
||||
if ( ! defined( 'WP_INSTALLING' ) )
|
||||
// Has to be get_row instead of get_var because of funkiness with 0, false, null values
|
||||
if ( is_object( $row ) ) {
|
||||
$value = $row->option_value;
|
||||
wp_cache_add( $option, $value, 'options' );
|
||||
} else { // option does not exist, so we must cache its non-existence
|
||||
$notoptions[$option] = true;
|
||||
wp_cache_set( 'notoptions', $notoptions, 'options' );
|
||||
return $default;
|
||||
} else { // option does not exist, so we must cache its non-existence
|
||||
$notoptions[$option] = true;
|
||||
wp_cache_set( 'notoptions', $notoptions, 'options' );
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$suppress = $wpdb->suppress_errors();
|
||||
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
|
||||
$wpdb->suppress_errors( $suppress );
|
||||
if ( is_object( $row ) )
|
||||
$value = $row->option_value;
|
||||
else
|
||||
return $default;
|
||||
}
|
||||
|
||||
// If home is not set use siteurl.
|
||||
|
|
Loading…
Reference in New Issue