PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 2.8.16
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v2.8.16
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 2.8.16, at admin/class-wpfnl-banner.php

496 lines 17.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WPFunnels\Admin\Banner;
3
4 /**
5 * SpecialOccasionBanner Class
6 *
7 * This class is responsible for displaying a special occasion banner in the WordPress admin.
8 *
9 * @package WPFunnels\Admin\Banner
10 */
11 class SpecialOccasionBanner {
12
13 /**
14 * The occasion identifier.
15 *
16 * @var string
17 */
18 private $occasion;
19
20 /**
21 * The button link.
22 *
23 * @var string
24 */
25 private $btn_link;
26
27 /**
28 * The start date and time for displaying the banner.
29 *
30 * @var int
31 */
32 private $start_date;
33
34 /**
35 * The end date and time for displaying the banner.
36 *
37 * @var int
38 */
39 private $end_date;
40
41 /**
42 * Constructor method for SpecialOccasionBanner class.
43 *
44 * @param string $occasion The occasion identifier.
45 * @param string $start_date The start date and time for displaying the banner.
46 * @param string $end_date The end date and time for displaying the banner.
47 */
48 public function __construct($occasion, $start_date, $end_date, $btn_link = '#' ) {
49 $this->occasion = $occasion;
50 $this->btn_link = $btn_link;
51 $this->start_date = strtotime($start_date);
52 $this->end_date = strtotime($end_date);
53
54 if ( !defined('WPFNL_PRO_VERSION') && 'yes' === get_option( '_is_wpfnl_black_friday_promotion', 'yes' )) {
55
56 // Hook into the admin_notices action to display the banner
57 add_action('admin_notices', [$this, 'display_banner']);
58
59 // Add styles
60 add_action('admin_head', array($this, 'add_styles'));
61 }
62
63
64 }
65
66
67 /**
68 * Displays the special occasion banner if the current date and time are within the specified range.
69 */
70 public function display_banner() {
71 $screen = get_current_screen();
72 $promotional_notice_pages = ['dashboard', 'plugins', 'toplevel_page_wp_funnels', 'wp-funnels_page_wpfnl_settings'];
73 $current_date_time = current_time('timestamp');
74
75 if (!in_array($screen->id, $promotional_notice_pages)) {
76 return;
77 }
78
79 if ( $current_date_time < $this->start_date || $current_date_time > $this->end_date ) {
80 return;
81 }
82 // Calculate the time remaining in seconds
83 $time_remaining = $this->end_date - $current_date_time;
84
85 ?>
86 <div class="<?php echo esc_attr($this->occasion); ?>-banner notice">
87 <div class="wpfnl-promotional-banner">
88 <div class="banner-overflow">
89
90 <div class="wpfnl-promotional-banner-wrapper">
91 <figure class="promotional-logo">
92 <img src="<?php echo esc_url( WPFNL_URL.'admin/assets/images/blackfriday-logo.webp' ); ?>" alt="black friday logo" />
93 </figure>
94
95 <div class="promotional-content">
96 <h4>
97 Super Sale <span>Is Live!</span>
98 </h4>
99 </div>
100
101 <div class="promotional-discount">
102 <figure>
103 <img src="<?php echo esc_url( WPFNL_URL.'admin/assets/images/blackfriday-discount-percent.webp' ); ?>" alt="black friday 35% off" />
104 </figure>
105 </div>
106
107 <div class="promotional-counter">
108 <ul class="countdown" id="wpfnl_countdown">
109 <li><span id="wpfnl_days">00</span> days</li>
110 <li><span id="wpfnl_hours">00</span> hours</li>
111 <li><span id="wpfnl_minutes">00</span> mins</li>
112 <!-- <li><span id="seconds">59</span> seconds</li> -->
113 </ul>
114 </div>
115
116 <div class="get-plugin-btn">
117 <a href="<?php echo esc_url($this->btn_link); ?>" target="_blank">
118 Flat <span>35%</span> OFF
119 </a>
120 </div>
121 </div>
122 </div>
123
124 <button class="close-promotional-banner" type="button" aria-label="close banner">
125 <svg width="12" height="13" fill="none" viewBox="0 0 12 13" xmlns="http://www.w3.org/2000/svg"><path stroke="#7A8B9A" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 1.97L1 11.96m0-9.99l10 9.99"/></svg>
126 </button>
127 </div>
128 </div>
129
130 <script>
131 var timeRemaining = <?php echo esc_js($time_remaining); ?>;
132
133 // Update the countdown every second
134 setInterval(function() {
135 var countdownElement = document.getElementById('wpfnl_countdown');
136 var daysElement = document.getElementById('wpfnl_days');
137 var hoursElement = document.getElementById('wpfnl_hours');
138 var minutesElement = document.getElementById('wpfnl_minutes');
139
140 // Decrease the remaining time
141 timeRemaining--;
142
143 // Calculate new days, hours, and minutes
144 var days = Math.floor(timeRemaining / (60 * 60 * 24));
145 var hours = Math.floor((timeRemaining % (60 * 60 * 24)) / (60 * 60));
146 var minutes = Math.floor((timeRemaining % (60 * 60)) / 60);
147
148
149 // Format values with leading zeros
150 days = (days < 10) ? '0' + days : days;
151 hours = (hours < 10) ? '0' + hours : hours;
152 minutes = (minutes < 10) ? '0' + minutes : minutes;
153
154 // Update the HTML
155 daysElement.textContent = days;
156 hoursElement.textContent = hours;
157 minutesElement.textContent = minutes;
158
159 // Check if the countdown has ended
160 if (timeRemaining <= 0) {
161 countdownElement.innerHTML = 'Campaign Ended';
162 }
163 }, 1000); // Update every second
164 </script>
165 <?php
166 }
167
168 /**
169 * Adds internal CSS styles for the special occasion banners.
170 */
171 public function add_styles() {
172 ?>
173 <style type="text/css">
174 @font-face {
175 font-family: "Circular Std Bold";
176 src: url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/circularstd-bold.woff2'; ?>) format("woff2"),
177 url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/circularstd-bold.woff'; ?>) format("woff");
178 font-weight: 700;
179 font-style: normal;
180 font-display: swap;
181 }
182
183 @font-face {
184 font-family: "Circular Std Book";
185 src: url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/CircularStd-Book.woff2'; ?>) format("woff2"),
186 url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/CircularStd-Book.woff'; ?>) format("woff");
187 font-weight: normal;
188 font-style: normal;
189 font-display: swap;
190 }
191
192 @font-face {
193 font-family: "Inter";
194 src: url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/Inter-Bold.woff2'; ?>) format("woff2"),
195 url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/Inter-Bold.woff'; ?>) format("woff");
196 font-weight: 700;
197 font-style: normal;
198 font-display: swap;
199 }
200
201 @font-face {
202 font-family: 'Lexend Deca';
203 src: url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/LexendDeca-SemiBold.woff2'; ?>) format("woff2"),
204 url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/LexendDeca-SemiBold.woff'; ?>) format("woff");
205 font-weight: 600;
206 font-style: normal;
207 font-display: swap;
208 }
209
210 @font-face {
211 font-family: 'Lexend Deca';
212 src: url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/LexendDeca-Bold.woff2'; ?>) format("woff2"),
213 url(<?php echo plugin_dir_url(__FILE__).'assets/fonts/LexendDeca-Bold.woff'; ?>) format("woff");
214 font-weight: 700;
215 font-style: normal;
216 font-display: swap;
217 }
218
219 .wpfnl-promotional-banner,
220 .wpfnl-promotional-banner * {
221 box-sizing: border-box;
222 }
223
224 .wp-funnels_page_wpfnl_settings .wpfnl-promotional-banner,
225 .toplevel_page_wp_funnels .wpfnl-promotional-banner {
226 margin: 20px 0;
227 width: calc(100% - 20px);
228 }
229
230 .wp-funnels_page_wpfnl_settings .black-friday-banner.notice,
231 .toplevel_page_wp_funnels .black-friday-banner.notice {
232 margin: 0;
233 }
234
235 .black-friday-banner.notice {
236 border: none;
237 padding: 0;
238 display: block;
239 background: transparent;
240 }
241
242 .wpfnl-promotional-banner {
243 background-color: #100E1A;
244 width: 100%;
245 background-image: url(<?php echo WPFNL_URL.'admin/assets/images/blckfriday-23-bg.webp'; ?>);
246 background-position: center;
247 background-repeat: no-repeat;
248 background-size: 100% 100%;
249 position: relative;
250 border: none;
251 padding: 9px 0;
252 box-shadow: none;
253 display: block;
254 }
255
256 .wpfnl-promotional-banner .banner-overflow {
257 overflow: hidden;
258 position: relative;
259 width: 100%;
260 }
261
262 .wpfnl-promotional-banner figure {
263 margin: 0;
264 }
265
266 .wpfnl-promotional-banner-wrapper {
267 display: flex;
268 flex-flow: row wrap;
269 align-items: center;
270 justify-content: space-between;
271 gap: 30px;
272 max-width: 1400px;
273 margin: 0 auto;
274 padding: 0 15px;
275 z-index: 1;
276 position: relative;
277 height: 100%;
278 }
279
280 .wpfnl-promotional-banner-wrapper .promotional-content {
281 max-width: 420px;
282 }
283
284 .wpfnl-promotional-banner-wrapper .promotional-logo img {
285 max-width: 230px;
286 position: relative;
287 top: 3px;
288 }
289
290 .wpfnl-promotional-banner-wrapper .promotional-content h4 {
291 margin: 0;
292 text-transform: none;
293 color: #ED8136;
294 font-family: 'Lexend Deca';
295 font-size: 30px;
296 font-style: normal;
297 font-weight: 700;
298 line-height: 1.37;
299 }
300
301 .wpfnl-promotional-banner-wrapper .promotional-content h4 span {
302 display: block;
303 color: #BEB4F4;
304 font-family: 'Lexend Deca';
305 font-size: 24px;
306 font-style: normal;
307 font-weight: 600;
308 line-height: 1.1;
309 letter-spacing: 1.68px;
310 text-transform: uppercase;
311 }
312
313 .promotional-discount {
314 position: relative;
315 top: 3px;
316 }
317
318 .wpfnl-promotional-banner-wrapper .countdown {
319 position: relative;
320 top: 3px;
321 }
322 .wpfnl-promotional-banner-wrapper .countdown {
323 display: flex;
324 justify-content: center;
325 gap: 20px;
326 margin: 0;
327 padding: 0;
328 }
329
330 .wpfnl-promotional-banner-wrapper .countdown li {
331 display: flex;
332 flex-direction: column;
333 text-align: center;
334 width: 68.5px;
335 font-size: 16px;
336 list-style-type: none;
337 font-family: "Circular Std Book";
338 line-height: 1.2;
339 font-weight: 500;
340 letter-spacing: 1.6px;
341 text-transform: uppercase;
342 text-align: center;
343 color: #A89CC3;
344 margin: 0;
345 }
346
347 .wpfnl-promotional-banner-wrapper .countdown li span {
348 font-size: 44px;
349 font-family: 'Inter', sans-serif;
350 font-weight: 700;
351 line-height: 1;
352 color: #fff;
353 text-align: center;
354 margin-bottom: 10px;
355 padding: 4px 2px;
356
357 border-radius: 10px;
358 border: 1px solid #FF0083;
359 background: linear-gradient(148deg, #2A0856 21.92%, #140102 80.41%);
360 box-shadow: 0px 5px 0px 0px #C90369;
361
362 }
363
364 .wpfnl-promotional-banner-wrapper .get-plugin-btn a {
365 text-decoration: none;
366 padding: 18px 31px 16px;
367 border-radius: 15px;
368 background: #ED8136;
369 color: #FFF;
370 text-align: center;
371 font-family: 'Lexend Deca';
372 font-size: 20px;
373 font-weight: 700;
374 line-height: 1;
375 display: block;
376 outline: none;
377 box-shadow: none;
378 }
379 .wpfnl-promotional-banner-wrapper .get-plugin-btn a:focus {
380 outline: none;
381 box-shadow: none;
382 }
383
384 .wpfnl-promotional-banner-wrapper .get-plugin-btn span {
385 font-family: 'Lexend Deca';
386 font-size: 26px;
387 font-weight: 700;
388 line-height: 1;
389 }
390
391 .wpfnl-promotional-banner .close-promotional-banner {
392 position: absolute;
393 top: -10px;
394 right: -9px;
395 background: #fff;
396 border: none;
397 padding: 8px 9px;
398 border-radius: 50%;
399 cursor: pointer;
400 }
401
402 .wpfnl-promotional-banner .close-promotional-banner svg {
403 display: block;
404 width: 10px;
405 }
406
407 @media only screen and (max-width: 1399px) {
408 .wpfnl-promotional-banner-wrapper .promotional-logo img {
409 max-width: 180px;
410 }
411 .wpfnl-promotional-banner .promotional-discount img {
412 max-width: 120px;
413 }
414
415 .wpfnl-promotional-banner-wrapper .promotional-content h4 {
416 font-size: 26px;
417 }
418 .wpfnl-promotional-banner-wrapper .promotional-content h4 span {
419 font-size: 20px;
420 }
421
422 .wpfnl-promotional-banner-wrapper .get-plugin-btn span {
423 font-size: 22px;
424 }
425
426 .wpfnl-promotional-banner-wrapper .countdown {
427 gap: 10px;
428 }
429 .wpfnl-promotional-banner-wrapper .countdown li {
430 width: 58px;
431 font-size: 14px;
432 }
433 .wpfnl-promotional-banner-wrapper .countdown li span {
434 font-size: 36px;
435 box-shadow: 0px 3px 0px 0px #C90369;
436 }
437
438 .wpfnl-promotional-banner-wrapper .get-plugin-btn a {
439 padding: 14px 18px 14px;
440 font-size: 18px;
441 font-weight: 600;
442 border-radius: 10px;
443 }
444 }
445
446 @media only screen and (max-width: 1199px) {
447 .wpfnl-promotional-banner-wrapper {
448 gap: 24px;
449 }
450
451 .wpfnl-promotional-banner-wrapper .promotional-logo img {
452 max-width: 140px;
453 }
454 .wpfnl-promotional-banner .promotional-discount img {
455 max-width: 90px;
456 }
457
458 .wpfnl-promotional-banner-wrapper .promotional-content h4 {
459 font-size: 22px;
460 }
461 .wpfnl-promotional-banner-wrapper .promotional-content h4 span {
462 font-size: 17px;
463 }
464
465 .wpfnl-promotional-banner-wrapper .countdown li {
466 width: 47px;
467 font-size: 11px;
468 }
469 .wpfnl-promotional-banner-wrapper .countdown li span {
470 font-size: 26px;
471 }
472
473 .wpfnl-promotional-banner-wrapper .get-plugin-btn a {
474 padding: 12px 14px 11px;
475 font-size: 15px;
476 border-radius: 10px;
477 }
478 .wpfnl-promotional-banner-wrapper .get-plugin-btn span {
479 font-size: 18px;
480 }
481
482 }
483
484 @media only screen and (max-width: 991px) {
485 .wpfnl-promotional-banner-wrapper .promotional-logo img {
486 max-width: 120px;
487 }
488 .wpfnl-promotional-banner .promotional-discount img {
489 max-width: 75px;
490 }
491
492 }
493 </style>
494 <?php
495 }
496 }