Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: default_site_option_{$option}

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 3 times in this file.

Line Code
1471            * @since 3.4.0
1472            * @since 4.4.0 The `$option` parameter was added.
1473            * @since 4.7.0 The `$network_id` parameter was added.
1474            *
1475            * @param mixed  $default_value The value to return if the site option does not exist
1476            *                              in the database.
1477            * @param string $option        Option name.
1478            * @param int    $network_id    ID of the network.
1479            */
1480           return apply_filters( "default_site_option_{$option}", $default_value, $option, $network_id );
1481      }
1482
1483      if ( ! is_multisite() ) {
1484           /** This filter is documented in wp-includes/option.php */
1485           $default_value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id );
1486           $value         = get_option( $option, $default_value );
1487      } else {
1488           $cache_key = "$network_id:$option";
1489           $value     = wp_cache_get( $cache_key, 'site-options' );
1490
1491           if ( ! isset( $value ) || false === $value ) {
1492                $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
1493
1494                // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
 
Line Code
1499                } else {
1500                     if ( ! is_array( $notoptions ) ) {
1501                          $notoptions = array();
1502                     }
1503
1504                     $notoptions[ $option ] = true;
1505                     wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1506
1507                     /** This filter is documented in wp-includes/option.php */
1508                     $value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id );
1509                }
1510           }
1511      }
1512
1513      if ( ! is_array( $notoptions ) ) {
1514           $notoptions = array();
1515           wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1516      }
1517