Skip to content

Commit

Permalink
Makes the mu-plugin src directory configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Taylor authored and Ian Jenkins committed Aug 27, 2021
1 parent 4a9257c commit ab11e71
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,13 @@ If you work on Windows but use a Linux VM to run your development server, you ma
"force-unix-separator": true
}
```

## Modifying the src directory of the mu plugins

You may wish to change the src directory you want the mu plugins to be loaded from. For example, on WordPress VIP projects
you may wish to load mu plugins from client-mu-plugins using this loader. To do this you can set a constant to tell the
mu plugin loader where your mu plugins are kept:

```php
define('MU_PLUGIN_LOADER_SRC_DIR', WPCOM_VIP_CLIENT_MU_PLUGIN_DIR . '/');
```
2 changes: 1 addition & 1 deletion src/lkwdwrd/mu-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
if (! defined('WP_INSTALLING') || ! WP_INSTALLING ) {
// Run the loader unless installing
Loader\mu_loader();
Loader\mu_loader(false, Loader\PS, defined('MU_PLUGIN_LOADER_SRC_DIR') ? MU_PLUGIN_LOADER_SRC_DIR : Loader\MUDIR);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lkwdwrd/util/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
function mu_loader( $plugins = false, $ps = PS, $mudir = MUDIR ): void {
if ( ! $plugins ) {
$plugins = get_muplugins();
$plugins = get_muplugins(ABSPATH, WP_PLUGIN_DIR, $mudir);
}
foreach( $plugins as $plugin ) {
// Conditionally register the MU plugin in WordPress 3.9 or newer.
Expand Down

0 comments on commit ab11e71

Please sign in to comment.