Skip to content

Instantly share code, notes, and snippets.

@gaswirth
Last active December 29, 2022 20:57
Show Gist options
  • Save gaswirth/eeb859d5151aa8835762b9b9064c33a2 to your computer and use it in GitHub Desktop.
Save gaswirth/eeb859d5151aa8835762b9b9064c33a2 to your computer and use it in GitHub Desktop.
A small plugin to allow using plugin directories within the `mu-plugins/` directory
<?php
/**
* Plugin Name: RHDWP MU Loader
* Author: Roundhouse Designs
* Author URI: https://roundhouse-designs.com
* Description: Loads plugins in directories from the `mu-plugins` folder.
* Version: 1.0.0
*
* @package RHD
* @version 1.0.0
*/
$wpmu_plugin_dir = opendir( WPMU_PLUGIN_DIR );
// List all the entries in this directory.
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( false !== ( $entry = readdir( $wpmu_plugin_dir ) ) ) {
$plugin_path = WPMU_PLUGIN_DIR . '/' . $entry;
// Load the plugin if this is a subdirectory.
if ( '.' !== $entry && '..' !== $entry && is_dir( $plugin_path ) && substr( $entry, 0, 1 ) !== '.' ) {
require $plugin_path . '/' . $entry . '.php';
}
}
closedir( $wpmu_plugin_dir );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment