PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.1.3
Adminify – White Label, Admin Menu Editor, Login Customizer v4.1.3
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Classes / Notifications / Base / Data.php

Data.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.1.3, at Inc/Classes/Notifications/Base/Data.php

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