Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$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;
}
}
}
@awps
Copy link
Author

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:

my-nice-plugin/my-nice-plugin.php

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