| 1 |
<?php |
| 2 |
|
| 3 |
Class WPVR_Notification_Bar { |
| 4 |
|
| 5 |
public function __construct() { |
| 6 |
// Hook into the admin_notices action to display the banner |
| 7 |
add_action('admin_notices', array($this, 'display_banner')); |
| 8 |
// Add styles |
| 9 |
add_action('admin_head', array($this, 'add_styles')); |
| 10 |
|
| 11 |
add_action('wp_ajax_wpvr_sale_notification_notice', array($this, 'wpvr_sale_notification_notice')); |
| 12 |
|
| 13 |
} |
| 14 |
|
| 15 |
|
| 16 |
/** |
| 17 |
* Displays the special occasion banner if the current date and time are within the specified range. |
| 18 |
*/ |
| 19 |
public function display_banner() |
| 20 |
{ |
| 21 |
|
| 22 |
$screen = get_current_screen(); |
| 23 |
$promotional_notice_pages = ['dashboard', 'plugins', 'edit-wpvr_item', 'toplevel_page_wpvr', 'wp-vr_page_wpvr-setup-wizard', 'wpvr_item', 'wp-vr_page_wpvr-addons','wp-vr_page_wpvr-setting']; |
| 24 |
if (!in_array($screen->id, $promotional_notice_pages)) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
$btn_link = 'https://rextheme.com/wpvr/wpvr-pricing/'; |
| 29 |
?> |
| 30 |
|
| 31 |
<section class="wpvr-promo-banner wpvr-promo-banner--regular" aria-labelledby="wpvr-promo-banner-title" id="wpvr-promo-banner"> |
| 32 |
<div class="wpvr-promo-banner__container"> |
| 33 |
<h2 class="wpvr-promo-banner__title" id="wpvr-promo-banner-title"> |
| 34 |
<a href="<?php echo esc_url($btn_link); ?>" target ="_blank" class="wpvr-promo-banner__link" aria-label="Get Special Discount"> |
| 35 |
<?php echo esc_html__('Get ', 'wpvr'); ?><strong class="wpvr-promo-banner__discount"><?php echo esc_html__(' 20% ', 'wpvr'); ?></strong><?php echo esc_html__(' Discount On ', 'wpvr'); ?><strong class="wpvr-promo-banner__discount"><?php echo esc_html__('WPVR', 'wpvr'); ?></strong> |
| 36 |
<span class="wpvr-promo-banner__icon" aria-hidden="true"> |
| 37 |
<svg class="wpvr-promo-banner__svg" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"> |
| 38 |
<title id="arrow-icon-title">Arrow Icon</title> |
| 39 |
<path d="M8.77887 2.05511L9.03494 1.79904H8.6728H5.17466C4.71928 1.79904 4.35014 1.42989 4.35014 0.97452C4.35014 0.519144 4.71928 0.15 5.17466 0.15H11.0253C11.4807 0.15 11.8498 0.519153 11.8498 0.97452V6.82164C11.8498 7.27701 11.4807 7.64616 11.0253 7.64616C10.5699 7.64616 10.2008 7.27701 10.2008 6.82164V3.32737V2.96524L9.94471 3.22131L1.5575 11.6084L1.55748 11.6085C1.23552 11.9305 0.713541 11.9305 0.391497 11.6085L0.391491 11.6084C0.0695031 11.2865 0.0695031 10.7644 0.391491 10.4424L0.285427 10.3363L0.391493 10.4424L8.77887 2.05511Z" fill="#3F04FE" stroke="white" stroke-width="0.3"/> |
| 40 |
</svg> |
| 41 |
</span> |
| 42 |
</a> |
| 43 |
</h2> |
| 44 |
|
| 45 |
<a class="wpvr-promo-banner__cross-icon" type="button" aria-label="close banner" id="wpvr-promo-banner__cross-icon"> |
| 46 |
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"> |
| 47 |
<path d="M11 1L1 11" stroke="#C8C0E2" stroke-linecap="round" stroke-linejoin="round"/> |
| 48 |
<path d="M1 1L11 11" stroke="#C8C0E2" stroke-linecap="round" stroke-linejoin="round"/> |
| 49 |
</svg> |
| 50 |
</a> |
| 51 |
|
| 52 |
</div> |
| 53 |
|
| 54 |
</section> |
| 55 |
<script> |
| 56 |
(function ($) { |
| 57 |
/** |
| 58 |
* Dismiss sale notification notice |
| 59 |
* |
| 60 |
* @param e |
| 61 |
*/ |
| 62 |
function wpvr_sale_notification_notice(e) { |
| 63 |
e.preventDefault(); |
| 64 |
$('#wpvr-promo-banner').hide(); // Ensure the correct element is selected |
| 65 |
jQuery.ajax({ |
| 66 |
type: "POST", |
| 67 |
url: ajaxurl, |
| 68 |
data: { |
| 69 |
action: "wpvr_sale_notification_notice", |
| 70 |
nonce: wpvr_global_obj.ajax_nonce |
| 71 |
}, |
| 72 |
success: function(response) { |
| 73 |
$('#wpvr-promo-banner').hide(); // Ensure the correct element is selected |
| 74 |
}, |
| 75 |
error: function(xhr, status, error) { |
| 76 |
console.error('AJAX request failed:', status, error); |
| 77 |
} |
| 78 |
}); |
| 79 |
} |
| 80 |
|
| 81 |
jQuery(document).ready(function($) { |
| 82 |
$(document).on('click', '#wpvr-promo-banner__cross-icon', wpvr_sale_notification_notice); |
| 83 |
}); |
| 84 |
})(jQuery); |
| 85 |
</script> |
| 86 |
<!-- .rex-feed-tb-notification end --> |
| 87 |
<?php |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
/** |
| 92 |
* Adds internal CSS styles for the special occasion banners. |
| 93 |
*/ |
| 94 |
public function add_styles() |
| 95 |
{ |
| 96 |
?> |
| 97 |
<style id="wpvr-promotional-banner-style" type="text/css"> |
| 98 |
:root { |
| 99 |
--vr-primary-color: #3F04FE; |
| 100 |
} |
| 101 |
|
| 102 |
@font-face { |
| 103 |
font-family: 'Roboto'; |
| 104 |
src: url(<?php echo esc_url(WPVR_PLUGIN_DIR_URL . 'admin/fonts/Roboto-Regular.woff2'); ?>) format('woff2'); |
| 105 |
font-weight: 400; |
| 106 |
font-style: normal; |
| 107 |
font-display: swap; |
| 108 |
} |
| 109 |
|
| 110 |
@font-face { |
| 111 |
font-family: 'Roboto'; |
| 112 |
src: url(<?php echo esc_url(WPVR_PLUGIN_DIR_URL . 'admin/fonts/Roboto-Bold.woff2'); ?>) format('woff2'); |
| 113 |
font-weight: 700; |
| 114 |
font-style: normal; |
| 115 |
font-display: swap; |
| 116 |
} |
| 117 |
|
| 118 |
.wpvr-promo-banner * { |
| 119 |
box-sizing: border-box; |
| 120 |
} |
| 121 |
|
| 122 |
@keyframes arrowMove { |
| 123 |
0% { transform: translate(0, 0); } |
| 124 |
50% { transform: translate(18px, -18px); } |
| 125 |
55% { opacity: 0; visibility: hidden; transform: translate(-18px, 18px); } |
| 126 |
100% { opacity: 1; visibility: visible; transform: translate(0, 0); } |
| 127 |
} |
| 128 |
|
| 129 |
.wpvr-promo-banner { |
| 130 |
margin-top: 40px; |
| 131 |
padding: 14px 0; |
| 132 |
text-align: center; |
| 133 |
border-radius: 5px; |
| 134 |
border-left: 2px solid var(--vr-primary-color); |
| 135 |
background: #FFF; |
| 136 |
box-shadow: 0px 1px 1px 0px rgba(63, 4, 254, 0.10); |
| 137 |
width: calc(100% - 20px); |
| 138 |
} |
| 139 |
|
| 140 |
.wpvr-promo-banner__container { |
| 141 |
display: flex; |
| 142 |
margin: 0 auto; |
| 143 |
padding: 0 20px; |
| 144 |
} |
| 145 |
|
| 146 |
.wpvr-promo-banner__title { |
| 147 |
display: block; |
| 148 |
margin: 0 auto; |
| 149 |
text-align: center; |
| 150 |
font-size: 18px; |
| 151 |
line-height: normal; |
| 152 |
} |
| 153 |
|
| 154 |
.wpvr-promo-banner__link { |
| 155 |
position: relative; |
| 156 |
font-family: 'Roboto'; |
| 157 |
font-size: 18px; |
| 158 |
font-style: normal; |
| 159 |
font-weight: 400; |
| 160 |
color: var(--vr-primary-color); |
| 161 |
transition: all .3s ease; |
| 162 |
text-decoration: none; |
| 163 |
} |
| 164 |
|
| 165 |
.wpvr-promo-banner__link:hover { |
| 166 |
color: var(--vr-primary-color); |
| 167 |
} |
| 168 |
|
| 169 |
.wpvr-promo-banner__link:focus { |
| 170 |
color: var(--vr-primary-color); |
| 171 |
box-shadow: none; |
| 172 |
outline: 0px solid transparent; |
| 173 |
} |
| 174 |
|
| 175 |
.wpvr-promo-banner__link::before { |
| 176 |
content: ""; |
| 177 |
position: absolute; |
| 178 |
left: 0; |
| 179 |
bottom: 1px; |
| 180 |
width: calc(100% - 33px); |
| 181 |
height: 1px; |
| 182 |
background-color: var(--vr-primary-color); |
| 183 |
transform: scaleX(1); |
| 184 |
transform-origin: bottom left; |
| 185 |
transition: transform .4s ease; |
| 186 |
} |
| 187 |
|
| 188 |
.wpvr-promo-banner__link:hover::before { |
| 189 |
transform: scaleX(0); |
| 190 |
transform-origin: bottom right; |
| 191 |
} |
| 192 |
|
| 193 |
.wpvr-promo-banner__link:hover svg { |
| 194 |
animation: arrowMove .5s .4s linear forwards; |
| 195 |
} |
| 196 |
|
| 197 |
.wpvr-promo-banner__discount { |
| 198 |
font-weight: bold; |
| 199 |
} |
| 200 |
|
| 201 |
.wpvr-promo-banner__icon { |
| 202 |
display: inline-block; |
| 203 |
margin-left: 21px; |
| 204 |
vertical-align: middle; |
| 205 |
width: 12px; |
| 206 |
height: 17px; |
| 207 |
overflow: hidden; |
| 208 |
line-height: 1; |
| 209 |
position: relative; |
| 210 |
top: 1px; |
| 211 |
} |
| 212 |
|
| 213 |
.wpvr-promo-banner__svg { |
| 214 |
fill: none; |
| 215 |
} |
| 216 |
|
| 217 |
.wpvr-promo-banner__cross-icon { |
| 218 |
cursor: pointer; |
| 219 |
transition: all .3s ease; |
| 220 |
} |
| 221 |
|
| 222 |
.wpvr-promo-banner__cross-icon svg:hover path { |
| 223 |
stroke: var(--vr-primary-color); |
| 224 |
} |
| 225 |
</style> |
| 226 |
|
| 227 |
<?php |
| 228 |
|
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
public function wpvr_sale_notification_notice() |
| 233 |
{ |
| 234 |
if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'wpvr')) { |
| 235 |
wp_die(__('Permission check failed', 'wpvr')); |
| 236 |
} |
| 237 |
update_option('wpvr_sell_notification_bar', 'yes'); |
| 238 |
echo json_encode(['success' => true,]); |
| 239 |
wp_die(); |
| 240 |
} |
| 241 |
|
| 242 |
} |