WP_REST_Block_Directory_Controller::prepare_links( array $plugin )

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

Parameters

$plugin

(array) (Required) The plugin data from WordPress.org.

Return

(array)

Source

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

Changelog

Version Description
5.5.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_block_directory_controller/prepare_links