Last active
March 9, 2021 15:07
-
-
Save awps/9d9d97ef743d78f32f10ca78d2ba1746 to your computer and use it in GitHub Desktop.
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 | |
$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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: