WC_REST_Layout_Templates_Controller::register_routes()publicWC 1.0

Register the routes for template layouts.

Method of the class: WC_REST_Layout_Templates_Controller{}

No Hooks.

Return

null. Nothing (null).

Usage

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

WC_REST_Layout_Templates_Controller::register_routes() code WC 9.5.1

public function register_routes() {
	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base,
		array(
			'methods'             => WP_REST_Server::READABLE,
			'callback'            => array( $this, 'get_items' ),
			'permission_callback' => array( $this, 'get_items_permissions_check' ),
			'args'                => array(
				'area' => array(
					'description' => __( 'Area to get templates for.', 'woocommerce' ),
					'type'        => 'string',
					'default'     => '',
				),
			),
		)
	);

	register_rest_route(
		$this->namespace,
		'/' . $this->rest_base . '/(?P<id>\w[\w\s\-]*)',
		array(
			'args' => array(
				'id' => array(
					'description' => __( 'Unique identifier for the resource.', 'woocommerce' ),
					'type'        => 'string',
				),
			),
			array(
				'methods'             => WP_REST_Server::READABLE,
				'callback'            => array( $this, 'get_item' ),
				'permission_callback' => array( $this, 'get_item_permissions_check' ),
				'args'                => array(),
			),
		)
	);
}