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

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