module.php
57 lines
| 1 | <?php |
| 2 | namespace Elementor\Modules\DevTools; |
| 3 | |
| 4 | use Elementor\Core\Base\App; |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly. |
| 8 | } |
| 9 | |
| 10 | /** |
| 11 | * Fix issue with 'Potentially polymorphic call. The code may be inoperable depending on the actual class instance passed as the argument.'. |
| 12 | * Its tells to the editor that instance() return right module. instead of base module. |
| 13 | * @method Module instance() |
| 14 | */ |
| 15 | class Module extends App { |
| 16 | /** |
| 17 | * @var Deprecation |
| 18 | */ |
| 19 | public $deprecation; |
| 20 | |
| 21 | public function __construct() { |
| 22 | $this->deprecation = new Deprecation( ELEMENTOR_VERSION ); |
| 23 | |
| 24 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_scripts' ] ); |
| 25 | add_action( 'admin_enqueue_scripts', [ $this, 'register_scripts' ] ); |
| 26 | add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] ); |
| 27 | add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_scripts' ] ); |
| 28 | add_action( 'elementor/common/after_register_scripts', [ $this, 'register_scripts' ] ); |
| 29 | } |
| 30 | |
| 31 | public function get_name() { |
| 32 | return 'dev-tools'; |
| 33 | } |
| 34 | |
| 35 | public function register_scripts() { |
| 36 | wp_register_script( |
| 37 | 'elementor-dev-tools', |
| 38 | $this->get_js_assets_url( 'dev-tools' ), |
| 39 | [], |
| 40 | ELEMENTOR_VERSION, |
| 41 | true |
| 42 | ); |
| 43 | |
| 44 | $this->print_config( 'elementor-dev-tools' ); |
| 45 | } |
| 46 | |
| 47 | protected function get_init_settings() { |
| 48 | return [ |
| 49 | 'isDebug' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), |
| 50 | 'urls' => [ |
| 51 | 'assets' => ELEMENTOR_ASSETS_URL, |
| 52 | ], |
| 53 | 'deprecation' => $this->deprecation->get_settings(), |
| 54 | ]; |
| 55 | } |
| 56 | } |
| 57 |