WP_REST_Block_Types_Controller::prepare_links()protectedWP 5.5.0

Prepares links for the request.

Метод класса: WP_REST_Block_Types_Controller{}

Хуков нет.

Возвращает

Массив. Links for the given block type.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_links( $block_type );
$block_type(WP_Block_Type) (обязательный)
Block type data.

Список изменений

С версии 5.5.0 Введена.

Код WP_REST_Block_Types_Controller::prepare_links() WP 6.4.3

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