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

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