From c8fa74c8b5e849562fb78bb1585835d1c2d9821a Mon Sep 17 00:00:00 2001 From: Andrzej Wojtczyk Date: Tue, 17 Apr 2018 00:21:47 +0200 Subject: [PATCH] Double check for subdomain installation. --- README.md | 5 +---- WordPressMultisiteSubdirectoryValetDriver.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7532cc9..46dafd6 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,8 @@ A custom driver for [Laravel Valet](https://laravel.com/docs/master/valet) that 1. `git clone https://github.com/Objectivco/WordPressMultisiteSubdirectoryValetDriver.git` 2. `cd WordPressMultisiteSubdirectoryValetDriver` 3. `cp WordPressMultisiteSubdirectoryValetDriver.php ~/.valet/Drivers` -4. Make sure your wp-config.php file has at least one of WP_ALLOW_MULTISITE or MULTISITE constants defined. +4. Make sure your wp-config.php file has `define('MULTISITE', true);` and `define('SUBDOMAIN_INSTALL', true);` constants defined. 5. Celebrate the pain you just avoided! ## Installs with WordPress root files in a subdirectory If your install has WordPress root files in a subdirectory (such as a submodule), simply change the class property `$wp_root` from false to the root directory name. - -## Caveats -This only works with the subdirectory URL scheme. If you have a subdomain site setup with Valet, this driver will probably break it. You'll need to modify the `serves()` function to prevent this driver from handling the request. diff --git a/WordPressMultisiteSubdirectoryValetDriver.php b/WordPressMultisiteSubdirectoryValetDriver.php index a72c39f..9c05edd 100644 --- a/WordPressMultisiteSubdirectoryValetDriver.php +++ b/WordPressMultisiteSubdirectoryValetDriver.php @@ -13,8 +13,15 @@ class WordPressMultisiteSubdirectoryValetDriver extends BasicValetDriver */ public function serves($sitePath, $siteName, $uri) { - // 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; + // 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) && + ( + //Double check if we are using subdomains. + strpos( file_get_contents($sitePath . '/wp-config.php'), "define('SUBDOMAIN_INSTALL',true)") || + strpos( file_get_contents($sitePath . '/wp-config.php'), "define('SUBDOMAIN_INSTALL', true)") + ); + } /**