author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* These functions are needed to load Multisite. |
|
4 |
* |
|
5 |
* @since 3.0.0 |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
* @subpackage Multisite |
|
9 |
*/ |
|
10 |
||
11 |
/** |
|
12 |
* Whether a subdomain configuration is enabled. |
|
13 |
* |
|
14 |
* @since 3.0.0 |
|
15 |
* |
|
16 |
* @return bool True if subdomain configuration is enabled, false otherwise. |
|
17 |
*/ |
|
18 |
function is_subdomain_install() { |
|
9 | 19 |
if ( defined( 'SUBDOMAIN_INSTALL' ) ) { |
0 | 20 |
return SUBDOMAIN_INSTALL; |
9 | 21 |
} |
0 | 22 |
|
16 | 23 |
return ( defined( 'VHOST' ) && 'yes' === VHOST ); |
0 | 24 |
} |
25 |
||
26 |
/** |
|
27 |
* Returns array of network plugin files to be included in global scope. |
|
28 |
* |
|
29 |
* The default directory is wp-content/plugins. To change the default directory |
|
5 | 30 |
* manually, define `WP_PLUGIN_DIR` and `WP_PLUGIN_URL` in `wp-config.php`. |
0 | 31 |
* |
32 |
* @access private |
|
33 |
* @since 3.1.0 |
|
5 | 34 |
* |
16 | 35 |
* @return string[] Array of absolute paths to files to include. |
0 | 36 |
*/ |
37 |
function wp_get_active_network_plugins() { |
|
38 |
$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); |
|
9 | 39 |
if ( empty( $active_plugins ) ) { |
0 | 40 |
return array(); |
9 | 41 |
} |
0 | 42 |
|
9 | 43 |
$plugins = array(); |
0 | 44 |
$active_plugins = array_keys( $active_plugins ); |
45 |
sort( $active_plugins ); |
|
46 |
||
47 |
foreach ( $active_plugins as $plugin ) { |
|
16 | 48 |
if ( ! validate_file( $plugin ) // $plugin must validate as file. |
49 |
&& '.php' === substr( $plugin, -4 ) // $plugin must end with '.php'. |
|
50 |
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist. |
|
9 | 51 |
) { |
52 |
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin; |
|
53 |
} |
|
0 | 54 |
} |
9 | 55 |
|
0 | 56 |
return $plugins; |
57 |
} |
|
58 |
||
59 |
/** |
|
60 |
* Checks status of current blog. |
|
61 |
* |
|
62 |
* Checks if the blog is deleted, inactive, archived, or spammed. |
|
63 |
* |
|
64 |
* Dies with a default message if the blog does not pass the check. |
|
65 |
* |
|
66 |
* To change the default message when a blog does not pass the check, |
|
67 |
* use the wp-content/blog-deleted.php, blog-inactive.php and |
|
68 |
* blog-suspended.php drop-ins. |
|
69 |
* |
|
5 | 70 |
* @since 3.0.0 |
71 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
* @return true|string Returns true on success, or drop-in file to include. |
0 | 73 |
*/ |
74 |
function ms_site_check() { |
|
75 |
||
76 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
* Filters checking the status of the current blog. |
0 | 78 |
* |
5 | 79 |
* @since 3.0.0 |
0 | 80 |
* |
16 | 81 |
* @param bool|null $check Whether to skip the blog status check. Default null. |
9 | 82 |
*/ |
0 | 83 |
$check = apply_filters( 'ms_site_check', null ); |
9 | 84 |
if ( null !== $check ) { |
0 | 85 |
return true; |
9 | 86 |
} |
0 | 87 |
|
16 | 88 |
// Allow super admins to see blocked sites. |
9 | 89 |
if ( is_super_admin() ) { |
0 | 90 |
return true; |
9 | 91 |
} |
0 | 92 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
$blog = get_site(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
|
0 | 95 |
if ( '1' == $blog->deleted ) { |
9 | 96 |
if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) { |
0 | 97 |
return WP_CONTENT_DIR . '/blog-deleted.php'; |
9 | 98 |
} else { |
5 | 99 |
wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) ); |
9 | 100 |
} |
0 | 101 |
} |
102 |
||
103 |
if ( '2' == $blog->deleted ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) { |
0 | 105 |
return WP_CONTENT_DIR . '/blog-inactive.php'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
$admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_network()->domain ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
wp_die( |
9 | 109 |
sprintf( |
16 | 110 |
/* translators: %s: Admin email link. */ |
9 | 111 |
__( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ), |
112 |
sprintf( '<a href="mailto:%1$s">%1$s</a>', $admin_email ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
} |
0 | 116 |
} |
117 |
||
16 | 118 |
if ( '1' == $blog->archived || '1' == $blog->spam ) { |
9 | 119 |
if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) { |
0 | 120 |
return WP_CONTENT_DIR . '/blog-suspended.php'; |
9 | 121 |
} else { |
0 | 122 |
wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) ); |
9 | 123 |
} |
0 | 124 |
} |
125 |
||
126 |
return true; |
|
127 |
} |
|
128 |
||
129 |
/** |
|
19 | 130 |
* Retrieves the closest matching network for a domain and path. |
5 | 131 |
* |
132 |
* @since 3.9.0 |
|
0 | 133 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
* @internal In 4.4.0, converted to a wrapper for WP_Network::get_by_path() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
* |
5 | 136 |
* @param string $domain Domain to check. |
137 |
* @param string $path Path to check. |
|
138 |
* @param int|null $segments Path segments to use. Defaults to null, or the full path. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
* @return WP_Network|false Network object if successful. False when no network is found. |
0 | 140 |
*/ |
5 | 141 |
function get_network_by_path( $domain, $path, $segments = null ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
return WP_Network::get_by_path( $domain, $path, $segments ); |
0 | 143 |
} |
144 |
||
145 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
* Retrieves the closest matching site object by its domain and path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
* This will not necessarily return an exact match for a domain and path. Instead, it |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
* breaks the domain and path into pieces that are then used to match the closest |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
* possibility from a query. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
* The intent of this method is to match a site object during bootstrap for a |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
* requested site address |
0 | 154 |
* |
5 | 155 |
* @since 3.9.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
* @since 4.7.0 Updated to always return a `WP_Site` object. |
5 | 157 |
* |
158 |
* @param string $domain Domain to check. |
|
159 |
* @param string $path Path to check. |
|
160 |
* @param int|null $segments Path segments to use. Defaults to null, or the full path. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
* @return WP_Site|false Site object if successful. False when no site is found. |
5 | 162 |
*/ |
163 |
function get_site_by_path( $domain, $path, $segments = null ) { |
|
164 |
$path_segments = array_filter( explode( '/', trim( $path, '/' ) ) ); |
|
0 | 165 |
|
5 | 166 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
* Filters the number of path segments to consider when searching for a site. |
5 | 168 |
* |
169 |
* @since 3.9.0 |
|
170 |
* |
|
171 |
* @param int|null $segments The number of path segments to consider. WordPress by default looks at |
|
172 |
* one path segment following the network path. The function default of |
|
173 |
* null only makes sense when you know the requested path should match a site. |
|
174 |
* @param string $domain The requested domain. |
|
175 |
* @param string $path The requested path, in full. |
|
176 |
*/ |
|
177 |
$segments = apply_filters( 'site_by_path_segments_count', $segments, $domain, $path ); |
|
0 | 178 |
|
5 | 179 |
if ( null !== $segments && count( $path_segments ) > $segments ) { |
180 |
$path_segments = array_slice( $path_segments, 0, $segments ); |
|
181 |
} |
|
182 |
||
183 |
$paths = array(); |
|
184 |
||
185 |
while ( count( $path_segments ) ) { |
|
186 |
$paths[] = '/' . implode( '/', $path_segments ) . '/'; |
|
187 |
array_pop( $path_segments ); |
|
0 | 188 |
} |
189 |
||
5 | 190 |
$paths[] = '/'; |
0 | 191 |
|
5 | 192 |
/** |
19 | 193 |
* Determines a site by its domain and path. |
5 | 194 |
* |
195 |
* This allows one to short-circuit the default logic, perhaps by |
|
196 |
* replacing it with a routine that is more optimal for your setup. |
|
197 |
* |
|
198 |
* Return null to avoid the short-circuit. Return false if no site |
|
199 |
* can be found at the requested domain and path. Otherwise, return |
|
200 |
* a site object. |
|
201 |
* |
|
202 |
* @since 3.9.0 |
|
203 |
* |
|
16 | 204 |
* @param null|false|WP_Site $site Site value to return by path. Default null |
205 |
* to continue retrieving the site. |
|
206 |
* @param string $domain The requested domain. |
|
207 |
* @param string $path The requested path, in full. |
|
208 |
* @param int|null $segments The suggested number of paths to consult. |
|
209 |
* Default null, meaning the entire path was to be consulted. |
|
210 |
* @param string[] $paths The paths to search for, based on $path and $segments. |
|
5 | 211 |
*/ |
212 |
$pre = apply_filters( 'pre_get_site_by_path', null, $domain, $path, $segments, $paths ); |
|
213 |
if ( null !== $pre ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
if ( false !== $pre && ! $pre instanceof WP_Site ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
$pre = new WP_Site( $pre ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
} |
5 | 217 |
return $pre; |
0 | 218 |
} |
219 |
||
5 | 220 |
/* |
221 |
* @todo |
|
16 | 222 |
* Caching, etc. Consider alternative optimization routes, |
5 | 223 |
* perhaps as an opt-in for plugins, rather than using the pre_* filter. |
224 |
* For example: The segments filter can expand or ignore paths. |
|
225 |
* If persistent caching is enabled, we could query the DB for a path <> '/' |
|
226 |
* then cache whether we can just always ignore paths. |
|
227 |
*/ |
|
228 |
||
229 |
// Either www or non-www is supported, not both. If a www domain is requested, |
|
230 |
// query for both to provide the proper redirect. |
|
231 |
$domains = array( $domain ); |
|
232 |
if ( 'www.' === substr( $domain, 0, 4 ) ) { |
|
233 |
$domains[] = substr( $domain, 4 ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
234 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
$args = array( |
9 | 237 |
'number' => 1, |
238 |
'update_site_meta_cache' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
if ( count( $domains ) > 1 ) { |
9 | 242 |
$args['domain__in'] = $domains; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
243 |
$args['orderby']['domain_length'] = 'DESC'; |
9 | 244 |
} else { |
245 |
$args['domain'] = array_shift( $domains ); |
|
5 | 246 |
} |
247 |
||
248 |
if ( count( $paths ) > 1 ) { |
|
9 | 249 |
$args['path__in'] = $paths; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
$args['orderby']['path_length'] = 'DESC'; |
9 | 251 |
} else { |
252 |
$args['path'] = array_shift( $paths ); |
|
0 | 253 |
} |
254 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
$result = get_sites( $args ); |
9 | 256 |
$site = array_shift( $result ); |
0 | 257 |
|
5 | 258 |
if ( $site ) { |
259 |
return $site; |
|
0 | 260 |
} |
261 |
||
5 | 262 |
return false; |
0 | 263 |
} |
264 |
||
265 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
* Identifies the network and site of a requested domain and path and populates the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
* corresponding network and site global objects as part of the multisite bootstrap process. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
* Prior to 4.6.0, this was a procedural block in `ms-settings.php`. It was wrapped into |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
* a function to facilitate unit tests. It should not be used outside of core. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
* Usually, it's easier to query the site first, which then declares its network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
* In limited situations, we either can or must find the network first. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
* If a network and site are found, a `true` response will be returned so that the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
* request can continue. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
* If neither a network or site is found, `false` or a URL string will be returned |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
* so that either an error can be shown or a redirect can occur. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
* @global WP_Network $current_site The current network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
* @global WP_Site $current_blog The current site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
* @param string $domain The requested domain. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
* @param string $path The requested path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
* @param bool $subdomain Optional. Whether a subdomain (true) or subdirectory (false) configuration. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
* Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
* @return bool|string True if bootstrap successfully populated `$current_blog` and `$current_site`. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
* False if bootstrap could not be properly completed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
* Redirect URL if parts exist, but the request as a whole can not be fulfilled. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
global $current_site, $current_blog; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
// If the network is defined in wp-config.php, we can simply use that. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) { |
9 | 300 |
$current_site = new stdClass; |
301 |
$current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
$current_site->domain = DOMAIN_CURRENT_SITE; |
9 | 303 |
$current_site->path = PATH_CURRENT_SITE; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
$current_site->blog_id = BLOG_ID_CURRENT_SITE; |
16 | 306 |
} elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) { // Deprecated. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
$current_site->blog_id = BLOGID_CURRENT_SITE; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
if ( 0 === strcasecmp( $current_site->domain, $domain ) && 0 === strcasecmp( $current_site->path, $path ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
$current_blog = get_site_by_path( $domain, $path ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
} elseif ( '/' !== $current_site->path && 0 === strcasecmp( $current_site->domain, $domain ) && 0 === stripos( $path, $current_site->path ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
// If the current network has a path and also matches the domain and path of the request, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
// we need to look for a site using the first path segment following the network's path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
$current_blog = get_site_by_path( $domain, $path, 1 + count( explode( '/', trim( $current_site->path, '/' ) ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
// Otherwise, use the first path segment (as usual). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
$current_blog = get_site_by_path( $domain, $path, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
} elseif ( ! $subdomain ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
* A "subdomain" installation can be re-interpreted to mean "can support any domain". |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
* If we're not dealing with one of these installations, then the important part is determining |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
* the network first, because we need the network's path to identify any sites. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
*/ |
16 | 326 |
$current_site = wp_cache_get( 'current_network', 'site-options' ); |
327 |
if ( ! $current_site ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
// Are there even two networks installed? |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
$networks = get_networks( array( 'number' => 2 ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
if ( count( $networks ) === 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
$current_site = array_shift( $networks ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
wp_cache_add( 'current_network', $current_site, 'site-options' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
} elseif ( empty( $networks ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
// A network not found hook should fire here. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
if ( empty( $current_site ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
$current_site = WP_Network::get_by_path( $domain, $path, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
if ( empty( $current_site ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
* Fires when a network cannot be found based on the requested domain and path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
* At the time of this action, the only recourse is to redirect somewhere |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
* and exit. If you want to declare a particular network, do so earlier. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
* @param string $domain The domain used to search for a network. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
* @param string $path The path used to search for a path. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
do_action( 'ms_network_not_found', $domain, $path ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
} elseif ( $path === $current_site->path ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
$current_blog = get_site_by_path( $domain, $path ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
// Search the network path + one more path segment (on top of the network path). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
$current_blog = get_site_by_path( $domain, $path, substr_count( $current_site->path, '/' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
// Find the site by the domain and at most the first path segment. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
$current_blog = get_site_by_path( $domain, $path, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
if ( $current_blog ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
$current_site = WP_Network::get_instance( $current_blog->site_id ? $current_blog->site_id : 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
// If you don't have a site with the same domain/path as a network, you're pretty screwed, but: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
$current_site = WP_Network::get_by_path( $domain, $path, 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
// The network declared by the site trumps any constants. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
if ( $current_blog && $current_blog->site_id != $current_site->id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
$current_site = WP_Network::get_instance( $current_blog->site_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
// No network has been found, bail. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
if ( empty( $current_site ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
/** This action is documented in wp-includes/ms-settings.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
do_action( 'ms_network_not_found', $domain, $path ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
// During activation of a new subdomain, the requested site does not yet exist. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
if ( empty( $current_blog ) && wp_installing() ) { |
9 | 390 |
$current_blog = new stdClass; |
16 | 391 |
$current_blog->blog_id = 1; |
392 |
$blog_id = 1; |
|
9 | 393 |
$current_blog->public = 1; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
// No site has been found, bail. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
if ( empty( $current_blog ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
// We're going to redirect to the network URL, with some possible modifications. |
9 | 399 |
$scheme = is_ssl() ? 'https' : 'http'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
$destination = "$scheme://{$current_site->domain}{$current_site->path}"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
* Fires when a network can be determined but a site cannot. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
* At the time of this action, the only recourse is to redirect somewhere |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
* and exit. If you want to declare a particular site, do so earlier. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
* @since 3.9.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
* |
18 | 410 |
* @param WP_Network $current_site The network that had been determined. |
411 |
* @param string $domain The domain used to search for a site. |
|
412 |
* @param string $path The path used to search for a site. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
do_action( 'ms_site_not_found', $current_site, $domain, $path ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
if ( $subdomain && ! defined( 'NOBLOGREDIRECT' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
// For a "subdomain" installation, redirect to the signup form specifically. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
$destination .= 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
} elseif ( $subdomain ) { |
16 | 420 |
/* |
421 |
* For a "subdomain" installation, the NOBLOGREDIRECT constant |
|
422 |
* can be used to avoid a redirect to the signup form. |
|
423 |
* Using the ms_site_not_found action is preferred to the constant. |
|
424 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
if ( '%siteurl%' !== NOBLOGREDIRECT ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
$destination = NOBLOGREDIRECT; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
} elseif ( 0 === strcasecmp( $current_site->domain, $domain ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
* If the domain we were searching for matches the network's domain, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
* it's no use redirecting back to ourselves -- it'll cause a loop. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
* As we couldn't find a site, we're simply not installed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
return $destination; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
// Figure out the current network's main site. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
if ( empty( $current_site->blog_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
$current_site->blog_id = get_main_site_id( $current_site->id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
/** |
0 | 449 |
* Displays a failure message. |
450 |
* |
|
451 |
* Used when a blog's tables do not exist. Checks for a missing $wpdb->site table as well. |
|
452 |
* |
|
453 |
* @access private |
|
454 |
* @since 3.0.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
* @since 4.4.0 The `$domain` and `$path` parameters were added. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
* @global wpdb $wpdb WordPress database abstraction object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* @param string $domain The requested domain for the error to reference. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* @param string $path The requested path for the error to reference. |
0 | 461 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
function ms_not_installed( $domain, $path ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
global $wpdb; |
0 | 464 |
|
5 | 465 |
if ( ! is_admin() ) { |
466 |
dead_db(); |
|
467 |
} |
|
468 |
||
0 | 469 |
wp_load_translations_early(); |
470 |
||
471 |
$title = __( 'Error establishing a database connection' ); |
|
5 | 472 |
|
9 | 473 |
$msg = '<h1>' . $title . '</h1>'; |
474 |
$msg .= '<p>' . __( 'If your site does not display, please contact the owner of this network.' ) . ''; |
|
475 |
$msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '</p>'; |
|
476 |
$query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) ); |
|
5 | 477 |
if ( ! $wpdb->get_var( $query ) ) { |
478 |
$msg .= '<p>' . sprintf( |
|
16 | 479 |
/* translators: %s: Table name. */ |
5 | 480 |
__( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s. You really should look at your database now.' ), |
481 |
'<code>' . $wpdb->site . '</code>' |
|
482 |
) . '</p>'; |
|
483 |
} else { |
|
484 |
$msg .= '<p>' . sprintf( |
|
16 | 485 |
/* translators: 1: Site URL, 2: Table name, 3: Database name. */ |
5 | 486 |
__( '<strong>Could not find site %1$s.</strong> Searched for table %2$s in database %3$s. Is that right?' ), |
487 |
'<code>' . rtrim( $domain . $path, '/' ) . '</code>', |
|
488 |
'<code>' . $wpdb->blogs . '</code>', |
|
489 |
'<code>' . DB_NAME . '</code>' |
|
490 |
) . '</p>'; |
|
491 |
} |
|
0 | 492 |
$msg .= '<p><strong>' . __( 'What do I do now?' ) . '</strong> '; |
9 | 493 |
$msg .= sprintf( |
16 | 494 |
/* translators: %s: Documentation URL. */ |
495 |
__( 'Read the <a href="%s" target="_blank">Debugging a WordPress Network</a> article. Some of the suggestions there may help you figure out what went wrong.' ), |
|
496 |
__( 'https://wordpress.org/support/article/debugging-a-wordpress-network/' ) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
); |
19 | 498 |
$msg .= ' ' . __( 'If you are still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>'; |
9 | 499 |
foreach ( $wpdb->tables( 'global' ) as $t => $table ) { |
16 | 500 |
if ( 'sitecategories' === $t ) { |
0 | 501 |
continue; |
9 | 502 |
} |
0 | 503 |
$msg .= '<li>' . $table . '</li>'; |
504 |
} |
|
505 |
$msg .= '</ul>'; |
|
506 |
||
5 | 507 |
wp_die( $msg, $title, array( 'response' => 500 ) ); |
0 | 508 |
} |
5 | 509 |
|
510 |
/** |
|
511 |
* This deprecated function formerly set the site_name property of the $current_site object. |
|
512 |
* |
|
513 |
* This function simply returns the object, as before. |
|
514 |
* The bootstrap takes care of setting site_name. |
|
515 |
* |
|
516 |
* @access private |
|
517 |
* @since 3.0.0 |
|
518 |
* @deprecated 3.9.0 Use get_current_site() instead. |
|
519 |
* |
|
18 | 520 |
* @param WP_Network $current_site |
521 |
* @return WP_Network |
|
5 | 522 |
*/ |
523 |
function get_current_site_name( $current_site ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
524 |
_deprecated_function( __FUNCTION__, '3.9.0', 'get_current_site()' ); |
5 | 525 |
return $current_site; |
526 |
} |
|
527 |
||
528 |
/** |
|
529 |
* This deprecated function managed much of the site and network loading in multisite. |
|
530 |
* |
|
531 |
* The current bootstrap code is now responsible for parsing the site and network load as |
|
532 |
* well as setting the global $current_site object. |
|
533 |
* |
|
534 |
* @access private |
|
535 |
* @since 3.0.0 |
|
536 |
* @deprecated 3.9.0 |
|
537 |
* |
|
18 | 538 |
* @global WP_Network $current_site |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
* |
18 | 540 |
* @return WP_Network |
5 | 541 |
*/ |
542 |
function wpmu_current_site() { |
|
543 |
global $current_site; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
544 |
_deprecated_function( __FUNCTION__, '3.9.0' ); |
5 | 545 |
return $current_site; |
546 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
548 |
/** |
19 | 549 |
* Retrieves an object containing information about the requested network. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
551 |
* @since 3.9.0 |
19 | 552 |
* @deprecated 4.7.0 Use get_network() |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
553 |
* @see get_network() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
554 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
555 |
* @internal In 4.6.0, converted to use get_network() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
556 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
557 |
* @param object|int $network The network's database row or ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
* @return WP_Network|false Object containing network information if found, false if not. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
559 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
function wp_get_network( $network ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
561 |
_deprecated_function( __FUNCTION__, '4.7.0', 'get_network()' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
562 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
563 |
$network = get_network( $network ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
564 |
if ( null === $network ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
565 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
return $network; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
} |