Ticket #31985: 31985.7.diff
File 31985.7.diff, 23.6 KB (added by , 9 years ago) |
---|
-
new file wp-includes/class-wp-network.php
diff --git a/wp-includes/class-wp-network.php b/wp-includes/class-wp-network.php new file mode 100644 index 0000000..957f682
- + 1 <?php 2 /** 3 * Multisite API: WP_Network object class 4 * 5 * @package WordPress 6 * @subpackage Multisite 7 * @since 4.4.0 8 */ 9 10 /** 11 * Core class used for interacting with a multisite network. 12 * 13 * Traditionally used for multisite, this class is used by the `$current_site` 14 * global to setup the current network. 15 * 16 * This class is most useful in WordPress multi-network installations where the 17 * ability to interact with any network of sites is required. 18 * 19 * @since 4.4.0 20 */ 21 class WP_Network { 22 23 /** 24 * Network ID. 25 * 26 * @since 4.4.0 27 * @access public 28 * @var int 29 */ 30 public $id; 31 32 /** 33 * Domain of the network. 34 * 35 * @since 4.4.0 36 * @access public 37 * @var string 38 */ 39 public $domain = ''; 40 41 /** 42 * Path of the network. 43 * 44 * @since 4.4.0 45 * @access public 46 * @var string 47 */ 48 public $path = ''; 49 50 /** 51 * The ID of the network's main site. 52 * 53 * Named "blog" vs. "site" for legacy reasons. A main site is mapped to 54 * the network when the network is created. 55 * 56 * @since 4.4.0 57 * @access public 58 * @var int 59 */ 60 public $blog_id = 0; 61 62 /** 63 * Domain used to set cookies for this network. 64 * 65 * @since 4.4.0 66 * @access public 67 * @var int 68 */ 69 public $cookie_domain = ''; 70 71 /** 72 * Name of this network. 73 * 74 * Named "site" vs. "network" for legacy reasons. 75 * 76 * @since 4.4.0 77 * @access public 78 * @var string 79 */ 80 public $site_name = ''; 81 82 /** 83 * Retrieve a network from the database by its ID. 84 * 85 * @since 4.4.0 86 * @access public 87 * 88 * @global wpdb $wpdb WordPress database abstraction object. 89 * 90 * @param int $network_id The ID of the network to retrieve. 91 * @return WP_Network|bool The network's object if found. False if not. 92 */ 93 public static function get_instance( $network_id ) { 94 global $wpdb; 95 96 if ( $network_id instanceof WP_Network ) { 97 return $network_id; 98 } 99 100 /** 101 * Determine a network by its network id. 102 * 103 * This allows one to short-circuit the default logic, perhaps by 104 * replacing it with a routine that is more optimal for your setup. 105 * 106 * Return null to avoid the short-circuit. Return false if no network 107 * can be found at the requested id. Otherwise, return 108 * an object. 109 * 110 * @since 4.4.0 111 * 112 * @param null|int $network_id The ID of the network to retrieve. 113 * @return WP_Network|object $network A network object. 114 */ 115 $network = apply_filters( 'pre_get_network', null, $network_id ); 116 if ( null === $network ) { 117 $network = wp_cache_get( $network_id, 'networks' ); 118 } 119 120 if ( ! $network ) { 121 $network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id ) ); 122 123 if ( empty( $network ) || is_wp_error( $network ) ) { 124 return false; 125 } 126 127 wp_cache_add( $network_id, $network, 'networks' ); 128 } 129 130 return new WP_Network( $network ); 131 } 132 133 /** 134 * Create a new WP_Network object. 135 * 136 * Will populate object properties from the object provided and assign other 137 * default properties based on that information. 138 * 139 * @since 4.4.0 140 * @access public 141 * 142 * @param WP_Network|object $network A network object. 143 */ 144 public function __construct( $network ) { 145 foreach( get_object_vars( $network ) as $key => $value ) { 146 $this->$key = $value; 147 } 148 149 self::load_core_options( $this->id ); 150 $this->set_cookie_domain(); 151 $this->set_site_name(); 152 } 153 154 /** 155 * Set the cookie domain based on the network domain. 156 * 157 * @todo What if the domain of the network doesn't match the current site? 158 * 159 * @since 4.4.0 160 * @access public 161 */ 162 private function set_cookie_domain() { 163 // The cookie domain may already be set during sunrise. 164 if ( ! empty( $this->cookie_domain ) ) { 165 return; 166 } 167 168 $this->cookie_domain = $this->domain; 169 if ( 'www.' === substr( $this->cookie_domain, 0, 4 ) ) { 170 $this->cookie_domain = substr( $this->cookie_domain, 4 ); 171 } 172 } 173 174 /** 175 * Set the name for this network's object. 176 * 177 * @since 4.4.0 178 * @access private 179 */ 180 private function set_site_name() { 181 // The site name may already be set during sunrise. 182 if ( ! empty( $this->site_name ) ) { 183 return; 184 } 185 186 $this->site_name = get_site_option( 'site_name' ); 187 if ( empty( $this->site_name ) ) { 188 $this->site_name = ucfirst( $this->domain ); 189 } 190 } 191 192 /** 193 * Retrieve a network by its domain and path. 194 * 195 * @since 4.4.0 196 * @access public 197 * @static 198 * 199 * @param string $domain Domain to check. 200 * @param string $path Path to check. 201 * @param int|null $segments Path segments to use. Defaults to null, or the full path. 202 * @return WP_Network|bool Network object if successful. False when no network is found. 203 */ 204 public static function get_by_path( $domain = '', $path = '', $segments = null ) { 205 global $wpdb; 206 207 $domains = array( $domain ); 208 $pieces = explode( '.', $domain ); 209 210 /* 211 * It's possible one domain to search is 'com', but it might as well 212 * be 'localhost' or some other locally mapped domain. 213 */ 214 while ( array_shift( $pieces ) ) { 215 if ( ! empty( $pieces ) ) { 216 $domains[] = implode( '.', $pieces ); 217 } 218 } 219 220 /* 221 * If we've gotten to this function during normal execution, there is 222 * more than one network installed. At this point, who knows how many 223 * we have. Attempt to optimize for the situation where networks are 224 * only domains, thus meaning paths never need to be considered. 225 * 226 * This is a very basic optimization; anything further could have 227 * drawbacks depending on the setup, so this is best done per-install. 228 */ 229 $using_paths = true; 230 if ( wp_using_ext_object_cache() ) { 231 $using_paths = wp_cache_get( 'networks_have_paths', 'site-options' ); 232 if ( false === $using_paths ) { 233 $using_paths = $wpdb->get_var( "SELECT id FROM {$wpdb->site} WHERE path <> '/' LIMIT 1" ); 234 wp_cache_add( 'networks_have_paths', (int) $using_paths, 'site-options' ); 235 } 236 } 237 238 $paths = array(); 239 if ( true === $using_paths ) { 240 $path_segments = array_filter( explode( '/', trim( $path, '/' ) ) ); 241 242 /** 243 * Filter the number of path segments to consider when searching for a site. 244 * 245 * @since 3.9.0 246 * 247 * @param int|null $segments The number of path segments to consider. WordPress by default looks at 248 * one path segment. The function default of null only makes sense when you 249 * know the requested path should match a network. 250 * @param string $domain The requested domain. 251 * @param string $path The requested path, in full. 252 */ 253 $segments = apply_filters( 'network_by_path_segments_count', $segments, $domain, $path ); 254 255 if ( ( null !== $segments ) && count( $path_segments ) > $segments ) { 256 $path_segments = array_slice( $path_segments, 0, $segments ); 257 } 258 259 while ( count( $path_segments ) ) { 260 $paths[] = '/' . implode( '/', $path_segments ) . '/'; 261 array_pop( $path_segments ); 262 } 263 264 $paths[] = '/'; 265 } 266 267 /** 268 * Determine a network by its domain and path. 269 * 270 * This allows one to short-circuit the default logic, perhaps by 271 * replacing it with a routine that is more optimal for your setup. 272 * 273 * Return null to avoid the short-circuit. Return false if no network 274 * can be found at the requested domain and path. Otherwise, return 275 * an object from wp_get_network(). 276 * 277 * @since 3.9.0 278 * 279 * @param null|bool|object $network Network value to return by path. 280 * @param string $domain The requested domain. 281 * @param string $path The requested path, in full. 282 * @param int|null $segments The suggested number of paths to consult. 283 * Default null, meaning the entire path was to be consulted. 284 * @param array $paths The paths to search for, based on $path and $segments. 285 */ 286 $pre = apply_filters( 'pre_get_network_by_path', null, $domain, $path, $segments, $paths ); 287 if ( null !== $pre ) { 288 return $pre; 289 } 290 291 // @todo Consider additional optimization routes, perhaps as an opt-in for plugins. 292 // We already have paths covered. What about how far domains should be drilled down (including www)? 293 294 $search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'"; 295 296 if ( false === $using_paths ) { 297 $network = $wpdb->get_row( " 298 SELECT * FROM {$wpdb->site} 299 WHERE domain IN ({$search_domains}) 300 ORDER BY CHAR_LENGTH(domain) 301 DESC LIMIT 1 302 " ); 303 304 if ( ! empty( $network ) && ! is_wp_error( $network ) ) { 305 return new WP_Network( $network ); 306 } 307 308 return false; 309 310 } else { 311 $search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'"; 312 $networks = $wpdb->get_results( " 313 SELECT * FROM {$wpdb->site} 314 WHERE domain IN ({$search_domains}) 315 AND path IN ({$search_paths}) 316 ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC 317 " ); 318 } 319 320 /* 321 * Domains are sorted by length of domain, then by length of path. 322 * The domain must match for the path to be considered. Otherwise, 323 * a network with the path of / will suffice. 324 */ 325 $found = false; 326 foreach ( $networks as $network ) { 327 if ( ( $network->domain === $domain ) || ( "www.{$network->domain}" === $domain ) ) { 328 if ( in_array( $network->path, $paths, true ) ) { 329 $found = true; 330 break; 331 } 332 } 333 if ( $network->path === '/' ) { 334 $found = true; 335 break; 336 } 337 } 338 339 if ( true === $found ) { 340 return new WP_Network( $network ); 341 } 342 343 return false; 344 } 345 346 /** 347 * Load a set of core site options for the network from the database and 348 * store them in cache for future retrieval. 349 * 350 * @since 4.4.0 351 * @access public 352 * @static 353 * 354 * @global wpdb $wpdb WordPress database abstraction object. 355 * 356 * @param int $network_id Network ID. 357 */ 358 public static function load_core_options( $network_id ) { 359 global $wpdb; 360 361 // Setup core options query 362 $meta_keys = self::get_core_option_keys(); 363 $core_options_in = "'" . implode( "', '", $meta_keys ) . "'"; 364 $sql = $wpdb->prepare( " 365 SELECT meta_key, meta_value 366 FROM {$wpdb->sitemeta} 367 WHERE meta_key IN ({$core_options_in}) 368 AND site_id = %d 369 ", $network_id ); 370 371 // Query for core network options 372 $options = $wpdb->get_results( $sql ); 373 374 // Bail if no options found 375 if ( empty( $options ) || is_wp_error( $options ) ) { 376 return; 377 } 378 379 // Loop through options and add them to the object cache 380 foreach ( $options as $option ) { 381 382 // Setup option values to cache 383 $key = $option->meta_key; 384 $cache_key = "{$network_id}:$key"; 385 $option->meta_value = maybe_unserialize( $option->meta_value ); 386 387 // Cache the option value 388 wp_cache_set( $cache_key, $option->meta_value, 'site-options' ); 389 } 390 } 391 392 /** 393 * Provide a list of core option keys used for network metadata. 394 * 395 * @since 4.4.0 396 * @access private 397 * @static 398 * 399 * @return array Option keys. 400 */ 401 private static function get_core_option_keys() { 402 $core_option_keys = array( 403 'site_name', 404 'siteurl', 405 'active_sitewide_plugins', 406 '_site_transient_timeout_theme_roots', 407 '_site_transient_theme_roots', 408 'site_admins', 409 'can_compress_scripts', 410 'global_terms_enabled', 411 'ms_files_rewriting' 412 ); 413 414 /** 415 * Provide a list of core option keys used for network metadata. 416 * 417 * @since 4.4.0 418 * 419 * @param array $core_option_keys Option keys. 420 */ 421 return apply_filters( 'get_core_option_keys', $core_option_keys ); 422 } 423 } -
wp-includes/ms-load.php
diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php index dd1024a..451e0dc 100644
a b function ms_site_check() { 113 113 * Retrieve a network object by its domain and path. 114 114 * 115 115 * @since 3.9.0 116 * 117 * @global wpdb $wpdb 116 * @since 4.4.0 Converted to a wrapper for WP_Network::get_by_path() 118 117 * 119 118 * @param string $domain Domain to check. 120 119 * @param string $path Path to check. 121 120 * @param int|null $segments Path segments to use. Defaults to null, or the full path. 122 * @return object|false Network object if successful. False when no network is found.121 * @return WP_Network|false Network object if successful. False when no network is found. 123 122 */ 124 123 function get_network_by_path( $domain, $path, $segments = null ) { 125 global $wpdb; 126 127 $domains = array( $domain ); 128 $pieces = explode( '.', $domain ); 129 130 /* 131 * It's possible one domain to search is 'com', but it might as well 132 * be 'localhost' or some other locally mapped domain. 133 */ 134 while ( array_shift( $pieces ) ) { 135 if ( $pieces ) { 136 $domains[] = implode( '.', $pieces ); 137 } 138 } 139 140 /* 141 * If we've gotten to this function during normal execution, there is 142 * more than one network installed. At this point, who knows how many 143 * we have. Attempt to optimize for the situation where networks are 144 * only domains, thus meaning paths never need to be considered. 145 * 146 * This is a very basic optimization; anything further could have drawbacks 147 * depending on the setup, so this is best done per-install. 148 */ 149 $using_paths = true; 150 if ( wp_using_ext_object_cache() ) { 151 $using_paths = wp_cache_get( 'networks_have_paths', 'site-options' ); 152 if ( false === $using_paths ) { 153 $using_paths = (bool) $wpdb->get_var( "SELECT id FROM $wpdb->site WHERE path <> '/' LIMIT 1" ); 154 wp_cache_add( 'networks_have_paths', (int) $using_paths, 'site-options' ); 155 } 156 } 157 158 $paths = array(); 159 if ( $using_paths ) { 160 $path_segments = array_filter( explode( '/', trim( $path, "/" ) ) ); 161 162 /** 163 * Filter the number of path segments to consider when searching for a site. 164 * 165 * @since 3.9.0 166 * 167 * @param int|null $segments The number of path segments to consider. WordPress by default looks at 168 * one path segment. The function default of null only makes sense when you 169 * know the requested path should match a network. 170 * @param string $domain The requested domain. 171 * @param string $path The requested path, in full. 172 */ 173 $segments = apply_filters( 'network_by_path_segments_count', $segments, $domain, $path ); 174 175 if ( null !== $segments && count($path_segments ) > $segments ) { 176 $path_segments = array_slice( $path_segments, 0, $segments ); 177 } 178 179 while ( count( $path_segments ) ) { 180 $paths[] = '/' . implode( '/', $path_segments ) . '/'; 181 array_pop( $path_segments ); 182 } 183 184 $paths[] = '/'; 185 } 186 187 /** 188 * Determine a network by its domain and path. 189 * 190 * This allows one to short-circuit the default logic, perhaps by 191 * replacing it with a routine that is more optimal for your setup. 192 * 193 * Return null to avoid the short-circuit. Return false if no network 194 * can be found at the requested domain and path. Otherwise, return 195 * an object from wp_get_network(). 196 * 197 * @since 3.9.0 198 * 199 * @param null|bool|object $network Network value to return by path. 200 * @param string $domain The requested domain. 201 * @param string $path The requested path, in full. 202 * @param int|null $segments The suggested number of paths to consult. 203 * Default null, meaning the entire path was to be consulted. 204 * @param array $paths The paths to search for, based on $path and $segments. 205 */ 206 $pre = apply_filters( 'pre_get_network_by_path', null, $domain, $path, $segments, $paths ); 207 if ( null !== $pre ) { 208 return $pre; 209 } 210 211 // @todo Consider additional optimization routes, perhaps as an opt-in for plugins. 212 // We already have paths covered. What about how far domains should be drilled down (including www)? 213 214 $search_domains = "'" . implode( "', '", $wpdb->_escape( $domains ) ) . "'"; 215 216 if ( ! $using_paths ) { 217 $network = $wpdb->get_row( "SELECT id, domain, path FROM $wpdb->site 218 WHERE domain IN ($search_domains) ORDER BY CHAR_LENGTH(domain) DESC LIMIT 1" ); 219 if ( $network ) { 220 return wp_get_network( $network ); 221 } 222 return false; 223 224 } else { 225 $search_paths = "'" . implode( "', '", $wpdb->_escape( $paths ) ) . "'"; 226 $networks = $wpdb->get_results( "SELECT id, domain, path FROM $wpdb->site 227 WHERE domain IN ($search_domains) AND path IN ($search_paths) 228 ORDER BY CHAR_LENGTH(domain) DESC, CHAR_LENGTH(path) DESC" ); 229 } 230 231 /* 232 * Domains are sorted by length of domain, then by length of path. 233 * The domain must match for the path to be considered. Otherwise, 234 * a network with the path of / will suffice. 235 */ 236 $found = false; 237 foreach ( $networks as $network ) { 238 if ( $network->domain === $domain || "www.$network->domain" === $domain ) { 239 if ( in_array( $network->path, $paths, true ) ) { 240 $found = true; 241 break; 242 } 243 } 244 if ( $network->path === '/' ) { 245 $found = true; 246 break; 247 } 248 } 249 250 if ( $found ) { 251 return wp_get_network( $network ); 252 } 253 254 return false; 124 return WP_Network::get_by_path( $domain, $path, $segments ); 255 125 } 256 126 257 127 /** 258 128 * Retrieve an object containing information about the requested network. 259 129 * 260 130 * @since 3.9.0 261 * 262 * @global wpdb $wpdb 131 * @since 4.4.0 Converted to leverage WP_Network 263 132 * 264 133 * @param object|int $network The network's database row or ID. 265 * @return object|false Object containing network information if found, false if not.134 * @return WP_Network|false Object containing network information if found, false if not. 266 135 */ 267 136 function wp_get_network( $network ) { 268 global $wpdb;269 270 137 if ( ! is_object( $network ) ) { 271 $network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d", $network ) ); 272 if ( ! $network ) { 273 return false; 274 } 138 $network = WP_Network::get_instance( $network ); 139 } else { 140 $network = new WP_Network( $network ); 275 141 } 276 142 277 143 return $network; -
wp-includes/ms-settings.php
diff --git a/wp-includes/ms-settings.php b/wp-includes/ms-settings.php index 88e7629..0a16ec0 100644
a b 10 10 * @since 3.0.0 11 11 */ 12 12 13 /** Include Multisite initialization functions */ 13 /** WP_Network class */ 14 require_once( ABSPATH . WPINC . '/class-wp-network.php' ); 15 16 /** Multisite loader */ 14 17 require_once( ABSPATH . WPINC . '/ms-load.php' ); 18 19 /** Default Multisite constants */ 15 20 require_once( ABSPATH . WPINC . '/ms-default-constants.php' ); 16 21 17 22 if ( defined( 'SUNRISE' ) ) { … … if ( !isset( $current_site ) || !isset( $current_blog ) ) { 75 80 // Are there even two networks installed? 76 81 $one_network = $wpdb->get_row( "SELECT * FROM $wpdb->site LIMIT 2" ); // [sic] 77 82 if ( 1 === $wpdb->num_rows ) { 78 $current_site = wp_get_network( $one_network );83 $current_site = new WP_Network( $one_network ); 79 84 wp_cache_add( 'current_network', $current_site, 'site-options' ); 80 85 } elseif ( 0 === $wpdb->num_rows ) { 81 86 ms_not_installed( $domain, $path ); 82 87 } 83 88 } 84 89 if ( empty( $current_site ) ) { 85 $current_site = get_network_by_path( $domain, $path, 1 );90 $current_site = WP_Network::get_by_path( $domain, $path, 1 ); 86 91 } 87 92 88 93 if ( empty( $current_site ) ) { … … if ( !isset( $current_site ) || !isset( $current_blog ) ) { 110 115 // Find the site by the domain and at most the first path segment. 111 116 $current_blog = get_site_by_path( $domain, $path, 1 ); 112 117 if ( $current_blog ) { 113 $current_site = wp_get_network( $current_blog->site_id ? $current_blog->site_id : 1 );118 $current_site = WP_Network::get_instance( $current_blog->site_id ? $current_blog->site_id : 1 ); 114 119 } else { 115 120 // If you don't have a site with the same domain/path as a network, you're pretty screwed, but: 116 $current_site = get_network_by_path( $domain, $path, 1 );121 $current_site = WP_Network::get_by_path( $domain, $path, 1 ); 117 122 } 118 123 } 119 124 120 125 // The network declared by the site trumps any constants. 121 126 if ( $current_blog && $current_blog->site_id != $current_site->id ) { 122 $current_site = wp_get_network( $current_blog->site_id );127 $current_site = WP_Network::get_instance( $current_blog->site_id ); 123 128 } 124 129 125 130 // No network has been found, bail. … … if ( !isset( $current_site ) || !isset( $current_blog ) ) { 179 184 exit; 180 185 } 181 186 182 // @todo What if the domain of the network doesn't match the current site?183 $current_site->cookie_domain = $current_site->domain;184 if ( 'www.' === substr( $current_site->cookie_domain, 0, 4 ) ) {185 $current_site->cookie_domain = substr( $current_site->cookie_domain, 4 );186 }187 188 187 // Figure out the current network's main site. 189 if ( ! isset( $current_site->blog_id ) ) {188 if ( empty( $current_site->blog_id ) ) { 190 189 if ( $current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path ) { 191 190 $current_site->blog_id = $current_blog->blog_id; 192 191 } elseif ( ! $current_site->blog_id = wp_cache_get( 'network:' . $current_site->id . ':main_site', 'site-options' ) ) { … … if ( !isset( $current_site ) || !isset( $current_blog ) ) { 206 205 } 207 206 208 207 $site_id = $current_blog->site_id; 209 wp_load_core_site_options( $site_id );210 208 } 211 209 212 210 $wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php … … $switched = false; 218 216 // need to init cache again after blog_id is set 219 217 wp_start_object_cache(); 220 218 221 if ( ! isset( $current_site->site_name ) ) { 222 $current_site->site_name = get_site_option( 'site_name' ); 223 if ( ! $current_site->site_name ) { 224 $current_site->site_name = ucfirst( $current_site->domain ); 225 } 219 if ( ! $current_site instanceof WP_Network ) { 220 $current_site = new WP_Network( $current_site ); 226 221 } 227 222 228 223 // Define upload directory constants -
wp-includes/option.php
diff --git a/wp-includes/option.php b/wp-includes/option.php index 5749f8b..fdc2902 100644
a b function wp_load_alloptions() { 193 193 } 194 194 195 195 /** 196 * Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used. 196 * Loads and caches certain often requested site options if is_multisite() 197 * and a persistent cache is not being used. 197 198 * 198 199 * @since 3.0.0 200 * @since 4.4.0 Converted to use WP_Network 199 201 * 200 * @global wpdb $wpdb 202 * @global wpdb $wpdb WordPress database abstraction object. 203 * 204 * @see WP_Network::load_core_options() 201 205 * 202 * @param int $ site_id Optional site ID for which to query the options. Defaults to the current site.206 * @param int $network_id Optional. ID of the network for which to load options. Defaults to the current network. 203 207 */ 204 function wp_load_core_site_options( $ site_id = null ) {208 function wp_load_core_site_options( $network_id = null ) { 205 209 global $wpdb; 206 210 207 if ( ! is_multisite() || wp_using_ext_object_cache() || defined( 'WP_INSTALLING' ) )211 if ( ! is_multisite() || wp_using_ext_object_cache() || defined( 'WP_INSTALLING' ) ) 208 212 return; 209 213 210 if ( empty($site_id) ) 211 $site_id = $wpdb->siteid; 212 213 $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' ); 214 215 $core_options_in = "'" . implode("', '", $core_options) . "'"; 216 $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) ); 217 218 foreach ( $options as $option ) { 219 $key = $option->meta_key; 220 $cache_key = "{$site_id}:$key"; 221 $option->meta_value = maybe_unserialize( $option->meta_value ); 222 223 wp_cache_set( $cache_key, $option->meta_value, 'site-options' ); 214 if ( empty( $network_id ) ) { 215 $network_id = $wpdb->siteid; 224 216 } 217 218 WP_Network::load_core_options( $network_id ); 225 219 } 226 220 227 221 /**