module.php
49 lines
| 1 | <?php |
| 2 | namespace Elementor\Modules\WebCli; |
| 3 | |
| 4 | use Elementor\Core\Base\App; |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly. |
| 8 | } |
| 9 | |
| 10 | class Module extends App { |
| 11 | |
| 12 | public function get_name() { |
| 13 | return 'web-cli'; |
| 14 | } |
| 15 | |
| 16 | public function __construct() { |
| 17 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_scripts' ] ); |
| 18 | add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ] ); |
| 19 | add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] ); |
| 20 | add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_scripts' ] ); |
| 21 | } |
| 22 | |
| 23 | public function register_scripts() { |
| 24 | wp_register_script( |
| 25 | 'elementor-web-cli', |
| 26 | $this->get_js_assets_url( 'web-cli' ), |
| 27 | [ |
| 28 | 'jquery', |
| 29 | ], |
| 30 | ELEMENTOR_VERSION, |
| 31 | true |
| 32 | ); |
| 33 | |
| 34 | $this->print_config( 'elementor-web-cli' ); |
| 35 | } |
| 36 | |
| 37 | protected function get_init_settings() { |
| 38 | return [ |
| 39 | 'isDebug' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), |
| 40 | 'urls' => [ |
| 41 | 'rest' => get_rest_url(), |
| 42 | 'assets' => ELEMENTOR_ASSETS_URL, |
| 43 | ], |
| 44 | 'nonce' => wp_create_nonce( 'wp_rest' ), |
| 45 | 'version' => ELEMENTOR_VERSION, |
| 46 | ]; |
| 47 | } |
| 48 | } |
| 49 |