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