From 52c3be160294ad8e1e44dea2ab25635a49730f77 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Thu, 10 Sep 2015 05:06:24 +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. Built from https://develop.svn.wordpress.org/trunk@33990 git-svn-id: http://core.svn.wordpress.org/trunk@33959 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-settings.php | 16 ++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-includes/ms-settings.php b/wp-includes/ms-settings.php index d7f42b367d..88e7629887 100644 --- a/wp-includes/ms-settings.php +++ b/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 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index adef3aa9c1..0d3caf063d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.