function wp_load_core_site_options( $site_id = null ) {}

Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used.


  • int $site_id: Optional site ID for which to query the options. Defaults to the current site.

Source code

function wp_load_core_site_options( $site_id = null ) {

	global $wpdb, $_wp_using_ext_object_cache;

	if ( !is_multisite() || $_wp_using_ext_object_cache || defined( 'WP_INSTALLING' ) )


	if ( empty($site_id) )

		$site_id = $wpdb->siteid;

	$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' );

	$core_options_in = "'" . implode("', '", $core_options) . "'";

	$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );

	foreach ( $options as $option ) {

		$key = $option->meta_key;

		$cache_key = "{$site_id}:$key";

		$option->meta_value = maybe_unserialize( $option->meta_value );

		wp_cache_set( $cache_key, $option->meta_value, 'site-options' );



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: