| @@ -40,31 +40,42 @@ | ||
| 40 | 40 | $this->get_app_js_config() |
| 41 | 41 | ); |
| 42 | 42 | }, 5 /* Before Elementor's admin enqueue scripts */ ); |
| 43 | 43 | |
| 44 | - add_action( 'elementor/editor/after_enqueue_scripts', function() { | |
| 45 | - wp_enqueue_script( | |
| 46 | - 'e-editor-notifications', | |
| 47 | - $this->get_js_assets_url( 'editor-notifications' ), | |
| 48 | - [ | |
| 49 | - 'elementor-editor', | |
| 50 | - 'elementor-v2-ui', | |
| 51 | - 'elementor-v2-icons', | |
| 52 | - 'elementor-v2-query', | |
| 53 | - 'wp-i18n', | |
| 54 | - ], | |
| 55 | - ELEMENTOR_VERSION, | |
| 56 | - true | |
| 57 | - ); | |
| 44 | + add_action( 'elementor/editor/v2/scripts/enqueue', [ $this, 'enqueue_editor_scripts' ] ); | |
| 45 | + add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] ); | |
| 58 | 46 | |
| 59 | - wp_localize_script( | |
| 60 | - 'e-editor-notifications', | |
| 61 | - 'elementorNotifications', | |
| 62 | - $this->get_app_js_config() | |
| 63 | - ); | |
| 64 | - } ); | |
| 47 | + add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); | |
| 48 | + } | |
| 65 | 49 | |
| 66 | - add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); | |
| 50 | + public function enqueue_editor_scripts() { | |
| 51 | + $deps = [ | |
| 52 | + 'elementor-editor', | |
| 53 | + 'elementor-v2-ui', | |
| 54 | + 'elementor-v2-icons', | |
| 55 | + 'elementor-v2-query', | |
| 56 | + 'wp-i18n', | |
| 57 | + ]; | |
| 58 | + | |
| 59 | + $is_editor_v2 = current_action() === 'elementor/editor/v2/scripts/enqueue'; | |
| 60 | + | |
| 61 | + if ( $is_editor_v2 ) { | |
| 62 | + $deps[] = 'elementor-v2-editor-app-bar'; | |
| 63 | + } | |
| 64 | + | |
| 65 | + wp_enqueue_script( | |
| 66 | + 'e-editor-notifications', | |
| 67 | + $this->get_js_assets_url( 'editor-notifications' ), | |
| 68 | + $deps, | |
| 69 | + ELEMENTOR_VERSION, | |
| 70 | + true | |
| 71 | + ); | |
| 72 | + | |
| 73 | + wp_localize_script( | |
| 74 | + 'e-editor-notifications', | |
| 75 | + 'elementorNotifications', | |
| 76 | + $this->get_app_js_config() | |
| 77 | + ); | |
| 67 | 78 | } |
| 68 | 79 | |
| 69 | 80 | private function get_app_js_config() : array { |
| 70 | 81 | return [ |