Skip to content

Instantly share code, notes, and snippets.

@acki
Created February 22, 2018 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acki/a7132dfdb97da3404259ee802cce2bd7 to your computer and use it in GitHub Desktop.
Save acki/a7132dfdb97da3404259ee802cce2bd7 to your computer and use it in GitHub Desktop.
WordPress MU Plugins autoloader
<?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