WP_REST_Server::__construct()publicWP 4.4.0

Instantiates the REST server.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$WP_REST_Server = new WP_REST_Server();
$WP_REST_Server->__construct();

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

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

Код WP_REST_Server::__construct() WP 6.6.2

public function __construct() {
	$this->endpoints = array(
		// Meta endpoints.
		'/'         => array(
			'callback' => array( $this, 'get_index' ),
			'methods'  => 'GET',
			'args'     => array(
				'context' => array(
					'default' => 'view',
				),
			),
		),
		'/batch/v1' => array(
			'callback' => array( $this, 'serve_batch_request_v1' ),
			'methods'  => 'POST',
			'args'     => array(
				'validation' => array(
					'type'    => 'string',
					'enum'    => array( 'require-all-validate', 'normal' ),
					'default' => 'normal',
				),
				'requests'   => array(
					'required' => true,
					'type'     => 'array',
					'maxItems' => $this->get_max_batch_size(),
					'items'    => array(
						'type'       => 'object',
						'properties' => array(
							'method'  => array(
								'type'    => 'string',
								'enum'    => array( 'POST', 'PUT', 'PATCH', 'DELETE' ),
								'default' => 'POST',
							),
							'path'    => array(
								'type'     => 'string',
								'required' => true,
							),
							'body'    => array(
								'type'                 => 'object',
								'properties'           => array(),
								'additionalProperties' => true,
							),
							'headers' => array(
								'type'                 => 'object',
								'properties'           => array(),
								'additionalProperties' => array(
									'type'  => array( 'string', 'array' ),
									'items' => array(
										'type' => 'string',
									),
								),
							),
						),
					),
				),
			),
		),
	);
}