Skip to content

Commit 54f9478

Browse files
Copilotswissspidy
andcommitted
Add clarifying comments about mu-plugin handling
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 5f67881 commit 54f9478

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Plugin_Command.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,17 @@ protected function get_all_items() {
240240
$items = $this->get_item_list();
241241

242242
// Get all mu-plugins including those in subfolders.
243+
// get_mu_plugins() only returns PHP files directly in the mu-plugins directory.
244+
// To also get plugins in subfolders, we use get_plugins() with a relative path.
243245
$mu_plugins = get_mu_plugins();
244246
if ( defined( 'WPMU_PLUGIN_DIR' ) ) {
247+
// Get plugins from mu-plugins subfolders using the relative path approach.
248+
// This is the standard WordPress method to access plugins in the mu-plugins directory.
245249
$mu_plugins_subfolder = get_plugins( '/../' . basename( WPMU_PLUGIN_DIR ) );
246-
// Merge subfolder plugins with the main mu-plugins list.
250+
// Merge subfolder plugins with root-level mu-plugins.
251+
// No duplicates possible: get_mu_plugins() returns 'plugin.php' (root only)
252+
// while get_plugins() returns 'subfolder/plugin.php' (different keys).
247253
foreach ( $mu_plugins_subfolder as $file => $plugin_data ) {
248-
// Only add if not already in the list (avoid duplicates from root-level plugins).
249254
if ( ! isset( $mu_plugins[ $file ] ) ) {
250255
$mu_plugins[ $file ] = $plugin_data;
251256
}

0 commit comments

Comments
 (0)