None of Gutenberg’s data stores expose selectors for this purpose yet, to the best of my knowledge. If any did, I would have expected to find it on core
. If and when the Gutenberg experience expands to the plugin management screen I reckon we’ll see such a thing implemented.
For the time being, if the relevant users have the activate_plugins
capability, you could acquire this data from the Plugins REST API endpoint using the @wordpress/api-fetch
package:
import apiFetch from '@wordpress/api-fetch';
// ...
const plugins = await apiFetch( { path: '/wp/v2/plugins' } );
The objects produced by the request will have the fields described by the endpoint’s schema, including the relative path to the main file, the name, version number, and active/inactive status.
It is possible to modify the permissions check callback for a core REST endpoint in order to expose this functionality to more users – but it’s not very direct, and generally inadvisable. Creating a new endpoint or controller would probably be a better solution if you need to customize it’s behavior.