Skip to content

Commit 6dd2924

Browse files
committed
Implement suggestion
Props mrsdizzie
1 parent 075ea64 commit 6dd2924

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

features/plugin-search.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ Feature: Search WordPress.org plugins
1818
"""
1919
name,slug,active_installs
2020
"""
21+
22+
Scenario: Search for plugins with url field
23+
Given a WP install
24+
25+
When I run `wp plugin search gutenberg --fields=slug,url --format=csv`
26+
Then STDOUT should contain:
27+
"""
28+
gutenberg,https://wordpress.org/plugins/gutenberg/
29+
"""

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,8 @@ protected function _search( $args, $assoc_args ) {
854854

855855
// Add `url` for plugin or theme on wordpress.org.
856856
foreach ( $items as $index => $item_object ) {
857-
if ( $item_object instanceof \stdClass ) {
858-
$item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/";
857+
if ( is_array( $item_object ) ) {
858+
$items[ $index ]['url'] = "https://wordpress.org/{$plural}/{$item_object['slug']}/";
859859
}
860860
}
861861

0 commit comments

Comments
 (0)