Skip to content

Instantly share code, notes, and snippets.

@JoryHogeveen
Created September 28, 2017 18:19
Show Gist options
  • Save JoryHogeveen/b91d144c9916df430c821fcd834a9667 to your computer and use it in GitHub Desktop.
Save JoryHogeveen/b91d144c9916df430c821fcd834a9667 to your computer and use it in GitHub Desktop.
WordPress mu-plugins loader
<?php
/**
* Load the mu-plugins just like regular plugins.
*/
$directory = scandir( WPMU_PLUGIN_DIR );
foreach ($directory as $dir) {
if ( $dir === '.' || $dir === '..' ) continue;
if ( is_dir( WPMU_PLUGIN_DIR . '/' . $dir ) && file_exists( WPMU_PLUGIN_DIR . '/' . $dir . '/' . $dir . '.php' ) ) {
define( 'MU_PLUGIN_' . strtoupper($dir) . '_URL', content_url() . '/mu-plugins/' . $dir );
include_once( WPMU_PLUGIN_DIR . '/' . $dir . '/' . $dir . '.php' );
}
}
@JoryHogeveen
Copy link
Author

Load the mu-plugins just like regular plugins.
Add this file in the wp-content/mu-plugins/ folder

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