Skip to content

Instantly share code, notes, and snippets.

@mrinal013
Created April 9, 2021 11:45
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 mrinal013/c8866e336abd1687f925e2b78e081262 to your computer and use it in GitHub Desktop.
Save mrinal013/c8866e336abd1687f925e2b78e081262 to your computer and use it in GitHub Desktop.
<?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