Method | Description | |
---|---|---|
addCommand ( $name, $class ) | back-compat | |
add_command ( string $name, string $callable, array $args = [] ) : true | Register a command to WP-CLI. | |
add_hook ( string $when, mixed $callback ) : null | Schedule a callback to be executed at a certain point. | |
add_man_dir ( ) | DEPRECATED STUFF | |
add_wp_hook ( string $tag, mixed $function_to_add, integer $priority = 10, integer $accepted_args = 1 ) : true | Add a callback to a WordPress action or filter. | |
colorize ( string $string ) : string | Colorize a string for output. | |
confirm ( string $question, array $assoc_args = [] ) | Ask for confirmation before running a destructive operation. | |
debug ( string $message, string $group = false ) : null | Display debug message prefixed with "Debug: " when --debug is used. | |
do_hook ( string $when ) : null | Execute callbacks registered to a given hook. | |
error ( string | WP_Error $message, boolean | integer $exit = true ) : null | Display error message prefixed with "Error: " and exit script. | |
error_multi_line ( $message_lines ) | Display a multi-line error message in a red box. Doesn't exit script. | |
error_to_string ( mixed $errors ) : string | Convert a wp_error into a string | |
get_cache ( ) : WP_CLI\FileCache | ||
get_config ( string $key = null ) : mixed | Get values of global configuration parameters. | |
get_configurator ( ) : |
Get the Configurator instance | |
get_http_cache_manager ( ) : WP_CLI\WpHttpCacheManager | ||
get_php_binary ( ) : string | Get the path to the PHP binary used when executing WP-CLI. | |
get_root_command ( ) | ||
get_runner ( ) | ||
get_value_from_arg_or_stdin ( array $args, integer $index ) : string | Read value from a positional argument or from STDIN. | |
halt ( integer $return_code ) | Halt script execution with a specific return code. | |
launch ( string $command, boolean $exit_on_error = true, boolean $return_detailed = false ) : integer | ProcessRun | Launch an arbitrary external process that takes over I/O. | |
launch_self ( string $command, array $args = [], array $assoc_args = [], boolean $exit_on_error = true, boolean $return_detailed = false, array $runtime_args = [] ) : integer | ProcessRun | Run a WP-CLI command in a new process reusing the current runtime arguments. | |
line ( string $message = '' ) : null | Display informational message without prefix, and ignore --quiet. | |
log ( string $message ) | Display informational message without prefix. | |
out ( $str ) | back-compat | |
print_value ( mixed $value, array $assoc_args = [] ) | Display a value, in various formats | |
read_value ( $raw_value, array $assoc_args = [] ) | Read a value, from various formats. | |
run_command ( array $args, array $assoc_args = [] ) | Run a given command within the current process using the same global parameters. | |
runcommand ( string $command, array $options = [] ) : mixed | Run a WP-CLI command. | |
set_logger ( object $logger ) | Set the logger instance. | |
set_url ( $url ) | Set the context in which WP-CLI should be run | |
success ( string $message ) : null | Display success message prefixed with "Success: ". | |
warning ( string $message ) : null | Display warning message prefixed with "Warning: ". |
Method | Description | |
---|---|---|
set_url_params ( $url_parts ) | ||
wp_hook_build_unique_id ( $tag, $function, $priority ) | Build Unique ID for storage and retrieval. |
public static add_command ( string $name, string $callable, array $args = [] ) : true | ||
$name | string | Name for the command (e.g. "post list" or "site empty"). |
$callable | string | Command implementation as a class, function or closure. |
$args | array | { Optional An associative array with additional registration parameters. 'before_invoke' => callback to execute before invoking the command, 'after_invoke' => callback to execute after invoking the command, 'shortdesc' => short description (80 char or less) for the command, 'synopsis' => the synopsis for the command (string or array), 'when' => execute callback on a named WP-CLI hook (e.g. before_wp_load), } |
return | true | True on success, hard error if registration failed. |
public static add_wp_hook ( string $tag, mixed $function_to_add, integer $priority = 10, integer $accepted_args = 1 ) : true | ||
$tag | string | Named WordPress action or filter. |
$function_to_add | mixed | Callable to execute when the action or filter is evaluated. |
$priority | integer | Priority to add the callback as. |
$accepted_args | integer | Number of arguments to pass to callback. |
return | true |
public static error_multi_line ( $message_lines ) |
public static error_to_string ( mixed $errors ) : string | ||
$errors | mixed | |
return | string |
public static get_cache ( ) : WP_CLI\FileCache | ||
return | WP_CLI\FileCache |
public static get_config ( string $key = null ) : mixed | ||
$key | string | Get value for a specific global configuration parameter. |
return | mixed |
public static get_configurator ( ) : |
||
return |
public static get_http_cache_manager ( ) : WP_CLI\WpHttpCacheManager | ||
return | WP_CLI\WpHttpCacheManager |
public static get_php_binary ( ) : string | ||
return | string |
public static launch ( string $command, boolean $exit_on_error = true, boolean $return_detailed = false ) : integer | ProcessRun | ||
$command | string | External process to launch. |
$exit_on_error | boolean | Whether to exit if the command returns an elevated return code. |
$return_detailed | boolean | Whether to return an exit status (default) or detailed execution results. |
return | integer | ProcessRun | The command exit status, or a ProcessRun object for full details. |
public static launch_self ( string $command, array $args = [], array $assoc_args = [], boolean $exit_on_error = true, boolean $return_detailed = false, array $runtime_args = [] ) : integer | ProcessRun | ||
$command | string | WP-CLI command to call. |
$args | array | Positional arguments to include when calling the command. |
$assoc_args | array | Associative arguments to include when calling the command. |
$exit_on_error | boolean | Whether to exit if the command returns an elevated return code. |
$return_detailed | boolean | Whether to return an exit status (default) or detailed execution results. |
$runtime_args | array | Override one or more global args (path,url,user,allow-root) |
return | integer | ProcessRun | The command exit status, or a ProcessRun instance |
public static print_value ( mixed $value, array $assoc_args = [] ) | ||
$value | mixed | Value to display. |
$assoc_args | array | Arguments passed to the command, determining format. |
public static read_value ( $raw_value, array $assoc_args = [] ) | ||
$assoc_args | array |
public static run_command ( array $args, array $assoc_args = [] ) | ||
$args | array | Positional arguments including command name. |
$assoc_args | array |
public static set_logger ( object $logger ) | ||
$logger | object |
public static set_url ( $url ) |