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