From 26862c078004141ee45d3549d02fa63d9f38d5ff Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Thu, 19 Jul 2018 12:11:25 +0100 Subject: [PATCH 1/3] Search: Add plugin or theme's URL on wordpress.org After the plugin_api() or theme_api() call is made, update the results with the generated URL for wordpress.org, made up of a hard-coded domain name, the plural of the item type, and the item's slug. Fixes #94. --- src/Plugin_Command.php | 1 + src/Theme_Command.php | 1 + src/WP_CLI/CommandWithUpgrade.php | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 80bdda9bd..53fdac81a 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -152,6 +152,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. diff --git a/src/Theme_Command.php b/src/Theme_Command.php index cc79948a4..97df15ced 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -125,6 +125,7 @@ public function status( $args ) { * **num_ratings**: Number of Theme Ratings * **homepage**: Theme Author's Homepage * **description**: Theme Description + * **url**: Theme's URL on wordpress.org * * [--format=] * : Render output in a particular format. diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 93e0d5eb8..e6e4ea34d 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -613,6 +613,11 @@ protected function _search( $args, $assoc_args ) { $items = $api->$plural; + // Add `url` for plugin or theme on wordpress.org. + foreach ( $items as $index => $item_object ) { + $item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/"; + } + if ( 'table' === $format ) { $count = \WP_CLI\Utils\get_flag_value( $api->info, 'results', 'unknown' ); \WP_CLI::success( sprintf( 'Showing %s of %s %s.', count( $items ), $count, $plural ) ); From 486e1290ce9b5d8282c37ed592c129e8481a7370 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Fri, 20 Jul 2018 09:27:50 +0200 Subject: [PATCH 2/3] Regenerate README.md file --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 4dd3b9d13..23dd6d3ca 100644 --- a/README.md +++ b/README.md @@ -451,6 +451,7 @@ search query. **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. @@ -1206,6 +1207,7 @@ search query. **num_ratings**: Number of Theme Ratings **homepage**: Theme Author's Homepage **description**: Theme Description + **url**: Theme's URL on wordpress.org [--format=] Render output in a particular format. @@ -1341,6 +1343,44 @@ wp theme update [...] [--all] [--exclude=] [--format=] [--format=] +~~~ + +**OPTIONS** + + [--field=] + Returns the value of a single field. + + [--format=] + Render output in a particular format. + --- + default: table + options: + - table + - json + - csv + - yaml + --- + +**EXAMPLES** + + # Gets a list of theme mods. + $ wp theme mod list + +------------------+---------+ + | key | value | + +------------------+---------+ + | background_color | dd3333 | + | link_color | #dd9933 | + | main_text_color | #8224e3 | + +------------------+---------+ + ## Installing This package is included with WP-CLI itself, no additional installation necessary. From 9fd8da4c97a6531a9f1103ab3ee18762369b1404 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Fri, 20 Jul 2018 20:01:20 +0100 Subject: [PATCH 3/3] Limit addition of URL property when item is a class See #94. --- src/WP_CLI/CommandWithUpgrade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index e6e4ea34d..1a0ed63ca 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -615,7 +615,9 @@ protected function _search( $args, $assoc_args ) { // Add `url` for plugin or theme on wordpress.org. foreach ( $items as $index => $item_object ) { - $item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/"; + if ( $item_object instanceof \stdClass ) { + $item_object->url = "https://wordpress.org/{$plural}/{$item_object->slug}/"; + } } if ( 'table' === $format ) {