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

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