WP_REST_Block_Directory_Controller::prepare_links( array $plugin ): array

In this article

Generates a list of links to include in the response for the plugin.

Parameters

$pluginarrayrequired
The plugin data from WordPress.org.

Return

array

Source

protected function prepare_links( $plugin ) {
	$links = array(
		'https://api.w.org/install-plugin' => array(
			'href' => add_query_arg( 'slug', urlencode( $plugin['slug'] ), rest_url( 'wp/v2/plugins' ) ),
		),
	);

	$plugin_file = $this->find_plugin_for_slug( $plugin['slug'] );

	if ( $plugin_file ) {
		$links['https://api.w.org/plugin'] = array(
			'href'       => rest_url( 'wp/v2/plugins/' . substr( $plugin_file, 0, - 4 ) ),
			'embeddable' => true,
		);
	}

	return $links;
}

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

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