30 * @since 3.0.0 |
30 * @since 3.0.0 |
31 */ |
31 */ |
32 global $current_site, $current_blog, $domain, $path, $site_id, $public; |
32 global $current_site, $current_blog, $domain, $path, $site_id, $public; |
33 |
33 |
34 /** WP_Network class */ |
34 /** WP_Network class */ |
35 require_once( ABSPATH . WPINC . '/class-wp-network.php' ); |
35 require_once ABSPATH . WPINC . '/class-wp-network.php'; |
36 |
36 |
37 /** WP_Site class */ |
37 /** WP_Site class */ |
38 require_once( ABSPATH . WPINC . '/class-wp-site.php' ); |
38 require_once ABSPATH . WPINC . '/class-wp-site.php'; |
39 |
39 |
40 /** Multisite loader */ |
40 /** Multisite loader */ |
41 require_once( ABSPATH . WPINC . '/ms-load.php' ); |
41 require_once ABSPATH . WPINC . '/ms-load.php'; |
42 |
42 |
43 /** Default Multisite constants */ |
43 /** Default Multisite constants */ |
44 require_once( ABSPATH . WPINC . '/ms-default-constants.php' ); |
44 require_once ABSPATH . WPINC . '/ms-default-constants.php'; |
45 |
45 |
46 if ( defined( 'SUNRISE' ) ) { |
46 if ( defined( 'SUNRISE' ) ) { |
47 include_once( WP_CONTENT_DIR . '/sunrise.php' ); |
47 include_once WP_CONTENT_DIR . '/sunrise.php'; |
48 } |
48 } |
49 |
49 |
50 /** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */ |
50 /** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */ |
51 ms_subdomain_constants(); |
51 ms_subdomain_constants(); |
52 |
52 |
53 // This block will process a request if the current network or current site objects |
53 // This block will process a request if the current network or current site objects |
54 // have not been populated in the global scope through something like `sunrise.php`. |
54 // have not been populated in the global scope through something like `sunrise.php`. |
55 if ( ! isset( $current_site ) || ! isset( $current_blog ) ) { |
55 if ( ! isset( $current_site ) || ! isset( $current_blog ) ) { |
56 |
56 |
57 $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); |
57 $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); |
58 if ( substr( $domain, -3 ) == ':80' ) { |
58 if ( ':80' === substr( $domain, -3 ) ) { |
59 $domain = substr( $domain, 0, -3 ); |
59 $domain = substr( $domain, 0, -3 ); |
60 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); |
60 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); |
61 } elseif ( substr( $domain, -4 ) == ':443' ) { |
61 } elseif ( ':443' === substr( $domain, -4 ) ) { |
62 $domain = substr( $domain, 0, -4 ); |
62 $domain = substr( $domain, 0, -4 ); |
63 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); |
63 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); |
64 } |
64 } |
65 |
65 |
66 $path = stripslashes( $_SERVER['REQUEST_URI'] ); |
66 $path = stripslashes( $_SERVER['REQUEST_URI'] ); |
92 |
92 |
93 $site_id = $current_blog->site_id; |
93 $site_id = $current_blog->site_id; |
94 wp_load_core_site_options( $site_id ); |
94 wp_load_core_site_options( $site_id ); |
95 } |
95 } |
96 |
96 |
97 $wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php |
97 $wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php. |
98 $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); |
98 $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); |
99 $table_prefix = $wpdb->get_blog_prefix(); |
99 $table_prefix = $wpdb->get_blog_prefix(); |
100 $_wp_switched_stack = array(); |
100 $_wp_switched_stack = array(); |
101 $switched = false; |
101 $switched = false; |
102 |
102 |
103 // need to init cache again after blog_id is set |
103 // Need to init cache again after blog_id is set. |
104 wp_start_object_cache(); |
104 wp_start_object_cache(); |
105 |
105 |
106 if ( ! $current_site instanceof WP_Network ) { |
106 if ( ! $current_site instanceof WP_Network ) { |
107 $current_site = new WP_Network( $current_site ); |
107 $current_site = new WP_Network( $current_site ); |
108 } |
108 } |
109 |
109 |
110 if ( ! $current_blog instanceof WP_Site ) { |
110 if ( ! $current_blog instanceof WP_Site ) { |
111 $current_blog = new WP_Site( $current_blog ); |
111 $current_blog = new WP_Site( $current_blog ); |
112 } |
112 } |
113 |
113 |
114 // Define upload directory constants |
114 // Define upload directory constants. |
115 ms_upload_constants(); |
115 ms_upload_constants(); |
116 |
116 |
117 /** |
117 /** |
118 * Fires after the current site and network have been detected and loaded |
118 * Fires after the current site and network have been detected and loaded |
119 * in multisite's bootstrap. |
119 * in multisite's bootstrap. |