PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.2.5
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.2.5
4.3.2 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 All 165 releases
← All changes | Inc/Classes/Notifications/Notifications.php +188 -191 4.2.254.0.2.5 View file →
@@ -1,177 +1,186 @@
1 1 <?php
2 2
3 -namespace PXLBSAdminify\Inc\Classes\Notifications;
3 +namespace WPAdminify\Inc\Classes\Notifications;
4 4
5 -use PXLBSAdminify\Inc\Classes\Notifications\Base\Date;
6 -use PXLBSAdminify\Inc\Classes\Helper;
5 +use WPAdminify\Inc\Classes\Notifications\Base\Date;
6 +use WPAdminify\Inc\Classes\Helper;
7 +
7 8 // No, Direct access Sir !!!
8 -if ( !defined( 'ABSPATH' ) ) {
9 - exit;
9 +if (!defined('ABSPATH')) {
10 + exit;
10 11 }
12 +
11 13 /**
12 14 * Notification Class
13 15 *
14 16 * Jewel Theme <support@jeweltheme.com>
15 17 */
16 -class Notifications {
17 - use Date;
18 - public $manager;
18 +class Notifications
19 +{
19 20
20 - public $conflict_days = 5;
21 + use Date;
21 22
22 - public $slug;
23 + public $manager;
23 24
24 - /**
25 - * Construction method
26 - */
27 - public function __construct() {
28 - $this->manager = new Manager();
29 - $this->slug = Helper::slug_cleanup();
30 - add_action( 'admin_print_scripts', array($this, 'init_notifications'), 99999999 );
31 - add_action(
32 - 'pxlbsadminify_display_notice',
33 - array($this, 'display_notice'),
34 - 10,
35 - 2
36 - );
37 - add_action(
38 - 'pxlbsadminify_display_popup',
39 - array($this, 'display_popup'),
40 - 10,
41 - 2
42 - );
43 - add_action( 'wp_ajax_pxlbsadminify_notification_action', array($this, 'pxlbsadminify_notification_action') );
44 - }
25 + public $conflict_days = 5;
45 26
46 - /**
47 - * Notification Action
48 - *
49 - * @author Jewel Theme <support@jeweltheme.com>
50 - */
51 - public function pxlbsadminify_notification_action() {
52 - check_ajax_referer( 'pxlbsadminify_notification_nonce' );
53 - // Security check - only administrators can manage notifications
54 - if ( !current_user_can( 'manage_options' ) ) {
55 - wp_send_json_error( array(
56 - 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
57 - ) );
58 - }
59 - $action_type = ( !empty( $_REQUEST['action_type'] ) ? sanitize_key( $_REQUEST['action_type'] ) : '' );
60 - $notification_type = ( !empty( $_REQUEST['notification_type'] ) ? sanitize_key( $_REQUEST['notification_type'] ) : '' );
61 - $trigger_time = ( !empty( $_REQUEST['trigger_time'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['trigger_time'] ) ) : '' );
62 - $exec_notifications = $this->manager->get_exec_notifications( $trigger_time, $notification_type );
63 - // No Executable Notifications found .
64 - if ( empty( $exec_notifications ) ) {
65 - die( 0 );
66 - }
67 - $count = 0;
68 - foreach ( $exec_notifications as $index => $notification ) {
69 - if ( 0 === $index ) {
70 - if ( 'disable' === $action_type ) {
71 - $notification->is_active = false;
72 - }
73 - $notification->fire( $trigger_time, $notification_type )->save();
74 - } else {
75 - $count++;
76 - $notification->maybe_delay( $this->date_increment( $trigger_time, $this->conflict_days * $count ) )->save();
77 - }
78 - }
79 - die( 0 );
80 - }
27 + public $slug;
81 28
82 - /**
83 - * Notification Setup
84 - *
85 - * @param [type] $type .
86 - *
87 - * @author Jewel Theme <support@jeweltheme.com>
88 - */
89 - public function setup_notifications_by_type( $type ) {
90 - // $trigger_time should be today .
91 - $trigger_time = $this->current_time();
92 - // Block if necessary .
93 - $notification_last_fired = get_option( "pxlbsadminify_{$type}_last_interact" );
94 - if ( $notification_last_fired ) {
95 - $notification_enable_date = $this->date_increment( $notification_last_fired, $this->conflict_days );
96 - if ( $this->date_is_prev( $trigger_time, $notification_enable_date ) ) {
97 - return;
98 - }
99 - }
100 - // Get Executable Notifications .
101 - $exec_notifications = $this->manager->get_exec_notifications( $trigger_time, $type );
102 - // No Executable Notifications found .
103 - if ( empty( $exec_notifications ) ) {
104 - return;
105 - }
106 - $notification = $exec_notifications[0];
107 - do_action( "pxlbsadminify_display_{$type}", $notification, $trigger_time );
108 - }
29 + /**
30 + * Construction method
31 + */
32 + public function __construct()
33 + {
34 + $this->manager = new Manager();
109 35
110 - /**
111 - * Notification initialization
112 - *
113 - * @author Jewel Theme <support@jeweltheme.com>
114 - */
115 - public function init_notifications() {
116 - add_action( 'admin_notices', array($this, 'setup_notifications') );
117 - add_action( 'network_admin_notices', array($this, 'setup_notifications') );
118 - }
36 + $this->slug = Helper::jltwp_adminify_slug_cleanup();
119 37
120 - /**
121 - * Notification setup
122 - *
123 - * @author Jewel Theme <support@jeweltheme.com>
124 - */
125 - public function setup_notifications() {
126 - $this->setup_notifications_by_type( 'notice' );
127 - $this->setup_notifications_by_type( 'popup' );
128 - }
38 + add_action('admin_print_scripts', array($this, 'init_notifications'), 99999999);
129 39
130 - /**
131 - * Display notice
132 - *
133 - * @param [type] $notice .
134 - * @param [type] $trigger_time .
135 - *
136 - * @return void
137 - * @author Jewel Theme <support@jeweltheme.com>
138 - */
139 - public function display_notice( $notice, $trigger_time ) {
140 - $notice->notice_header();
141 - $notice->notice_content();
142 - $notice->notice_footer();
143 - $notice->core_script( $trigger_time );
144 - }
40 + add_action('jltwp_adminify_display_notice', array($this, 'display_notice'), 10, 2);
41 + add_action('jltwp_adminify_display_popup', array($this, 'display_popup'), 10, 2);
145 42
146 - /**
147 - * Display Popup
148 - *
149 - * @param [type] $popup .
150 - * @param [type] $trigger_time .
151 - *
152 - * @return void
153 - * @author Jewel Theme <support@jeweltheme.com>
154 - */
155 - public function display_popup( $popup, $trigger_time ) {
156 - $screen = get_current_screen();
157 - if ( !in_array( $screen->id, ['toplevel_page_wp-adminify-settings', 'dashboard'] ) ) {
158 - return;
159 - }
160 - $image_url = $popup->get_content( 'image_url' );
161 - ?>
43 + add_action('wp_ajax_jltwp_adminify_notification_action', array($this, 'notification_action'));
44 + }
162 45
163 - <div class="wp-adminify-popup" id="wp-adminify-popup" data-plugin="<?php
164 - echo esc_attr( $this->slug );
165 - ?>" tabindex="1">
46 + /**
47 + * Notification Action
48 + *
49 + * @author Jewel Theme <support@jeweltheme.com>
50 + */
51 + public function notification_action()
52 + {
53 + check_ajax_referer('jltwp_adminify_notification_nonce');
166 54
55 + $action_type = !empty($_REQUEST['action_type']) ? sanitize_key($_REQUEST['action_type']) : '';
56 + $notification_type = !empty($_REQUEST['notification_type']) ? sanitize_key($_REQUEST['notification_type']) : '';
57 + $trigger_time = !empty($_REQUEST['trigger_time']) ? sanitize_text_field(wp_unslash($_REQUEST['trigger_time'])) : '';
58 +
59 + $exec_notifications = $this->manager->get_exec_notifications($trigger_time, $notification_type);
60 +
61 + // No Executable Notifications found .
62 + if (empty($exec_notifications)) {
63 + die(0);
64 + }
65 +
66 + $count = 0;
67 +
68 + foreach ($exec_notifications as $index => $notification) {
69 + if (0 === $index) {
70 + if ('disable' === $action_type) {
71 + $notification->is_active = false;
72 + }
73 + $notification->fire($trigger_time, $notification_type)->save();
74 + } else {
75 + ++$count;
76 + $notification->maybe_delay($this->date_increment($trigger_time, $this->conflict_days * $count))->save();
77 + }
78 + }
79 +
80 + die(0);
81 + }
82 +
83 +
84 + /**
85 + * Notification Setup
86 + *
87 + * @param [type] $type .
88 + *
89 + * @author Jewel Theme <support@jeweltheme.com>
90 + */
91 + public function setup_notifications_by_type($type)
92 + {
93 + // $trigger_time should be today .
94 + $trigger_time = $this->current_time();
95 +
96 + // Block if necessary .
97 + $notification_last_fired = get_option("jltwp_adminify_{$type}_last_interact");
98 +
99 + if ($notification_last_fired) {
100 + $notification_enable_date = $this->date_increment($notification_last_fired, $this->conflict_days);
101 +
102 + if ($this->date_is_prev($trigger_time, $notification_enable_date)) {
103 + return;
104 + }
105 + }
106 +
107 + // Get Executable Notifications .
108 + $exec_notifications = $this->manager->get_exec_notifications($trigger_time, $type);
109 +
110 + // No Executable Notifications found .
111 + if (empty($exec_notifications)) {
112 + return;
113 + }
114 +
115 + $notification = $exec_notifications[0];
116 +
117 + do_action("jltwp_adminify_display_{$type}", $notification, $trigger_time);
118 + }
119 +
120 + /**
121 + * Notification initialization
122 + *
123 + * @author Jewel Theme <support@jeweltheme.com>
124 + */
125 + public function init_notifications()
126 + {
127 + add_action('admin_notices', array($this, 'setup_notifications'));
128 + add_action('network_admin_notices', array($this, 'setup_notifications'));
129 + }
130 +
131 +
132 + /**
133 + * Notification setup
134 + *
135 + * @author Jewel Theme <support@jeweltheme.com>
136 + */
137 + public function setup_notifications()
138 + {
139 + $this->setup_notifications_by_type('notice');
140 + $this->setup_notifications_by_type('popup');
141 + }
142 +
143 +
144 +
145 + /**
146 + * Display notice
147 + *
148 + * @param [type] $notice .
149 + * @param [type] $trigger_time .
150 + *
151 + * @return void
152 + * @author Jewel Theme <support@jeweltheme.com>
153 + */
154 + public function display_notice($notice, $trigger_time)
155 + {
156 + $notice->notice_header();
157 + $notice->notice_content();
158 + $notice->notice_footer();
159 +
160 + $notice->core_script($trigger_time);
161 + }
162 +
163 + /**
164 + * Display Popup
165 + *
166 + * @param [type] $popup .
167 + * @param [type] $trigger_time .
168 + *
169 + * @return void
170 + * @author Jewel Theme <support@jeweltheme.com>
171 + */
172 + public function display_popup($popup, $trigger_time)
173 + {
174 + $image_url = $popup->get_content('image_url');
175 + $notice = !empty($popup->get_content('notice')) ? $popup->get_content('notice') : '';
176 +?>
177 +
178 + <div class="wp-adminify-popup" id="wp-adminify-popup" data-plugin="<?php echo esc_attr($this->slug); ?>" tabindex="1">
179 +
167 180 <div class="wp-adminify-popup-overlay"></div>
168 181
169 - <div class="wp-adminify-popup-modal" style="background-image: url('<?php
170 - echo esc_url( $image_url );
171 - ?>'); --wp-adminify-popup-color: <?php
172 - echo esc_attr( $popup->get_content( 'btn_color' ) );
173 - ?>;">
182 + <div class="wp-adminify-popup-modal" style="background-image: url('<?php echo esc_url($image_url); ?>'); --wp-adminify-popup-color: <?php echo esc_attr($popup->get_content('btn_color')); ?>;">
174 183
175 184 <!-- close -->
176 185 <div class="wp-adminify-popup-modal-close popup-dismiss">×</div>
177 186
@@ -179,53 +188,48 @@
179 188 <div class="wp-adminify-popup-modal-footer">
180 189
181 190 <!-- countdown -->
182 191 <div class="wp-adminify-popup-countdown" style="display: none;">
183 - <span class="wp-adminify-popup-countdown-text"><?php
184 - echo esc_html__( 'Deal Ends In', 'adminify' );
185 - ?></span>
192 +
193 + <?php if ($notice) { ?>
194 + <span data-counter="notice" style="color:#F4B740; font-size:14px; padding-bottom:20px; font-style:italic;">
195 + <?php echo esc_html__('Notice:', 'adminify'); ?> <?php echo esc_html($notice); ?>
196 + </span>
197 + <?php } ?>
198 +
199 + <span class="wp-adminify-popup-countdown-text"><?php echo esc_html__('Deal Ends In', 'adminify'); ?></span>
186 200 <div class="wp-adminify-popup-countdown-time">
187 201 <div>
188 202 <span data-counter="days">00</span>
189 - <span><?php
190 - echo esc_html__( 'Days', 'adminify' );
191 - ?></span>
203 + <span><?php echo esc_html__('Days', 'adminify'); ?></span>
192 204 </div>
193 205 <span>:</span>
194 206 <div>
195 207 <span data-counter="hours">00</span>
196 - <span><?php
197 - echo esc_html__( 'Hours', 'adminify' );
198 - ?></span>
208 + <span><?php echo esc_html__('Hours', 'adminify'); ?></span>
199 209 </div>
200 210 <span>:</span>
201 211 <div>
202 212 <span data-counter="minutes">00</span>
203 - <span><?php
204 - echo esc_html__( 'Minutes', 'adminify' );
205 - ?></span>
213 + <span><?php echo esc_html__('Minutes', 'adminify'); ?></span>
206 214 </div>
207 215 <span>:</span>
208 216 <div>
209 217 <span data-counter="seconds">00</span>
210 - <span><?php
211 - echo esc_html__( 'Seconds', 'adminify' );
212 - ?></span>
218 + <span><?php echo esc_html__('Seconds', 'adminify'); ?></span>
213 219 </div>
214 220 </div>
215 221 </div>
216 222
217 223 <!-- button -->
218 - <a class="wp-adminify-popup-button" style="color: #fff !important" target="_blank" href="<?php
219 - echo esc_url( $popup->get_content( 'button_url' ) );
220 - ?>">
221 - <?php
222 - if ( jltwp_adminify()->can_use_premium_code() ) {
223 - echo esc_html__( 'Upgrade Now', 'adminify' );
224 - } else {
225 - echo esc_html( $popup->get_content( 'button_text' ) );
226 - }
227 - ?>
224 + <a class="wp-adminify-popup-button" target="_blank" href="<?php echo esc_url($popup->get_content('button_url')); ?>">
225 + <?php
226 + if (jltwp_adminify()->can_use_premium_code()) {
227 + echo esc_html__('Upgrade Now', 'adminify');
228 + } else {
229 + echo esc_html($popup->get_content('button_text'));
230 + }
231 + ?>
228 232 </a>
229 233 </div>
230 234 </div>
231 235 </div>
@@ -230,40 +234,33 @@
230 234 </div>
231 235 </div>
232 236
233 237 <script>
234 - function pxlbsadminify_popup_action(evt, $this, $action_type) {
238 + function jltwp_adminify_popup_action(evt, $this, $action_type) {
235 239
236 240 evt.preventDefault();
237 241
238 242 $this.closest('.wp-adminify-popup').fadeOut(200);
239 243
240 - jQuery.post('<?php
241 - echo esc_url( admin_url( 'admin-ajax.php' ) );
242 - ?>', {
243 - action: 'pxlbsadminify_notification_action',
244 - _wpnonce: '<?php
245 - echo esc_js( wp_create_nonce( 'pxlbsadminify_notification_nonce' ) );
246 - ?>',
244 + jQuery.post('<?php echo esc_url(admin_url('admin-ajax.php')); ?>', {
245 + action: 'jltwp_adminify_notification_action',
246 + _wpnonce: '<?php echo esc_js(wp_create_nonce('jltwp_adminify_notification_nonce')); ?>',
247 247 action_type: $action_type,
248 248 notification_type: 'popup',
249 - trigger_time: '<?php
250 - echo esc_attr( $trigger_time );
251 - ?>'
249 + trigger_time: '<?php echo esc_attr($trigger_time); ?>'
252 250 });
253 251 }
254 252
255 253 // Notice Dismiss
256 254 jQuery('body').on('click', '.wp-adminify-popup .popup-dismiss', function(evt) {
257 - pxlbsadminify_popup_action(evt, jQuery(this), 'dismiss');
255 + jltwp_adminify_popup_action(evt, jQuery(this), 'dismiss');
258 256 });
259 257
260 258 // Notice Disable
261 259 jQuery('body').on('click', '.wp-adminify-popup .popup-disable', function(evt) {
262 - pxlbsadminify_popup_action(evt, jQuery(this), 'disable');
260 + jltwp_adminify_popup_action(evt, jQuery(this), 'disable');
263 261 });
264 262 </script>
265 263
266 - <?php
267 - }
268 -
264 +<?php
265 + }
269 266 }