Skip to navigation
WP_CLI::xxxx outputs like WP_CLI::success
09.12.25
1. WP_CLI::line( $message ) Prints a single line of text. PHP WP_CLI::line( 'Just a line of output.' ); 2. WP_CLI::success( $message ) Prints a success message in green. PHP WP_CLI::success( 'Operation completed successfully.' ); 3. WP_CLI::warning( $message ) Prints a warning message in yellow. PHP WP_CLI::warning( 'This is a warning.' ); 4. WP_CLI::error( $message, $exit_code = 1 ) Prints an error message in red and exits with a status code. PHP WP_CLI::error( 'Something went wrong!' ); 5. WP_CLI::log( $message ) Prints a message (alias for line() but will be displayed only if not in quiet mode). PHP WP_CLI::log( 'Logging a normal message.' ); 6. WP_CLI::halt( $exit_code = 1 ) Stops the execution, optionally with an exit code (no message). PHP WP_CLI::halt( 2 ); 7. WP_CLI::confirm( $message, $assoc_args = array() ) Prompts user for confirmation before proceeding. PHP WP_CLI::confirm( 'Are you sure you want to do this?' ); 8. WP_CLI::prompt( $question, $options = false ) Prompts user for input. PHP $name = WP_CLI::prompt( 'What is your name?' ); 9. WP_CLI::launch( $command, $exit_on_error = true, $return_detailed = false ) Executes a shell command. PHP WP_CLI::launch( 'ls -la' ); 10. WP_CLI::add_command( $name, $callable, $args = array() ) Registers a custom WP-CLI command. PHP WP_CLI::add_command( 'hello', 'hello_callback' ); 11. WP_CLI::error_multi_line( $messages, $exit_code = 1 ) Prints a multi-line error message and exits. PHP WP_CLI::error_multi_line( [ 'First error.', 'Second error.' ] ); The most relevant output methods for CLI scripts Most commonly used for WP-CLI commands are: WP_CLI::line WP_CLI::log WP_CLI::success WP_CLI::warning WP_CLI::error WP_CLI::error_multi_line
https://wp-cli.org/
Reply
Anonymous
Information Epoch 1766751588
Design for visibility.
Home
Notebook
Contact us