Skip to content

Commit 81717cb

Browse files
Copilotswissspidy
andauthored
List mu-plugins from subfolders (#484)
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent ec19f99 commit 81717cb

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

features/plugin.feature

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,31 @@ Feature: Manage WordPress plugins
817817
| name | title | description |
818818
| test-mu | Test mu-plugin | Test mu-plugin description |
819819

820+
Scenario: Listing mu-plugins should include plugins from subfolders
821+
Given a WP install
822+
And a wp-content/mu-plugins/test-mu-root.php file:
823+
"""
824+
<?php
825+
// Plugin Name: Test MU Root
826+
// Description: Test mu-plugin in root
827+
// Version: 1.0.0
828+
"""
829+
And a wp-content/mu-plugins/subfolder-plugin/subfolder-plugin.php file:
830+
"""
831+
<?php
832+
/**
833+
* Plugin Name: Subfolder MU Plugin
834+
* Description: Test mu-plugin in subfolder
835+
* Version: 2.0.0
836+
*/
837+
"""
838+
839+
When I run `wp plugin list --status=must-use --fields=name,title,version`
840+
Then STDOUT should be a table containing rows:
841+
| name | title | version |
842+
| test-mu-root | Test MU Root | 1.0.0 |
843+
| subfolder-plugin | Subfolder MU Plugin | 2.0.0 |
844+
820845
@require-wp-5.5
821846
Scenario: Listing plugins should include name and auto_update
822847
Given a WP install

src/Plugin_Command.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ protected function status_single( $args ) {
333333
protected function get_all_items() {
334334
$items = $this->get_item_list();
335335

336-
foreach ( get_mu_plugins() as $file => $mu_plugin ) {
336+
// Get all mu-plugins including those in subfolders.
337+
$mu_plugins_from_root = get_mu_plugins();
338+
$all_mu_plugins = get_plugins( '/../' . basename( WPMU_PLUGIN_DIR ) );
339+
$mu_plugins = array_replace( $all_mu_plugins, $mu_plugins_from_root );
340+
341+
foreach ( $mu_plugins as $file => $mu_plugin ) {
337342
$mu_version = '';
338343
if ( ! empty( $mu_plugin['Version'] ) ) {
339344
$mu_version = $mu_plugin['Version'];

0 commit comments

Comments
 (0)