From 383c3079d87573cfd2bd590b54c5143eb9da113d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Nov 2025 14:17:13 +0100 Subject: [PATCH 1/4] Remove `url` field from plugin command docs This field never existed. --- src/Plugin_Command.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index ef5b061fb..0cf75f923 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -170,7 +170,6 @@ public function status( $args ) { * **icons**: Plugin's Icon Image Link * **active_installs**: Plugin's Number of Active Installs * **contributors**: Plugin's List of Contributors - * **url**: Plugin's URL on wordpress.org * * [--format=] * : Render output in a particular format. From 075ea64c2eef57a26a24beab832c49b84a57f824 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Nov 2025 19:01:28 +0100 Subject: [PATCH 2/4] Revert "Remove `url` field from plugin command docs" This reverts commit 383c3079d87573cfd2bd590b54c5143eb9da113d. --- src/Plugin_Command.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 0cf75f923..ef5b061fb 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -170,6 +170,7 @@ public function status( $args ) { * **icons**: Plugin's Icon Image Link * **active_installs**: Plugin's Number of Active Installs * **contributors**: Plugin's List of Contributors + * **url**: Plugin's URL on wordpress.org * * [--format=] * : Render output in a particular format. From 6dd2924914703a50574ea055e28635d38a6d6b23 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Nov 2025 19:04:29 +0100 Subject: [PATCH 3/4] Implement suggestion Props mrsdizzie --- features/plugin-search.feature | 9 +++++++++ src/WP_CLI/CommandWithUpgrade.php | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/features/plugin-search.feature b/features/plugin-search.feature index ddf80d442..ab5e5bbc6 100644 --- a/features/plugin-search.feature +++ b/features/plugin-search.feature @@ -18,3 +18,12 @@ Feature: Search WordPress.org plugins """ name,slug,active_installs """ + + Scenario: Search for plugins with url field + Given a WP install + + When I run `wp plugin search gutenberg --fields=slug,url --format=csv` + Then STDOUT should contain: + """ + gutenberg,https://wordpress.org/plugins/gutenberg/ + """ diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 798d8ca92..ff5fd2145 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -854,8 +854,8 @@ protected function _search( $args, $assoc_args ) { // Add `url` for plugin or theme on wordpress.org. foreach ( $items as $index => $item_object ) { - if ( $item_object instanceof \stdClass ) { - $item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/"; + if ( is_array( $item_object ) ) { + $items[ $index ]['url'] = "https://wordpress.org/{$plural}/{$item_object['slug']}/"; } } From ffdaf58c1f90023c70d4f34e2025d5caecea856f Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 6 Nov 2025 20:59:07 +0100 Subject: [PATCH 4/4] Try fix for WP 4.9 --- src/WP_CLI/CommandWithUpgrade.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index ff5fd2145..f64c8c955 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -853,9 +853,12 @@ protected function _search( $args, $assoc_args ) { $items = $api->$plural; // Add `url` for plugin or theme on wordpress.org. + // In older WP versions these used to be objects. foreach ( $items as $index => $item_object ) { if ( is_array( $item_object ) ) { $items[ $index ]['url'] = "https://wordpress.org/{$plural}/{$item_object['slug']}/"; + } elseif ( $item_object instanceof \stdClass ) { + $item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/"; } }