WP_CLI::launch
Launch an arbitrary external process that takes over I/O.
# `wp core download` falls back to the `tar` binary when PharData isn't available
if ( ! class_exists( 'PharData' ) ) {
$cmd = "tar xz --strip-components=1 --directory=%s -f $tarball";
WP_CLI::launch( Utils\esc_cmd( $cmd, $dest ) );
return;
}
Метод класса: WP_CLI{}
Хуков нет.
Возвращает
int|ProcessRun. The command exit status, or a ProcessRun object for full details.
Использование
$result = WP_CLI::launch( $command, $exit_on_error, $return_detailed );
- $command(строка) (обязательный)
- External process to launch.
- $exit_on_error(true|false)
- Whether to exit if the command returns an elevated return code.
По умолчанию:true - $return_detailed(true|false)
- Whether to return an exit status (default) or detailed execution results.
По умолчанию:false
Код WP_CLI::launch() WP CLI::launch WP-CLI 2.13.0-alpha
public static function launch( $command, $exit_on_error = true, $return_detailed = false ) {
Utils\check_proc_available( 'launch' );
$proc = Process::create( $command );
$results = $proc->run();
if ( -1 === $results->return_code ) {
self::warning( "Spawned process returned exit code {$results->return_code}, which could be caused by a custom compiled version of PHP that uses the --enable-sigchild option." );
}
if ( $results->return_code && $exit_on_error ) {
exit( $results->return_code );
}
if ( $return_detailed ) {
return $results;
}
return $results->return_code;
}