PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.4.8
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.4.8
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / admin / class-promotion.php

class-promotion.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.4.8, at includes/admin/class-promotion.php

349 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Promotional offer class
5 */
6 class WeForms_Admin_Promotion {
7
8 public function __construct() {
9 add_action( 'admin_notices', [ $this, 'promotional_offer' ] );
10 add_action( 'admin_notices', [ $this, 'weforms_review_notice_message' ] );
11 add_action( 'wp_ajax_weforms-dismiss-promotional-offer-notice', [ $this, 'dismiss_promotional_offer' ] );
12 add_action( 'wp_ajax_weforms-dismiss-review-notice', [ $this, 'dismiss_review_notice' ] );
13 }
14
15 /**
16 * Promotional offer notice
17 *
18 * @return void
19 *
20 * @since 1.2.6
21 */
22 public function promotional_offer() {
23 if ( !current_user_can( 'manage_options' ) ) {
24 return;
25 }
26
27 if ( class_exists( 'WeForms_Pro' ) ) {
28 return;
29 }
30
31 // check if it has already been dismissed
32 $offer_key = 'weforms_promotional_offer_notice';
33 $offer_start_date = strtotime( '2019-11-20 00:00:01' );
34 $offer_end_date = strtotime( '2019-12-04 23:59:00' );
35 $hide_notice = get_option( $offer_key, 'show' );
36
37 if ( 'hide' == $hide_notice ) {
38 return;
39 }
40
41 if ( $offer_start_date < current_time( 'timestamp' ) && current_time( 'timestamp' ) < $offer_end_date ) {
42 ?>
43 <div class="notice notice-success is-dismissible" id="weforms-bfcm-notice">
44 <div class="logo">
45 <img src="<?php echo esc_attr( WEFORMS_ASSET_URI ) . '/images/promo-logo.png' ?>" alt="weForms">
46 </div>
47 <div class="content">
48 <p>Biggest Sale of the year on this</p>
49
50 <h3><span class="highlight-green"> Black Friday &amp; </span>Cyber Monday</h3>
51 <p>Claim your discount on <span class="highlight-olive">weForms</span> till 4th December</p>
52 </div>
53 <div class="call-to-action">
54 <a target="_blank" href="https://wedevs.com/weforms/pricing?utm_campaign=black_friday_&_cyber_monday&utm_medium=banner&utm_source=plugin_dashboard">
55 <img src="<?php echo esc_attr( WEFORMS_ASSET_URI ) . '/images/promo-btn.png' ?>" alt="Btn">
56 </a>
57 <p>
58 <span class="highlight-green">Coupon: </span>
59 <span class="coupon-code">BFCM2019</span>
60 </p>
61 </div>
62 </div>
63
64 <style>
65 #weforms-bfcm-notice {
66 font-size: 14px;
67 border-left: none;
68 background: #398085;
69 color: #fff;
70 display: flex
71 }
72
73 #weforms-bfcm-notice .notice-dismiss:before {
74 color: #76E5FF;
75 }
76
77 #weforms-bfcm-notice .notice-dismiss:hover:before {
78 color: #b71c1c;
79 }
80
81 #weforms-bfcm-notice .logo {
82 text-align: center;
83 text-align: center;
84 margin: auto 50px;
85 }
86
87 #weforms-bfcm-notice .logo img {
88 width: 80%;
89 }
90
91 #weforms-bfcm-notice .highlight-green {
92 color: #72F3FB;
93 }
94
95 #weforms-bfcm-notice .highlight-olive {
96 color: #7CF5AA;
97 }
98
99 #weforms-bfcm-notice .content {
100 margin-top: 5px;
101 }
102
103 #weforms-bfcm-notice .content h3 {
104 color: #FFF;
105 margin: 12px 0 5px;
106 font-weight: normal;
107 font-size: 30px;
108 }
109
110 #weforms-bfcm-notice .content p {
111 margin-top: 12px;
112 padding: 0;
113 letter-spacing: .4px;
114 color: #ffffff;
115 font-size: 15px;
116 }
117
118 #weforms-bfcm-notice .call-to-action {
119 margin-left: 10%;
120 margin-top: 20px;
121 }
122
123 #weforms-bfcm-notice .call-to-action a:focus {
124 box-shadow: none;
125 }
126
127 #weforms-bfcm-notice .call-to-action p {
128 font-size: 16px;
129 color: #fff;
130 margin-top: 1px;
131 text-align: center;
132 }
133
134 #weforms-bfcm-notice .coupon-code {
135 -moz-user-select: all;
136 -webkit-user-select: all;
137 user-select: all;
138 }
139 </style>
140
141 <script type='text/javascript'>
142 jQuery('body').on('click', '#weforms-bfcm-notice .notice-dismiss', function (e) {
143 e.preventDefault();
144
145 wp.ajax.post('weforms-dismiss-promotional-offer-notice', {
146 dismissed: true,
147 _wpnonce: '<?php echo esc_attr ( wp_create_nonce( 'weforms' ) ); ?>'
148 });
149 });
150 </script>
151 <?php
152 }
153 }
154
155 /**
156 * @return void
157 *
158 **@since 1.3.5
159 */
160 public function weforms_review_notice_message() {
161 // Show only to Admins
162 if ( !current_user_can( 'manage_options' ) ) {
163 return;
164 }
165
166 $dismiss_notice = get_option( 'weforms_review_notice_dismiss', 'no' );
167 $activation_time = get_option( 'weforms_installed' );
168 $total_entries = weforms_count_entries();
169
170 $args = [
171 'order' => 'DESC',
172 'orderby' => 'post_date',
173 ];
174
175 $contact_forms = weforms()->form->get_forms( $args );
176 $form_published = count( $contact_forms['forms'] );
177
178 // check if it has already been dismissed
179 // and don't show notice in 45 days of installation, 3888000 = 45 Days in seconds
180 if ( 'yes' == $dismiss_notice ) {
181 return;
182 }
183
184 if (
185 ( time() - $activation_time < 3888000 )
186 && $total_entries < 25
187 && $form_published < 3
188 ) {
189 return;
190 } ?>
191 <div id="weforms-review-notice" class="weforms-review-notice">
192 <div class="weforms-review-thumbnail">
193 <img src="<?php echo esc_attr( WEFORMS_ASSET_URI ) . '/images/icon-weforms.png' ?>" alt="">
194 </div>
195 <div class="weforms-review-text">
196 <?php if ( $total_entries >= 25 ) : ?>
197 <h3><?php wp_kses_post( __( 'Enjoying <strong>weForms</strong>?', 'weforms' ) ) ?></h3>
198 <p><?php wp_kses_post( __('Seems like you are getting a good response using <strong>weForms</strong>. Would you please show us a little love by rating us in the <a href="https://wordpress.org/support/plugin/weforms/reviews/#postform" target="_blank"><strong>WordPress.org</strong></a>?', 'weforms') ) ?></p>
199 <?php else: ?>
200 <h3><?php wp_kses_post( __( 'Enjoying <strong>weForms</strong>?', 'weforms' ) ) ?></h3>
201 <p><?php wp_kses_post( __( 'Hope that you had a neat and snappy experience with the tool. Would you please show us a little love by rating us in the <a href="https://wordpress.org/support/plugin/weforms/reviews/#postform" target="_blank"><strong>WordPress.org</strong></a>?', 'weforms' ) ) ?></p>
202 <?php endif; ?>
203
204 <ul class="weforms-review-ul">
205 <li><a href="https://wordpress.org/support/plugin/weforms/reviews/#postform" target="_blank"><span
206 class="dashicons dashicons-external"></span><?php esc_html_e( 'Sure! I\'d love to!', 'weforms' ) ?>
207 </a></li>
208 <li><a href="#" class="notice-dismiss"><span
209 class="dashicons dashicons-smiley"></span><?php esc_html_e( 'I\'ve already left a review', 'weforms' ) ?>
210 </a></li>
211 <li><a href="#" class="notice-dismiss"><span
212 class="dashicons dashicons-dismiss"></span><?php esc_html_e( 'Never show again', 'weforms' ) ?>
213 </a>
214 </li>
215 </ul>
216 </div>
217 </div>
218 <style type="text/css">
219 #weforms-review-notice .notice-dismiss {
220 padding: 0 0 0 26px;
221 }
222
223 #weforms-review-notice .notice-dismiss:before {
224 display: none;
225 }
226
227 #weforms-review-notice.weforms-review-notice {
228 padding: 15px 15px 15px 0;
229 background-color: #fff;
230 border-radius: 3px;
231 margin: 20px 20px 0 0;
232 border-left: 4px solid transparent;
233 }
234
235 #weforms-review-notice .weforms-review-thumbnail {
236 width: 114px;
237 float: left;
238 line-height: 80px;
239 text-align: center;
240 border-right: 4px solid transparent;
241 }
242
243 #weforms-review-notice .weforms-review-thumbnail img {
244 width: 60px;
245 vertical-align: middle;
246 }
247
248 #weforms-review-notice .weforms-review-text {
249 overflow: hidden;
250 }
251
252 #weforms-review-notice .weforms-review-text h3 {
253 font-size: 24px;
254 margin: 0 0 5px;
255 font-weight: 400;
256 line-height: 1.3;
257 }
258
259 #weforms-review-notice .weforms-review-text p {
260 font-size: 13px;
261 margin: 0 0 5px;
262 }
263
264 #weforms-review-notice .weforms-review-ul {
265 margin: 0;
266 padding: 0;
267 }
268
269 #weforms-review-notice .weforms-review-ul li {
270 display: inline-block;
271 margin-right: 15px;
272 }
273
274 #weforms-review-notice .weforms-review-ul li a {
275 display: inline-block;
276 color: #82C776;
277 text-decoration: none;
278 padding-left: 26px;
279 position: relative;
280 }
281
282 #weforms-review-notice .weforms-review-ul li a span {
283 position: absolute;
284 left: 0;
285 top: -2px;
286 }
287 </style>
288 <script type='text/javascript'>
289 jQuery('body').on('click', '#weforms-review-notice .notice-dismiss', function (e) {
290 e.preventDefault();
291 jQuery("#weforms-review-notice").hide();
292
293 wp.ajax.post('weforms-dismiss-review-notice', {
294 dismissed: true,
295 _wpnonce: '<?php echo esc_attr ( wp_create_nonce( 'weforms' ) ); ?>'
296 });
297 });
298 </script>
299 <?php
300 }
301
302 /**
303 * Dismiss promotion notice
304 *
305 * @return void
306 *
307 * @since 1.2.6
308 */
309 public function dismiss_promotional_offer() {
310 if( empty( $_POST['_wpnonce'] ) ) {
311 wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
312 }
313
314 if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'weforms' ) ) {
315 wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
316 }
317
318 if ( ! isset( $_POST['reason_id'] ) ) {
319 wp_send_json_error();
320 }
321
322 if ( ! empty( $_POST['dismissed'] ) ) {
323 $offer_key = 'weforms_promotional_offer_notice';
324 update_option( $offer_key, 'hide' );
325 }
326 }
327
328 /**
329 * Dismiss review notice
330 *
331 * @return void
332 *
333 **@since 1.3.5
334 */
335 public function dismiss_review_notice() {
336 if( empty( $_POST['_wpnonce'] ) ) {
337 wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
338 }
339
340 if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'weforms' ) ) {
341 wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
342 }
343
344 if ( ! empty( $_POST['dismissed'] ) ) {
345 update_option( 'weforms_review_notice_dismiss', 'yes' );
346 }
347 }
348 }
349