Definition:
function get_site_option( $option, $default = false, $use_cache = true ) {}
Retrieve site option value based on name of option.
Parameters
- string $option: Name of option to retrieve. Expected to not be SQL-escaped.
- mixed $default: Optional value to return if option doesn’t exist. Default false.
- bool $use_cache: Whether to use cache. Multisite only. Default true.
Return values
returns:Value set for the option.
Defined filters
- pre_site_option_$option
apply_filters( 'pre_site_option_' . $option, false )
Source code
function get_site_option( $option, $default = false, $use_cache = true ) { global $wpdb; // Allow plugins to short-circuit site options. $pre = apply_filters( 'pre_site_option_' . $option, false ); if ( false !== $pre ) return $pre; if ( !is_multisite() ) { $value = get_option($option, $default); } else { $cache_key = "{$wpdb->siteid}:$option"; if ( $use_cache ) $value = wp_cache_get($cache_key, 'site-options'); if ( !isset($value) || (false === $value) ) { $row = $wpdb->get_row( $wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ); // Has to be get_row instead of get_var because of funkiness with 0, false, null values if ( is_object( $row ) ) { $value = $row->meta_value; $value = maybe_unserialize( $value ); wp_cache_set( $cache_key, $value, 'site-options' ); } else { $value = $default; } } }
1697
No comments yet... Be the first to leave a reply!