Skip to content

Commit

Permalink
Merge pull request #305 from alexstine/add/mu-plugin-title
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored May 25, 2022
2 parents 5d23f5b + fb44a3d commit 68f1fcf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
19 changes: 19 additions & 0 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -676,3 +676,22 @@ Feature: Manage WordPress plugins
Error: Parameter errors:
Invalid value specified for 'status' (Filter the output by plugin status.)
"""

Scenario: Listing mu-plugins should include name and title
Given a WP install
And a wp-content/mu-plugins/test-mu.php file:
"""
<?php
// Plugin Name: Test mu-plugin
// Description: Test mu-plugin description
"""

When I run `wp plugin list --fields=name,title`
Then STDOUT should be a table containing rows:
| name | title |
| test-mu | Test mu-plugin |

When I run `wp plugin list --fields=name,title,description`
Then STDOUT should be a table containing rows:
| name | title | description |
| test-mu | Test mu-plugin | Test mu-plugin description |
14 changes: 12 additions & 2 deletions src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ protected function get_all_items() {
$mu_version = $mu_plugin['Version'];
}

$mu_title = '';
if ( ! empty( $mu_plugin['Name'] ) ) {
$mu_title = $mu_plugin['Title'];
}

$mu_description = '';
if ( ! empty( $mu_plugin['Description'] ) ) {
$mu_description = $mu_plugin['Description'];
}

$items[ $file ] = array(
'name' => Utils\get_plugin_name( $file ),
'status' => 'must-use',
Expand All @@ -242,8 +252,8 @@ protected function get_all_items() {
'update_package' => null,
'version' => $mu_version,
'update_id' => '',
'title' => '',
'description' => '',
'title' => $mu_title,
'description' => $mu_description,
'file' => $file,
);
}
Expand Down

0 comments on commit 68f1fcf

Please sign in to comment.