wp_load_core_site_options
Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used.
Description
wp_load_core_site_options( (null) $site_id = null );
Parameters (1)
- 0. $site_id — Optional. (null) =>
null
- Site ID for which to query the options. Defaults to the current site.
Usage
if ( !function_exists( 'wp_load_core_site_options' ) ) { require_once ABSPATH . WPINC . '/option.php'; } // Optional site ID for which to query the options. Defaults to the current site. $site_id = null; // NOTICE! Understand what this does before running. $result = wp_load_core_site_options($site_id);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/option.php
- function wp_load_core_site_options( $site_id = null ) {
- global $wpdb;
- return;
- 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', 'ms_files_rewriting' );
- $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' );
- }
- }