Skip to content

Instantly share code, notes, and snippets.

@awps
Last active March 9, 2021 15:07
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 awps/9d9d97ef743d78f32f10ca78d2ba1746 to your computer and use it in GitHub Desktop.
Save awps/9d9d97ef743d78f32f10ca78d2ba1746 to your computer and use it in GitHub Desktop.
<?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