RestApi
in package
Class RestApi
This class handles the REST API endpoints for importing and exporting WooCommerce Blueprints.
Table of Contents
- MAX_FILE_SIZE = 52428800
- Maximum allowed file size in bytes (50MB)
- $coming_soon_helper : ComingSoonHelper
- ComingSoonHelper instance.
- $namespace : string
- Endpoint namespace.
- __construct() : mixed
- Constructor.
- check_export_permission() : bool|WP_Error
- General permission check for export requests.
- check_import_permission() : bool|WP_Error
- General permission check for import requests.
- export() : WP_HTTP_Response
- Handle the export request.
- get_import_allowed() : WP_REST_Response
- Get whether blueprint imports are allowed.
- get_import_allowed_schema() : array<string|int, mixed>
- Get the schema for the import-allowed endpoint.
- get_import_step_response_schema() : array<string|int, mixed>
- Get the schema for the import-step endpoint.
- import_step() : WP_REST_Response|array<string|int, mixed>
- Import a single step.
- register_routes() : mixed
- Register routes.
- get_max_file_size() : int
- Get maximum allowed file size for blueprint uploads.
- can_import_blueprint() : bool
- Check if blueprint imports are allowed based on site status, configuration, and session token.
- steps_payload_to_blueprint_steps() : array<string|int, mixed>
- Convert step list from the frontend to the backend format.
Constants
MAX_FILE_SIZE
Maximum allowed file size in bytes (50MB)
public
mixed
MAX_FILE_SIZE
= 52428800
Properties
$coming_soon_helper
ComingSoonHelper instance.
protected
ComingSoonHelper
$coming_soon_helper
$namespace
Endpoint namespace.
protected
string
$namespace
= 'wc-admin'
Methods
__construct()
Constructor.
public
__construct() : mixed
Return values
mixed —check_export_permission()
General permission check for export requests.
public
check_export_permission() : bool|WP_Error
Return values
bool|WP_Error —check_import_permission()
General permission check for import requests.
public
check_import_permission() : bool|WP_Error
Return values
bool|WP_Error —export()
Handle the export request.
public
export(WP_REST_Request $request) : WP_HTTP_Response
Parameters
- $request : WP_REST_Request
-
The request object.
Return values
WP_HTTP_Response — The response object.get_import_allowed()
Get whether blueprint imports are allowed.
public
get_import_allowed() : WP_REST_Response
Return values
WP_REST_Response —get_import_allowed_schema()
Get the schema for the import-allowed endpoint.
public
get_import_allowed_schema() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_import_step_response_schema()
Get the schema for the import-step endpoint.
public
get_import_step_response_schema() : array<string|int, mixed>
Return values
array<string|int, mixed> —import_step()
Import a single step.
public
import_step(WP_REST_Request $request) : WP_REST_Response|array<string|int, mixed>
Parameters
- $request : WP_REST_Request
-
The request object.
Return values
WP_REST_Response|array<string|int, mixed> —register_routes()
Register routes.
public
register_routes() : mixed
Tags
Return values
mixed —get_max_file_size()
Get maximum allowed file size for blueprint uploads.
protected
get_max_file_size() : int
Return values
int — Maximum file size in bytescan_import_blueprint()
Check if blueprint imports are allowed based on site status, configuration, and session token.
private
can_import_blueprint([string|null $session_token = null ]) : bool
Parameters
- $session_token : string|null = null
-
Optional session token for import session.
Return values
bool — Returns true if imports are allowed, false otherwise.steps_payload_to_blueprint_steps()
Convert step list from the frontend to the backend format.
private
steps_payload_to_blueprint_steps(array<string|int, mixed> $steps) : array<string|int, mixed>
From: { "settings": ["setWCSettings", "setWCShippingZones", "setWCShippingMethods", "setWCShippingRates"], "plugins": ["akismet/akismet.php], "themes": ["approach], }
To:
["setWCSettings", "setWCShippingZones", "setWCShippingMethods", "setWCShippingRates", "installPlugin", "installTheme"]
Parameters
- $steps : array<string|int, mixed>
-
steps payload from the frontend.