Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WpOrgApi: allow specifying fields request param #5893

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions php/WP_CLI/WpOrgApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,21 @@ public function get_plugin_checksums( $plugin, $version ) {
*
* @param string $plugin Plugin slug to query.
* @param string $locale Optional. Locale to request info for. Defaults to 'en_US'.
* @param array $fields Optional. Fields to include/omit from the response.
* @return array|false False on failure. Associative array of the offer on success.
* @throws RuntimeException If the remote request failed.
*/
public function get_plugin_info( $plugin, $locale = 'en_US' ) {
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,
Expand All @@ -240,16 +245,21 @@ public function get_plugin_info( $plugin, $locale = 'en_US' ) {
*
* @param string $theme Theme slug to query.
* @param string $locale Optional. Locale to request info for. Defaults to 'en_US'.
* @param array $fields Optional. Fields to include/omit from the response.
* @return array|false False on failure. Associative array of the offer on success.
* @throws RuntimeException If the remote request failed.
*/
public function get_theme_info( $theme, $locale = 'en_US' ) {
public function get_theme_info( $theme, $locale = 'en_US', array $fields = [] ) {
$action = 'theme_information';
$request = [
'locale' => $locale,
'slug' => $theme,
];

if ( ! empty( $fields ) ) {
$request['fields'] = $fields;
}

$url = sprintf(
'%s?%s',
self::THEME_INFO_ENDPOINT,
Expand Down