From 18cd42aa79c60a307420567c4c32bcc6ea5b7aa3 Mon Sep 17 00:00:00 2001 From: softglazee Date: Sat, 24 Oct 2026 07:35:48 +0500 Subject: [PATCH] Fix `wp ability list --format=ids` output The `ids` format of the formatter expects plain values, but the ability rows were passed as arrays, which printed "Array" once per ability and an "Array to string conversion" warning each. Pass the ability names instead, the same way `wp cron event list` passes the hook names. --- features/ability.feature | 7 +++++++ src/Ability_Command.php | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/features/ability.feature b/features/ability.feature index 81e230c..4718434 100644 --- a/features/ability.feature +++ b/features/ability.feature @@ -95,6 +95,13 @@ Feature: Manage abilities registered via the WordPress Abilities API. "name":"test-plugin\/get-site-title" """ + When I run `wp ability list --category=test-category --format=ids` + Then STDOUT should be: + """ + test-plugin/get-site-title test-plugin/echo-input + """ + And STDERR should be empty + @require-wp-6.9 Scenario: Get ability details. Given a wp-content/mu-plugins/test-ability.php file: diff --git a/src/Ability_Command.php b/src/Ability_Command.php index 3a21351..90fc993 100644 --- a/src/Ability_Command.php +++ b/src/Ability_Command.php @@ -242,6 +242,12 @@ public function list_( $args, $assoc_args ): void { } $formatter = $this->get_formatter( $assoc_args, $this->default_fields ); + + // The ids format expects plain values, so pass the ability names. + if ( 'ids' === $formatter->format ) { + $items = wp_list_pluck( $items, 'name' ); + } + $formatter->display_items( $items ); }