PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 3.0.4
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v3.0.4
3.1.9 3.1.8 3.1.7 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 trunk 1.3.7 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9 2.9.1 2.9.2
folders / includes / class-review-box.php
folders / includes Last commit date
class-affiliate.php 2 years ago class-polylang.php 2 years ago class-review-box.php 2 years ago class-upgrade-box.php 2 years ago class-wpml.php 2 years ago folders.class.php 1 year ago form.class.php 2 years ago media.replace.php 1 year ago plugins.class.php 2 years ago svg.class.php 1 year ago tree.class.php 2 years ago
class-review-box.php
734 lines
1 <?php
2 /**
3 * Review Class
4 *
5 * @author : Premio <contact@premio.io>
6 * @license : GPL2
7 * */
8
9 if (defined('ABSPATH') === false) {
10 exit;
11 }
12
13 class Folders_Free_Review_Box
14 {
15
16 /**
17 * The Name of this plugin.
18 *
19 * @var string $pluginName The Name of this plugin.
20 * @since 1.0.0
21 * @access public
22 */
23 public $pluginName = "Folders";
24
25 /**
26 * The Slug of this plugin.
27 *
28 * @var string $pluginSlug The Slug of this plugin.
29 * @since 1.0.0
30 * @access public
31 */
32 public $pluginSlug = "folders";
33
34 /**
35 * The Plugin review status.
36 *
37 * @var string $reviewStatus The Slug of this plugin.
38 * @since 1.0.0
39 * @access public
40 */
41 public $reviewStatus = true;
42
43 /**
44 * The plugin slug for WordPress
45 *
46 * @var string $wpPluginSlug The Slug of this plugin.
47 * @since 1.0.0
48 * @access public
49 */
50 public $wpPluginSlug = "folders";
51
52 /**
53 * Define the core functionality of the plugin.
54 *
55 * Set the plugin name and the plugin version that can be used throughout the plugin.
56 * Load the dependencies, define the locale, and set the hooks for the admin area and
57 * the public-facing side of the site.
58 *
59 * @since 1.0.0
60 */
61 public function __construct()
62 {
63 $isHidden = get_option( $this->pluginSlug . "_hide_review_box" );
64 if ( $isHidden !== false ) {
65 $this->reviewStatus = false;
66 }
67
68 $currentCount = get_option( $this->pluginSlug . "_show_review_box_after" );
69 if ( $currentCount === false ) {
70 $date = gmdate( "Y-m-d", strtotime( "+14 days" ) );
71 add_option( $this->pluginSlug . "_show_review_box_after", $date );
72 $this->reviewStatus = false;
73 }
74
75 $dateToShow = get_option( $this->pluginSlug . "_show_review_box_after" );
76 if ( $dateToShow !== false ) {
77 $currentDate = gmdate( "Y-m-d" );
78 if ( $currentDate < $dateToShow ) {
79 $this->reviewStatus = false;
80 }
81 }
82
83 //$this->reviewStatus = true;
84 $page_views = intval(get_option("get_folders_page_views"));
85 if($this->reviewStatus) {
86 add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
87 add_action('admin_notices', [$this, 'admin_notices']);
88 } else {
89 if($page_views == 1 || $page_views == 2) {
90 add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']);
91 }
92 }
93 add_action("wp_ajax_".$this->pluginSlug."_review_box", [$this, "form_review_box"]);
94 add_action("wp_ajax_".$this->pluginSlug."_review_box_message", [$this, "form_review_box_message"]);
95
96 }//end __construct()
97
98
99 public function enqueue_scripts() {
100 if (current_user_can('manage_options')) {
101 wp_enqueue_style($this->pluginSlug."-star-rating-svg", plugins_url('../assets/css/star-rating-svg.css', __FILE__), [], WCP_FOLDER_VERSION);
102 wp_enqueue_script($this->pluginSlug."-star-rating-svg", plugins_url('../assets/js/jquery.star-rating-svg.min.js', __FILE__), ['jquery'], WCP_FOLDER_VERSION, true);
103 wp_localize_script(
104 $this->pluginSlug."-star-rating-svg",
105 'pr_rating_settings',
106 ['has_settings' => 1]
107 );
108
109 }
110 }
111
112 /**
113 * Updates settings for Review Box Message
114 *
115 * @since 1.0.0
116 * @access public
117 * @return $status
118 */
119 public function form_review_box_message()
120 {
121 if (current_user_can('manage_options')) {
122 $nonce = filter_input(INPUT_POST, 'nonce');
123
124 if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_review_box_message")) {
125 add_option($this->pluginSlug."_hide_review_box", "1");
126 update_option("get_folders_page_views", -1);
127 $rating = filter_input(INPUT_POST, 'rating');
128 $message = filter_input(INPUT_POST, 'message');
129
130 global $current_user;
131 $postMessage = [];
132
133 $domain = site_url();
134 $user_name = $current_user->first_name." ".$current_user->last_name;
135 $email = $current_user->user_email;
136
137 $messageData = [];
138 $messageData['key'] = "email";
139 $messageData['value'] = $email;
140 $postMessage[] = $messageData;
141
142 $messageData = [];
143 $messageData['key'] = "stars";
144 $messageData['value'] = $rating;
145 $postMessage[] = $messageData;
146
147 $messageData = [];
148 $messageData['key'] = "message";
149 $messageData['value'] = $message;
150 $postMessage[] = $messageData;
151
152 $apiParams = [
153 'title' => 'Review for '.$this->pluginName.' WordPress',
154 'domain' => $domain,
155 'email' => "contact@premio.io",
156 'url' => site_url(),
157 'name' => $user_name,
158 'message' => $postMessage,
159 'plugin' => $this->pluginName,
160 'type' => "Review",
161 ];
162
163 // Sending message to Crisp API
164 $apiResponse = wp_safe_remote_post("https://premioapps.com/premio/send-feedback-api.php", ['body' => $apiParams, 'timeout' => 15, 'sslverify' => true]);
165
166 if (is_wp_error($apiResponse)) {
167 wp_safe_remote_post("https://premioapps.com/premio/send-feedback-api.php", ['body' => $apiParams, 'timeout' => 15, 'sslverify' => false]);
168 }
169 }
170 die;
171 }
172
173 }//end form_review_box_message()
174
175 /**
176 * Updates settings for Review Box
177 *
178 * @since 1.0.0
179 * @access public
180 * @return status
181 */
182 public function form_review_box()
183 {
184 if (current_user_can('manage_options')) {
185 $nonce = esc_attr(filter_input(INPUT_POST, 'nonce'));
186 $days = esc_attr(filter_input(INPUT_POST, 'days'));
187 if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_review_box")) {
188 update_option("get_folders_page_views", 4);
189 if ($days == -1) {
190 add_option($this->pluginSlug."_hide_review_box", "1");
191 update_option("get_folders_page_views", -1);
192 } else {
193 $date = gmdate("Y-m-d", strtotime("+".$days." days"));
194 update_option($this->pluginSlug."_show_review_box_after", $date);
195 }
196 }
197 die;
198 }
199 }//end form_review_box()
200
201
202 /**
203 * Show Review HTML
204 *
205 * @since 1.0.0
206 * @access public
207 * @return html
208 */
209 public function admin_notices()
210 {
211 if (!current_user_can('manage_options')) {
212 return;
213 }
214 ?>
215
216 <!-- premio default review box -->
217 <div class="notice notice-info premio-notice <?php echo esc_attr($this->pluginSlug) ?>-premio-review-box">
218
219 <!-- premio review box default -->
220 <style id="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default-stylesheet">
221 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box {
222 position: relative;
223 border-left-color: #B78DEB;
224 padding: 18px 25px 18px 15px !important;
225 }
226
227 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__title {
228 color: #000000;
229 font-size: 18px;
230 line-height: 27px;
231 font-weight: 600;
232 font-family: 'Arial';
233 margin: 0;
234 }
235
236 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__title span{
237 color: #B78DEB;
238 }
239
240 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default p {
241 color: #595959;
242 line-height: 21px;
243 vertical-align: middle;
244 padding: 0 10px 7px 0;
245 font-size: 14px;
246 }
247
248 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-default__dismiss-btn {
249 position: absolute;
250 right: 5px;
251 top: 5px;
252 opacity: .6;
253 border: 0;
254 padding: 0;
255 background-color: transparent;
256 cursor: pointer;
257 }
258
259 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-default__dismiss-btn:hover {
260 opacity: 1;
261 }
262
263 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder {
264 display: inline-flex;
265 align-items: center;
266 gap: 15px;
267 }
268
269 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder-img {
270 width: 30px;
271 height: 30px;
272 display: inline-block;
273 vertical-align: middle;
274 border-radius: 15px;
275 }
276 </style>
277
278 <!-- premio review box thank you -->
279 <style id="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you-stylesheet">
280 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you {
281 display: none;
282 }
283 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you .thanks-wrap {
284 display: inline-flex;
285 gap: 12px;
286 align-items: center;
287 flex-wrap: wrap;
288 }
289 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__dismiss-btn {
290 position: absolute;
291 top: 5px;
292 right: 5px;
293 opacity: .6;
294 border: 0;
295 padding: 0;
296 background-color: transparent;
297 cursor: pointer;
298 }
299
300 <?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__dismiss-btn:hover {
301 opacity: 1;
302 }
303
304 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__image {
305 width: 100%;
306 height: auto;
307 max-width: 200px;
308 }
309
310 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message .title {
311 font-weight: bold;
312 font-size: 18px;
313 }
314
315 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message .desc {
316 padding: 8px 0;
317 }
318
319 .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message .footer {
320 font-weight: bold;
321 }
322
323 </style>
324
325 <!-- review box popup stylesheet-->
326 <style id="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup-stylesheet">
327
328 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup {
329 position: fixed;
330 width: 100%;
331 height: 100%;
332 z-index: 10001;
333 background: rgba(0, 0, 0, 0.65);
334 top: 0;
335 left: 0;
336 display: none;
337 }
338
339 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__dismiss-btn {
340 position: absolute;
341 right: 5px;
342 top: 5px;
343 opacity: .6;
344 border: 0;
345 padding: 0;
346 background-color: transparent;
347 cursor: pointer;
348 }
349
350 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__dismiss-btn:hover {
351 opacity: 1;
352 }
353
354 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__content {
355 background: #ffffff;
356 padding: 20px;
357 position: absolute;
358 max-width: 450px;
359 width: 100%;
360 margin: 0 auto;
361 top: 45%;
362 left: 0;
363 right: 0;
364 -webkit-border-radius: 5px;
365 -moz-border-radius: 5px;
366 border-radius: 5px;
367 }
368
369 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__title {
370 padding: 0 0 10px 0;
371 font-weight: bold;
372 }
373
374 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options a {
375 display: block;
376 margin: 10px 0 5px 0;
377 color: #333;
378 text-decoration: none;
379 }
380
381 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options .dismiss {
382 color: #999;
383 }
384 </style>
385
386 <!-- feedback popup stylesheet-->
387 <style id="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup-stylesheet">
388
389 .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup {
390 position: fixed;
391 width: 100%;
392 height: 100%;
393 z-index: 10001;
394 background: rgba(0, 0, 0, 0.65);
395 top: 0;
396 left: 0;
397 display: none;
398 }
399
400 .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__dismiss-btn {
401 position: absolute;
402 right: 5px;
403 top: 5px;
404 opacity: .6;
405 border: 0;
406 padding: 0;
407 background-color: transparent;
408 cursor: pointer;
409 }
410
411 .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__dismiss-btn:hover {
412 opacity: 1;
413 }
414
415 .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__content {
416 background: #ffffff;
417 padding: 20px;
418 position: absolute;
419 max-width: 450px;
420 width: 100%;
421 margin: 0 auto;
422 top: 50%;
423 transform: translateY(-50%);
424 left: 0;
425 right: 0;
426 -webkit-border-radius: 5px;
427 -moz-border-radius: 5px;
428 border-radius: 5px;
429 }
430
431 .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form {
432 display: flex;
433 flex-direction: column;
434 gap: 10px;
435 }
436
437 .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form textarea {
438 padding: 10px;
439 margin-top: 15px;
440 }
441
442 .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form button {
443 border: none;
444 padding: 10px 0;
445 width: 100%;
446 background: #ff6624;
447 color: #fff;
448 border-radius: 4px;
449 cursor: pointer;
450 display: inline-block;
451 }
452
453 .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options .dismiss {
454 color: #999;
455 }
456 .please-rate-us {
457 padding: 10px 0 0;
458 }
459 .please-rate-us .rate-us-title {
460 vertical-align: middle;
461 }
462 .please-rate-us .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__rating {
463 vertical-align: middle;
464 }
465 </style>
466
467 <!-- default layout -->
468 <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default">
469 <h2 class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__title">
470 <?php esc_html_e('Your', 'folders') ?> <span><?php esc_html_e('feedback', 'folders') ?></span> <?php esc_html_e('matters, please leave a review', 'folders') ?> 🙏
471 </h2>
472
473 <button class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-default__dismiss-btn">
474 <span class="dashicons dashicons-no-alt"></span>
475 </button>
476
477 <p><?php
478 $message = esc_html__("Hi there, it seems like %1\$s is bringing you some value, and that's pretty awesome! Can you please show us some love and rate %2\$s on WordPress? It'll only take 2 minutes of your time, and will really help us spread the word", 'folders');
479 printf(esc_attr($message), "<b>".esc_attr($this->pluginName)."</b>", esc_attr($this->pluginName));?></p>
480
481 <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder">
482 <span>
483 <b><?php esc_html_e('Gal Dubinski', 'folders') ?></b>,
484 <?php esc_html_e('Co-founder', 'folders') ?>
485 </span>
486 <img class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder-img" width="30" height="30" src="<?php echo esc_url(WCP_FOLDER_URL."assets/images/owner.jpg") ?>" />
487 </div>
488
489 <div class="please-rate-us">
490 <div class="rate-us-title"><?php esc_html_e("Please rate us:"); ?></div>
491 <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__rating"></div>
492 </div>
493 </div> <!--end .premio-review-box__default-->
494
495 <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you">
496 <div class="thanks-wrap">
497 <button class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__dismiss-btn">
498 <span class="dashicons dashicons-no-alt"></span>
499 </button>
500
501 <img class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__image" width="200" src="<?php echo esc_url(WCP_FOLDER_URL."assets/images/thanks.gif") ?>" />
502
503 <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message">
504 <div class="title"><?php esc_html_e("You are awesome ", 'folders')?> &#128591;</div>
505 <div class="desc"><?php esc_html_e("Thanks for your support, we really appreciate it!", 'folders')?></div>
506 <div class="footer"><?php esc_html_e("Premio team ", 'folders')?></div>
507 </div>
508 </div>
509 </div> <!--end .premio-review-box__thank-you-->
510
511 <!-- review popup -->
512 <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup">
513 <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__content">
514 <button class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__dismiss-btn">
515 <span class="dashicons dashicons-no-alt"></span>
516 </button>
517 <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__title">
518 <?php esc_html_e("Would you like us to remind you about this later?", 'folders')?>
519 </div>
520
521 <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options">
522 <a href="#" data-days="3"><?php esc_html_e("Remind me in 3 days ", 'folders')?></a>
523 <a href="#" data-days="10"><?php esc_html_e("Remind me in 10 days ", 'folders')?></a>
524 <a href="#" data-days="-1" class="dismiss"><?php esc_html_e("Don't remind me about this ", 'folders')?></a>
525 </div>
526 </div>
527 </div> <!--end .review-box-popup-->
528
529 <!-- feedback popup -->
530 <div class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup">
531 <div class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__content">
532 <button class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__dismiss-btn">
533 <span class="dashicons dashicons-no-alt"></span>
534 </button>
535 <form class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form">
536 <textarea name="message" id="message" cols="30" rows="5" placeholder="What's your feedback?"></textarea>
537 <button id="submit-btn" type="submit"><?php esc_html_e('Submit', 'folders') ?></button>
538 </form>
539 </div>
540 </div> <!--end .feedback-popup-->
541
542 </div> <!--end .premio-notice-->
543
544 <script>
545 (function($) {
546
547 $(document).ready(function() {
548 function FoldersFreeReview() {
549 this.prefix = "<?php echo esc_attr($this->pluginSlug) ?>";
550 this.reviewLink = "https://wordpress.org/support/plugin/<?php echo esc_attr($this->wpPluginSlug) ?>/reviews/?filter=5";
551 this.rating = 5;
552
553 this.renderRating();
554 this.bindEvents();
555 }
556
557 FoldersFreeReview.prototype.getSelectors = function () {
558 return {
559 body: 'body',
560 rating: `.${this.prefix}-premio-review-box__default__rating`,
561 reviewBox: `.${this.prefix}-premio-review-box`,
562 feedbackForm: `.${this.prefix}-feedback-popup__form`,
563 reminderPopup: `.${this.prefix}-review-box-popup`,
564 feedbackPopup: `.${this.prefix}-feedback-popup`,
565 reviewBoxDefault: `.${this.prefix}-premio-review-box__default`,
566 reviewBoxThankYou: `.${this.prefix}-premio-review-box__thank-you`,
567 defaultDismissBtn: `.${this.prefix}-review-box-default__dismiss-btn`,
568 thankYouDismissBtn: `.${this.prefix}-premio-review-box__thank-you__dismiss-btn`,
569 feedbackDismissBtn: `.${this.prefix}-feedback-popup__dismiss-btn`,
570 reminderPopupOptions: `.${this.prefix}-review-box-popup__options a`,
571 reminderPopupDismissBtn: `.${this.prefix}-review-box-popup__dismiss-btn`,
572 }
573 }
574
575 FoldersFreeReview.prototype.getElements = function () {
576 const selectors = this.getSelectors();
577 return {
578 $body: $(selectors.body),
579 $rating: $(selectors.rating),
580 $reviewBox: $(selectors.reviewBox),
581 $feedbackForm: $(selectors.feedbackForm),
582 $reminderPopup: $(selectors.reminderPopup),
583 $feedbackPopup: $(selectors.feedbackPopup),
584 $reviewBoxDefault: $(selectors.reviewBoxDefault),
585 $reviewBoxThankYou: $(selectors.reviewBoxThankYou),
586 $defaultDismissBtn: $(selectors.defaultDismissBtn),
587 $thankYouDismissBtn: $(selectors.thankYouDismissBtn),
588 $feedbackDismissBtn: $(selectors.feedbackDismissBtn),
589 $reminderPopupOptions: $(selectors.reminderPopupOptions),
590 $reminderPopupDismissBtn: $(selectors.reminderPopupDismissBtn)
591 }
592 }
593
594 FoldersFreeReview.prototype.bindEvents = function () {
595 const elements = this.getElements();
596 const selectors = this.getSelectors();
597
598 elements.$body.addClass("has-premio-box");
599 elements.$defaultDismissBtn.on('click', this.toggleReminderPopup.bind(elements));
600 elements.$reminderPopupDismissBtn.on('click', this.toggleReminderPopup.bind(elements, false));
601 elements.$reminderPopupOptions.on('click', this.reminderHandler.bind(this));
602 elements.$thankYouDismissBtn.on('click', this.thankYouDismissHandler.bind(this));
603 elements.$feedbackDismissBtn.on('click', this.feedbackToggle.bind(this, false));
604 elements.$feedbackForm.on('submit', this.feedbackFormHandler.bind(this));
605
606 //close reminder/feedback popup when click outside
607 $(window).on('click', ev => {
608 const $target = $(ev.target);
609 if (
610 elements.$reminderPopup.hasClass('open') &&
611 $target.parents(selectors.reminderPopup).length === 0
612 ) {
613 elements.$reminderPopupDismissBtn.trigger('click');
614 }
615
616 if (
617 elements.$feedbackPopup.hasClass('open') &&
618 $target.parents(selectors.feedbackPopup).length === 0
619 ) {
620 elements.$feedbackDismissBtn.trigger('click');
621 }
622 })
623 }
624
625 FoldersFreeReview.prototype.feedbackFormHandler = function (ev) {
626 ev.preventDefault();
627 const elements = this.getElements();
628 const message = elements.$feedbackForm.find('#message').val();
629 const rating = this.rating;
630
631 $.ajax({
632 url: "<?php echo esc_url(admin_url("admin-ajax.php")) ?>",
633 data: {
634 action: "<?php echo esc_attr($this->pluginSlug) ?>_review_box_message",
635 rating: rating,
636 nonce: "<?php echo esc_attr(wp_create_nonce($this->pluginSlug . "_review_box_message")) ?>",
637 message: message
638 },
639 type: "post",
640 });
641 elements.$feedbackDismissBtn.trigger('click');
642 elements.$reviewBox.remove();
643 elements.$reminderPopup.remove();
644 // send hide request after submitting feedback form
645 this.sendHideRequest(-1);
646 }
647
648 FoldersFreeReview.prototype.thankYouDismissHandler = function () {
649 const elements = this.getElements();
650 elements.$reviewBox.remove();
651 elements.$reminderPopup.remove();
652 this.sendHideRequest(-1);
653 }
654
655 FoldersFreeReview.prototype.reminderHandler = function (ev) {
656 ev.preventDefault();
657 const dataDays = $(ev.target).data("days");
658 const elements = this.getElements();
659
660 elements.$body.removeClass("has-premio-box");
661 elements.$reminderPopupDismissBtn.trigger('click');
662 elements.$reviewBox.remove();
663 this.sendHideRequest(dataDays);
664 }
665
666 FoldersFreeReview.prototype.sendHideRequest = function (dataDays = -1) {
667 $.ajax({
668 url: "<?php echo esc_url(admin_url("admin-ajax.php")) ?>",
669 data: "action=<?php echo esc_attr($this->pluginSlug) ?>_review_box&days=" + dataDays + "&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug . "_review_box")) ?>",
670 type: "post",
671 });
672 }
673
674 FoldersFreeReview.prototype.toggleReminderPopup = function (action = true) {
675 if (action) {
676 this.$reminderPopup.fadeIn(200, function () {
677 $(this).addClass('open')
678 });
679 } else {
680 this.$reminderPopup.fadeOut(200).removeClass('open');
681 }
682 }
683
684 FoldersFreeReview.prototype.feedbackToggle = function (action = true) {
685 const elements = this.getElements();
686 if (action) {
687 elements.$feedbackPopup.fadeIn(200, function () {
688 $(this).addClass('open')
689 });
690 } else {
691 elements.$rating.starRating('unload');
692 elements.$reviewBoxDefault.append(`<div class="${this.prefix}-premio-review-box__default__rating"></div>`)
693 elements.$feedbackPopup.fadeOut(200).removeClass('open');
694 this.renderRating();
695 }
696 }
697
698 FoldersFreeReview.prototype.renderRating = function () {
699 const self = this;
700 const elements = self.getElements();
701 elements.$rating.starRating({
702 initialRating: self.rating,
703 useFullStars: true,
704 strokeColor: '#894A00',
705 strokeWidth: 10,
706 minRating: 1,
707 starSize: 25,
708 callback(currentRate) {
709 if (currentRate !== 5) {
710 self.rating = currentRate;
711 self.feedbackToggle(true);
712 } else {
713 elements.$reviewBoxDefault.hide();
714 elements.$reviewBoxThankYou.show();
715 window.open(self.reviewLink, '_blank');
716 self.sendHideRequest(-1);
717 }
718 }
719 })
720 }
721
722 new FoldersFreeReview();
723 });
724
725 })( jQuery )
726 </script>
727 <?php
728
729 }//end admin_notices()
730
731 }//end class
732
733 $Folders_Free_Review_Box = new Folders_Free_Review_Box();
734