Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,31 @@ Feature: Manage WordPress plugins
| name | title | description |
| test-mu | Test mu-plugin | Test mu-plugin description |

Scenario: Listing mu-plugins should include plugins from subfolders
Given a WP install
And a wp-content/mu-plugins/test-mu-root.php file:
"""
<?php
// Plugin Name: Test MU Root
// Description: Test mu-plugin in root
// Version: 1.0.0
"""
And a wp-content/mu-plugins/subfolder-plugin/subfolder-plugin.php file:
"""
<?php
/**
* Plugin Name: Subfolder MU Plugin
* Description: Test mu-plugin in subfolder
* Version: 2.0.0
*/
"""

When I run `wp plugin list --status=must-use --fields=name,title,version`
Then STDOUT should be a table containing rows:
| name | title | version |
| test-mu-root | Test MU Root | 1.0.0 |
| subfolder-plugin | Subfolder MU Plugin | 2.0.0 |
Comment thread
swissspidy marked this conversation as resolved.

@require-wp-5.5
Scenario: Listing plugins should include name and auto_update
Given a WP install
Expand Down
20 changes: 19 additions & 1 deletion src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,25 @@ protected function status_single( $args ) {
protected function get_all_items() {
$items = $this->get_item_list();

foreach ( get_mu_plugins() as $file => $mu_plugin ) {
// Get all mu-plugins including those in subfolders.
// get_mu_plugins() only returns PHP files directly in the mu-plugins directory.
// To also get plugins in subfolders, we use get_plugins() with a relative path.
$mu_plugins = get_mu_plugins();
if ( defined( 'WPMU_PLUGIN_DIR' ) ) {
// Get plugins from mu-plugins subfolders using the relative path approach.
// This is the standard WordPress method to access plugins in the mu-plugins directory.
$mu_plugins_subfolder = get_plugins( '/../' . basename( WPMU_PLUGIN_DIR ) );
// Merge subfolder plugins with root-level mu-plugins.
// No duplicates possible: get_mu_plugins() returns 'plugin.php' (root only)
// while get_plugins() returns 'subfolder/plugin.php' (different keys).
foreach ( $mu_plugins_subfolder as $file => $plugin_data ) {
if ( ! isset( $mu_plugins[ $file ] ) ) {
$mu_plugins[ $file ] = $plugin_data;
}
}
}
Comment thread
swissspidy marked this conversation as resolved.
Outdated

foreach ( $mu_plugins as $file => $mu_plugin ) {
$mu_version = '';
if ( ! empty( $mu_plugin['Version'] ) ) {
$mu_version = $mu_plugin['Version'];
Expand Down