Created
February 22, 2018 13:16
-
-
Save acki/a7132dfdb97da3404259ee802cce2bd7 to your computer and use it in GitHub Desktop.
WordPress MU Plugins autoloader
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 | |
/** | |
* This file is for loading all mu-plugins within subfolders | |
* where the PHP file name is exactly like the directory name + .php. | |
* | |
* Example: /mu-tools/mu-tools.php | |
*/ | |
$dirs = glob(dirname(__FILE__) . '/*' , GLOB_ONLYDIR); | |
foreach( $dirs as $dir ) { | |
if( file_exists( $dir . DIRECTORY_SEPARATOR . basename($dir) . ".php" ) ) { | |
require( $dir . DIRECTORY_SEPARATOR . basename( $dir ) . ".php" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment