Skip to content

Commit

Permalink
Search: Add plugin or theme's URL on wordpress.org
Browse files Browse the repository at this point in the history
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 wp-cli#94.
  • Loading branch information
GaryJones committed Jul 19, 2018
1 parent fe25c2a commit e1e1844
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Plugin_Command.php
Expand Up @@ -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=<format>]
* : Render output in a particular format.
Expand Down
1 change: 1 addition & 0 deletions src/Theme_Command.php
Expand Up @@ -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=<format>]
* : Render output in a particular format.
Expand Down
5 changes: 5 additions & 0 deletions src/WP_CLI/CommandWithUpgrade.php
Expand Up @@ -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 ) );
Expand Down

0 comments on commit e1e1844

Please sign in to comment.