PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.5
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.5
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.5, at Inc/Classes/Notifications/Latest_Updates.php

463 lines 14.9 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_items =
90 __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Fixed:</strong> Resolved an admin UI layout display issue. </span><br>', 'adminify')
91 . __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Improved:</strong> Compatibility with WordPress 7.0 and the updated block editor. </span><br>', 'adminify')
92 . __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Fixed:</strong> Dark mode now saves correctly and applies consistently across the admin area and the block editor. </span><br>', 'adminify')
93 . __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Added:</strong> Adminify admin bar shortcut now opens the WordPress command palette. </span><br>', 'adminify')
94 . __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Improved:</strong> Editor spacing and frame edges in the Adminify admin interface. </span><br>', 'adminify')
95 . __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Improved:</strong> FluentCRM toolbar alignment inside the Adminify admin interface. </span><br>', 'adminify')
96 . __('<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> <strong>Fixed:</strong> Plugin dependency activation notice now displays correctly. </span><br>', 'adminify');
97
98 $pxlbsadminify_changelog_message = sprintf(
99 /* translators: %1$s: changelogs page URL. %2$s: link anchor text. %3$s: plugin update heading HTML. %4$s: changelog list items HTML. */
100 __('%3$s %4$s <br> <strong>Check Changelogs for </strong> <a href="%1$s" target="__blank">%2$s</a>', 'adminify'),
101 esc_url_raw('https://wpadminify.com/changelogs'),
102 __('More about Updates ', 'adminify'),
103 /** Changelog Items
104 * Starts from: %3$s
105 */
106
107 '<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
108 // changelogs
109 $pxlbsadminify_changelog_items
110 );
111 printf(wp_kses_post($pxlbsadminify_changelog_message));
112 }
113
114 $this->pxlbsadminify_handle_plugin_update_notice_dismiss();
115 }
116
117 /**
118 * Notice Header
119 *
120 * @author Jewel Theme <support@jeweltheme.com>
121 */
122 public function notice_header() {
123 if ( ! $this->is_adminify_settings_page() ) {
124 echo '<div class="wp-adminify-notice-hidden" style="display:none;"><div>';
125 return;
126 }
127
128 $notice_status = get_option('pxlbsadminify_plugin_update_info_notice', true );
129 if ( 'forever' === $notice_status ) {
130 echo '<div class="wp-adminify-notice-hidden" style="display:none;"><div>';
131 return;
132 }
133
134 if("dismissed" !== $notice_status){
135 $border_colors = array(
136 'info' => '#72aee6',
137 'success' => '#00a32a',
138 'warning' => '#dba617',
139 'error' => '#d63638',
140 );
141 $border_color = isset( $border_colors[ $this->color ] ) ? $border_colors[ $this->color ] : $border_colors['info'];
142 ?>
143 <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;">
144 <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;">
145 <span class="dashicons dashicons-no-alt"></span>
146 </button>
147 <div class="wp-adminify-notice-content">
148 <?php
149 }else{ echo '<div class="wp-adminify-notice-hidden" style="display:none;"><div>';}
150 }
151
152 public function pxlbsadminify_handle_plugin_update_notice_dismiss() { ?>
153
154 <!-- Update Notice Confirmation Modal -->
155 <div id="wp-adminify-update-notice-modal" class="wp-adminify-update-modal-overlay">
156 <div class="wp-adminify-update-modal">
157 <button type="button" class="wp-adminify-update-modal-close" id="wp-adminify-modal-close">
158 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
159 <path d="M13 1L1 13M1 1L13 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
160 </svg>
161 </button>
162 <div class="wp-adminify-update-modal-icon">
163 <div class="wp-adminify-update-modal-icon-ring">
164 <svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
165 <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"/>
166 </svg>
167 </div>
168 </div>
169 <h3 class="wp-adminify-update-modal-title"><?php echo esc_html__('Want to see future updates?', 'adminify'); ?></h3>
170 <p class="wp-adminify-update-modal-desc"><?php echo esc_html__('Stay informed about new features and improvements.', 'adminify'); ?></p>
171 <div class="wp-adminify-update-modal-buttons">
172 <button type="button" id="wp-adminify-notice-yes" class="wp-adminify-update-btn wp-adminify-update-btn-primary">
173 <span><?php echo esc_html__('Yes, notify me', 'adminify'); ?></span>
174 </button>
175 <button type="button" id="wp-adminify-notice-forever" class="wp-adminify-update-btn wp-adminify-update-btn-secondary">
176 <span><?php echo esc_html__("Don't show again", 'adminify'); ?></span>
177 </button>
178 </div>
179 </div>
180 </div>
181
182 <style>
183 .wp-adminify-update-modal-overlay {
184 --modal-accent: #5046e5;
185 --modal-accent-light: #6366f1;
186 --modal-accent-glow: rgba(80, 70, 229, 0.35);
187 --modal-text: #1e293b;
188 --modal-text-muted: #64748b;
189 --modal-bg: #ffffff;
190 --modal-border: #e2e8f0;
191 --modal-danger: #ef4444;
192
193 display: none;
194 position: fixed;
195 top: 0;
196 left: 0;
197 width: 100%;
198 height: 100%;
199 background: rgba(15, 23, 42, 0.5);
200 backdrop-filter: blur(8px);
201 -webkit-backdrop-filter: blur(8px);
202 z-index: 999999;
203 align-items: center;
204 justify-content: center;
205 }
206
207 .wp-adminify-update-modal {
208 background: var(--modal-bg);
209 padding: 48px 44px 44px;
210 border-radius: 20px;
211 max-width: 460px;
212 width: calc(100% - 32px);
213 text-align: center;
214 box-shadow:
215 0 0 0 1px rgba(0, 0, 0, 0.03),
216 0 2px 4px rgba(0, 0, 0, 0.02),
217 0 12px 24px rgba(0, 0, 0, 0.06),
218 0 32px 64px rgba(0, 0, 0, 0.12);
219 position: relative;
220 animation: wpAdminifyModalAppear 0.35s cubic-bezier(0.16, 1, 0.3, 1);
221 }
222
223 @keyframes wpAdminifyModalAppear {
224 from {
225 opacity: 0;
226 transform: scale(0.92) translateY(8px);
227 }
228 to {
229 opacity: 1;
230 transform: scale(1) translateY(0);
231 }
232 }
233
234 .wp-adminify-update-modal-close {
235 position: absolute;
236 top: 18px;
237 right: 18px;
238 width: 36px;
239 height: 36px;
240 border: none;
241 background: transparent;
242 color: var(--modal-danger);
243 cursor: pointer;
244 display: flex;
245 align-items: center;
246 justify-content: center;
247 border-radius: 10px;
248 transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
249 opacity: 0.7;
250 }
251
252 .wp-adminify-update-modal-close:hover {
253 background: #fef2f2;
254 opacity: 1;
255 transform: scale(1.05);
256 }
257
258 .wp-adminify-update-modal-close:active {
259 transform: scale(0.95);
260 }
261
262 .wp-adminify-update-modal-icon {
263 margin-bottom: 24px;
264 display: flex;
265 justify-content: center;
266 }
267
268 .wp-adminify-update-modal-icon-ring {
269 width: 64px;
270 height: 64px;
271 border-radius: 50%;
272 border: 2px solid var(--modal-accent);
273 display: flex;
274 align-items: center;
275 justify-content: center;
276 color: var(--modal-accent);
277 background: linear-gradient(135deg, rgba(80, 70, 229, 0.04) 0%, rgba(99, 102, 241, 0.08) 100%);
278 animation: wpAdminifyIconPulse 2s ease-in-out infinite;
279 }
280
281 @keyframes wpAdminifyIconPulse {
282 0%, 100% {
283 box-shadow: 0 0 0 0 rgba(80, 70, 229, 0.15);
284 }
285 50% {
286 box-shadow: 0 0 0 8px rgba(80, 70, 229, 0);
287 }
288 }
289
290 .wp-adminify-update-modal-title {
291 margin: 0 0 8px;
292 font-size: 22px;
293 font-weight: 600;
294 color: var(--modal-text);
295 letter-spacing: -0.02em;
296 line-height: 1.3;
297 }
298
299 .wp-adminify-update-modal-desc {
300 margin: 0 0 32px;
301 font-size: 15px;
302 color: var(--modal-text-muted);
303 line-height: 1.6;
304 }
305
306 .wp-adminify-update-modal-buttons {
307 display: flex;
308 flex-direction: row;
309 gap: 12px;
310 }
311
312 .wp-adminify-update-btn {
313 position: relative;
314 padding: 16px 24px;
315 border: none;
316 border-radius: 12px;
317 cursor: pointer;
318 font-size: 15px;
319 font-weight: 600;
320 letter-spacing: -0.01em;
321 transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
322 flex: 1;
323 overflow: hidden;
324 white-space: nowrap;
325 }
326
327 .wp-adminify-update-btn span {
328 position: relative;
329 z-index: 1;
330 }
331
332 .wp-adminify-update-btn-primary {
333 background: linear-gradient(135deg, var(--modal-accent-light) 0%, var(--modal-accent) 100%);
334 color: #fff;
335 }
336
337 .wp-adminify-update-btn-primary:hover {
338 background: linear-gradient(135deg, var(--modal-accent) 0%, #4338ca 100%);
339 }
340
341 .wp-adminify-update-btn-primary:active {
342 background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
343 }
344
345 .wp-adminify-update-btn-secondary {
346 background: #fef2f2;
347 color: #dc2626;
348 }
349
350 .wp-adminify-update-btn-secondary:hover {
351 background: #fee2e2;
352 color: #b91c1c;
353 }
354
355 .wp-adminify-update-btn-secondary:active {
356 background: #fecaca;
357 color: #991b1b;
358 }
359
360 /* Responsive adjustments */
361 @media (max-width: 520px) {
362 .wp-adminify-update-modal {
363 padding: 40px 28px 32px;
364 border-radius: 16px;
365 }
366 .wp-adminify-update-modal-title {
367 font-size: 20px;
368 }
369 .wp-adminify-update-modal-buttons {
370 flex-direction: column;
371 }
372 .wp-adminify-update-btn {
373 padding: 14px 20px;
374 flex: none;
375 width: 100%;
376 }
377 }
378 </style>
379
380 <script>
381 (function($) {
382 var $modal = $('#wp-adminify-update-notice-modal');
383 var $noticeContainer = null;
384
385 function pxlbsadminify_run_dismiss_ajax(action_type) {
386 $.post('<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', {
387 action: 'pxlbsadminify_plugin_update_info',
388 _wpnonce: '<?php echo esc_js( wp_create_nonce( 'dismiss_notice_nonce' ) ); ?>',
389 action_type: action_type
390 }).then(function(response) {
391 console.log(response);
392 });
393 }
394
395 function closeModal() {
396 $modal.css('display', 'none');
397 }
398
399 // Notice Dismiss - Show Modal
400 $(document).on('click', '.wp-adminify-notice-plugin-update-info .wp-adminify-notice-dismiss', function(evt) {
401 evt.preventDefault();
402 evt.stopImmediatePropagation();
403 $noticeContainer = $(this).closest('.wp-adminify-notice-plugin-update-info');
404 $modal.css('display', 'flex');
405 });
406
407 // "Yes" button - Dismiss temporarily
408 $(document).on('click', '#wp-adminify-notice-yes', function(evt) {
409 evt.preventDefault();
410 if ($noticeContainer) {
411 $noticeContainer.slideUp(200);
412 }
413 pxlbsadminify_run_dismiss_ajax('dismiss');
414 closeModal();
415 });
416
417 // "Don't show me again" button - Dismiss forever
418 $(document).on('click', '#wp-adminify-notice-forever', function(evt) {
419 evt.preventDefault();
420 if ($noticeContainer) {
421 $noticeContainer.slideUp(200);
422 }
423 pxlbsadminify_run_dismiss_ajax('forever');
424 closeModal();
425 });
426
427 // Close modal on X button click
428 $(document).on('click', '#wp-adminify-modal-close', function(evt) {
429 evt.preventDefault();
430 closeModal();
431 });
432
433 // Close modal on overlay click
434 $modal.on('click', function(evt) {
435 if (evt.target === this) {
436 closeModal();
437 }
438 });
439
440 // Close modal on Escape key
441 $(document).on('keydown', function(evt) {
442 if (evt.key === 'Escape' && $modal.is(':visible')) {
443 closeModal();
444 }
445 });
446 })(jQuery);
447 </script>
448
449 <?php
450 }
451
452 /**
453 * Intervals
454 *
455 * @author Jewel Theme <support@jeweltheme.com>
456 */
457 public function intervals()
458 {
459 return array(0);
460 }
461 }
462 }
463