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
1486            * @since 3.4.0
1487            * @since 4.4.0 The `$option` parameter was added.
1488            * @since 4.7.0 The `$network_id` parameter was added.
1489            *
1490            * @param mixed  $default_value The value to return if the site option does not exist
1491            *                              in the database.
1492            * @param string $option        Option name.
1493            * @param int    $network_id    ID of the network.
1494            */
1495           return apply_filters( "default_site_option_{$option}", $default_value, $option, $network_id );
1496      }
1497
1498      if ( ! is_multisite() ) {
1499           /** This filter is documented in wp-includes/option.php */
1500           $default_value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id );
1501           $value         = get_option( $option, $default_value );
1502      } else {
1503           $cache_key = "$network_id:$option";
1504           $value     = wp_cache_get( $cache_key, 'site-options' );
1505
1506           if ( ! isset( $value ) || false === $value ) {
1507                $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
1508
1509                // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
 
Line Code
1514                } else {
1515                     if ( ! is_array( $notoptions ) ) {
1516                          $notoptions = array();
1517                     }
1518
1519                     $notoptions[ $option ] = true;
1520                     wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1521
1522                     /** This filter is documented in wp-includes/option.php */
1523                     $value = apply_filters( 'default_site_option_' . $option, $default_value, $option, $network_id );
1524                }
1525           }
1526      }
1527
1528      if ( ! is_array( $notoptions ) ) {
1529           $notoptions = array();
1530           wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1531      }
1532