| 1 |
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 |
|
| 3 |
new Jetpack_JSON_API_Plugins_List_Endpoint( |
| 4 |
array( |
| 5 |
'description' => 'Get installed Plugins on your blog', |
| 6 |
'method' => 'GET', |
| 7 |
'path' => '/sites/%s/plugins', |
| 8 |
'stat' => 'plugins', |
| 9 |
'min_version' => '1', |
| 10 |
'max_version' => '1.1', |
| 11 |
'path_labels' => array( |
| 12 |
'$site' => '(int|string) The site ID, The site domain', |
| 13 |
), |
| 14 |
'allow_jetpack_site_auth' => true, |
| 15 |
'response_format' => array( |
| 16 |
'plugins' => '(plugin) An array of plugin objects.', |
| 17 |
), |
| 18 |
'example_request_data' => array( |
| 19 |
'headers' => array( |
| 20 |
'authorization' => 'Bearer YOUR_API_TOKEN', |
| 21 |
), |
| 22 |
), |
| 23 |
'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.org/plugins', |
| 24 |
) |
| 25 |
); |
| 26 |
|
| 27 |
/** |
| 28 |
* Plugins list endpoint class. |
| 29 |
* |
| 30 |
* GET /sites/%s/plugins |
| 31 |
* |
| 32 |
* No v1.2 versions since they are .com only |
| 33 |
*/ |
| 34 |
class Jetpack_JSON_API_Plugins_List_Endpoint extends Jetpack_JSON_API_Plugins_Endpoint { |
| 35 |
/** |
| 36 |
* Needed capabilities. |
| 37 |
* |
| 38 |
* @var string |
| 39 |
*/ |
| 40 |
protected $needed_capabilities = 'activate_plugins'; |
| 41 |
|
| 42 |
/** |
| 43 |
* Validate the input. |
| 44 |
* |
| 45 |
* @param string $plugin - the plugin. |
| 46 |
* |
| 47 |
* @return bool |
| 48 |
*/ |
| 49 |
public function validate_input( $plugin ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 50 |
wp_update_plugins(); |
| 51 |
$this->plugins = array_keys( get_plugins() ); |
| 52 |
return true; |
| 53 |
} |
| 54 |
} |
| 55 |
|