Skip to content

Commit a9a40b4

Browse files
authored
WpOrgApi: allow specifying fields request param (#5893)
Required for wp-cli/extension-command#394
1 parent 7038788 commit a9a40b4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

php/WP_CLI/WpOrgApi.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,21 @@ public function get_plugin_checksums( $plugin, $version ) {
210210
*
211211
* @param string $plugin Plugin slug to query.
212212
* @param string $locale Optional. Locale to request info for. Defaults to 'en_US'.
213+
* @param array $fields Optional. Fields to include/omit from the response.
213214
* @return array|false False on failure. Associative array of the offer on success.
214215
* @throws RuntimeException If the remote request failed.
215216
*/
216-
public function get_plugin_info( $plugin, $locale = 'en_US' ) {
217+
public function get_plugin_info( $plugin, $locale = 'en_US', array $fields = [] ) {
217218
$action = 'plugin_information';
218219
$request = [
219220
'locale' => $locale,
220221
'slug' => $plugin,
221222
];
222223

224+
if ( ! empty( $fields ) ) {
225+
$request['fields'] = $fields;
226+
}
227+
223228
$url = sprintf(
224229
'%s?%s',
225230
self::PLUGIN_INFO_ENDPOINT,
@@ -240,16 +245,21 @@ public function get_plugin_info( $plugin, $locale = 'en_US' ) {
240245
*
241246
* @param string $theme Theme slug to query.
242247
* @param string $locale Optional. Locale to request info for. Defaults to 'en_US'.
248+
* @param array $fields Optional. Fields to include/omit from the response.
243249
* @return array|false False on failure. Associative array of the offer on success.
244250
* @throws RuntimeException If the remote request failed.
245251
*/
246-
public function get_theme_info( $theme, $locale = 'en_US' ) {
252+
public function get_theme_info( $theme, $locale = 'en_US', array $fields = [] ) {
247253
$action = 'theme_information';
248254
$request = [
249255
'locale' => $locale,
250256
'slug' => $theme,
251257
];
252258

259+
if ( ! empty( $fields ) ) {
260+
$request['fields'] = $fields;
261+
}
262+
253263
$url = sprintf(
254264
'%s?%s',
255265
self::THEME_INFO_ENDPOINT,

0 commit comments

Comments
 (0)