PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.4
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.4
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 / Latest_Updates.php

Latest_Updates.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.4, at Inc/Classes/Notifications/Latest_Updates.php

454 lines 13.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Classes\Notifications;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 use PXLBSAdminify\Inc\Classes\Notifications\Model\Notice;
10
11 if (!class_exists('Latest_Updates')) {
12 /**
13 * Latest Pugin Updates Notice Class
14 *
15 * Jewel Theme <support@jeweltheme.com>
16 */
17 class Latest_Updates extends Notice
18 {
19 public $type = 'notice';
20 public $color = 'info';
21
22 /**
23 * Check if we're on the WP Adminify settings page
24 *
25 * @return bool
26 */
27 private function is_adminify_settings_page() {
28 global $pagenow;
29 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change.
30 return is_admin() && $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'wp-adminify-settings';
31 }
32
33 /**
34 * Latest Updates Notice
35 *
36 * @return void
37 */
38 public function __construct()
39 {
40 parent::__construct();
41 if(is_admin()){
42 // TODO: Need to check about conflicts with other plugins
43 // add_action( 'admin_footer', array( $this, 'pxlbsadminify_handle_plugin_update_notice_dismiss' ),99999 );
44 add_action( 'wp_ajax_pxlbsadminify_plugin_update_info', array( $this, 'pxlbsadminify_plugin_update_info' ) );
45 }
46 }
47
48 /**
49 * Handles the AJAX request for the plugin update info notice dismissal.
50 *
51 * Triggered when the user clicks the Dismiss button in the notice.
52 *
53 * @since 1.0
54 *
55 * @return void
56 */
57 public function pxlbsadminify_plugin_update_info() {
58 if (!current_user_can('install_plugins')) {
59 return;
60 }
61
62 // Verify nonce for security.
63 check_ajax_referer( 'dismiss_notice_nonce', 'nonce' );
64
65 $action_type = isset( $_POST['action_type'] ) ? sanitize_text_field( wp_unslash( $_POST['action_type'] ) ) : 'dismiss';
66 $option_value = ( 'forever' === $action_type ) ? 'forever' : 'dismissed';
67
68 wp_send_json_success( array( 'message' => 'Notice dismissed.', 'data' => update_option('pxlbsadminify_plugin_update_info_notice', $option_value ) ) );
69 }
70
71
72 /**
73 * Notice Content
74 *
75 * @author Jewel Theme <support@jeweltheme.com>
76 */
77 public function notice_content()
78 {
79 if ( ! $this->is_adminify_settings_page() ) {
80 return;
81 }
82
83 $forever_notice = get_option('pxlbsadminify_plugin_update_info_notice', true );
84 if( 'forever' === $forever_notice ){
85 return;
86 }
87
88 if("dismissed" !== $forever_notice){
89 $pxlbsadminify_changelog_message = sprintf(
90 /* translators: %1$s: changelogs page URL. %2$s: link anchor text. %3$s: plugin update heading HTML. %4$s, %5$s, %6$s, %7$s %8$s %9$s %10$s %11$s: changelog list item HTML. */
91 __('%3$s %4$s <br> <strong>Check Changelogs for </strong> <a href="%1$s" target="__blank">%2$s</a>', 'adminify'),
92 esc_url_raw('https://wpadminify.com/changelogs'),
93 __('More about Updates ', 'adminify'),
94 /** Changelog Items
95 * Starts from: %3$s
96 */
97
98 '<h3 class="adminify-update-head">' . PXLBSADMINIFY . ' <span><small><em>v' . esc_html(PXLBSADMINIFY_VER) . '</em></small>' . __(' has some updates..', 'adminify') . '</span></h3><br>', // %3$s
99 // changelogs
100 __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Fixed:</strong> Admin Bar Editor with Adminify UI white screen issue fixed. </span><br>', 'adminify'),
101 );
102 printf(wp_kses_post($pxlbsadminify_changelog_message));
103 }
104
105 $this->pxlbsadminify_handle_plugin_update_notice_dismiss();
106 }
107
108 /**
109 * Notice Header
110 *
111 * @author Jewel Theme <support@jeweltheme.com>
112 */
113 public function notice_header() {
114 if ( ! $this->is_adminify_settings_page() ) {
115 echo '<div class="wp-adminify-notice-hidden" style="display:none;"><div>';
116 return;
117 }
118
119 $notice_status = get_option('pxlbsadminify_plugin_update_info_notice', true );
120 if ( 'forever' === $notice_status ) {
121 echo '<div class="wp-adminify-notice-hidden" style="display:none;"><div>';
122 return;
123 }
124
125 if("dismissed" !== $notice_status){
126 $border_colors = array(
127 'info' => '#72aee6',
128 'success' => '#00a32a',
129 'warning' => '#dba617',
130 'error' => '#d63638',
131 );
132 $border_color = isset( $border_colors[ $this->color ] ) ? $border_colors[ $this->color ] : $border_colors['info'];
133 ?>
134 <div class="wp-adminify-notice--ignored wp-adminify-notice wp-adminify-notice-<?php echo esc_attr( $this->color ); ?> wp-adminify-notice-<?php echo esc_attr( $this->get_id() ); ?> wp-adminify-notice-plugin-update-info" style="background: #fff; border-left: 4px solid <?php echo esc_attr( $border_color ); ?>; padding: 10px 12px; margin: 5px 15px 2px 0; box-shadow: 0 1px 1px rgba(0,0,0,.04); position: relative;">
135 <button type="button" class="wp-adminify-notice-dismiss" data-notice-type="plugin_update_notice" style="position: absolute; top: 0; right: 1px; border: none; margin: 0; padding: 9px; background: none; color: #787c82; cursor: pointer;">
136 <span class="dashicons dashicons-no-alt"></span>
137 </button>
138 <div class="wp-adminify-notice-content">
139 <?php
140 }else{ echo '<div class="wp-adminify-notice-hidden" style="display:none;"><div>';}
141 }
142
143 public function pxlbsadminify_handle_plugin_update_notice_dismiss() { ?>
144
145 <!-- Update Notice Confirmation Modal -->
146 <div id="wp-adminify-update-notice-modal" class="wp-adminify-update-modal-overlay">
147 <div class="wp-adminify-update-modal">
148 <button type="button" class="wp-adminify-update-modal-close" id="wp-adminify-modal-close">
149 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
150 <path d="M13 1L1 13M1 1L13 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
151 </svg>
152 </button>
153 <div class="wp-adminify-update-modal-icon">
154 <div class="wp-adminify-update-modal-icon-ring">
155 <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
156 <path d="M12 16V12M12 8H12.01M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
157 </svg>
158 </div>
159 </div>
160 <h3 class="wp-adminify-update-modal-title"><?php echo esc_html__('Want to see future updates?', 'adminify'); ?></h3>
161 <p class="wp-adminify-update-modal-desc"><?php echo esc_html__('Stay informed about new features and improvements.', 'adminify'); ?></p>
162 <div class="wp-adminify-update-modal-buttons">
163 <button type="button" id="wp-adminify-notice-yes" class="wp-adminify-update-btn wp-adminify-update-btn-primary">
164 <span><?php echo esc_html__('Yes, notify me', 'adminify'); ?></span>
165 </button>
166 <button type="button" id="wp-adminify-notice-forever" class="wp-adminify-update-btn wp-adminify-update-btn-secondary">
167 <span><?php echo esc_html__("Don't show again", 'adminify'); ?></span>
168 </button>
169 </div>
170 </div>
171 </div>
172
173 <style>
174 .wp-adminify-update-modal-overlay {
175 --modal-accent: #5046e5;
176 --modal-accent-light: #6366f1;
177 --modal-accent-glow: rgba(80, 70, 229, 0.35);
178 --modal-text: #1e293b;
179 --modal-text-muted: #64748b;
180 --modal-bg: #ffffff;
181 --modal-border: #e2e8f0;
182 --modal-danger: #ef4444;
183
184 display: none;
185 position: fixed;
186 top: 0;
187 left: 0;
188 width: 100%;
189 height: 100%;
190 background: rgba(15, 23, 42, 0.5);
191 backdrop-filter: blur(8px);
192 -webkit-backdrop-filter: blur(8px);
193 z-index: 999999;
194 align-items: center;
195 justify-content: center;
196 }
197
198 .wp-adminify-update-modal {
199 background: var(--modal-bg);
200 padding: 48px 44px 44px;
201 border-radius: 20px;
202 max-width: 460px;
203 width: calc(100% - 32px);
204 text-align: center;
205 box-shadow:
206 0 0 0 1px rgba(0, 0, 0, 0.03),
207 0 2px 4px rgba(0, 0, 0, 0.02),
208 0 12px 24px rgba(0, 0, 0, 0.06),
209 0 32px 64px rgba(0, 0, 0, 0.12);
210 position: relative;
211 animation: wpAdminifyModalAppear 0.35s cubic-bezier(0.16, 1, 0.3, 1);
212 }
213
214 @keyframes wpAdminifyModalAppear {
215 from {
216 opacity: 0;
217 transform: scale(0.92) translateY(8px);
218 }
219 to {
220 opacity: 1;
221 transform: scale(1) translateY(0);
222 }
223 }
224
225 .wp-adminify-update-modal-close {
226 position: absolute;
227 top: 18px;
228 right: 18px;
229 width: 36px;
230 height: 36px;
231 border: none;
232 background: transparent;
233 color: var(--modal-danger);
234 cursor: pointer;
235 display: flex;
236 align-items: center;
237 justify-content: center;
238 border-radius: 10px;
239 transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
240 opacity: 0.7;
241 }
242
243 .wp-adminify-update-modal-close:hover {
244 background: #fef2f2;
245 opacity: 1;
246 transform: scale(1.05);
247 }
248
249 .wp-adminify-update-modal-close:active {
250 transform: scale(0.95);
251 }
252
253 .wp-adminify-update-modal-icon {
254 margin-bottom: 24px;
255 display: flex;
256 justify-content: center;
257 }
258
259 .wp-adminify-update-modal-icon-ring {
260 width: 64px;
261 height: 64px;
262 border-radius: 50%;
263 border: 2px solid var(--modal-accent);
264 display: flex;
265 align-items: center;
266 justify-content: center;
267 color: var(--modal-accent);
268 background: linear-gradient(135deg, rgba(80, 70, 229, 0.04) 0%, rgba(99, 102, 241, 0.08) 100%);
269 animation: wpAdminifyIconPulse 2s ease-in-out infinite;
270 }
271
272 @keyframes wpAdminifyIconPulse {
273 0%, 100% {
274 box-shadow: 0 0 0 0 rgba(80, 70, 229, 0.15);
275 }
276 50% {
277 box-shadow: 0 0 0 8px rgba(80, 70, 229, 0);
278 }
279 }
280
281 .wp-adminify-update-modal-title {
282 margin: 0 0 8px;
283 font-size: 22px;
284 font-weight: 600;
285 color: var(--modal-text);
286 letter-spacing: -0.02em;
287 line-height: 1.3;
288 }
289
290 .wp-adminify-update-modal-desc {
291 margin: 0 0 32px;
292 font-size: 15px;
293 color: var(--modal-text-muted);
294 line-height: 1.6;
295 }
296
297 .wp-adminify-update-modal-buttons {
298 display: flex;
299 flex-direction: row;
300 gap: 12px;
301 }
302
303 .wp-adminify-update-btn {
304 position: relative;
305 padding: 16px 24px;
306 border: none;
307 border-radius: 12px;
308 cursor: pointer;
309 font-size: 15px;
310 font-weight: 600;
311 letter-spacing: -0.01em;
312 transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
313 flex: 1;
314 overflow: hidden;
315 white-space: nowrap;
316 }
317
318 .wp-adminify-update-btn span {
319 position: relative;
320 z-index: 1;
321 }
322
323 .wp-adminify-update-btn-primary {
324 background: linear-gradient(135deg, var(--modal-accent-light) 0%, var(--modal-accent) 100%);
325 color: #fff;
326 }
327
328 .wp-adminify-update-btn-primary:hover {
329 background: linear-gradient(135deg, var(--modal-accent) 0%, #4338ca 100%);
330 }
331
332 .wp-adminify-update-btn-primary:active {
333 background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
334 }
335
336 .wp-adminify-update-btn-secondary {
337 background: #fef2f2;
338 color: #dc2626;
339 }
340
341 .wp-adminify-update-btn-secondary:hover {
342 background: #fee2e2;
343 color: #b91c1c;
344 }
345
346 .wp-adminify-update-btn-secondary:active {
347 background: #fecaca;
348 color: #991b1b;
349 }
350
351 /* Responsive adjustments */
352 @media (max-width: 520px) {
353 .wp-adminify-update-modal {
354 padding: 40px 28px 32px;
355 border-radius: 16px;
356 }
357 .wp-adminify-update-modal-title {
358 font-size: 20px;
359 }
360 .wp-adminify-update-modal-buttons {
361 flex-direction: column;
362 }
363 .wp-adminify-update-btn {
364 padding: 14px 20px;
365 flex: none;
366 width: 100%;
367 }
368 }
369 </style>
370
371 <script>
372 (function($) {
373 var $modal = $('#wp-adminify-update-notice-modal');
374 var $noticeContainer = null;
375
376 function pxlbsadminify_run_dismiss_ajax(action_type) {
377 $.post('<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', {
378 action: 'pxlbsadminify_plugin_update_info',
379 _wpnonce: '<?php echo esc_js( wp_create_nonce( 'dismiss_notice_nonce' ) ); ?>',
380 action_type: action_type
381 }).then(function(response) {
382 console.log(response);
383 });
384 }
385
386 function closeModal() {
387 $modal.css('display', 'none');
388 }
389
390 // Notice Dismiss - Show Modal
391 $(document).on('click', '.wp-adminify-notice-plugin-update-info .wp-adminify-notice-dismiss', function(evt) {
392 evt.preventDefault();
393 evt.stopImmediatePropagation();
394 $noticeContainer = $(this).closest('.wp-adminify-notice-plugin-update-info');
395 $modal.css('display', 'flex');
396 });
397
398 // "Yes" button - Dismiss temporarily
399 $(document).on('click', '#wp-adminify-notice-yes', function(evt) {
400 evt.preventDefault();
401 if ($noticeContainer) {
402 $noticeContainer.slideUp(200);
403 }
404 pxlbsadminify_run_dismiss_ajax('dismiss');
405 closeModal();
406 });
407
408 // "Don't show me again" button - Dismiss forever
409 $(document).on('click', '#wp-adminify-notice-forever', function(evt) {
410 evt.preventDefault();
411 if ($noticeContainer) {
412 $noticeContainer.slideUp(200);
413 }
414 pxlbsadminify_run_dismiss_ajax('forever');
415 closeModal();
416 });
417
418 // Close modal on X button click
419 $(document).on('click', '#wp-adminify-modal-close', function(evt) {
420 evt.preventDefault();
421 closeModal();
422 });
423
424 // Close modal on overlay click
425 $modal.on('click', function(evt) {
426 if (evt.target === this) {
427 closeModal();
428 }
429 });
430
431 // Close modal on Escape key
432 $(document).on('keydown', function(evt) {
433 if (evt.key === 'Escape' && $modal.is(':visible')) {
434 closeModal();
435 }
436 });
437 })(jQuery);
438 </script>
439
440 <?php
441 }
442
443 /**
444 * Intervals
445 *
446 * @author Jewel Theme <support@jeweltheme.com>
447 */
448 public function intervals()
449 {
450 return array(0);
451 }
452 }
453 }
454