WordPress at a glance
function is not described

WP_REST_Plugins_Controller::get_plugin_data() protected WP 5.5.0

Gets the plugin header data for a plugin.

{} It's a 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.

Code of WP_REST_Plugins_Controller::get_plugin_data() WP 5.5.1

<?php
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;
}