Created
April 26, 2020 07:56
-
-
Save trvswgnr/64bc9237f420a4d56097447b11396625 to your computer and use it in GitHub Desktop.
Automatically load plugins in folders inside the mu-plugins folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Automatically loads plugins in folders | |
* | |
* @package mu-plugin-autoloader | |
*/ | |
$dirs = array_filter( glob( WPMU_PLUGIN_DIR . '/*' ), 'is_dir' ); | |
foreach ( $dirs as $dirpath ) { | |
$regex = '/([^\/]+$)/'; | |
preg_match( $regex, $dirpath, $matches ); | |
$dirname = $matches[0]; | |
require_once WPMU_PLUGIN_DIR . "/$dirname/$dirname.php"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment