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