WordPress Help
Official documentation, learning resources, and contributor guides collected from WordPress.org.
-
WP_CLI::runcommand()
Run a WP-CLI command. Usage WP_CLI::runcommand( $command, $options = [] ) $command (string) WP-CLI command to run, including arguments. $options (array) { Configuration options for command execution. @type bool $launch Launches a new process (true) or reuses the existing process (false). Default: true. @type bool $exit_error Halts the script on error. Default: true. @type bool|string…
-
WP_CLI::do_hook()
Execute callbacks registered to a given hook. Usage WP_CLI::do_hook( $when, $args ) $when (string) Identifier for the hook. …$args (mixed) Optional. Arguments that will be passed onto the callback provided by `WP_CLI::add_hook()`. @return (null|mixed) the first optional argument if optional<br /> arguments were passed, otherwise returns null. Notes See WP_CLI::add_hook() for details on WP-CLI’s internal…
-
WP_CLIUtilsbasename()
Locale-independent version of basename() Usage WP_CLI\Utils\basename( $path, $suffix = ” ) $path (string) $suffix (string) @return (string) Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request. Related WP_CLI\Utils\write_csv() – Write data as CSV to a given file. WP_CLI\Utils\http_request() – Make a HTTP request to…
-
WP_CLI::error_multi_line()
Display a multi-line error message in a red box. Doesn’t exit script. Usage WP_CLI::error_multi_line( $message_lines ) $message_lines (array) Multi-line error message to be displayed. Notes Error message is written to STDERR. Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request. Related WP_CLI\Utils\format_items() – Render…
-
WP_CLI::error()
Display error message prefixed with “Error: ” and exit script. Usage WP_CLI::error( $message, $exit = true ) $message (string|WP_Error|Exception|Throwable) Message to write to STDERR. $exit (boolean|integer) True defaults to exit(1). @return (null) Notes Error message is written to STDERR. Defaults to halting script execution with return code 1. Use WP_CLI::warning() instead when script execution should…
-
WP_CLI::get_config()
Get values of global configuration parameters. Usage WP_CLI::get_config( $key = null ) $key (string) Get value for a specific global configuration parameter. @return (mixed) Notes Provides access to –path=<path>, –url=<url>, and other values of the global configuration parameters. WP_CLI::log( ‘The –url=<url> value is: ‘ . WP_CLI::get_config( ‘url’ ) ); Internal API documentation is generated from…
-
WP_CLI::get_php_binary()
Get the path to the PHP binary used when executing WP-CLI. Usage WP_CLI::get_php_binary() @return (string) Notes Environment values permit specific binaries to be indicated. Note: moved to Utils, left for BC. Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request. Related WP_CLI\Utils\get_home_dir() – Get…
-
WP_CLI::add_command()
Register a command to WP-CLI. Usage WP_CLI::add_command( $name, $callable, $args = [] ) $name (string) Name for the command (e.g. “post list” or “site empty”). $callable (callable|object|string|string[]) Command implementation as a class, function or closure. $args (array) { Optional. An associative array with additional registration parameters. @type callable $before_invoke Callback to execute before invoking the…
-
WP_CLI::add_hook()
Schedule a callback to be executed at a certain point. Usage WP_CLI::add_hook( $when, $callback ) $when (string) Identifier for the hook. $callback (callable) Callback to execute when hook is called. @return (void) Notes Hooks conceptually are very similar to WordPress actions. WP-CLI hooks are typically called before WordPress is loaded. WP-CLI hooks include: before_add_command:<command> –…
-
Quick Start
Congratulations! You’ve installed WP-CLI for the first time, and are ready to level-up your use of WordPress. This page contains a brief introduction to WP-CLI with some example usage. Introduction WP-CLI is a command line interface for WordPress. The project’s goal is to offer a complete alternative to the WordPress admin; for any action you…