Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS;
$iterator = new \FilesystemIterator(__DIR__, $flags);
foreach ($iterator as $path => $item) {
if ($item->isDir()) {
$muPath = trailingslashit($path);
$fileName = basename($item->getFileName());
$filePath = "{$muPath}/{$fileName}.php";
if (file_exists($filePath)) {
require_once $filePath;
Copy link

awps commented Mar 9, 2021

Save this code in a file and place it in WordPress mu-plugins folder. It will load all mu-plugins that are inside directories. But, the entry file must match the plugin directory name. Example:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment