WooCommerce Code Reference

WC_CLI_Runner
in package

WC API to WC CLI Bridge.

Hooks into the REST API, figures out which endpoints come from WC, and registers them as CLI commands.

Forked from wp-cli/restful (by Daniel Bachhuber, released under the MIT license https://opensource.org/licenses/MIT). https://github.com/wp-cli/restful

Tags
version
3.0.0

Table of Contents

$disabled_endpoints  : array<string|int, mixed>
Endpoints to disable (meaning they will not be available as CLI commands).
$target_rest_version  : string
The version of the REST API we should target to generate commands.
after_wp_load()  : mixed
Register's all endpoints as commands once WP and WC have all loaded.
register_route_commands()  : mixed
Generates command information and tells WP CLI about all commands available from a route.

Properties

$disabled_endpoints

Endpoints to disable (meaning they will not be available as CLI commands).

private static array<string|int, mixed> $disabled_endpoints = array('settings', 'settings/(?P<group_id>[\w-]+)', 'settings/(?P<group_id>[\w-]+)/batch', 'settings/(?P<group_id>[\w-]+)/(?P<id>[\w-]+)', 'system_status', 'system_status/tools', 'system_status/tools/(?P<id>[\w-]+)', 'reports', 'reports/sales', 'reports/top_sellers')

Some of these can either be done via WP already, or are offered with some other changes (like tools).

$target_rest_version

The version of the REST API we should target to generate commands.

private static string $target_rest_version = 'v2'

Methods

after_wp_load()

Register's all endpoints as commands once WP and WC have all loaded.

public static after_wp_load() : mixed
Return values
mixed

register_route_commands()

Generates command information and tells WP CLI about all commands available from a route.

private static register_route_commands(WC_CLI_REST_Command $rest_command, string $route, array<string|int, mixed> $route_data[, array<string|int, mixed> $command_args = array() ]) : mixed
Parameters
$rest_command : WC_CLI_REST_Command

WC-API command.

$route : string

Path to route endpoint.

$route_data : array<string|int, mixed>

Command data.

$command_args : array<string|int, mixed> = array()

WP-CLI command arguments.

Return values
mixed