Skip to content

Commit 71a1d23

Browse files
committed
Replaced the api.wp call with the appropriate class.
1 parent fd9a235 commit 71a1d23

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Plugin_Command.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use WP_CLI\ParsePluginNameInput;
44
use WP_CLI\Utils;
5+
use WP_CLI\WpOrgApi;
56

67
/**
78
* Manages plugins, including installs, activations, and updates.
@@ -775,9 +776,13 @@ protected function get_wporg_data( $plugin_name ) {
775776
}
776777

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

0 commit comments

Comments
 (0)