WordPress at a glance
function is not described

WP_REST_Block_Directory_Controller::prepare_links() protected WP 5.5.0

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

{} It's a method of the class: WP_REST_Block_Directory_Controller{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $plugin );
$plugin(array) (required)
The plugin data from WordPress.org.

Changelog

Since 5.5.0 Introduced.

Code of WP_REST_Block_Directory_Controller::prepare_links() WP 5.5.1

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