Created
April 24, 2015 23:23
-
-
Save ericmann/608018a71cb04581b259 to your computer and use it in GitHub Desktop.
Simple autoloader for WordPress Must-Use plugins. The loader assumes plugins use the format `{plugin-name}\{plugin-name}`.php for their core file. If not, they're skipped.
This file contains hidden or 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 | |
/** | |
* MU-Plugin Autoloader | |
* | |
* @author Eric Mann <[email protected]> | |
* @license MIT | |
* @copyright 2015 Eric Mann | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
$paths = scandir( dirname( __FILE__ ) ); | |
$paths = array_diff( $paths, array( '..', '.' ) ); | |
foreach( $paths as $maybe_plugin ) { | |
if ( strpos( $maybe_plugin, '.php' ) != 0 ) { | |
continue; | |
} | |
// Attempt to get the loader file. | |
$core_file = WPMU_PLUGIN_DIR . "/{$maybe_plugin}/{$maybe_plugin}.php"; | |
if ( file_exists( $core_file ) ) { | |
require_once $core_file; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment