Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
11 changes: 9 additions & 2 deletions WordPressMultisiteSubdirectoryValetDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
);

}

/**
Expand Down