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