Skip to content

Instantly share code, notes, and snippets.

@vanushwashere
Last active Mar 3, 2021
Embed
What would you like to do?
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