Multisite: Add action to handle network not found

`ms_network_not_found` fires when the global `$current_site` has not been filled and `ms_not_installed()` is about to fire. It cannot be used to populate `$current_site`, but can be used to capture the request and redirect or present a custom error.

Props rmccue.
Fixes #31702.

Built from https://develop.svn.wordpress.org/trunk@33990


git-svn-id: http://core.svn.wordpress.org/trunk@33959 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Jeremy Felt 2015-09-10 05:06:24 +00:00
parent 7278744dd0
commit 52c3be1602
2 changed files with 17 additions and 1 deletions

View File

@ -86,6 +86,19 @@ if ( !isset( $current_site ) || !isset( $current_blog ) ) {
} }
if ( empty( $current_site ) ) { if ( empty( $current_site ) ) {
/**
* Fires when a network cannot be found based on the requested domain and path.
*
* At the time of this action, the only recourse is to redirect somewhere
* and exit. If you want to declare a particular network, do so earlier.
*
* @since 4.4.0
*
* @param string $domain The domain used to search for a network.
* @param string $path The path used to search for a path.
*/
do_action( 'ms_network_not_found', $domain, $path );
ms_not_installed( $domain, $path ); ms_not_installed( $domain, $path );
} elseif ( $path === $current_site->path ) { } elseif ( $path === $current_site->path ) {
$current_blog = get_site_by_path( $domain, $path ); $current_blog = get_site_by_path( $domain, $path );
@ -111,6 +124,9 @@ if ( !isset( $current_site ) || !isset( $current_blog ) ) {
// No network has been found, bail. // No network has been found, bail.
if ( empty( $current_site ) ) { if ( empty( $current_site ) ) {
/** This action is documented in wp-includes/ms-settings.php */
do_action( 'ms_network_not_found', $domain, $path );
ms_not_installed( $domain, $path ); ms_not_installed( $domain, $path );
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-33989'; $wp_version = '4.4-alpha-33990';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.