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

384 lines 13.0 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_eid_ul_fitr_26_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-01-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_wp_funnels', 'wpfunnels_page_edit_funnel', 'wp-funnels_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="wpf-halloween-offer">
109 <div class="gwpf-container">
110 <div class="promotional-banner">
111 <div class="banner-content">
112 <div class="banner-text">
113 🔥 Eid ul-Fitr Special: Claim A Huge <span class="highlighted-text">40% OFF</span> On WPFunnels! - Limited Time Deal!
114 </div>
115
116 <a href="<?php echo esc_url($this->btn_link); ?>" class="cta-button" role="button" aria-label="get special discount " target="_blank">
117 <?php
118 echo __('View Offer', 'getwpfunnels');
119 ?>
120 <svg width="11" height="11" fill="none" viewBox="0 0 11 11" xmlns="http://www.w3.org/2000/svg"><path fill="#3C1F7D" stroke="#3C1F7D" stroke-width=".2" d="M9.419.1a.88.88 0 01.88.881V9.42a.88.88 0 11-1.761 0V3.11l-6.934 6.933A.88.88 0 01.358 8.796l6.934-6.934H.982A.88.88 0 11.981.1h8.437z"/></svg>
121 </a>
122 </div>
123 </div>
124 </div>
125 </section>
126 </div>
127
128 <button class="close-promotional-banner" type="button" aria-label="close banner">
129 <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>
130 </button>
131 </div>
132 </div>
133 <!-- .gwpf-tb-notification end -->
134
135 <script>
136 function updateCountdown() {
137 var endDate = new Date("2026-01-07 23:59:59").getTime();
138 var now = new Date().getTime();
139 var timeLeft = endDate - now;
140
141 var days = Math.floor(timeLeft / (1000 * 60 * 60 * 24));
142 var hours = Math.floor((timeLeft % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
143 var minutes = Math.floor((timeLeft % (1000 * 60 * 60)) / (1000 * 60));
144 var seconds = Math.floor((timeLeft % (1000 * 60)) / 1000);
145
146 var daysElement = document.getElementById('wpf-halloween-days');
147 var hoursElement = document.getElementById('wpf-halloween-hours');
148 var minsElement = document.getElementById('wpf-halloween-mins');
149 var secsElement = document.getElementById('wpf-halloween-secs');
150
151 if (daysElement) {
152 daysElement.innerHTML = days;
153 }
154
155 if (hoursElement) {
156 hoursElement.innerHTML = hours;
157 }
158
159 if (minsElement) {
160 minsElement.innerHTML = minutes;
161 }
162 if (secsElement) {
163 secsElement.innerHTML = seconds;
164 }
165 }
166
167 document.addEventListener('DOMContentLoaded', function() {
168 updateCountdown();
169 setInterval(updateCountdown, 1000); // Update every minute
170 });
171 </script>
172 <?php
173 }
174
175 /**
176 * Adds internal CSS styles for the special occasion banners.
177 */
178 public function add_styles() {
179 ?>
180 <style type="text/css">
181 .gwpf-tb__notification,
182 .gwpf-tb__notification * {
183 box-sizing: border-box;
184 }
185
186 .gwpf-promotional-notice.notice {
187 display: block;
188 background: none;
189 border: none;
190 box-shadow: none;
191 padding: 0;
192 margin: 0;
193 }
194
195 .gwpf-tb__notification {
196 width: calc(100% - 20px);
197 margin: 20px 0 20px;
198 background-repeat: no-repeat;
199 background-size: cover;
200 position: relative;
201 border: none;
202 box-shadow: none;
203 display: block;
204 max-height: 110px;
205 }
206 .wpfunnels_page_wp_funnels .gwpf-tb__notification {
207 width: calc(100% - 40px);
208 margin: 20px 0 20px 20px;
209 }
210
211 .gwpf-tb__notification .banner-overflow {
212 position: relative;
213 width: 100%;
214 z-index: 1;
215 }
216
217 /* ---banner style start--- */
218 .gwpf-promotional-banner {
219 position: relative;
220 background-color: #2d1568;
221 background: linear-gradient(90deg, #AC77FD -6.28%, #3C1F7D 21.34%, #3C1F7D 87.74%, #AC77FD 130.48%);
222 z-index: 1111;
223 padding: 6px 0;
224 }
225 .gwpf-promotional-banner .promotional-banner {
226 color: white;
227 padding: 3px 20px 0;
228 /* padding: 12px 20px; */
229 text-align: center;
230 font-size: 14px;
231 line-height: 1.4;
232 position: relative;
233 }
234 .gwpf-promotional-banner .banner-content {
235 max-width: 1200px;
236 margin: 0 auto;
237 display: inline-flex;
238 align-items: center;
239 justify-content: center;
240 flex-wrap: wrap;
241 gap: 20px;
242 row-gap: 8px;
243 position: relative;
244 }
245 .gwpf-promotional-banner .banner-text {
246 display: flex;
247 align-items: center;
248 flex-wrap: wrap;
249 gap: 6px;
250 row-gap: 0;
251 justify-content: center;
252 font-size: 16px;
253 color: #fff;
254 font-weight: 400;
255 line-height: 1.4;
256 text-transform: capitalize;
257 letter-spacing: 0;
258 }
259 .gwpf-promotional-banner .banner-text svg {
260 display: block;
261 }
262 .gwpf-promotional-banner .banner-text .highlighted-text {
263 color: #ee8134;
264 font-weight: 700;
265 }
266 .gwpf-promotional-banner .halloween-bird-left {
267 position: absolute;
268 left: -47px;
269 bottom: -7px;
270 }
271 .gwpf-promotional-banner .halloween-bird-right {
272 position: absolute;
273 right: -50px;
274 top: -5px;
275 }
276 .gwpf-promotional-banner .cta-button {
277 color: #3C1F7D;
278 font-size: 16px;
279 font-style: normal;
280 font-weight: 700;
281 line-height: normal;
282 text-decoration: none;
283 text-decoration-thickness: 2px;
284 text-underline-offset: 5px;
285 display: inline-flex;
286 align-items: center;
287 gap: 5px;
288 transition: all 0.2s ease;
289 background: #fff;
290 padding: 9px 14px;
291 border-radius: 50px;
292 }
293 .gwpf-promotional-banner .cta-button svg {
294 transition: transform 0.3s ease;
295 }
296
297 .gwpf-promotional-banner .cta-button:focus,
298 .gwpf-promotional-banner .cta-button:visited {
299 color: #3C1F7D !important;
300 }
301 .gwpf-promotional-banner .cta-button:hover {
302 color: #3C1F7D !important;
303 }
304 .gwpf-promotional-banner .cta-button:hover svg path {
305 stroke: #3C1F7D;
306 fill: #3C1F7D;
307 }
308
309 .gwpf-promotional-banner .cta-button:hover svg {
310 transform: translateX(3px);
311 }
312
313
314 .gwpf-tb__notification .close-promotional-banner {
315 position: absolute;
316 top: -10px;
317 right: -9px;
318 background: #fff;
319 border: none;
320 padding: 0;
321 border-radius: 50%;
322 cursor: pointer;
323 z-index: 9;
324 width: 30px;
325 height: 30px;
326 display: flex;
327 align-items: center;
328 justify-content: center;
329 }
330
331 .gwpf-tb__notification .close-promotional-banner svg {
332 width: 22px;
333 display: block;
334 }
335
336 @media only screen and (max-width: 991px) {
337 .promotional-banner {
338 padding: 16px 20px;
339 }
340
341 .gwpf-tb__notification {
342 margin: 60px 0 20px;
343 }
344
345 .gwpf-tb__notification .close-promotional-banner {
346 width: 25px;
347 height: 25px;
348 }
349 }
350
351 @media only screen and (max-width: 767px) {
352 .wpvr-promotional-banner {
353 padding-top: 20px;
354 padding-bottom: 30px;
355 max-height: none;
356 }
357
358 .wpvr-promotional-banner {
359 max-height: none;
360 }
361 }
362
363 @media only screen and (max-width: 575px) {
364 .promotional-banner {
365 padding: 16px 55px;
366 font-size: 13px;
367 }
368 .gwpf-promotional-banner .halloween-bird-left {
369 left: -12px;
370 bottom: inherit;
371 top: -5px;
372 }
373 .gwpf-promotional-banner .halloween-bird-right {
374 right: -12px;
375 bottom: -7px;
376 top: inherit;
377 }
378 }
379 </style>
380 <?php
381 }
382
383 }
384