WP_REST_Plugins_Controller::get_plugin_data()
Gets the plugin header data for a plugin.
Method of the class: WP_REST_Plugins_Controller{}
No Hooks.
Return
Array|WP_Error
. The plugin data, or a WP_Error if the plugin is not installed.
Usage
// protected - for code of main (parent) or child class $result = $this->get_plugin_data( $plugin );
- $plugin(string) (required)
- The plugin file to get data for.
Changelog
Since 5.5.0 | Introduced. |
WP_REST_Plugins_Controller::get_plugin_data() WP REST Plugins Controller::get plugin data code WP 6.3
protected function get_plugin_data( $plugin ) { $plugins = get_plugins(); if ( ! isset( $plugins[ $plugin ] ) ) { return new WP_Error( 'rest_plugin_not_found', __( 'Plugin not found.' ), array( 'status' => 404 ) ); } $data = $plugins[ $plugin ]; $data['_file'] = $plugin; return $data; }