Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simplify fetching requires header values
  • Loading branch information
ernilambar committed Apr 25, 2024
commit ea5566b96ab09917ee63c87abf054ab1c7ae335b
18 changes: 3 additions & 15 deletions src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -986,23 +986,11 @@ public function get( $args, $assoc_args ) {
'version' => $plugin_data['Version'],
'description' => wordwrap( $plugin_data['Description'] ),
'status' => $this->get_status( $file ),
'requires_wp' => '',
'requires_php' => '',
'requires_plugins' => '',
'requires_wp' => ! empty( $plugin_data['RequiresWP'] ) ? $plugin_data['RequiresWP'] : '',
'requires_php' => ! empty( $plugin_data['RequiresPHP'] ) ? $plugin_data['RequiresPHP'] : '',
'requires_plugins' => ! empty( $plugin_data['RequiresPlugins'] ) ? $plugin_data['RequiresPlugins'] : '',
];

$require_fields = [
'requires_wp' => 'RequiresWP',
'requires_php' => 'RequiresPHP',
'requires_plugins' => 'RequiresPlugins',
];

foreach ( $require_fields as $field_key => $data_key ) {
if ( isset( $plugin_data[ $data_key ] ) && ! empty( $plugin_data[ $data_key ] ) ) {
$plugin_obj->{$field_key} = $plugin_data[ $data_key ];
}
}

if ( empty( $assoc_args['fields'] ) ) {
$assoc_args['fields'] = $default_fields;
}
Expand Down