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

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