| 1 |
<?php |
| 2 |
namespace Elementor\Modules\WpCli; |
| 3 |
|
| 4 |
use Elementor\Core\Base\Module as BaseModule; |
| 5 |
use Elementor\Core\Logger\Manager as Logger; |
| 6 |
use Elementor\Plugin; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
class Module extends BaseModule { |
| 13 |
|
| 14 |
/** |
| 15 |
* Get module name. |
| 16 |
* |
| 17 |
* @since 2.0.0 |
| 18 |
* @access public |
| 19 |
* |
| 20 |
* @return string Module name. |
| 21 |
*/ |
| 22 |
public function get_name() { |
| 23 |
return 'wp-cli'; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* @since 2.1.0 |
| 28 |
* @access public |
| 29 |
* @static |
| 30 |
*/ |
| 31 |
public static function is_active() { |
| 32 |
return defined( 'WP_CLI' ) && WP_CLI; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* @param Logger $logger |
| 37 |
* @access public |
| 38 |
*/ |
| 39 |
public function register_cli_logger( $logger ) { |
| 40 |
$logger->register_logger( 'cli', 'Elementor\Modules\WpCli\Cli_Logger' ); |
| 41 |
$logger->set_default_logger( 'cli' ); |
| 42 |
} |
| 43 |
|
| 44 |
public function init_common() { |
| 45 |
Plugin::$instance->init_common(); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* |
| 50 |
* @since 2.1.0 |
| 51 |
* @access public |
| 52 |
*/ |
| 53 |
public function __construct() { |
| 54 |
add_action( 'cli_init', [ $this, 'init_common' ] ); |
| 55 |
add_action( 'elementor/loggers/register', [ $this, 'register_cli_logger' ] ); |
| 56 |
|
| 57 |
\WP_CLI::add_command( 'elementor', '\Elementor\Modules\WpCli\Command' ); |
| 58 |
\WP_CLI::add_command( 'elementor update', '\Elementor\Modules\WpCli\Update' ); |
| 59 |
\WP_CLI::add_command( 'elementor library', '\Elementor\Modules\WpCli\Library' ); |
| 60 |
} |
| 61 |
} |
| 62 |
|