WordPress Help

Official documentation, learning resources, and contributor guides collected from WordPress.org.

  • WP_CLIUtilsnormalize_path()

    Normalize a filesystem path. Usage WP_CLI\Utils\normalize_path( $path ) $path (string) Path to normalize. @return (string) path. Notes On Windows systems, replaces backslashes with forward slashes and forces upper-case drive letters. Allows for two leading slashes for Windows network shares, but ensures that all other duplicate slashes are reduced to a single one. Ensures upper-case drive…

    Read guide

  • WP_CLIUtilsparse_ssh_url()

    Parse a SSH url for its host, port, and path. Usage WP_CLI\Utils\parse_ssh_url( $url, $component = -1 ) $url (string) $component (int) @return (mixed) Notes Similar to parse_url(), but adds support for defined SSH aliases. host OR host/path/to/wordpress OR host:port/path/to/wordpress Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please…

    Read guide

  • WP_CLI::log()

    Display informational message without prefix. Usage WP_CLI::log( $message ) $message (string) Message to write to STDOUT. Notes Message is written to STDOUT, or discarded when –quiet flag is supplied. # `wp cli update` lets user know of each step in the update process. WP_CLI::log( sprintf( ‘Downloading from %s…’, $download_url ) ); Internal API documentation is…

    Read guide

  • WP_CLI::read_value()

    Read a value, from various formats. Usage WP_CLI::read_value( $raw_value, $assoc_args = [] ) $raw_value (string) $assoc_args (array) 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\launch_editor_for_input() – Launch system’s $EDITOR for the user to edit some text. WP_CLI\Utils\get_flag_value() – Return the flag…

    Read guide

  • WP_CLI::run_command()

    Run a given command within the current process using the same global parameters. Usage WP_CLI::run_command( $args, $assoc_args = [] ) $args (array) Positional arguments including command name. $assoc_args (array) Notes Use WP_CLI::runcommand() instead, which is easier to use and works better. To run a command using a new process with the same global parameters, use…

    Read guide

  • 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…

    Read guide

  • 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…

    Read guide

  • 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…

    Read guide

  • 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…

    Read guide

  • 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…

    Read guide