Created
December 4, 2023 13:18
-
-
Save MakarandMane/02b37bfa0ad39a71690a32236e0f5016 to your computer and use it in GitHub Desktop.
Custom WP-CLI command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements example command. | |
*/ | |
class Hello_WPGenius_Command { | |
/** | |
* Prints a greeting. | |
* | |
* ## OPTIONS | |
* | |
* <name> | |
* : The name of the person to greet. | |
* | |
* [--type=<type>] | |
* : Whether or not to greet the person with success or error. | |
* --- | |
* default: success | |
* options: | |
* - success | |
* - error | |
* --- | |
* | |
* ## EXAMPLES | |
* | |
* wp example hello Newman | |
* | |
* @when after_wp_load | |
*/ | |
function hello( $args, $assoc_args ) { | |
list( $name ) = $args; | |
// Print the message with type | |
$type = $assoc_args['type']; | |
WP_CLI::$type( "Hello, $name!" ); | |
} | |
} | |
WP_CLI::add_command( 'example', 'Hello_WPGenius_Command' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment