mystickymenu
Last commit date
admin
9 months ago
css
1 year ago
fonts
4 years ago
images
1 year ago
js
9 months ago
languages
2 years ago
class-email-signup.php
1 year ago
class-help.php
1 year ago
class-review-box.php
1 year ago
class-upgrade-box.php
9 months ago
index.php
8 years ago
mystickymenu-admin-widgetanalytics.php
1 year ago
mystickymenu-affiliate.php
9 months ago
mystickymenu-contact-leads.php
1 year ago
mystickymenu-deactivate-form.php
1 year ago
mystickymenu-fonts.php
2 years ago
mystickymenu-popup.php
1 year ago
mystickymenu-review-popup.php
9 months ago
mystickymenu.php
9 months ago
mystickymeny-new-welcomebar.php
1 year ago
readme.txt
8 months ago
recommended-plugins.php
1 year ago
stickymenu-dashboard.php
9 months ago
uninstall.php
2 years ago
upgrade-to-pro.php
1 year ago
welcome-bar.php
9 months ago
class-review-box.php
718 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 myStickyMenu_Pro_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 = "My Sticky Bar"; |
| 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 = "my-sticky-menu"; |
| 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 = "mystickymenu"; |
| 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 = date( "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 = date( "Y-m-d" ); |
| 78 | if ( $currentDate < $dateToShow ) { |
| 79 | $this->reviewStatus = false; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // $this->reviewStatus = true; |
| 84 | if($this->reviewStatus) { |
| 85 | add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']); |
| 86 | add_action('admin_notices', [$this, 'admin_notices']); |
| 87 | } |
| 88 | add_action("wp_ajax_".$this->pluginSlug."_review_box", [$this, "form_review_box"]); |
| 89 | add_action("wp_ajax_".$this->pluginSlug."_review_box_message", [$this, "form_review_box_message"]); |
| 90 | |
| 91 | |
| 92 | }//end __construct() |
| 93 | |
| 94 | public function enqueue_scripts() { |
| 95 | if (current_user_can('manage_options')) { |
| 96 | wp_enqueue_style($this->pluginSlug."-star-rating-svg", plugins_url('css/star-rating-svg.css', __FILE__), [], MYSTICKY_VERSION); |
| 97 | wp_enqueue_script($this->pluginSlug."-star-rating-svg", plugins_url('js/jquery.star-rating-svg.min.js', __FILE__), ['jquery'], MYSTICKY_VERSION, true); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Updates settings for Review Box Message |
| 103 | * |
| 104 | * @since 1.0.0 |
| 105 | * @access public |
| 106 | * @return status |
| 107 | */ |
| 108 | public function form_review_box_message() |
| 109 | { |
| 110 | if (current_user_can('manage_options')) { |
| 111 | $nonce = filter_input(INPUT_POST, 'nonce'); |
| 112 | |
| 113 | if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_review_box_message")) { |
| 114 | add_option($this->pluginSlug."_hide_review_box", "1"); |
| 115 | $rating = filter_input(INPUT_POST, 'rating'); |
| 116 | $message = filter_input(INPUT_POST, 'message'); |
| 117 | |
| 118 | global $current_user; |
| 119 | $postMessage = []; |
| 120 | |
| 121 | $domain = site_url(); |
| 122 | $user_name = $current_user->first_name." ".$current_user->last_name; |
| 123 | $email = $current_user->user_email; |
| 124 | |
| 125 | $messageData = []; |
| 126 | $messageData['key'] = "email"; |
| 127 | $messageData['value'] = $email; |
| 128 | $postMessage[] = $messageData; |
| 129 | |
| 130 | $messageData = []; |
| 131 | $messageData['key'] = "stars"; |
| 132 | $messageData['value'] = $rating; |
| 133 | $postMessage[] = $messageData; |
| 134 | |
| 135 | $messageData = []; |
| 136 | $messageData['key'] = "message"; |
| 137 | $messageData['value'] = $message; |
| 138 | $postMessage[] = $messageData; |
| 139 | |
| 140 | $apiParams = [ |
| 141 | 'title' => 'Review for '.$this->pluginName.' WordPress', |
| 142 | 'domain' => $domain, |
| 143 | 'email' => "contact@premio.io", |
| 144 | 'url' => site_url(), |
| 145 | 'name' => $user_name, |
| 146 | 'message' => $postMessage, |
| 147 | 'plugin' => $this->pluginName, |
| 148 | 'type' => "Review", |
| 149 | ]; |
| 150 | |
| 151 | // Sending message to Crisp API |
| 152 | $apiResponse = wp_safe_remote_post("https://premioapps.com/premio/send-feedback-api.php", ['body' => $apiParams, 'timeout' => 15, 'sslverify' => true]); |
| 153 | |
| 154 | if (is_wp_error($apiResponse)) { |
| 155 | wp_safe_remote_post("https://premioapps.com/premio/send-feedback-api.php", ['body' => $apiParams, 'timeout' => 15, 'sslverify' => false]); |
| 156 | } |
| 157 | } |
| 158 | die; |
| 159 | } |
| 160 | |
| 161 | }//end form_review_box_message() |
| 162 | |
| 163 | /** |
| 164 | * Updates settings for Review Box |
| 165 | * |
| 166 | * @since 1.0.0 |
| 167 | * @access public |
| 168 | * @return status |
| 169 | */ |
| 170 | public function form_review_box() |
| 171 | { |
| 172 | if (current_user_can('manage_options')) { |
| 173 | $nonce = filter_input(INPUT_POST, 'nonce'); |
| 174 | $days = filter_input(INPUT_POST, 'days'); |
| 175 | if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_review_box")) { |
| 176 | if ($days == -1) { |
| 177 | add_option($this->pluginSlug."_hide_review_box", "1"); |
| 178 | } else { |
| 179 | $date = date("Y-m-d", strtotime("+".$days." days")); |
| 180 | update_option($this->pluginSlug."_show_review_box_after", $date); |
| 181 | } |
| 182 | } |
| 183 | die; |
| 184 | } |
| 185 | |
| 186 | }//end form_review_box() |
| 187 | |
| 188 | |
| 189 | /** |
| 190 | * Show Review HTML |
| 191 | * |
| 192 | * @since 1.0.0 |
| 193 | * @access public |
| 194 | * @return html |
| 195 | */ |
| 196 | public function admin_notices() |
| 197 | { |
| 198 | if (!current_user_can('manage_options')) { |
| 199 | return; |
| 200 | } |
| 201 | ?> |
| 202 | |
| 203 | <!-- premio default review box --> |
| 204 | <div class="notice notice-info premio-notice <?php echo esc_attr($this->pluginSlug) ?>-premio-review-box"> |
| 205 | |
| 206 | <!-- premio review box default --> |
| 207 | <style id="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default-stylesheet"> |
| 208 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box { |
| 209 | position: relative; |
| 210 | border-left-color: #B78DEB; |
| 211 | padding: 18px 25px 18px 15px !important; |
| 212 | } |
| 213 | |
| 214 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__title { |
| 215 | color: #000000; |
| 216 | font-size: 18px; |
| 217 | line-height: 27px; |
| 218 | font-weight: 600; |
| 219 | font-family: 'Arial'; |
| 220 | margin: 0; |
| 221 | } |
| 222 | |
| 223 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__title span{ |
| 224 | color: #B78DEB; |
| 225 | } |
| 226 | |
| 227 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default p { |
| 228 | color: #595959; |
| 229 | line-height: 21px; |
| 230 | vertical-align: middle; |
| 231 | padding: 0 10px 7px 0; |
| 232 | font-size: 14px; |
| 233 | } |
| 234 | |
| 235 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-default__dismiss-btn { |
| 236 | position: absolute; |
| 237 | right: 5px; |
| 238 | top: 5px; |
| 239 | opacity: .6; |
| 240 | border: 0; |
| 241 | padding: 0; |
| 242 | background-color: transparent; |
| 243 | cursor: pointer; |
| 244 | } |
| 245 | |
| 246 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-default__dismiss-btn:hover { |
| 247 | opacity: 1; |
| 248 | } |
| 249 | |
| 250 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder { |
| 251 | display: inline-flex; |
| 252 | align-items: center; |
| 253 | gap: 15px; |
| 254 | } |
| 255 | |
| 256 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder-img { |
| 257 | width: 30px; |
| 258 | height: 30px; |
| 259 | display: inline-block; |
| 260 | vertical-align: middle; |
| 261 | border-radius: 15px; |
| 262 | } |
| 263 | </style> |
| 264 | |
| 265 | <!-- premio review box thank you --> |
| 266 | <style id="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you-stylesheet"> |
| 267 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you { |
| 268 | display: none; |
| 269 | } |
| 270 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you .thanks-wrap { |
| 271 | display: inline-flex; |
| 272 | gap: 12px; |
| 273 | align-items: center; |
| 274 | flex-wrap: wrap; |
| 275 | } |
| 276 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__dismiss-btn { |
| 277 | position: absolute; |
| 278 | top: 5px; |
| 279 | right: 5px; |
| 280 | opacity: .6; |
| 281 | border: 0; |
| 282 | padding: 0; |
| 283 | background-color: transparent; |
| 284 | cursor: pointer; |
| 285 | } |
| 286 | |
| 287 | <?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__dismiss-btn:hover { |
| 288 | opacity: 1; |
| 289 | } |
| 290 | |
| 291 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__image { |
| 292 | width: 100%; |
| 293 | height: auto; |
| 294 | max-width: 200px; |
| 295 | } |
| 296 | |
| 297 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message .title { |
| 298 | font-weight: bold; |
| 299 | font-size: 18px; |
| 300 | } |
| 301 | |
| 302 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message .desc { |
| 303 | padding: 8px 0; |
| 304 | } |
| 305 | |
| 306 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message .footer { |
| 307 | font-weight: bold; |
| 308 | } |
| 309 | |
| 310 | </style> |
| 311 | |
| 312 | <!-- review box popup stylesheet--> |
| 313 | <style id="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup-stylesheet"> |
| 314 | |
| 315 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup { |
| 316 | position: fixed; |
| 317 | width: 100%; |
| 318 | height: 100%; |
| 319 | z-index: 10001; |
| 320 | background: rgba(0, 0, 0, 0.65); |
| 321 | top: 0; |
| 322 | left: 0; |
| 323 | display: none; |
| 324 | } |
| 325 | |
| 326 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__dismiss-btn { |
| 327 | position: absolute; |
| 328 | right: 5px; |
| 329 | top: 5px; |
| 330 | opacity: .6; |
| 331 | border: 0; |
| 332 | padding: 0; |
| 333 | background-color: transparent; |
| 334 | cursor: pointer; |
| 335 | } |
| 336 | |
| 337 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__dismiss-btn:hover { |
| 338 | opacity: 1; |
| 339 | } |
| 340 | |
| 341 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__content { |
| 342 | background: #ffffff; |
| 343 | padding: 20px; |
| 344 | position: absolute; |
| 345 | max-width: 450px; |
| 346 | width: 100%; |
| 347 | margin: 0 auto; |
| 348 | top: 45%; |
| 349 | left: 0; |
| 350 | right: 0; |
| 351 | -webkit-border-radius: 5px; |
| 352 | -moz-border-radius: 5px; |
| 353 | border-radius: 5px; |
| 354 | } |
| 355 | |
| 356 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__title { |
| 357 | padding: 0 0 10px 0; |
| 358 | font-weight: bold; |
| 359 | } |
| 360 | |
| 361 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options a { |
| 362 | display: block; |
| 363 | margin: 10px 0 5px 0; |
| 364 | color: #333; |
| 365 | text-decoration: none; |
| 366 | } |
| 367 | |
| 368 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options .dismiss { |
| 369 | color: #999; |
| 370 | } |
| 371 | </style> |
| 372 | |
| 373 | <!-- feedback popup stylesheet--> |
| 374 | <style id="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup-stylesheet"> |
| 375 | |
| 376 | .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup { |
| 377 | position: fixed; |
| 378 | width: 100%; |
| 379 | height: 100%; |
| 380 | z-index: 10001; |
| 381 | background: rgba(0, 0, 0, 0.65); |
| 382 | top: 0; |
| 383 | left: 0; |
| 384 | display: none; |
| 385 | } |
| 386 | |
| 387 | .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__dismiss-btn { |
| 388 | position: absolute; |
| 389 | right: 5px; |
| 390 | top: 5px; |
| 391 | opacity: .6; |
| 392 | border: 0; |
| 393 | padding: 0; |
| 394 | background-color: transparent; |
| 395 | cursor: pointer; |
| 396 | } |
| 397 | |
| 398 | .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__dismiss-btn:hover { |
| 399 | opacity: 1; |
| 400 | } |
| 401 | |
| 402 | .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__content { |
| 403 | background: #ffffff; |
| 404 | padding: 20px; |
| 405 | position: absolute; |
| 406 | max-width: 450px; |
| 407 | width: 100%; |
| 408 | margin: 0 auto; |
| 409 | top: 50%; |
| 410 | transform: translateY(-50%); |
| 411 | left: 0; |
| 412 | right: 0; |
| 413 | -webkit-border-radius: 5px; |
| 414 | -moz-border-radius: 5px; |
| 415 | border-radius: 5px; |
| 416 | } |
| 417 | |
| 418 | .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form { |
| 419 | display: flex; |
| 420 | flex-direction: column; |
| 421 | gap: 10px; |
| 422 | } |
| 423 | |
| 424 | .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form textarea { |
| 425 | padding: 10px; |
| 426 | margin-top: 15px; |
| 427 | } |
| 428 | |
| 429 | .<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form button { |
| 430 | border: none; |
| 431 | padding: 10px 0; |
| 432 | width: 100%; |
| 433 | background: #ff6624; |
| 434 | color: #fff; |
| 435 | border-radius: 4px; |
| 436 | cursor: pointer; |
| 437 | display: inline-block; |
| 438 | } |
| 439 | |
| 440 | .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options .dismiss { |
| 441 | color: #999; |
| 442 | } |
| 443 | .please-rate-us { |
| 444 | padding: 10px 0 0; |
| 445 | } |
| 446 | .please-rate-us .rate-us-title { |
| 447 | vertical-align: middle; |
| 448 | } |
| 449 | .please-rate-us .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__rating { |
| 450 | vertical-align: middle; |
| 451 | } |
| 452 | </style> |
| 453 | |
| 454 | <!-- default layout --> |
| 455 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default"> |
| 456 | <h2 class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__title"> |
| 457 | <?php esc_html_e('Your', 'mystickymenu') ?> <span><?php esc_html_e('feedback', 'mystickymenu') ?></span> <?php esc_html_e('matters, please leave a review', 'mystickymenu') ?> 🙏 |
| 458 | </h2> |
| 459 | |
| 460 | <button class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-default__dismiss-btn"> |
| 461 | <span class="dashicons dashicons-no-alt"></span> |
| 462 | </button> |
| 463 | |
| 464 | <p><?php printf( 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", 'mystickymenu'), "<b>". esc_html($this->pluginName) ."</b>", esc_html($this->pluginName) );?></p> |
| 465 | |
| 466 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder"> |
| 467 | <span> |
| 468 | <b><?php esc_html_e('Gal Dubinski', 'mystickymenu') ?></b>, |
| 469 | <?php esc_html_e('Co-founder', 'mystickymenu') ?> |
| 470 | </span> |
| 471 | <img class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__co-founder-img" width="30" height="30" src="<?php echo esc_url(MYSTICKYMENU_URL."images/premio-owner.png") ?>" /> |
| 472 | </div> |
| 473 | |
| 474 | <div class="please-rate-us"> |
| 475 | <div class="rate-us-title"><?php esc_html_e("Please rate us:"); ?></div> |
| 476 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__default__rating"></div> |
| 477 | </div> |
| 478 | </div> <!--end .premio-review-box__default--> |
| 479 | |
| 480 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you"> |
| 481 | <div class="thanks-wrap"> |
| 482 | <button class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__dismiss-btn"> |
| 483 | <span class="dashicons dashicons-no-alt"></span> |
| 484 | </button> |
| 485 | |
| 486 | <img class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__image" width="200" src="<?php echo esc_url(MYSTICKYMENU_URL."images/thanks.gif") ?>" /> |
| 487 | |
| 488 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box__thank-you__message"> |
| 489 | <div class="title"><?php esc_html_e("You are awesome ", 'mystickymenu')?> 🙏</div> |
| 490 | <div class="desc"><?php esc_html_e("Thanks for your support, we really appreciate it!", 'mystickymenu')?></div> |
| 491 | <div class="footer"><?php esc_html_e("Premio team ", 'mystickymenu')?></div> |
| 492 | </div> |
| 493 | </div> |
| 494 | </div> <!--end .premio-review-box__thank-you--> |
| 495 | |
| 496 | <!-- review popup --> |
| 497 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup"> |
| 498 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__content"> |
| 499 | <button class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__dismiss-btn"> |
| 500 | <span class="dashicons dashicons-no-alt"></span> |
| 501 | </button> |
| 502 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__title"> |
| 503 | <?php esc_html_e("Would you like us to remind you about this later?", 'mystickymenu')?> |
| 504 | </div> |
| 505 | |
| 506 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup__options"> |
| 507 | <a href="#" data-days="3"><?php esc_html_e("Remind me in 3 days ", 'mystickymenu')?></a> |
| 508 | <a href="#" data-days="10"><?php esc_html_e("Remind me in 10 days ", 'mystickymenu')?></a> |
| 509 | <a href="#" data-days="-1" class="dismiss"><?php esc_html_e("Don't remind me about this ", 'mystickymenu')?></a> |
| 510 | </div> |
| 511 | </div> |
| 512 | </div> <!--end .review-box-popup--> |
| 513 | |
| 514 | <!-- feedback popup --> |
| 515 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup"> |
| 516 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__content"> |
| 517 | <button class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__dismiss-btn"> |
| 518 | <span class="dashicons dashicons-no-alt"></span> |
| 519 | </button> |
| 520 | <form class="<?php echo esc_attr($this->pluginSlug) ?>-feedback-popup__form"> |
| 521 | <textarea name="message" id="message" cols="30" rows="5" placeholder="What's your feedback?"></textarea> |
| 522 | <button id="submit-btn" type="submit"><?php esc_html_e('Submit', 'mystickymenu') ?></button> |
| 523 | </form> |
| 524 | </div> |
| 525 | </div> <!--end .feedback-popup--> |
| 526 | |
| 527 | </div> <!--end .premio-notice--> |
| 528 | |
| 529 | <script> |
| 530 | (function($) { |
| 531 | function FoldersFreeReview() { |
| 532 | this.prefix = "<?php echo esc_attr($this->pluginSlug) ?>"; |
| 533 | this.reviewLink = "https://wordpress.org/support/plugin/<?php echo esc_attr($this->wpPluginSlug) ?>/reviews/?filter=5"; |
| 534 | this.rating = 5; |
| 535 | |
| 536 | this.renderRating(); |
| 537 | this.bindEvents(); |
| 538 | } |
| 539 | |
| 540 | FoldersFreeReview.prototype.getSelectors = function() { |
| 541 | return { |
| 542 | body: 'body', |
| 543 | rating: `.${this.prefix}-premio-review-box__default__rating`, |
| 544 | reviewBox: `.${this.prefix}-premio-review-box`, |
| 545 | feedbackForm: `.${this.prefix}-feedback-popup__form`, |
| 546 | reminderPopup: `.${this.prefix}-review-box-popup`, |
| 547 | feedbackPopup: `.${this.prefix}-feedback-popup`, |
| 548 | reviewBoxDefault: `.${this.prefix}-premio-review-box__default`, |
| 549 | reviewBoxThankYou: `.${this.prefix}-premio-review-box__thank-you`, |
| 550 | defaultDismissBtn: `.${this.prefix}-review-box-default__dismiss-btn`, |
| 551 | thankYouDismissBtn: `.${this.prefix}-premio-review-box__thank-you__dismiss-btn`, |
| 552 | feedbackDismissBtn: `.${this.prefix}-feedback-popup__dismiss-btn`, |
| 553 | reminderPopupOptions: `.${this.prefix}-review-box-popup__options a`, |
| 554 | reminderPopupDismissBtn: `.${this.prefix}-review-box-popup__dismiss-btn`, |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | FoldersFreeReview.prototype.getElements = function() { |
| 559 | const selectors = this.getSelectors(); |
| 560 | return { |
| 561 | $body: $(selectors.body), |
| 562 | $rating: $(selectors.rating), |
| 563 | $reviewBox: $(selectors.reviewBox), |
| 564 | $feedbackForm: $(selectors.feedbackForm), |
| 565 | $reminderPopup: $(selectors.reminderPopup), |
| 566 | $feedbackPopup: $(selectors.feedbackPopup), |
| 567 | $reviewBoxDefault: $(selectors.reviewBoxDefault), |
| 568 | $reviewBoxThankYou: $(selectors.reviewBoxThankYou), |
| 569 | $defaultDismissBtn: $(selectors.defaultDismissBtn), |
| 570 | $thankYouDismissBtn: $(selectors.thankYouDismissBtn), |
| 571 | $feedbackDismissBtn: $(selectors.feedbackDismissBtn), |
| 572 | $reminderPopupOptions: $(selectors.reminderPopupOptions), |
| 573 | $reminderPopupDismissBtn: $(selectors.reminderPopupDismissBtn) |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | FoldersFreeReview.prototype.bindEvents = function() { |
| 578 | const elements = this.getElements(); |
| 579 | const selectors = this.getSelectors(); |
| 580 | |
| 581 | elements.$body.addClass("has-premio-box"); |
| 582 | elements.$defaultDismissBtn.on('click', this.toggleReminderPopup.bind(elements)); |
| 583 | elements.$reminderPopupDismissBtn.on('click', this.toggleReminderPopup.bind(elements, false)); |
| 584 | elements.$reminderPopupOptions.on('click', this.reminderHandler.bind(this)); |
| 585 | elements.$thankYouDismissBtn.on('click', this.thankYouDismissHandler.bind(this)); |
| 586 | elements.$feedbackDismissBtn.on('click', this.feedbackToggle.bind(this, false)); |
| 587 | elements.$feedbackForm.on('submit', this.feedbackFormHandler.bind(this)); |
| 588 | |
| 589 | //close reminder/feedback popup when click outside |
| 590 | $(window).on('click', ev => { |
| 591 | const $target = $(ev.target); |
| 592 | if( |
| 593 | elements.$reminderPopup.hasClass('open') && |
| 594 | $target.parents( selectors.reminderPopup ).length === 0 |
| 595 | ) { |
| 596 | elements.$reminderPopupDismissBtn.trigger('click'); |
| 597 | } |
| 598 | |
| 599 | if( |
| 600 | elements.$feedbackPopup.hasClass('open') && |
| 601 | $target.parents( selectors.feedbackPopup ).length === 0 |
| 602 | ) { |
| 603 | elements.$feedbackDismissBtn.trigger('click'); |
| 604 | } |
| 605 | }) |
| 606 | } |
| 607 | |
| 608 | FoldersFreeReview.prototype.feedbackFormHandler = function(ev) { |
| 609 | ev.preventDefault(); |
| 610 | const elements = this.getElements(); |
| 611 | const message = elements.$feedbackForm.find('#message').val(); |
| 612 | const rating = this.rating; |
| 613 | |
| 614 | $.ajax({ |
| 615 | url: "<?php echo esc_url(admin_url("admin-ajax.php")) ?>", |
| 616 | data: { |
| 617 | action: "<?php echo esc_attr($this->pluginSlug) ?>_review_box_message", |
| 618 | rating: rating, |
| 619 | nonce: "<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_review_box_message")) ?>", |
| 620 | message: message |
| 621 | }, |
| 622 | type: "post", |
| 623 | }); |
| 624 | elements.$feedbackDismissBtn.trigger('click'); |
| 625 | elements.$reviewBox.remove(); |
| 626 | elements.$reminderPopup.remove(); |
| 627 | // send hide request after submitting feedback form |
| 628 | this.sendHideRequest( -1 ); |
| 629 | } |
| 630 | |
| 631 | FoldersFreeReview.prototype.thankYouDismissHandler = function() { |
| 632 | const elements = this.getElements(); |
| 633 | elements.$reviewBox.remove(); |
| 634 | elements.$reminderPopup.remove(); |
| 635 | this.sendHideRequest( -1 ); |
| 636 | } |
| 637 | |
| 638 | FoldersFreeReview.prototype.reminderHandler = function(ev) { |
| 639 | ev.preventDefault(); |
| 640 | const dataDays = $(ev.target).data("days"); |
| 641 | const elements = this.getElements(); |
| 642 | |
| 643 | elements.$body.removeClass("has-premio-box"); |
| 644 | elements.$reminderPopupDismissBtn.trigger('click'); |
| 645 | elements.$reviewBox.remove(); |
| 646 | this.sendHideRequest( dataDays ); |
| 647 | } |
| 648 | |
| 649 | FoldersFreeReview.prototype.sendHideRequest = function( dataDays = -1 ) { |
| 650 | $.ajax({ |
| 651 | url: "<?php echo esc_url(admin_url("admin-ajax.php")) ?>", |
| 652 | data: "action=<?php echo esc_attr($this->pluginSlug) ?>_review_box&days=" + dataDays + "&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_review_box")) ?>", |
| 653 | type: "post", |
| 654 | }); |
| 655 | } |
| 656 | |
| 657 | FoldersFreeReview.prototype.toggleReminderPopup = function( action = true ) { |
| 658 | if( action ) { |
| 659 | this.$reminderPopup.fadeIn(200, function(){ |
| 660 | $(this).addClass('open') |
| 661 | }); |
| 662 | } else { |
| 663 | this.$reminderPopup.fadeOut(200).removeClass('open'); |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | FoldersFreeReview.prototype.feedbackToggle = function( action = true ) { |
| 668 | const elements = this.getElements(); |
| 669 | console.log(action); |
| 670 | if( action ) { |
| 671 | console.log(elements.$feedbackPopup); |
| 672 | elements.$feedbackPopup.fadeIn(200, function(){ |
| 673 | $(this).addClass('open') |
| 674 | }); |
| 675 | } else { |
| 676 | elements.$rating.starRating('unload'); |
| 677 | elements.$reviewBoxDefault.append(`<div class="${this.prefix}-premio-review-box__default__rating"></div>`) |
| 678 | elements.$feedbackPopup.fadeOut(200).removeClass('open'); |
| 679 | this.renderRating(); |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | FoldersFreeReview.prototype.renderRating = function() { |
| 684 | const self = this; |
| 685 | const elements = self.getElements(); |
| 686 | elements.$rating.starRating({ |
| 687 | initialRating : self.rating, |
| 688 | useFullStars : true, |
| 689 | strokeColor : '#894A00', |
| 690 | strokeWidth : 10, |
| 691 | minRating : 1, |
| 692 | starSize : 25, |
| 693 | callback( currentRate ) { |
| 694 | if( currentRate !== 5 ) { |
| 695 | self.rating = currentRate; |
| 696 | self.feedbackToggle(true); |
| 697 | } else { |
| 698 | elements.$reviewBoxDefault.hide(); |
| 699 | elements.$reviewBoxThankYou.show(); |
| 700 | window.open( self.reviewLink , '_blank'); |
| 701 | self.sendHideRequest( -1 ); |
| 702 | } |
| 703 | } |
| 704 | }) |
| 705 | } |
| 706 | |
| 707 | new FoldersFreeReview(); |
| 708 | |
| 709 | })( jQuery ) |
| 710 | </script> |
| 711 | <?php |
| 712 | |
| 713 | }//end admin_notices() |
| 714 | |
| 715 | }//end class |
| 716 | |
| 717 | //$myStickyMenu_Pro_review_box = new myStickyMenu_Pro_review_box(); |
| 718 |