WP_REST_Plugins_Controller::get_plugin_data( string $plugin )

Gets the plugin header data for a plugin.


Parameters Parameters

$plugin

(string) (Required) The plugin file to get data for.


Top ↑

Return Return

(array|WP_Error) The plugin data, or a WP_Error if the plugin is not installed.


Top ↑

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.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;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.