From 837b6c3e3e97c60d2d0d6f117075594fe9015b02 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 10 Sep 2015 05:05:14 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@33990 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-settings.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index d7f42b367d..88e7629887 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -86,6 +86,19 @@ if ( !isset( $current_site ) || !isset( $current_blog ) ) { } 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 ); } elseif ( $path === $current_site->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. 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 ); }