Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Plugin Name: Custom CLI
*/
class CustomWPCLI {
function __construct() {
add_action( 'cli_init', array( $this, 'mrinal_cli_register_commands' ) );
}
function mrinal_cli_register_commands() {
WP_CLI::add_command( 'github', array( $this, 'http_request' ) );
}
function http_request( $user ) {
$response = WP_CLI\Utils\http_request( 'GET', 'https://api.github.com/users/' . $user[0] );
update_option( 'github', $response );
}
}
new CustomWPCLI();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment