Skip to content

Commit

Permalink
Replaced the api.wp call with the appropriate class.
Browse files Browse the repository at this point in the history
  • Loading branch information
janw-me committed Nov 11, 2023
1 parent fd9a235 commit 71a1d23
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use WP_CLI\ParsePluginNameInput;
use WP_CLI\Utils;
use WP_CLI\WpOrgApi;

/**
* Manages plugins, including installs, activations, and updates.
Expand Down Expand Up @@ -775,9 +776,13 @@ protected function get_wporg_data( $plugin_name ) {
}

if ( $this->check_wporg ) {
$request = wp_remote_head( 'https://api.wordpress.org/plugins/info/1.0/' . $plugin_name );
$response_code = wp_remote_retrieve_response_code( $request );
if ( 200 === $response_code ) {
try {
$plugin_data = ( new WpOrgApi() )->get_plugin_info( $plugin_name );
} catch ( Exception $e ) {
// Request failed. The plugin is not (active) on .org.
$plugin_data = false;
}
if ( $plugin_data ) {
$data['status'] = 'active';
if ( ! $this->check_wporg['last_updated'] ) {
return $data; // The plugin is active on .org, but we don't need the date.
Expand Down

0 comments on commit 71a1d23

Please sign in to comment.