PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.1
Elementor Website Builder – more than just a page builder v3.29.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / notifications / module.php

module.php in Elementor Website Builder – more than just a page builder 3.29.1, at modules/notifications/module.php

102 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\Notifications;
3
4 use Elementor\Core\Base\Module as BaseModule;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 class Module extends BaseModule {
11
12 public function get_name() {
13 return 'notification-center';
14 }
15
16 public function __construct() {
17 parent::__construct();
18
19 add_action( 'elementor/admin_top_bar/before_enqueue_scripts', function() {
20 if ( ! current_user_can( 'manage_options' ) ) {
21 return;
22 }
23
24 wp_enqueue_script(
25 'e-admin-notifications',
26 $this->get_js_assets_url( 'admin-notifications' ),
27 [
28 'elementor-v2-ui',
29 'elementor-v2-icons',
30 'elementor-v2-query',
31 'wp-i18n',
32 ],
33 ELEMENTOR_VERSION,
34 true
35 );
36
37 wp_localize_script(
38 'e-admin-notifications',
39 'elementorNotifications',
40 $this->get_app_js_config()
41 );
42
43 wp_set_script_translations( 'e-editor-notifications', 'elementor' );
44 }, 5 /* Before Elementor's admin enqueue scripts */ );
45
46 add_action( 'elementor/editor/v2/scripts/enqueue', [ $this, 'enqueue_editor_scripts' ] );
47 add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_editor_scripts' ] );
48
49 add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
50 }
51
52 public function enqueue_editor_scripts() {
53 $deps = [
54 'elementor-editor',
55 'elementor-v2-ui',
56 'elementor-v2-icons',
57 'elementor-v2-query',
58 'wp-i18n',
59 ];
60
61 $is_editor_v2 = current_action() === 'elementor/editor/v2/scripts/enqueue';
62
63 if ( $is_editor_v2 ) {
64 $deps[] = 'elementor-v2-editor-app-bar';
65 }
66
67 wp_enqueue_script(
68 'e-editor-notifications',
69 $this->get_js_assets_url( 'editor-notifications' ),
70 $deps,
71 ELEMENTOR_VERSION,
72 true
73 );
74
75 wp_localize_script(
76 'e-editor-notifications',
77 'elementorNotifications',
78 $this->get_app_js_config()
79 );
80
81 wp_set_script_translations( 'e-editor-notifications', 'elementor' );
82 }
83
84 private function get_app_js_config(): array {
85 return [
86 'is_unread' => Options::has_unread_notifications(),
87 ];
88 }
89
90 public function register_ajax_actions( $ajax ) {
91 $ajax->register_ajax_action( 'notifications_get', [ $this, 'ajax_get_notifications' ] );
92 }
93
94 public function ajax_get_notifications() {
95 $notifications = API::get_notifications_by_conditions( true );
96
97 Options::mark_notification_read( $notifications );
98
99 return $notifications;
100 }
101 }
102