get_blog_option [ WordPress Function ]
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Retrieve option value based on setting name and blog_id.
If the option does not exist or does not have a value, then the return value will be false. This is useful to check whether you need to install an option and is commonly used during installation of plugin options and to test whether upgrading is required.
There is a filter called 'blog_option_$option' with the $option being replaced with the option name. The filter takes two parameters. $value and $blog_id. It returns $value. The 'option_$option' filter in get_option() is not called.
Source
<?php
function get_blog_option( $blog_id, $setting, $default = false ) {
global $wpdb;
if ( null === $blog_id )
$blog_id = $wpdb->blogid;
$key = $blog_id . '-' . $setting . '-blog_option';
$value = wp_cache_get( $key, 'site-options' );
if ( $value == null ) {
if ( $blog_id == $wpdb->blogid ) {
$value = get_option( $setting, $default );
$notoptions = wp_cache_get( 'notoptions', 'options' );
if ( isset( $notoptions[$setting] ) ) {
wp_cache_set( $key, 'noop', 'site-options' );
$value = $default;
} elseif ( $value == false ) {
wp_cache_set( $key, 'falsevalue', 'site-options' );
} else {
wp_cache_set( $key, $value, 'site-options' );
}
return apply_filters( 'blog_option_' . $setting, $value, $blog_id );
} else {
$blog_prefix = $wpdb->get_blog_prefix( $blog_id );
$row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$blog_prefix}options WHERE option_name = %s", $setting ) );
if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
$value = $row->option_value;
if ( $value == false )
wp_cache_set( $key, 'falsevalue', 'site-options' );
else
wp_cache_set( $key, $value, 'site-options' );
} else { // option does not exist, so we must cache its non-existence
wp_cache_set( $key, 'noop', 'site-options' );
$value = $default;
}
}
} elseif ( $value == 'noop' ) {
$value = $default;
} elseif ( $value == 'falsevalue' ) {
$value = false;
}
// If home is not set use siteurl.
if ( 'home' == $setting && '' == $value )
return get_blog_option( $blog_id, 'siteurl' );
if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
$value = untrailingslashit( $value );
return apply_filters( 'blog_option_' . $setting, maybe_unserialize( $value ), $blog_id );
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- WPMU Functions/get blog option « WordPress Codex
Description. Returns data relating to a specific blog. Parameters. $blog_id: ( integer) (required) ID of blog queried. Default: None. $setting: (string) (required) ...
codex.wordpress.org - Function Reference/get blog option « WordPress Codex
Description. Retrieve option value based on setting name and blog_id. If the option does not exist or does not have a value, then the return value will be false.
codex.wordpress.org - Get_blog_option issue
Apr 6, 2012 ... How does this plugin relate to the get_blog_option( $blog_id, 'blog_public' ) setting? I have a site on my multisite that is in admin only mode ...
premium.wpmudev.org - get_blog_option (WordPress Function) - WPSeek.com
WordPress lookup for get_blog_option, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com