funnels.php
178 lines
| 1 | <?php |
| 2 | if ( ! class_exists( 'brcompare_free_funnels' ) ) { |
| 3 | class brcompare_free_funnels { |
| 4 | function __construct() { |
| 5 | //delete_option('berocket_admin_notices'); |
| 6 | //update_option('berocket_last_close_notices_time', 1); |
| 7 | $this->spring_premium_days_2026(); |
| 8 | } |
| 9 | |
| 10 | public function spring_premium_days_2026(): void { |
| 11 | $name = 'spring_premium_days_2026'; |
| 12 | $media = '?utm_source=free_plugin&utm_medium=admin_notice&utm_campaign=spring_2026&utm_content=top_banner_cta&utm_term=compare'; |
| 13 | $start_time = mktime(0, 0, 0, 4, 13, 2026); |
| 14 | $end_time = mktime(23, 59, 59, 4, 17, 2026); |
| 15 | $c_notice = berocket_admin_notices::get_notice_by_priority_and_name( 19, $name ); |
| 16 | |
| 17 | $is_closed = false; |
| 18 | if ( isset( $c_notice['closed'] ) and $c_notice['closed'] > 0 ) { |
| 19 | $is_closed = true; |
| 20 | } |
| 21 | |
| 22 | if ( ! $is_closed and $start_time <= time() and $end_time > time() ) { |
| 23 | new berocket_admin_notices( array( |
| 24 | 'start' => $start_time, |
| 25 | 'end' => $end_time, |
| 26 | 'name' => $name, |
| 27 | 'html' => ' |
| 28 | <div class="berocket-notice-template-big"> |
| 29 | <div class="berocket-notice-description-container"> |
| 30 | <h1 style="padding-top: 0;line-height: 0.8;">🌿 Spring Premium Days - <b class="br-notice-text-label">Save 30% on Premium</b> Plugins!</h1> |
| 31 | <h3>Build a faster, smarter, and more profitable WooCommerce store</h3> |
| 32 | <ul style="font-size: 16px"> |
| 33 | <li>Faster product discovery and smoother navigation</li> |
| 34 | <li>Smart features to boost conversions and engagement</li> |
| 35 | <li>Priority support to save your time and resolve issues faster</li> |
| 36 | </ul> |
| 37 | <p><i>30% OFF applies to all BeRocket plugins.</i></p> |
| 38 | </div> |
| 39 | <div class="berocket-notice-actions-container"> |
| 40 | <div class="berocket-notice-countdown-container"> |
| 41 | <span class="berocket-notice-countdown-title">Hurry Up! Deal ends in:</span> |
| 42 | <ul class="berocket-notice-countdown-timer" data-endtime="' . ($end_time) . '"> |
| 43 | <li class="berocket-notice-countdown-days"><span>0</span><br />Days</li> |
| 44 | <li class="berocket-notice-countdown-hours"><span>0</span><br />Hours</li> |
| 45 | <li class="berocket-notice-countdown-minutes"><span>0</span><br />Minutes</li> |
| 46 | <li class="berocket-notice-countdown-seconds"><span>0</span><br />Seconds</li> |
| 47 | </ul> |
| 48 | </div> |
| 49 | <div class="berocket-notice-buttons-container"> |
| 50 | <a href="https://berocket.com/plugins/' . $media . '" |
| 51 | class="button notice-action-link not_berocket_button" target="_blank" |
| 52 | style="position: static; display: inline-block; right: 0; top: 0; margin: 0;font-size: 24px;padding-left: 25px;padding-right: 25px;">Get Premium → 30% OFF</a> |
| 53 | </div> |
| 54 | </div> |
| 55 | </div>', |
| 56 | 'type' => 'warning', |
| 57 | 'righthtml' => '<span class="berocket-notice-dismiss notice-dismiss berocket_no_thanks" role="button" tabindex="0"> |
| 58 | <span class="screen-reader-text"> |
| 59 | <input class="berocket-notice-dismiss-check" type="checkbox" value="1">Dismiss this notice. |
| 60 | </span> |
| 61 | </span>', |
| 62 | 'subscribe' => false, |
| 63 | 'priority' => 19, |
| 64 | 'image' => '', |
| 65 | ) ); |
| 66 | |
| 67 | $this->br_show_admin_notice_sign(); |
| 68 | $this->br_show_admin_notice_timer(); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | public function br_show_admin_notice_sign(): void { |
| 73 | add_action('admin_head', function () { |
| 74 | echo " |
| 75 | <style> |
| 76 | #toplevel_page_berocket_account .toplevel_page_berocket_account .wp-menu-name:after { |
| 77 | content: '!'; |
| 78 | display: flex; |
| 79 | vertical-align: top; |
| 80 | box-sizing: border-box; |
| 81 | margin: 0; |
| 82 | padding: 0 5px; |
| 83 | min-width: 22px; |
| 84 | border-radius: 0; |
| 85 | background-color: #0fc972; |
| 86 | color: #fff; |
| 87 | font-size: 18px; |
| 88 | line-height: 1.6; |
| 89 | text-align: center; |
| 90 | z-index: 26; |
| 91 | position: absolute; |
| 92 | right: 10px; |
| 93 | top: 2px; |
| 94 | bottom: 2px; |
| 95 | align-items: center; |
| 96 | justify-content: center; |
| 97 | font-weight: 600; |
| 98 | } |
| 99 | </style> |
| 100 | "; |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | public function br_show_admin_notice_timer(): void { |
| 105 | add_action('admin_head', function () { |
| 106 | echo " |
| 107 | <script> |
| 108 | function berocket_notice_countdown() { |
| 109 | time = jQuery('.berocket-notice-countdown-timer').data('endtime')*1 - Math.floor(Date.now()/1000); |
| 110 | berocket_notice_countdown_timer(time); |
| 111 | } |
| 112 | function berocket_notice_countdown_timer(time) { |
| 113 | formatted_time = berocket_notice_countdown_timer_format_time(time); |
| 114 | jQuery('.berocket-notice-countdown-days span').text(formatted_time.days); |
| 115 | jQuery('.berocket-notice-countdown-hours span').text(formatted_time.hours); |
| 116 | jQuery('.berocket-notice-countdown-minutes span').text(formatted_time.minutes); |
| 117 | jQuery('.berocket-notice-countdown-seconds span').text(formatted_time.seconds); |
| 118 | if ( time > 0 ) { |
| 119 | setTimeout(berocket_notice_countdown_timer, 1000, time-1); |
| 120 | } |
| 121 | } |
| 122 | function berocket_notice_countdown_timer_format_time(totalSeconds) { |
| 123 | const days = Math.floor(totalSeconds / 86400); |
| 124 | totalSeconds %= 86400; |
| 125 | |
| 126 | const hours = Math.floor(totalSeconds / 3600); |
| 127 | totalSeconds %= 3600; |
| 128 | |
| 129 | const minutes = Math.floor(totalSeconds / 60); |
| 130 | const seconds = totalSeconds % 60; |
| 131 | |
| 132 | return { days, hours, minutes, seconds }; |
| 133 | } |
| 134 | jQuery(document).ready(function () { |
| 135 | berocket_notice_countdown(); |
| 136 | }); |
| 137 | </script> |
| 138 | <style> |
| 139 | .berocket-notice-countdown-container { |
| 140 | background: #ffd453; |
| 141 | width: 516px; |
| 142 | margin: 0 auto; |
| 143 | border-radius: 10px; |
| 144 | padding: 13px 0 7px; |
| 145 | } |
| 146 | .berocket-notice-countdown-title { |
| 147 | font-size: 16px; |
| 148 | } |
| 149 | .berocket-notice.notice-warning ul.berocket-notice-countdown-timer { |
| 150 | display: flex; |
| 151 | gap: 10px; |
| 152 | justify-content: center; |
| 153 | margin-bottom: 0; |
| 154 | padding-left: 10px !important; |
| 155 | padding-right: 10px !important; |
| 156 | } |
| 157 | .berocket-notice-countdown-timer li { |
| 158 | list-style-type: none; |
| 159 | background: white; |
| 160 | height: 60px; |
| 161 | width: 80px; |
| 162 | border-radius: 10px; |
| 163 | font-size: 15px; |
| 164 | padding: 10px 5px; |
| 165 | box-sizing: border-box; |
| 166 | } |
| 167 | .berocket-notice-countdown-timer li span { |
| 168 | font-size: 24px; |
| 169 | font-weight: 700; |
| 170 | } |
| 171 | </style> |
| 172 | "; |
| 173 | }); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | new brcompare_free_funnels(); |
| 178 | } |