Source: Make WordPress: CLI

  • WP_CLIUtilsparse_str_to_argv()

    Parse a string of command line arguments into an $argv-esqe variable. Usage WP_CLI\Utils\parse_str_to_argv( $arguments ) $arguments (string) @return (array<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\launch_editor_for_input() – Launch system’s $EDITOR for the user to edit some text. WP_CLI\Utils\get_flag_value() – Return…

  • WP_CLIUtilsproc_open_compat()

    Windows compatible proc_open(). Works around bug in PHP, and also deals with *nix-like ENV_VAR=blah cmd environment variable prefixes. Usage WP_CLI\Utils\proc_open_compat( $cmd, $descriptorspec, $pipes, $cwd = null, $env = null, $other_options = null ) $cmd (string) Command to execute. list<string>|resource> (array<int,) $descriptorspec Indexed array of descriptor numbers and their values. resource> (array<int,) &$pipes Indexed array of…

  • WP_CLIUtilshttp_request()

    Make a HTTP request to a remote URL. Usage WP_CLI\Utils\http_request( $method, $url, $data = null, $headers = [], $options = [] ) $method (string) HTTP method (GET, POST, DELETE, etc.). $url (string) URL to make the HTTP request to. $data (array|null) Data to send either as a query string for GET/HEAD requests, or in the…

  • WP_CLIUtilsisPiped()

    Checks whether the output of the current script is a TTY or a pipe / redirect Usage WP_CLI\Utils\isPiped() @return (bool) Notes Returns true if STDOUT output is being redirected to a pipe or a file; false is output is being sent directly to the terminal. If an env variable SHELL_PIPE exists, the returned result depends…

  • WP_CLIUtilsget_temp_dir()

    Get the system’s temp directory. Warns user if it isn’t writable. Usage WP_CLI\Utils\get_temp_dir() @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\get_home_dir() – Get the home directory. WP_CLI\Utils\trailingslashit() – Appends a trailing slash. WP_CLI\Utils\normalize_path() – Normalize a filesystem path. WP_CLI\Utils\get_php_binary()…

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