Skip to content

Instantly share code, notes, and snippets.

@vanushwashere
Last active March 3, 2021 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanushwashere/3ef39ad435ec5507e43e376a68831ef5 to your computer and use it in GitHub Desktop.
Save vanushwashere/3ef39ad435ec5507e43e376a68831ef5 to your computer and use it in GitHub Desktop.
A 'Hello World' for WP CLI
<?php
/*
Plugin Name: 10web Hello World
Plugin URI: https://10web.io/
Description: Teaching the basics of WP-CLI
Author: Vanush 10web
Version: 1.0.0
Author URI: https://10web.io/
*/
/**
* My custom command to print greeting.
*/
class TWC_CLI {
/**
* Returns 'Hello World'
*
* @since 0.0.1
* @author Vanush 10web
*/
public function hello_world() {
WP_CLI::line( 'Hello World!' );
}
}
/**
* Registers our command when cli get's initialized.
*
* @since 1.0.0
* @author Vanush 10web
*/
function twc_cli_register_commands() {
WP_CLI::add_command( 'twc', 'TWC_CLI' );
}
add_action( 'cli_init', 'twc_cli_register_commands' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment