CLIService.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\WordPress\CLI; |
| 4 | |
| 5 | use \WP_CLI; |
| 6 | |
| 7 | /** |
| 8 | * Our CLI service. |
| 9 | */ |
| 10 | class CLIService { |
| 11 | /** |
| 12 | * Bootstrap the service. |
| 13 | * |
| 14 | * @return void |
| 15 | */ |
| 16 | public function bootstrap() { |
| 17 | if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { |
| 18 | return; |
| 19 | } |
| 20 | add_action( 'cli_init', [ $this, 'registerCLICommands' ] ); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Registers CLI commands. |
| 25 | * |
| 26 | * @return void |
| 27 | */ |
| 28 | public function registerCLICommands() { |
| 29 | $surecart = new CLICommands(); |
| 30 | WP_CLI::add_command( 'surecart', $surecart ); |
| 31 | } |
| 32 | } |
| 33 |