WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WP_REST_Block_Renderer_Controller::register_routes() public WP 5.0.0

Registers the necessary REST API routes, one for each dynamic block.

{} Это метод класса: WP_REST_Block_Renderer_Controller{}

Хуков нет.

Возвращает

Null. Ничего.

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

$WP_REST_Block_Renderer_Controller = new WP_REST_Block_Renderer_Controller();
$WP_REST_Block_Renderer_Controller->register_routes();

Заметки

  • Смотрите: register_rest_route()

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

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

Код WP_REST_Block_Renderer_Controller::register_routes() WP 5.5.3

<?php
public function register_routes() {
	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<name>[a-z0-9-]+/[a-z0-9-]+)',
		array(
			'args'   => array(
				'name' => array(
					'description' => __( 'Unique registered name for the block.' ),
					'type'        => 'string',
				),
			),
			array(
				'methods'             => array( WP_REST_Server::READABLE, WP_REST_Server::CREATABLE ),
				'callback'            => array( $this, 'get_item' ),
				'permission_callback' => array( $this, 'get_item_permissions_check' ),
				'args'                => array(
					'context'    => $this->get_context_param( array( 'default' => 'view' ) ),
					'attributes' => array(
						'description'       => __( 'Attributes for the block' ),
						'type'              => 'object',
						'default'           => array(),
						'validate_callback' => static function ( $value, $request ) {
							$block = WP_Block_Type_Registry::get_instance()->get_registered( $request['name'] );

							if ( ! $block ) {
								// This will get rejected in ::get_item().
								return true;
							}

							$schema = array(
								'type'                 => 'object',
								'properties'           => $block->get_attributes(),
								'additionalProperties' => false,
							);

							return rest_validate_value_from_schema( $value, $schema );
						},
						'sanitize_callback' => static function ( $value, $request ) {
							$block = WP_Block_Type_Registry::get_instance()->get_registered( $request['name'] );

							if ( ! $block ) {
								// This will get rejected in ::get_item().
								return true;
							}

							$schema = array(
								'type'                 => 'object',
								'properties'           => $block->get_attributes(),
								'additionalProperties' => false,
							);

							return rest_sanitize_value_from_schema( $value, $schema );
						},
					),
					'post_id'    => array(
						'description' => __( 'ID of the post context.' ),
						'type'        => 'integer',
					),
				),
			),
			'schema' => array( $this, 'get_public_item_schema' ),
		)
	);
}