class-wc-cli.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Enables WooCommerce, via the the command line.
  4. *
  5. * @package WooCommerce\CLI
  6. * @version 3.0.0
  7. */
  8. defined( 'ABSPATH' ) || exit;
  9. /**
  10. * CLI class.
  11. */
  12. class WC_CLI {
  13. /**
  14. * Load required files and hooks to make the CLI work.
  15. */
  16. public function __construct() {
  17. $this->includes();
  18. $this->hooks();
  19. }
  20. /**
  21. * Load command files.
  22. */
  23. private function includes() {
  24. require_once dirname( __FILE__ ) . '/cli/class-wc-cli-runner.php';
  25. require_once dirname( __FILE__ ) . '/cli/class-wc-cli-rest-command.php';
  26. require_once dirname( __FILE__ ) . '/cli/class-wc-cli-tool-command.php';
  27. require_once dirname( __FILE__ ) . '/cli/class-wc-cli-update-command.php';
  28. }
  29. /**
  30. * Sets up and hooks WP CLI to our CLI code.
  31. */
  32. private function hooks() {
  33. WP_CLI::add_hook( 'after_wp_load', 'WC_CLI_Runner::after_wp_load' );
  34. WP_CLI::add_hook( 'after_wp_load', 'WC_CLI_Tool_Command::register_commands' );
  35. WP_CLI::add_hook( 'after_wp_load', 'WC_CLI_Update_Command::register_commands' );
  36. }
  37. }
  38. new WC_CLI();