Automattic\WooCommerce\Admin\Features\Blueprint

RestApi::register_routes()publicWC 9.3.0

Register routes.

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

Хуков нет.

Возвращает

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

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

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

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

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

Код RestApi::register_routes() WC 9.7.1

public function register_routes() {
	register_rest_route(
		$this->namespace,
		'/blueprint/queue',
		array(
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'queue' ),
				'permission_callback' => array( $this, 'check_permission' ),
			),
			'schema' => array( $this, 'get_queue_response_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/blueprint/process',
		array(
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'process' ),
				'permission_callback' => array( $this, 'check_permission' ),
				'args'                => array(
					'reference'     => array(
						'description' => __( 'The reference of the uploaded file', 'woocommerce' ),
						'type'        => 'string',
						'required'    => true,
					),
					'process_nonce' => array(
						'description' => __( 'The nonce for processing the uploaded file', 'woocommerce' ),
						'type'        => 'string',
						'required'    => true,
					),
				),
			),
			'schema' => array( $this, 'get_process_response_schema' ),
		)
	);

	register_rest_route(
		$this->namespace,
		'/blueprint/import',
		array(
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'import' ),
				'permission_callback' => array( $this, 'check_permission' ),
			),
		)
	);

	register_rest_route(
		$this->namespace,
		'/blueprint/export',
		array(
			array(
				'methods'             => \WP_REST_Server::CREATABLE,
				'callback'            => array( $this, 'export' ),
				'permission_callback' => array( $this, 'check_permission' ),
				'args'                => array(
					'steps'         => array(
						'description' => __( 'A list of plugins to install', 'woocommerce' ),
						'type'        => 'object',
						'properties'  => array(
							'settings' => array(
								'type'  => 'array',
								'items' => array(
									'type' => 'string',
								),
							),
							'plugins'  => array(
								'type'  => 'array',
								'items' => array(
									'type' => 'string',
								),
							),
							'themes'   => array(
								'type'  => 'array',
								'items' => array(
									'type' => 'string',
								),
							),
						),
						'default'     => array(),
						'required'    => true,
					),
					'export_as_zip' => array(
						'description' => __( 'Export as a zip file', 'woocommerce' ),
						'type'        => 'boolean',
						'default'     => false,
						'required'    => false,
					),
				),
			),
		)
	);
}