Automattic\WooCommerce\Admin\Features\Blueprint
RestApi::register_routes
Register routes.
Method of the class: RestApi{}
No Hooks.
Returns
null. Nothing (null).
Usage
$RestApi = new RestApi(); $RestApi->register_routes();
Changelog
| Since 9.3.0 | Introduced. |
RestApi::register_routes() RestApi::register routes code WC 10.5.0
public function register_routes() {
register_rest_route(
$this->namespace,
'/blueprint/export',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array( $this, 'export' ),
'permission_callback' => array( $this, 'check_export_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,
),
),
),
)
);
register_rest_route(
$this->namespace,
'/blueprint/import-step',
array(
array(
'methods' => \WP_REST_Server::CREATABLE,
'callback' => array( $this, 'import_step' ),
'permission_callback' => array( $this, 'check_import_permission' ),
'args' => array(
'step_definition' => array(
'description' => __( 'The step definition to import', 'woocommerce' ),
'type' => 'object',
'required' => true,
),
),
),
'schema' => array( $this, 'get_import_step_response_schema' ),
)
);
register_rest_route(
$this->namespace,
'/blueprint/import-allowed',
array(
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array( $this, 'get_import_allowed' ),
'permission_callback' => function () {
return current_user_can( 'manage_woocommerce' );
},
),
'schema' => array( $this, 'get_import_allowed_schema' ),
)
);
}