PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / trunk
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits vtrunk
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / classes / notifications / base / data.php

data.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits trunk, at inc/classes/notifications/base/data.php

146 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Inc\Classes\Notifications\Base;
4
5 // No, Direct access Sir !!!
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9
10 /**
11 * Data abstract class
12 *
13 * Jewel Theme <support@jeweltheme.com>
14 */
15 abstract class Data
16 {
17
18 use Date;
19
20 public $notifications = array();
21
22 /**
23 * Get Notifications
24 *
25 * @param [type] $instance_key .
26 *
27 * @author Jewel Theme <support@jeweltheme.com>
28 */
29 public function get_notification($instance_key)
30 {
31 if (array_key_exists($instance_key, $this->notifications)) {
32 return $this->notifications[$instance_key];
33 }
34
35 return null;
36 }
37
38 /**
39 * Get Notificaiton
40 *
41 * @param [type] $type .
42 *
43 * @author Jewel Theme <support@jeweltheme.com>
44 */
45 public function get_notifications($type = null)
46 {
47 $notifications = $this->notifications;
48
49 if ($type) {
50 $notifications = wp_list_filter($notifications, array('type' => $type));
51 }
52
53 return $notifications;
54 }
55
56 /**
57 * Get Active notifications
58 *
59 * @param [type] $type .
60 *
61 * @author Jewel Theme <support@jeweltheme.com>
62 */
63 public function get_active_notifications($type = null)
64 {
65 $notifications = wp_list_filter($this->get_notifications($type), array('is_active' => true));
66
67 return wp_list_sort($notifications, 'next_exec_time');
68 }
69
70 /**
71 * Get executable notifications
72 *
73 * @param [type] $date .
74 * @param [type] $type .
75 *
76 * @author Jewel Theme <support@jeweltheme.com>
77 */
78 public function get_exec_notifications($date = null, $type = null)
79 {
80 if (!$date) {
81 $date = $this->current_time();
82 }
83
84 $notifications = $this->get_active_notifications($type);
85
86 $_notifications = array();
87
88 foreach ($notifications as $notification) {
89 if (empty($notification->next_exec_time)) {
90 continue;
91 }
92
93 if ($this->date_is_current_or_prev($notification->next_exec_time, $date)) {
94 $_notifications[] = $notification;
95 }
96 }
97
98 return $_notifications;
99 }
100
101 /**
102 * Get Upcoming Notificaitons
103 *
104 * @param [type] $date .
105 * @param [type] $type .
106 *
107 * @author Jewel Theme <support@jeweltheme.com>
108 */
109 public function get_upcoming_notifications($date = null, $type = null)
110 {
111 if (!$date) {
112 $date = $this->current_time();
113 }
114
115 $notifications = $this->get_active_notifications($type);
116
117 $_notifications = array();
118
119 foreach ($notifications as $notification) {
120 if (empty($notification->next_exec_time)) {
121 continue;
122 }
123
124 if ($this->date_is_next($notification->next_exec_time, $date)) {
125 $_notifications[] = $notification;
126 }
127 }
128
129 return $_notifications;
130 }
131
132 /**
133 * Register Instance
134 *
135 * @param [type] $instance .
136 *
137 * @author Jewel Theme <support@jeweltheme.com>
138 */
139 public function register($instance)
140 {
141 if (!array_key_exists($instance->get_id(), $this->notifications)) {
142 $this->notifications[$instance->get_id()] = $instance;
143 }
144 }
145 }
146