1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Used to set up and fix common variables and include |
4
|
|
|
* the Multisite procedural and class library. |
5
|
|
|
* |
6
|
|
|
* Allows for some configuration in wp-config.php (see ms-default-constants.php) |
7
|
|
|
* |
8
|
|
|
* @package WordPress |
9
|
|
|
* @subpackage Multisite |
10
|
|
|
* @since 3.0.0 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Objects representing the current network and current site. |
15
|
|
|
* |
16
|
|
|
* These may be populated through a custom `sunrise.php`. If not, then this |
17
|
|
|
* file will attempt to populate them based on the current request. |
18
|
|
|
* |
19
|
|
|
* @global WP_Network $current_site The current network. |
20
|
|
|
* @global object $current_blog The current site. |
21
|
|
|
* @since 3.0.0 |
22
|
|
|
*/ |
23
|
|
|
global $current_site, $current_blog; |
24
|
|
|
|
25
|
|
|
/** WP_Network class */ |
26
|
|
|
require_once( ABSPATH . WPINC . '/class-wp-network.php' ); |
27
|
|
|
|
28
|
|
|
/** WP_Site class */ |
29
|
|
|
require_once( ABSPATH . WPINC . '/class-wp-site.php' ); |
30
|
|
|
|
31
|
|
|
/** Multisite loader */ |
32
|
|
|
require_once( ABSPATH . WPINC . '/ms-load.php' ); |
33
|
|
|
|
34
|
|
|
/** Default Multisite constants */ |
35
|
|
|
require_once( ABSPATH . WPINC . '/ms-default-constants.php' ); |
36
|
|
|
|
37
|
|
|
if ( defined( 'SUNRISE' ) ) { |
38
|
|
|
include_once( WP_CONTENT_DIR . '/sunrise.php' ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */ |
42
|
|
|
ms_subdomain_constants(); |
43
|
|
|
|
44
|
|
|
// This block will process a request if the current network or current site objects |
45
|
|
|
// have not been populated in the global scope through something like `sunrise.php`. |
46
|
|
|
if ( !isset( $current_site ) || !isset( $current_blog ) ) { |
47
|
|
|
|
48
|
|
|
$domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); |
49
|
|
|
if ( substr( $domain, -3 ) == ':80' ) { |
50
|
|
|
$domain = substr( $domain, 0, -3 ); |
51
|
|
|
$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); |
52
|
|
|
} elseif ( substr( $domain, -4 ) == ':443' ) { |
53
|
|
|
$domain = substr( $domain, 0, -4 ); |
54
|
|
|
$_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$path = stripslashes( $_SERVER['REQUEST_URI'] ); |
58
|
|
|
if ( is_admin() ) { |
59
|
|
|
$path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path ); |
60
|
|
|
} |
61
|
|
|
list( $path ) = explode( '?', $path ); |
62
|
|
|
|
63
|
|
|
$bootstrap_result = ms_load_current_site_and_network( $domain, $path, is_subdomain_install() ); |
64
|
|
|
|
65
|
|
|
if ( true === $bootstrap_result ) { |
|
|
|
|
66
|
|
|
// `$current_blog` and `$current_site are now populated. |
67
|
|
|
} elseif ( false === $bootstrap_result ) { |
68
|
|
|
ms_not_installed( $domain, $path ); |
69
|
|
|
} else { |
70
|
|
|
header( 'Location: ' . $bootstrap_result ); |
71
|
|
|
exit; |
72
|
|
|
} |
73
|
|
|
unset( $bootstrap_result ); |
74
|
|
|
|
75
|
|
|
$blog_id = $current_blog->blog_id; |
76
|
|
|
$public = $current_blog->public; |
77
|
|
|
|
78
|
|
|
if ( empty( $current_blog->site_id ) ) { |
79
|
|
|
// This dates to [MU134] and shouldn't be relevant anymore, |
80
|
|
|
// but it could be possible for arguments passed to insert_blog() etc. |
81
|
|
|
$current_blog->site_id = 1; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$site_id = $current_blog->site_id; |
85
|
|
|
wp_load_core_site_options( $site_id ); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php |
89
|
|
|
$wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); |
90
|
|
|
$table_prefix = $wpdb->get_blog_prefix(); |
91
|
|
|
$_wp_switched_stack = array(); |
92
|
|
|
$switched = false; |
93
|
|
|
|
94
|
|
|
// need to init cache again after blog_id is set |
95
|
|
|
wp_start_object_cache(); |
96
|
|
|
|
97
|
|
|
if ( ! $current_site instanceof WP_Network ) { |
98
|
|
|
$current_site = new WP_Network( $current_site ); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
if ( ! $current_blog instanceof WP_Site ) { |
102
|
|
|
$current_blog = new WP_Site( $current_blog ); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
// Define upload directory constants |
106
|
|
|
ms_upload_constants(); |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Fires after the current site and network have been detected and loaded |
110
|
|
|
* in multisite's bootstrap. |
111
|
|
|
* |
112
|
|
|
* @since 4.6.0 |
113
|
|
|
*/ |
114
|
|
|
do_action( 'ms_loaded' ); |
115
|
|
|
|
This check looks for the bodies of
if
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
if
bodies can be removed. If you have an empty if but statements in theelse
branch, consider inverting the condition.could be turned into
This is much more concise to read.