From 30827727338c076acc5e462d1a7fe037e1eb7682 Mon Sep 17 00:00:00 2001 From: Phil Baker Date: Fri, 1 Nov 2024 22:45:05 +0000 Subject: [PATCH] Allow for wp-config being outside the docroot --- WordPressMultisiteSubdirectoryValetDriver.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/WordPressMultisiteSubdirectoryValetDriver.php b/WordPressMultisiteSubdirectoryValetDriver.php index 5b870b6..57ad4d3 100644 --- a/WordPressMultisiteSubdirectoryValetDriver.php +++ b/WordPressMultisiteSubdirectoryValetDriver.php @@ -13,14 +13,23 @@ class WordPressMultisiteSubdirectoryValetDriver extends BasicValetDriver */ public function serves(string $sitePath, string $siteName, string $uri): bool { + // set wp-config.php path + $wpConfig = $sitePath . '/wp-config.php'; + + // if the usual path does not exist + // check the parent directory instead + if (!file_exists($wpConfig)) { + $wpConfig = dirname($sitePath) . '/wp-config.php'; + } + // Look for MULTISITE in wp-config.php. It should be there for multisite installs. - return file_exists($sitePath . '/wp-config.php') && - (strpos( file_get_contents($sitePath . '/wp-config.php'), 'MULTISITE') !== false) && + return file_exists($wpConfig) && + (strpos( file_get_contents($wpConfig), 'MULTISITE') !== false) && ( //Double check if we are using subdomains. - strpos( file_get_contents($sitePath . '/wp-config.php'), "define('SUBDOMAIN_INSTALL',false)") || - strpos( file_get_contents($sitePath . '/wp-config.php'), "define('SUBDOMAIN_INSTALL', false)") || - strpos( file_get_contents($sitePath . '/wp-config.php'), "define( 'SUBDOMAIN_INSTALL', false )") + strpos( file_get_contents($wpConfig), "define('SUBDOMAIN_INSTALL',false)") || + strpos( file_get_contents($wpConfig), "define('SUBDOMAIN_INSTALL', false)") || + strpos( file_get_contents($wpConfig), "define( 'SUBDOMAIN_INSTALL', false )") ); }