Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: blog_option_{$setting}

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
301                $notoptions = wp_cache_get( 'notoptions', 'options' );
302                if ( isset( $notoptions[$setting] ) ) {
303                     wp_cache_set( $key, 'noop', 'site-options' );
304                     $value = $default;
305                } elseif ( $value == false ) {
306                     wp_cache_set( $key, 'falsevalue', 'site-options' );
307                } else {
308                     wp_cache_set( $key, $value, 'site-options' );
309                }
310                return apply_filters( 'blog_option_' . $setting, $value, $blog_id );
311           } else {
312                $blog_prefix = $wpdb->get_blog_prefix( $blog_id );
313                $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$blog_prefix}options WHERE option_name = %s", $setting ) );
314                if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
315                     $value = $row->option_value;
316                     if ( $value == false )
317                          wp_cache_set( $key, 'falsevalue', 'site-options' );
318                     else
319                          wp_cache_set( $key, $value, 'site-options' );
 
Line Code
331      if ( 'home' == $setting && '' == $value )
332           return get_blog_option( $blog_id, 'siteurl' );
333
334      if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
335           $value = untrailingslashit( $value );
336
337      if (! @unserialize( $value ) )
338           $value = stripslashes( $value );
339
340      return apply_filters( 'blog_option_' . $setting, maybe_unserialize( $value ), $blog_id );
341 }
342
343 function add_blog_option( $id, $key, $value ) {
344      $id = (int) $id;
345
346      switch_to_blog($id);
347      add_option( $key, $value );
348      restore_current_blog();
349      wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options' );