| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Promotional offer class |
| 5 |
*/ |
| 6 |
|
| 7 |
class WeForms_Admin_Promotion { |
| 8 |
|
| 9 |
public function __construct() { |
| 10 |
add_action( 'admin_notices', array( $this, 'promotional_offer' ) ); |
| 11 |
add_action( 'wp_ajax_weforms-dismiss-promotional-offer-notice', array( $this, 'dismiss_promotional_offer' ) ); |
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* Promotional offer notice |
| 16 |
* |
| 17 |
* @since 1.2.6 |
| 18 |
* |
| 19 |
* @return void |
| 20 |
*/ |
| 21 |
public function promotional_offer() { |
| 22 |
// Show only to Admins |
| 23 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 24 |
return; |
| 25 |
} |
| 26 |
|
| 27 |
// 2018-03-26 23:59:00 |
| 28 |
if ( time() > 1522108740 ) { |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
// check if wpuf is showing banner |
| 33 |
if ( class_exists( 'WPUF_Admin_Promotion' ) ) { |
| 34 |
return; |
| 35 |
} |
| 36 |
|
| 37 |
// check if it has already been dismissed |
| 38 |
$hide_notice = get_option( 'weforms_promotional_offer_notice', 'no' ); |
| 39 |
|
| 40 |
if ( 'hide' == $hide_notice ) { |
| 41 |
return; |
| 42 |
} |
| 43 |
|
| 44 |
// $product_text = ( weforms()->is_pro() ) ? __( 'Pro upgrade and all extensions, ', 'weforms' ) : __( 'all extensions, ', 'weforms' ); |
| 45 |
|
| 46 |
// $offer_msg = __( '<h2><span class="dashicons dashicons-awards"></span> weDevs 5th Birthday Offer</h2>', 'weforms' ); |
| 47 |
$offer_msg = sprintf( __( '<p> |
| 48 |
<strong class="highlight-text" style="font-size: 18px">It’s Our Birthday <span class="weforms-cake" style="font-size: 20px"> 🎂</span> |
| 49 |
But You Get The Present <span class="weforms-gift" style="font-size: 20px"> 🎁</span> </strong><br> |
| 50 |
Get 25% Discount with coupon: |
| 51 |
<a target="_blank" href="%1$s"><strong> we25 </strong></a> |
| 52 |
<br> |
| 53 |
Offer ending soon! |
| 54 |
</p>', 'weforms' ), 'https://wedevs.com/in/get-25-off' ); |
| 55 |
|
| 56 |
?> |
| 57 |
<div class="notice is-dismissible" id="weforms-promotional-offer-notice"> |
| 58 |
<table> |
| 59 |
<tbody> |
| 60 |
<tr> |
| 61 |
<td class="image-container"> |
| 62 |
<img src="https://ps.w.org/weforms/assets/icon-256x256.png" alt=""> |
| 63 |
</td> |
| 64 |
<td class="message-container"> |
| 65 |
<?php echo $offer_msg; ?> |
| 66 |
</td> |
| 67 |
</tr> |
| 68 |
</tbody> |
| 69 |
</table> |
| 70 |
|
| 71 |
<span class="dashicons dashicons-megaphone"></span> |
| 72 |
<a href="https://wedevs.com/in/get-25-off" class="button button-primary promo-btn" target="_blank"><?php _e( 'Get the Offer', 'weforms' ); ?></a> |
| 73 |
</div><!-- #weforms-promotional-offer-notice --> |
| 74 |
|
| 75 |
<style> |
| 76 |
#weforms-promotional-offer-notice { |
| 77 |
background-image: linear-gradient(35deg,#00c9ff 0%, #92fe9d 100%) !important; |
| 78 |
border: 0px; |
| 79 |
padding: 0; |
| 80 |
opacity: 0; |
| 81 |
} |
| 82 |
|
| 83 |
.wrap > #weforms-promotional-offer-notice { |
| 84 |
opacity: 1; |
| 85 |
} |
| 86 |
|
| 87 |
#weforms-promotional-offer-notice table { |
| 88 |
border-collapse: collapse; |
| 89 |
width: 100%; |
| 90 |
} |
| 91 |
|
| 92 |
#weforms-promotional-offer-notice table td { |
| 93 |
padding: 0; |
| 94 |
} |
| 95 |
|
| 96 |
#weforms-promotional-offer-notice table td.image-container { |
| 97 |
background-color: #ebf0f4; |
| 98 |
vertical-align: middle; |
| 99 |
width: 95px; |
| 100 |
} |
| 101 |
|
| 102 |
#weforms-promotional-offer-notice img { |
| 103 |
max-width: 100%; |
| 104 |
max-height: 100px; |
| 105 |
vertical-align: middle; |
| 106 |
} |
| 107 |
|
| 108 |
#weforms-promotional-offer-notice table td.message-container { |
| 109 |
padding: 0 10px; |
| 110 |
} |
| 111 |
|
| 112 |
#weforms-promotional-offer-notice h2{ |
| 113 |
color: rgba(250, 250, 250, 0.77); |
| 114 |
margin-bottom: 10px; |
| 115 |
font-weight: normal; |
| 116 |
margin: 16px 0 14px; |
| 117 |
-webkit-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 118 |
-moz-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 119 |
-o-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 120 |
text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 121 |
} |
| 122 |
|
| 123 |
#weforms-promotional-offer-notice h2 span { |
| 124 |
position: relative; |
| 125 |
top: 0; |
| 126 |
} |
| 127 |
|
| 128 |
#weforms-promotional-offer-notice p{ |
| 129 |
color: rgba(250, 250, 250, 0.77); |
| 130 |
font-size: 14px; |
| 131 |
margin-bottom: 10px; |
| 132 |
-webkit-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 133 |
-moz-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 134 |
-o-text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 135 |
text-shadow: 0.1px 0.1px 0px rgba(250, 250, 250, 0.24); |
| 136 |
} |
| 137 |
|
| 138 |
#weforms-promotional-offer-notice p strong.highlight-text{ |
| 139 |
color: #fff; |
| 140 |
} |
| 141 |
|
| 142 |
#weforms-promotional-offer-notice p a { |
| 143 |
color: #fafafa; |
| 144 |
} |
| 145 |
|
| 146 |
#weforms-promotional-offer-notice .notice-dismiss:before { |
| 147 |
color: #fff; |
| 148 |
} |
| 149 |
|
| 150 |
#weforms-promotional-offer-notice span.dashicons-megaphone { |
| 151 |
position: absolute; |
| 152 |
bottom: 46px; |
| 153 |
right: 248px; |
| 154 |
color: rgba(253, 253, 253, 0.29); |
| 155 |
font-size: 96px; |
| 156 |
transform: rotate(-21deg); |
| 157 |
} |
| 158 |
|
| 159 |
#weforms-promotional-offer-notice a.promo-btn{ |
| 160 |
background: #149269; |
| 161 |
border-color: #149269 #149269 #149269; |
| 162 |
box-shadow: 0 1px 0 #149269; |
| 163 |
/*color: #45E2D0;*/ |
| 164 |
text-decoration: none; |
| 165 |
text-shadow: none; |
| 166 |
position: absolute; |
| 167 |
top: 30px; |
| 168 |
right: 26px; |
| 169 |
height: 40px; |
| 170 |
line-height: 40px; |
| 171 |
width: 130px; |
| 172 |
text-align: center; |
| 173 |
font-weight: 600; |
| 174 |
} |
| 175 |
|
| 176 |
</style> |
| 177 |
|
| 178 |
<script type='text/javascript'> |
| 179 |
jQuery('body').on('click', '#weforms-promotional-offer-notice .notice-dismiss', function(e) { |
| 180 |
e.preventDefault(); |
| 181 |
|
| 182 |
wp.ajax.post('weforms-dismiss-promotional-offer-notice', { |
| 183 |
dismissed: true |
| 184 |
}); |
| 185 |
}); |
| 186 |
</script> |
| 187 |
<?php |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
/** |
| 192 |
* Dismiss promotion notice |
| 193 |
* |
| 194 |
* @since 1.2.6 |
| 195 |
* |
| 196 |
* @return void |
| 197 |
*/ |
| 198 |
public function dismiss_promotional_offer() { |
| 199 |
if ( ! empty( $_POST['dismissed'] ) ) { |
| 200 |
$offer_key = 'weforms_promotional_offer_notice'; |
| 201 |
update_option( $offer_key, 'hide' ); |
| 202 |
} |
| 203 |
} |
| 204 |
} |