WP_CLI
WpOrgApi::get_plugin_info
Gets a plugin's info.
Method of the class: WpOrgApi{}
No Hooks.
Returns
Array|false. False on failure. Associative array of the offer on success.
Usage
$WpOrgApi = new WpOrgApi(); $WpOrgApi->get_plugin_info( $plugin, $locale, $fields );
- $plugin(string) (required)
- Plugin slug to query.
- $locale(string)
- Locale to request info for.
Default: 'en_US' - $fields(array)
- Fields to include/omit from the response.
Default: []
WpOrgApi::get_plugin_info() WpOrgApi::get plugin info code WP-CLI 2.13.0-alpha
public function get_plugin_info( $plugin, $locale = 'en_US', array $fields = [] ) {
$action = 'plugin_information';
$request = [
'locale' => $locale,
'slug' => $plugin,
];
if ( ! empty( $fields ) ) {
$request['fields'] = $fields;
}
$url = sprintf(
'%s?%s',
self::PLUGIN_INFO_ENDPOINT,
http_build_query( compact( 'action', 'request' ), '', '&' )
);
$response = $this->json_get_request( $url );
if ( ! is_array( $response ) ) {
return false;
}
return $response;
}