WP_CLI

WpOrgApi::get_plugin_info()publicWP-CLI 1.0

Gets a plugin's info.

Метод класса: WpOrgApi{}

Хуков нет.

Возвращает

Массив|false. False on failure. Associative array of the offer on success.

Использование

$WpOrgApi = new WpOrgApi();
$WpOrgApi->get_plugin_info( $plugin, $locale );
$plugin(строка) (обязательный)
Plugin slug to query.
$locale(строка)
Locale to request info for.
По умолчанию: 'en_US'

Код WpOrgApi::get_plugin_info() WP-CLI 2.8.0-alpha

public function get_plugin_info( $plugin, $locale = 'en_US' ) {
	$action  = 'plugin_information';
	$request = [
		'locale' => $locale,
		'slug'   => $plugin,
	];

	$url = sprintf(
		'%s?%s',
		self::PLUGIN_INFO_ENDPOINT,
		http_build_query( compact( 'action', 'request' ), null, '&' )
	);

	$response = $this->json_get_request( $url );

	if ( ! is_array( $response ) ) {
		return false;
	}

	return $response;
}