WordPress at a glance
function is not described

WP_REST_Block_Types_Controller::prepare_links() protected WP 5.5.0

Prepares links for the request.

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

No Hooks.

Return

Array. Links for the given block type.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $block_type );
$block_type(WP_Block_Type) (required)
Block type data.

Changelog

Since 5.5.0 Introduced.

Code of WP_REST_Block_Types_Controller::prepare_links() WP 5.5.1

<?php
protected function prepare_links( $block_type ) {
	list( $namespace ) = explode( '/', $block_type->name );

	$links = array(
		'collection' => array(
			'href' => rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ),
		),
		'self'       => array(
			'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $block_type->name ) ),
		),
		'up'         => array(
			'href' => rest_url( sprintf( '%s/%s/%s', $this->namespace, $this->rest_base, $namespace ) ),
		),
	);

	if ( $block_type->is_dynamic() ) {
		$links['https://api.w.org/render-block'] = array(
			'href' => add_query_arg( 'context', 'edit', rest_url( sprintf( '%s/%s/%s', 'wp/v2', 'block-renderer', $block_type->name ) ) ),
		);
	}

	return $links;
}