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