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
1257            * @since 3.4.0
1258            * @since 4.4.0 The `$option` parameter was added.
1259            * @since 4.7.0 The `$network_id` parameter was added.
1260            *
1261            * @param mixed  $default    The value to return if the site option does not exist
1262            *                           in the database.
1263            * @param string $option     Option name.
1264            * @param int    $network_id ID of the network.
1265            */
1266           return apply_filters( "default_site_option_{$option}", $default, $option, $network_id );
1267      }
1268
1269      if ( ! is_multisite() ) {
1270           /** This filter is documented in wp-includes/option.php */
1271           $default = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
1272           $value   = get_option( $option, $default );
1273      } else {
1274           $cache_key = "$network_id:$option";
1275           $value     = wp_cache_get( $cache_key, 'site-options' );
1276
1277           if ( ! isset( $value ) || false === $value ) {
1278                $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) );
1279
1280                // Has to be get_row instead of get_var because of funkiness with 0, false, null values
 
Line Code
1284                     wp_cache_set( $cache_key, $value, 'site-options' );
1285                } else {
1286                     if ( ! is_array( $notoptions ) ) {
1287                          $notoptions = array();
1288                     }
1289                     $notoptions[ $option ] = true;
1290                     wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1291
1292                     /** This filter is documented in wp-includes/option.php */
1293                     $value = apply_filters( 'default_site_option_' . $option, $default, $option, $network_id );
1294                }
1295           }
1296      }
1297
1298      if ( ! is_array( $notoptions ) ) {
1299           $notoptions = array();
1300           wp_cache_set( $notoptions_key, $notoptions, 'site-options' );
1301      }
1302