PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.0
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.0
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / admin / class-wpfnl-banner.php

class-wpfnl-banner.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.0, at admin/class-wpfnl-banner.php

513 lines 17.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPFunnels\Admin\Banner;
4
5 /**
6 * SpecialOccasionBanner Class
7 *
8 * This class is responsible for displaying a special occasion banner in the WordPress admin.
9 *
10 * @package WPFunnels\Admin\Banner
11 */
12 class SpecialOccasionBanner
13 {
14
15 /**
16 * The occasion identifier.
17 *
18 * @var string
19 */
20 private $occasion;
21
22 /**
23 * The button link.
24 *
25 * @var string
26 */
27 private $btn_link;
28
29 /**
30 * The start date and time for displaying the banner.
31 *
32 * @var int
33 */
34 private $start_date;
35
36 /**
37 * The end date and time for displaying the banner.
38 *
39 * @var int
40 */
41 private $end_date;
42
43 /**
44 * Constructor method for SpecialOccasionBanner class.
45 *
46 * @param string $occasion The occasion identifier.
47 * @param string $start_date The start date and time for displaying the banner.
48 * @param string $end_date The end date and time for displaying the banner.
49 */
50 public function __construct($occasion, $start_date, $end_date, $btn_link = '#')
51 {
52 $this->occasion = $occasion;
53 $this->btn_link = $btn_link;
54 $this->start_date = strtotime($start_date);
55 $this->end_date = strtotime($end_date);
56
57 if ('yes' === get_option('_is_show_us_banner', 'yes')) {
58 // Hook into the admin_notices action to display the banner
59 add_action('admin_notices', [$this, 'display_banner']);
60 add_action('admin_head', array($this, 'add_styles'));
61 }
62 }
63
64 /**
65 * Calculate time remaining until Halloween
66 *
67 * @return array Time remaining in days, hours, and minutes
68 */
69 public function wpf_get_promotion_banner_countdown()
70 {
71 $end_date = strtotime('2026-07-07 23:59:59');
72 $now = current_time('timestamp');
73 $diff = $end_date - $now;
74
75 return array(
76 'days' => floor($diff / (60 * 60 * 24)),
77 'hours' => floor(($diff % (60 * 60 * 24)) / (60 * 60)),
78 'mins' => floor(($diff % (60 * 60)) / 60),
79 'secs' => $diff % 60,
80 );
81 }
82
83 /**
84 * Displays the special occasion banner if the current date and time are within the specified range.
85 */
86 public function display_banner()
87 {
88 $screen = get_current_screen();
89 $promotional_notice_pages = ['dashboard', 'plugins', 'wpfunnels_page_store_checkout','wpfunnels_page_wp_funnels', 'wpfunnels_page_wpfunnels_integrations', 'wpfunnels_page_wpfnl_automations', 'wpfunnels_page_edit_funnel', 'wpfunnels_page_wpfnl_settings'];
90 $current_date_time = current_time('timestamp');
91
92 if (!in_array($screen->id, $promotional_notice_pages)) {
93 return;
94 }
95
96 if ($current_date_time < $this->start_date || $current_date_time > $this->end_date) {
97 return;
98 }
99
100 // Calculate the time remaining in seconds
101 $time_remaining = $this->end_date - $current_date_time;
102
103 $countdown = $this->wpf_get_promotion_banner_countdown();
104 ?>
105 <div class="gwpf-promotional-notice <?php echo esc_attr($this->occasion); ?>-banner notice">
106 <div class="gwpf-tb__notification">
107 <div class="banner-overflow">
108 <section class="gwpf-promotional-banner" aria-labelledby="US independence day offer">
109 <div class="gwpf-container">
110 <div class="promotional-banner">
111 <div class="banner-content">
112 <div class="banner-logo-area">
113 <span class="us-flag">
114 <img src="<?php echo WPFNL_DIR_URL . 'admin/assets/images/us-flag.webp'; ?>" alt="us-flag" width="117" height="70">
115 </span>
116 <span class="discount-text">
117 <small><?php echo __('Happy 4th Of July!', 'wpfunnels'); ?></small>
118 <?php echo __('Get 30% Off', 'wpfunnels'); ?>
119 </span>
120 </div>
121
122 <div class="countdown-timer" id="wpf-promo-countdown">
123 <div class="countdown-item">
124 <span id="wpf-promo-days"><?php echo esc_html(str_pad($countdown['days'], 2, '0', STR_PAD_LEFT)); ?></span>
125 <small><?php echo __('DAY', 'wpfunnels'); ?></small>
126 </div>
127 <div class="countdown-item">
128 <span id="wpf-promo-hours"><?php echo esc_html(str_pad($countdown['hours'], 2, '0', STR_PAD_LEFT)); ?></span>
129 <small><?php echo __('HR', 'wpfunnels'); ?></small>
130 </div>
131 <div class="countdown-item">
132 <span id="wpf-promo-mins"><?php echo esc_html(str_pad($countdown['mins'], 2, '0', STR_PAD_LEFT)); ?></span>
133 <small><?php echo __('MIN', 'wpfunnels'); ?></small>
134 </div>
135 <div class="countdown-item">
136 <span id="wpf-promo-secs"><?php echo esc_html(str_pad($countdown['secs'], 2, '0', STR_PAD_LEFT)); ?></span>
137 <small><?php echo __('SEC', 'wpfunnels'); ?></small>
138 </div>
139 </div>
140
141 <a href="<?php echo esc_url($this->btn_link); ?>" class="cta-button" role="button" aria-label="claim your deal" target="_blank">
142 <?php
143 echo __('Claim Your Deal', 'wpfunnels');
144 ?>
145 <svg xmlns="http://www.w3.org/2000/svg" width="8" height="9" viewBox="0 0 8 9" fill="none"><path d="M8 0.703124V8.29686C8 8.48334 7.93415 8.66218 7.81694 8.79405C7.69973 8.92591 7.54076 8.99999 7.375 8.99999C7.20924 8.99999 7.05027 8.92591 6.93306 8.79405C6.81585 8.66218 6.75 8.48334 6.75 8.29686V2.40061L1.06695 8.79406C0.949738 8.92592 0.790765 9 0.625004 9C0.459243 9 0.30027 8.92592 0.183059 8.79406C0.0658485 8.6622 0 8.48335 0 8.29687C0 8.11039 0.0658485 7.93155 0.183059 7.79968L5.86613 1.40625H0.625012C0.459252 1.40625 0.300281 1.33217 0.183071 1.20031C0.0658608 1.06845 1.28672e-05 0.889604 1.28672e-05 0.703124C1.28672e-05 0.516644 0.0658608 0.337802 0.183071 0.20594C0.300281 0.0740789 0.459252 0 0.625012 0L7.375 0C7.54076 0 7.69973 0.0740789 7.81694 0.20594C7.93415 0.337802 8 0.516644 8 0.703124Z" fill="#fff"/></svg>
146 </a>
147 </div>
148 </div>
149 </div>
150 </section>
151 </div>
152
153 <button class="close-promotional-banner" type="button" aria-label="close banner">
154 <svg width="12" height="13" fill="none" viewBox="0 0 12 13" xmlns="http://www.w3.org/2000/svg"><path stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 1.97L1 11.96m0-9.99l10 9.99"/></svg>
155 </button>
156 </div>
157 </div>
158 <!-- .gwpf-tb-notification end -->
159
160 <script>
161 (function() {
162 var countdownInterval;
163
164 function pad(num) {
165 return String(num).padStart(2, '0');
166 }
167
168 function updateCountdown() {
169 var endDate = new Date("2026-07-07 23:59:59").getTime();
170 var now = new Date().getTime();
171 var timeLeft = endDate - now;
172
173 if (timeLeft <= 0) {
174 clearInterval(countdownInterval);
175
176 var banner = document.querySelector('.gwpf-promotional-notice');
177 if (banner) {
178 banner.style.display = 'none';
179 }
180
181 return;
182 }
183
184 var days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
185 var hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
186 var minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
187 var seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);
188
189 var daysElement = document.getElementById('wpf-promo-days');
190 var hoursElement = document.getElementById('wpf-promo-hours');
191 var minsElement = document.getElementById('wpf-promo-mins');
192 var secsElement = document.getElementById('wpf-promo-secs');
193
194 if (daysElement) {
195 daysElement.innerHTML = pad(days);
196 }
197
198 if (hoursElement) {
199 hoursElement.innerHTML = pad(hours);
200 }
201
202 if (minsElement) {
203 minsElement.innerHTML = pad(minutes);
204 }
205 if (secsElement) {
206 secsElement.innerHTML = pad(seconds);
207 }
208 }
209
210 document.addEventListener('DOMContentLoaded', function() {
211 updateCountdown();
212 countdownInterval = setInterval(updateCountdown, 1000);
213 });
214 })();
215 </script>
216 <?php
217 }
218
219 /**
220 * Adds internal CSS styles for the special occasion banners.
221 */
222 public function add_styles() {
223 ?>
224 <style type="text/css">
225 .gwpf-tb__notification,
226 .gwpf-tb__notification * {
227 box-sizing: border-box;
228 }
229
230 .gwpf-promotional-notice.notice {
231 display: block;
232 background: none;
233 border: none;
234 box-shadow: none;
235 padding: 0;
236 margin: 0;
237 }
238
239 .gwpf-tb__notification {
240 width: calc(100% - 20px);
241 margin: 20px 0 20px;
242 background-repeat: no-repeat;
243 background-size: cover;
244 position: relative;
245 border: none;
246 box-shadow: none;
247 display: block;
248 max-height: 110px;
249 }
250
251 .wpfunnels_page_wpfnl_settings .gwpf-tb__notification,
252 .wpfunnels_page_wp_funnels .gwpf-tb__notification {
253 width: calc(100% - 40px);
254 margin: 20px 0 20px 20px;
255 }
256
257 .gwpf-tb__notification .banner-overflow {
258 position: relative;
259 width: 100%;
260 z-index: 1;
261 }
262
263 /* ---banner style start--- */
264 .gwpf-promotional-banner {
265 position: relative;
266 z-index: 1111;
267 padding: 0;
268 /* padding: 6px 0; */
269 background: #7D4CEF;
270 box-shadow: 0 1px 1px 0 rgba(32, 28, 254, 0.10);
271 }
272 .gwpf-promotional-banner .promotional-banner {
273 /* padding: 12px 20px; */
274 padding-top: 1px;
275 text-align: center;
276 font-size: 14px;
277 line-height: 1.4;
278 position: relative;
279 height: 70px;
280 }
281 .gwpf-promotional-banner .banner-content {
282 max-width: 1200px;
283 margin: 0 auto;
284 display: inline-flex;
285 align-items: center;
286 justify-content: center;
287 flex-wrap: wrap;
288 gap: 70px;
289 row-gap: 8px;
290 position: relative;
291 }
292 .gwpf-promotional-banner .banner-logo-area {
293 display: flex;
294 align-items: center;
295 gap: 17px;
296 }
297
298 .gwpf-promotional-banner .banner-logo-area img {
299 display: block;
300 position: relative;
301 top: -1px;
302 }
303
304 .gwpf-promotional-banner .discount-text {
305 color: #FFF;
306 font-family: 'Inter', sans-serif;
307 font-size: 24px;
308 font-weight: 700;
309 line-height: 1.2;
310 letter-spacing: -0.084px;
311 display: flex;
312 flex-flow: column;
313 align-items: flex-start;
314 gap: 7px;
315
316 }
317
318 .gwpf-promotional-banner .discount-text small {
319 color: #FFF;
320 font-family: 'Inter', sans-serif;
321 font-size: 16px;
322 font-weight: 500;
323 line-height: 1;
324 letter-spacing: -0.32px;
325 }
326 .gwpf-promotional-banner .banner-text {
327 display: flex;
328 align-items: center;
329 flex-wrap: wrap;
330 gap: 6px;
331 row-gap: 0;
332 justify-content: center;
333 font-size: 15px;
334 color: #100627;
335 font-weight: 400;
336 line-height: 1.4;
337 text-transform: capitalize;
338 letter-spacing: 0;
339 }
340 .gwpf-promotional-banner .banner-text svg {
341 display: block;
342 }
343 .gwpf-promotional-banner .banner-text .highlighted-text {
344 color: #ee8134;
345 font-weight: 700;
346 }
347
348 .gwpf-promotional-banner .countdown-timer {
349 display: flex;
350 align-items: center;
351 gap: 2px;
352 }
353 .gwpf-promotional-banner .countdown-item {
354 display: flex;
355 flex-direction: column;
356 align-items: center;
357 justify-content: center;
358 gap: 4px;
359 min-width: 50px;
360 height: 50px;
361 padding: 4px 6px;
362 color: #fff;
363 line-height: 1.2;
364 border: 1px solid #8555f5;
365 background: rgba(54, 30, 107, 0.40);
366
367 }
368
369 .gwpf-promotional-banner .countdown-item:first-child {
370 border-radius: 4px 0 0 4px;
371 }
372
373 .gwpf-promotional-banner .countdown-item:last-child {
374 border-radius: 0 4px 4px 0;
375 }
376
377 .gwpf-promotional-banner .countdown-item span {
378 font-size: 20px;
379 font-weight: 600;
380 line-height: 1;
381 font-family: 'Inter', sans-serif;
382 }
383 .gwpf-promotional-banner .countdown-item small {
384 text-transform: uppercase;
385 color: rgba(255, 255, 255, 0.80);
386 text-align: center;
387 font-family: Inter;
388 font-size: 12px;
389 font-weight: 400;
390 line-height: 1;
391 letter-spacing: 0.24px;
392 }
393 .gwpf-promotional-banner .cta-button {
394 color: #fff;
395 font-size: 15px;
396 font-style: normal;
397 font-weight: 600;
398 line-height: 1;
399 text-decoration: none;
400 display: inline-flex;
401 align-items: center;
402 gap: 5px;
403 transition: all 0.2s ease;
404 background: #F7941D;
405 border-radius: 6px;
406 padding: 12px 15px;
407 font-family: 'Inter', sans-serif;
408 }
409 .gwpf-promotional-banner .cta-button svg {
410 transition: transform 0.3s ease;
411 }
412
413 /* .gwpf-promotional-banner .cta-button:focus,
414 .gwpf-promotional-banner .cta-button:visited {
415 color: #3C1F7D !important;
416 }
417 .gwpf-promotional-banner .cta-button:hover {
418 color: #3C1F7D !important;
419 }
420 .gwpf-promotional-banner .cta-button:hover svg path {
421 stroke: #3C1F7D;
422 fill: #3C1F7D;
423 } */
424
425 .gwpf-promotional-banner .cta-button:hover {
426 text-decoration: none;
427 color: #fff;
428 }
429 .gwpf-promotional-banner .cta-button:hover svg {
430 transform: translateX(3px);
431 }
432
433
434 .gwpf-tb__notification .close-promotional-banner {
435 position: absolute;
436 top: 50%;
437 right: 10px;
438 transform: translateY(-50%);
439 background: transparent;
440 border: none;
441 padding: 0;
442 border-radius:0;
443 cursor: pointer;
444 z-index: 9;
445 width: 30px;
446 height: 30px;
447 display: flex;
448 align-items: center;
449 justify-content: center;
450 }
451
452 .gwpf-tb__notification .close-promotional-banner svg {
453 width: 11px;
454 height: 11px;
455 display: block;
456 }
457
458 @media only screen and (max-width: 1199px) {
459 .gwpf-promotional-banner .banner-content {
460 gap: 40px;
461 row-gap: 8px;
462 }
463 }
464
465 @media only screen and (max-width: 991px) {
466 .promotional-banner {
467 padding: 16px 20px;
468 }
469
470 .gwpf-tb__notification {
471 margin: 60px 0 20px;
472 }
473
474 .gwpf-tb__notification .close-promotional-banner {
475 width: 25px;
476 height: 25px;
477 }
478 }
479
480 @media only screen and (max-width: 767px) {
481 .wpvr-promotional-banner {
482 padding-top: 20px;
483 padding-bottom: 30px;
484 max-height: none;
485 }
486
487 .wpvr-promotional-banner {
488 max-height: none;
489 }
490 }
491
492 @media only screen and (max-width: 575px) {
493 .promotional-banner {
494 padding: 16px 55px;
495 font-size: 13px;
496 }
497 .gwpf-promotional-banner .halloween-bird-left {
498 left: -12px;
499 bottom: inherit;
500 top: -5px;
501 }
502 .gwpf-promotional-banner .halloween-bird-right {
503 right: -12px;
504 bottom: -7px;
505 top: inherit;
506 }
507 }
508 </style>
509 <?php
510 }
511
512 }
513