WP_REST_Plugins_Controller::get_items()
Retrieves a collection of plugins.
Method of the class: WP_REST_Plugins_Controller{}
No Hooks.
Return
WP_REST_Response|WP_Error
. Response object on success, or WP_Error object on failure.
Usage
$WP_REST_Plugins_Controller = new WP_REST_Plugins_Controller(); $WP_REST_Plugins_Controller->get_items( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Changelog
Since 5.5.0 | Introduced. |
WP_REST_Plugins_Controller::get_items() WP REST Plugins Controller::get items code WP 6.6.1
public function get_items( $request ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; $plugins = array(); foreach ( get_plugins() as $file => $data ) { if ( is_wp_error( $this->check_read_permission( $file ) ) ) { continue; } $data['_file'] = $file; if ( ! $this->does_plugin_match_request( $request, $data ) ) { continue; } $plugins[] = $this->prepare_response_for_collection( $this->prepare_item_for_response( $data, $request ) ); } return new WP_REST_Response( $plugins ); }