WP_CLI::runcommand() Edit

Run a WP-CLIWP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/ https://make.wordpress.org/cli/ command.


Usage Usage

WP_CLI::runcommand( $command, $options = array() )
$command (string) WP-CLI command to run, including arguments.
$options (array) Configuration options for command execution.
@return (mixed)

Top ↑

Notes Notes

Launches a new child process to run a specified WP-CLI command.
Optionally:

  • Run the command in an existing process.
  • Prevent halting script execution on error.
  • Capture and return STDOUT, or full details about command execution.
  • Parse JSONJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. output if the command rendered it.
$options = array(
  'return'     => true,   // Return 'STDOUT'; use 'all' for full object.
  'parse'      => 'json', // Parse captured STDOUT to JSON array.
  'launch'     => false,  // Reuse the current process.
  'exit_error' => true,   // Halt script execution on error.
);
$plugins = WP_CLI::runcommand( 'plugin list --format=json', $options );

Internal APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. documentation is generated from the WP-CLI codebase on every releaseRelease A release is the distribution of the final version of an application. A software release may be either public or private and generally constitutes the initial or new generation of a new or upgraded application. A release is preceded by the distribution of alpha and then beta versions of the software.. To suggest improvements, please submit a pull request.


Top ↑

  • WP_CLI::launch() – Launch an arbitrary external process that takes over I/O.
  • WP_CLI::launch_self() – Run a WP-CLI command in a new process reusing the current runtime arguments.
  • WP_CLI::run_command() – Run a given command within the current process using the same global parameters.

Last updated: