← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+118
-120
4.0.5
→
3.4.4
View file →
| @@ -11,9 +11,8 @@ | ||
| 11 | 11 | |
| 12 | 12 | namespace ThemeisleSDK\Modules; |
| 13 | 13 | |
| 14 | 14 | use ThemeisleSDK\Common\Abstract_Module; |
| 15 | -use ThemeisleSDK\Loader; | |
| 16 | 15 | use ThemeisleSDK\Product; |
| 17 | 16 | |
| 18 | 17 | // Exit if accessed directly. |
| 19 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -48,24 +47,27 @@ | ||
| 48 | 47 | * |
| 49 | 48 | * @var array $options_plugin The main options list for plugins. |
| 50 | 49 | */ |
| 51 | 50 | private $options_plugin = array( |
| 52 | - 'id3' => array( | |
| 53 | - 'id' => 3, | |
| 54 | - 'type' => 'text', | |
| 55 | - | |
| 51 | + 'I found a better plugin' => array( | |
| 52 | + 'id' => 3, | |
| 53 | + 'type' => 'text', | |
| 54 | + 'placeholder' => 'What\'s the plugin\'s name?', | |
| 56 | 55 | ), |
| 57 | - 'id4' => array( | |
| 58 | - 'type' => 'textarea', | |
| 59 | - 'id' => 4, | |
| 56 | + 'I could not get the plugin to work' => array( | |
| 57 | + 'type' => 'textarea', | |
| 58 | + 'placeholder' => 'What problem are you experiencing?', | |
| 59 | + 'id' => 4, | |
| 60 | 60 | ), |
| 61 | - 'id5' => array( | |
| 62 | - 'id' => 5, | |
| 63 | - 'type' => 'textarea', | |
| 61 | + 'I no longer need the plugin' => array( | |
| 62 | + 'id' => 5, | |
| 63 | + 'type' => 'textarea', | |
| 64 | + 'placeholder' => 'If you could improve one thing about our product, what would it be?', | |
| 64 | 65 | ), |
| 65 | - 'id6' => array( | |
| 66 | - 'type' => 'textarea', | |
| 67 | - 'id' => 6, | |
| 66 | + 'It\'s a temporary deactivation. I\'m just debugging an issue.' => array( | |
| 67 | + 'type' => 'textarea', | |
| 68 | + 'placeholder' => 'What problem are you experiencing?', | |
| 69 | + 'id' => 6, | |
| 68 | 70 | ), |
| 69 | 71 | ); |
| 70 | 72 | /** |
| 71 | 73 | * Default options for theme. |
| @@ -72,23 +74,23 @@ | ||
| 72 | 74 | * |
| 73 | 75 | * @var array $options_theme The main options list for themes. |
| 74 | 76 | */ |
| 75 | 77 | private $options_theme = array( |
| 76 | - 'id7' => array( | |
| 78 | + 'I don\'t know how to make it look like demo' => array( | |
| 77 | 79 | 'id' => 7, |
| 78 | 80 | ), |
| 79 | - 'id8' => array( | |
| 80 | - 'type' => 'text', | |
| 81 | - 'id' => 8, | |
| 81 | + 'It lacks options' => array( | |
| 82 | + 'placeholder' => 'What option is missing?', | |
| 83 | + 'type' => 'text', | |
| 84 | + 'id' => 8, | |
| 82 | 85 | ), |
| 83 | - 'id9' => array( | |
| 84 | - 'id' => 9, | |
| 85 | - 'type' => 'text', | |
| 86 | + 'Is not working with a plugin that I need' => array( | |
| 87 | + 'id' => 9, | |
| 88 | + 'type' => 'text', | |
| 89 | + 'placeholder' => 'What is the name of the plugin', | |
| 86 | 90 | ), |
| 87 | - 'id10' => array( | |
| 88 | - | |
| 89 | - 'title' => '', | |
| 90 | - 'id' => 10, | |
| 91 | + 'I want to try a new design, I don\'t like {theme} style' => array( | |
| 92 | + 'id' => 10, | |
| 91 | 93 | ), |
| 92 | 94 | ); |
| 93 | 95 | /** |
| 94 | 96 | * Default other option. |
| @@ -95,18 +97,43 @@ | ||
| 95 | 97 | * |
| 96 | 98 | * @var array $other The other option |
| 97 | 99 | */ |
| 98 | 100 | private $other = array( |
| 99 | - 'id999' => array( | |
| 100 | - 'id' => 999, | |
| 101 | - 'type' => 'textarea', | |
| 101 | + 'Other' => array( | |
| 102 | + 'id' => 999, | |
| 103 | + 'type' => 'textarea', | |
| 104 | + 'placeholder' => 'What can we do better?', | |
| 102 | 105 | ), |
| 103 | 106 | ); |
| 107 | + /** | |
| 108 | + * Default heading for plugin. | |
| 109 | + * | |
| 110 | + * @var string $heading_plugin The heading of the modal | |
| 111 | + */ | |
| 112 | + private $heading_plugin = 'What\'s wrong?'; | |
| 113 | + /** | |
| 114 | + * Default heading for theme. | |
| 115 | + * | |
| 116 | + * @var string $heading_theme The heading of the modal | |
| 117 | + */ | |
| 118 | + private $heading_theme = 'What does not work for you in {theme}?'; | |
| 119 | + /** | |
| 120 | + * Default submit button action text. | |
| 121 | + * | |
| 122 | + * @var string $button_submit The text of the deactivate button | |
| 123 | + */ | |
| 124 | + private $button_submit = 'Submit & Deactivate'; | |
| 125 | + /** | |
| 126 | + * Default cancel button. | |
| 127 | + * | |
| 128 | + * @var string $button_cancel The text of the cancel button | |
| 129 | + */ | |
| 130 | + private $button_cancel = 'Skip & Deactivate'; | |
| 104 | 131 | |
| 105 | 132 | /** |
| 106 | 133 | * Loads the additional resources |
| 107 | 134 | */ |
| 108 | - public function load_resources() { | |
| 135 | + function load_resources() { | |
| 109 | 136 | $screen = get_current_screen(); |
| 110 | 137 | |
| 111 | 138 | if ( ! $screen || ! in_array( $screen->id, array( 'theme-install', 'plugins' ) ) ) { |
| 112 | 139 | return; |
| @@ -127,13 +154,13 @@ | ||
| 127 | 154 | /** |
| 128 | 155 | * Render theme feedback drawer. |
| 129 | 156 | */ |
| 130 | 157 | private function render_theme_feedback_popup() { |
| 131 | - $heading = str_replace( '{theme}', $this->product->get_name(), Loader::$labels['uninstall']['heading_theme'] ); | |
| 132 | - $button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', Loader::$labels['uninstall']['submit'] ); | |
| 158 | + $heading = str_replace( '{theme}', $this->product->get_name(), $this->heading_theme ); | |
| 159 | + $button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', 'Submit' ); | |
| 133 | 160 | $options = $this->options_theme; |
| 134 | 161 | $options = $this->randomize_options( apply_filters( $this->product->get_key() . '_feedback_deactivate_options', $options ) ); |
| 135 | - $info_disclosure_link = '<a href="#" class="info-disclosure-link">' . apply_filters( $this->product->get_slug() . '_themeisle_sdk_info_collect_cta', Loader::$labels['uninstall']['cta_info'] ) . '</a>'; | |
| 162 | + $info_disclosure_link = '<a href="#" class="info-disclosure-link">' . apply_filters( $this->product->get_slug() . '_themeisle_sdk_info_collect_cta', 'What info do we collect?' ) . '</a>'; | |
| 136 | 163 | |
| 137 | 164 | $options += $this->other; |
| 138 | 165 | |
| 139 | 166 | ?> |
| @@ -138,10 +165,9 @@ | ||
| 138 | 165 | |
| 139 | 166 | ?> |
| 140 | 167 | <div class="ti-theme-uninstall-feedback-drawer ti-feedback"> |
| 141 | 168 | <div class="popup--header"> |
| 142 | - <h5><?php echo wp_kses( $heading, array( 'span' => true ) ); ?></h5> | |
| 143 | - <?php $this->do_popup_header_after_heading_action( 'theme' ); ?> | |
| 169 | + <h5><?php echo wp_kses( $heading, array( 'span' => true ) ); ?> </h5> | |
| 144 | 170 | <button class="toggle"><span>×</span></button> |
| 145 | 171 | </div><!--/.popup--header--> |
| 146 | 172 | <div class="popup--body"> |
| 147 | 173 | <?php $this->render_options_list( $options ); ?> |
| @@ -151,9 +177,9 @@ | ||
| 151 | 177 | <?php |
| 152 | 178 | echo wp_kses_post( $info_disclosure_link ); |
| 153 | 179 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 154 | 180 | echo '<div class="buttons">'; |
| 155 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function has an internal sanitization. | |
| 181 | + echo get_submit_button( | |
| 156 | 182 | $button_submit, |
| 157 | 183 | 'secondary', |
| 158 | 184 | $this->product->get_key() . 'ti-deactivate-yes', |
| 159 | 185 | false, |
| @@ -209,9 +235,9 @@ | ||
| 209 | 235 | font-size: 13px; |
| 210 | 236 | } |
| 211 | 237 | |
| 212 | 238 | .ti-feedback .popup--form input[type="radio"] { |
| 213 | - <?php echo is_rtl() ? 'margin: 0 0 0 10px;' : 'margin: 0 10px 0 0;'; ?> | |
| 239 | + margin: 0 10px 0 0; | |
| 214 | 240 | } |
| 215 | 241 | |
| 216 | 242 | .ti-feedback .popup--form input[type="radio"]:checked ~ textarea { |
| 217 | 243 | display: block; |
| @@ -287,9 +313,9 @@ | ||
| 287 | 313 | width: 100%; |
| 288 | 314 | } |
| 289 | 315 | |
| 290 | 316 | .ti-feedback .buttons input:last-child { |
| 291 | - <?php echo is_rtl() ? 'margin-right: auto;' : 'margin-left: auto;'; ?> | |
| 317 | + margin-left: auto; | |
| 292 | 318 | } |
| 293 | 319 | |
| 294 | 320 | .ti-theme-uninstall-feedback-drawer { |
| 295 | 321 | border-top-left-radius: 5px; |
| @@ -339,21 +365,15 @@ | ||
| 339 | 365 | .ti-plugin-uninstall-feedback-popup .popup--header:before { |
| 340 | 366 | content: ""; |
| 341 | 367 | display: block; |
| 342 | 368 | position: absolute; |
| 369 | + border: 20px solid #23A1CE; | |
| 370 | + left: -10px; | |
| 343 | 371 | top: 50%; |
| 372 | + border-top: 20px solid transparent; | |
| 373 | + border-bottom: 20px solid transparent; | |
| 374 | + border-left: 0; | |
| 344 | 375 | transform: translateY(-50%); |
| 345 | - <?php | |
| 346 | - echo is_rtl() ? | |
| 347 | - 'right: -10px; | |
| 348 | - border-top: 20px solid transparent; | |
| 349 | - border-left: 20px solid #23A1CE; | |
| 350 | - border-bottom: 20px solid transparent;' : | |
| 351 | - 'left: -10px; | |
| 352 | - border-top: 20px solid transparent; | |
| 353 | - border-right: 20px solid #23A1CE; | |
| 354 | - border-bottom: 20px solid transparent;'; | |
| 355 | - ?> | |
| 356 | 376 | } |
| 357 | 377 | |
| 358 | 378 | .ti-plugin-uninstall-feedback-popup { |
| 359 | 379 | display: none; |
| @@ -359,9 +379,10 @@ | ||
| 359 | 379 | display: none; |
| 360 | 380 | position: absolute; |
| 361 | 381 | white-space: normal; |
| 362 | 382 | width: 400px; |
| 363 | - <?php echo is_rtl() ? 'right: calc( 100% + 15px );' : 'left: calc( 100% + 15px );'; ?> top: -15px; | |
| 383 | + left: 100%; | |
| 384 | + top: -15px; | |
| 364 | 385 | } |
| 365 | 386 | |
| 366 | 387 | .ti-plugin-uninstall-feedback-popup.sending-feedback .popup--body i { |
| 367 | 388 | animation: rotation 2s infinite linear; |
| @@ -386,9 +407,9 @@ | ||
| 386 | 407 | .ti-plugin-uninstall-feedback-popup.active { |
| 387 | 408 | display: block; |
| 388 | 409 | } |
| 389 | 410 | |
| 390 | - tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>"] .deactivate { | |
| 411 | + tr[data-plugin^="<?php echo $this->product->get_slug(); ?>"] .deactivate { | |
| 391 | 412 | position: relative; |
| 392 | 413 | } |
| 393 | 414 | |
| 394 | 415 | body.ti-feedback-open .ti-feedback-overlay { |
| @@ -447,22 +468,22 @@ | ||
| 447 | 468 | $('.ti-theme-uninstall-feedback-drawer input[type="radio"]').on('change', function () { |
| 448 | 469 | var radio = $(this); |
| 449 | 470 | if (radio.parent().find('textarea').length > 0 && |
| 450 | 471 | radio.parent().find('textarea').val().length === 0) { |
| 451 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 472 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 452 | 473 | radio.parent().find('textarea').on('keyup', function (e) { |
| 453 | 474 | if ($(this).val().length === 0) { |
| 454 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 475 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 455 | 476 | } else { |
| 456 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 477 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 457 | 478 | } |
| 458 | 479 | }); |
| 459 | 480 | } else { |
| 460 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 481 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 461 | 482 | } |
| 462 | 483 | }); |
| 463 | 484 | |
| 464 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { | |
| 485 | + $('#<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) { | |
| 465 | 486 | e.preventDefault(); |
| 466 | 487 | e.stopPropagation(); |
| 467 | 488 | |
| 468 | 489 | var selectedOption = $( |
| @@ -468,9 +489,9 @@ | ||
| 468 | 489 | var selectedOption = $( |
| 469 | 490 | '.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked'); |
| 470 | 491 | $.post(ajaxurl, { |
| 471 | 492 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 472 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 493 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 473 | 494 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 474 | 495 | 'msg': selectedOption.parent().find('textarea').val(), |
| 475 | 496 | 'type': 'theme', |
| 476 | 497 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -485,21 +506,8 @@ | ||
| 485 | 506 | do_action( $this->product->get_key() . '_uninstall_feedback_after_js' ); |
| 486 | 507 | } |
| 487 | 508 | |
| 488 | 509 | /** |
| 489 | - * Fires after the popup header heading, allowing products to output extra markup. | |
| 490 | - * | |
| 491 | - * @param string $context Popup context. Either `theme` or `plugin`. | |
| 492 | - */ | |
| 493 | - private function do_popup_header_after_heading_action( $context ) { | |
| 494 | - do_action( | |
| 495 | - $this->product->get_key() . '_uninstall_feedback_popup_header_after_heading', | |
| 496 | - $this->product, | |
| 497 | - $context | |
| 498 | - ); | |
| 499 | - } | |
| 500 | - | |
| 501 | - /** | |
| 502 | 510 | * Render the options list. |
| 503 | 511 | * |
| 504 | 512 | * @param array $options the options for the feedback form. |
| 505 | 513 | */ |
| @@ -510,23 +518,18 @@ | ||
| 510 | 518 | 'textarea' => 2, |
| 511 | 519 | ]; |
| 512 | 520 | ?> |
| 513 | 521 | <ul class="popup--form"> |
| 514 | - <?php | |
| 515 | - foreach ( $options as $idx => $attributes ) { | |
| 516 | - $title = Loader::$labels['uninstall']['options'][ $idx ]['title']; | |
| 517 | - $placeholder = array_key_exists( 'placeholder', Loader::$labels['uninstall']['options'][ $idx ] ) ? Loader::$labels['uninstall']['options'][ $idx ]['placeholder'] : ''; | |
| 518 | - ?> | |
| 522 | + <?php foreach ( $options as $title => $attributes ) { ?> | |
| 519 | 523 | <li ti-option-id="<?php echo esc_attr( $attributes['id'] ); ?>"> |
| 520 | - <input type="radio" name="ti-deactivate-option" | |
| 521 | - id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> | |
| 524 | + <input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> | |
| 522 | 525 | <label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 523 | - <?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?> | |
| 526 | + <?php echo str_replace( '{theme}', $this->product->get_name(), $title ); ?> | |
| 524 | 527 | </label> |
| 525 | 528 | <?php |
| 526 | 529 | if ( array_key_exists( 'type', $attributes ) ) { |
| 527 | - | |
| 528 | - echo '<textarea width="100%" rows="' . esc_attr( $inputs_row_map[ $attributes['type'] ] ) . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>'; | |
| 530 | + $placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : ''; | |
| 531 | + echo '<textarea width="100%" rows="' . $inputs_row_map[ $attributes['type'] ] . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>'; | |
| 529 | 532 | } |
| 530 | 533 | ?> |
| 531 | 534 | </li> |
| 532 | 535 | <?php } ?> |
| @@ -537,20 +540,18 @@ | ||
| 537 | 540 | /** |
| 538 | 541 | * Render plugin feedback popup. |
| 539 | 542 | */ |
| 540 | 543 | private function render_plugin_feedback_popup() { |
| 541 | - $button_cancel = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_cancel', Loader::$labels['uninstall']['button_cancel'] ); | |
| 542 | - $button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', Loader::$labels['uninstall']['button_submit'] ); | |
| 544 | + $button_cancel = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_cancel', $this->button_cancel ); | |
| 545 | + $button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', $this->button_submit ); | |
| 543 | 546 | $options = $this->randomize_options( apply_filters( $this->product->get_key() . '_feedback_deactivate_options', $this->options_plugin ) ); |
| 544 | - $info_disclosure_link = '<a href="#" class="info-disclosure-link">' . apply_filters( $this->product->get_slug() . '_themeisle_sdk_info_collect_cta', Loader::$labels['uninstall']['cta_info'] ) . '</a>'; | |
| 547 | + $info_disclosure_link = '<a href="#" class="info-disclosure-link">' . apply_filters( $this->product->get_slug() . '_themeisle_sdk_info_collect_cta', 'What info do we collect?' ) . '</a>'; | |
| 545 | 548 | |
| 546 | 549 | $options += $this->other; |
| 547 | 550 | ?> |
| 548 | - <div class="ti-plugin-uninstall-feedback-popup ti-feedback" | |
| 549 | - id="<?php echo esc_attr( $this->product->get_slug() . '_uninstall_feedback_popup' ); ?>"> | |
| 551 | + <div class="ti-plugin-uninstall-feedback-popup ti-feedback" id="<?php echo esc_attr( $this->product->get_slug() . '_uninstall_feedback_popup' ); ?>"> | |
| 550 | 552 | <div class="popup--header"> |
| 551 | - <h5><?php echo wp_kses( Loader::$labels['uninstall']['heading_plugin'], array( 'span' => true ) ); ?> </h5> | |
| 552 | - <?php $this->do_popup_header_after_heading_action( 'plugin' ); ?> | |
| 553 | + <h5><?php echo wp_kses( $this->heading_plugin, array( 'span' => true ) ); ?> </h5> | |
| 553 | 554 | </div><!--/.popup--header--> |
| 554 | 555 | <div class="popup--body"> |
| 555 | 556 | <?php $this->render_options_list( $options ); ?> |
| 556 | 557 | </div><!--/.popup--body--> |
| @@ -559,15 +560,15 @@ | ||
| 559 | 560 | <?php |
| 560 | 561 | echo wp_kses_post( $info_disclosure_link ); |
| 561 | 562 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 562 | 563 | echo '<div class="buttons">'; |
| 563 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 564 | + echo get_submit_button( | |
| 564 | 565 | $button_cancel, |
| 565 | 566 | 'secondary', |
| 566 | 567 | $this->product->get_key() . 'ti-deactivate-no', |
| 567 | 568 | false |
| 568 | 569 | ); |
| 569 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 570 | + echo get_submit_button( | |
| 570 | 571 | $button_submit, |
| 571 | 572 | 'primary', |
| 572 | 573 | $this->product->get_key() . 'ti-deactivate-yes', |
| 573 | 574 | false, |
| @@ -594,17 +595,16 @@ | ||
| 594 | 595 | ?> |
| 595 | 596 | <script type="text/javascript" id="ti-deactivate-js"> |
| 596 | 597 | (function ($) { |
| 597 | 598 | $(document).ready(function () { |
| 598 | - var targetElement = 'tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>/"] span.deactivate a'; | |
| 599 | - var $deactivateLink = $(targetElement); | |
| 600 | - var redirectUrl = $deactivateLink.attr('href'); | |
| 599 | + var targetElement = 'tr[data-plugin^="<?php echo $this->product->get_slug(); ?>/"] span.deactivate a'; | |
| 600 | + var redirectUrl = $(targetElement).attr('href'); | |
| 601 | 601 | if ($('.ti-feedback-overlay').length === 0) { |
| 602 | 602 | $('body').prepend('<div class="ti-feedback-overlay"></div>'); |
| 603 | 603 | } |
| 604 | - $('<?php echo esc_attr( $popup_id ); ?> ').appendTo($deactivateLink.parent()); | |
| 604 | + $('<?php echo esc_attr( $popup_id ); ?> ').appendTo($(targetElement).parent()); | |
| 605 | 605 | |
| 606 | - $deactivateLink.on('click', function (e) { | |
| 606 | + $(targetElement).on('click', function (e) { | |
| 607 | 607 | e.preventDefault(); |
| 608 | 608 | $('<?php echo esc_attr( $popup_id ); ?> ').addClass('active'); |
| 609 | 609 | $('body').addClass('ti-feedback-open'); |
| 610 | 610 | $('.ti-feedback-overlay').on('click', function () { |
| @@ -621,25 +621,25 @@ | ||
| 621 | 621 | $('<?php echo esc_attr( $popup_id ); ?> input[type="radio"]').on('change', function () { |
| 622 | 622 | var radio = $(this); |
| 623 | 623 | if (radio.parent().find('textarea').length > 0 && |
| 624 | 624 | radio.parent().find('textarea').val().length === 0) { |
| 625 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 625 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 626 | 626 | radio.parent().find('textarea').on('keyup', function (e) { |
| 627 | 627 | if ($(this).val().length === 0) { |
| 628 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 628 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 629 | 629 | } else { |
| 630 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 630 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 631 | 631 | } |
| 632 | 632 | }); |
| 633 | 633 | } else { |
| 634 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 634 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 635 | 635 | } |
| 636 | 636 | }); |
| 637 | 637 | |
| 638 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-no').on('click', function (e) { | |
| 638 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-no').on('click', function (e) { | |
| 639 | 639 | e.preventDefault(); |
| 640 | 640 | e.stopPropagation(); |
| 641 | - $deactivateLink.unbind('click'); | |
| 641 | + $(targetElement).unbind('click'); | |
| 642 | 642 | $('body').removeClass('ti-feedback-open'); |
| 643 | 643 | $('<?php echo esc_attr( $popup_id ); ?>').remove(); |
| 644 | 644 | if (redirectUrl !== '') { |
| 645 | 645 | location.href = redirectUrl; |
| @@ -645,17 +645,17 @@ | ||
| 645 | 645 | location.href = redirectUrl; |
| 646 | 646 | } |
| 647 | 647 | }); |
| 648 | 648 | |
| 649 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { | |
| 649 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) { | |
| 650 | 650 | e.preventDefault(); |
| 651 | 651 | e.stopPropagation(); |
| 652 | - $deactivateLink.unbind('click'); | |
| 652 | + $(targetElement).unbind('click'); | |
| 653 | 653 | var selectedOption = $( |
| 654 | 654 | '<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked'); |
| 655 | 655 | var data = { |
| 656 | 656 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 657 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 657 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 658 | 658 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 659 | 659 | 'msg': selectedOption.parent().find('textarea').val(), |
| 660 | 660 | 'type': 'plugin', |
| 661 | 661 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -694,14 +694,13 @@ | ||
| 694 | 694 | private function get_disclosure_labels() { |
| 695 | 695 | $disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product ); |
| 696 | 696 | $disclosure_labels = array_merge( |
| 697 | 697 | [ |
| 698 | - 'title' => Loader::$labels['uninstall']['disclosure']['title'], | |
| 698 | + 'title' => 'Below is a detailed view of all data that ThemeIsle will receive if you fill in this survey. No domain name, email address or IP addresses are transmited after you submit the survey.', | |
| 699 | 699 | 'items' => [ |
| 700 | - sprintf( Loader::$labels['uninstall']['disclosure']['version'], '<strong>', ucwords( $this->product->get_type() ), '</strong>', '<code>', $this->product->get_version(), '</code>' ), | |
| 701 | - sprintf( Loader::$labels['uninstall']['disclosure']['website'], '<strong>', '</strong>', '<code>', get_site_url(), '</code>' ), | |
| 702 | - sprintf( Loader::$labels['uninstall']['disclosure']['usage'], '<strong>', '</strong>', '<code>', ( time() - $this->product->get_install_time() ), 's</code>' ), | |
| 703 | - sprintf( Loader::$labels['uninstall']['disclosure']['reason'], '<strong>', '</strong>', '<i>', '</i>' ), | |
| 700 | + sprintf( '%s %s version %s %s %s %s', '<strong>', ucwords( $this->product->get_type() ), '</strong>', '<code>', $this->product->get_version(), '</code>' ), | |
| 701 | + sprintf( '%sCurrent website:%s %s %s %s', '<strong>', '</strong>', '<code>', get_site_url(), '</code>' ), | |
| 702 | + sprintf( '%s Uninstall reason %s %s Selected reason from the above survey %s ', '<strong>', '</strong>', '<i>', '</i>' ), | |
| 704 | 703 | ], |
| 705 | 704 | ], |
| 706 | 705 | $disclosure_new_labels |
| 707 | 706 | ); |
| @@ -719,9 +718,9 @@ | ||
| 719 | 718 | * Randomizes the options array. |
| 720 | 719 | * |
| 721 | 720 | * @param array $options The options array. |
| 722 | 721 | */ |
| 723 | - public function randomize_options( $options ) { | |
| 722 | + function randomize_options( $options ) { | |
| 724 | 723 | $new = array(); |
| 725 | 724 | $keys = array_keys( $options ); |
| 726 | 725 | shuffle( $keys ); |
| 727 | 726 | |
| @@ -734,9 +733,9 @@ | ||
| 734 | 733 | |
| 735 | 734 | /** |
| 736 | 735 | * Called when the deactivate button is clicked. |
| 737 | 736 | */ |
| 738 | - public function post_deactivate() { | |
| 737 | + function post_deactivate() { | |
| 739 | 738 | check_ajax_referer( (string) __CLASS__, 'nonce' ); |
| 740 | 739 | |
| 741 | 740 | $this->post_deactivate_or_cancel(); |
| 742 | 741 | |
| @@ -748,10 +747,10 @@ | ||
| 748 | 747 | } |
| 749 | 748 | $this->call_api( |
| 750 | 749 | array( |
| 751 | 750 | 'type' => 'deactivate', |
| 752 | - 'id' => sanitize_key( $_POST['id'] ), | |
| 753 | - 'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '', | |
| 751 | + 'id' => $_POST['id'], | |
| 752 | + 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', | |
| 754 | 753 | ) |
| 755 | 754 | ); |
| 756 | 755 | wp_send_json( [] ); |
| 757 | 756 | |
| @@ -760,16 +759,16 @@ | ||
| 760 | 759 | /** |
| 761 | 760 | * Called when the deactivate/cancel button is clicked. |
| 762 | 761 | */ |
| 763 | 762 | private function post_deactivate_or_cancel() { |
| 764 | - if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 763 | + if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { | |
| 765 | 764 | return; |
| 766 | 765 | } |
| 767 | - if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 766 | + if ( 'theme' !== $_POST['type'] ) { | |
| 768 | 767 | return; |
| 769 | 768 | } |
| 770 | 769 | |
| 771 | - set_transient( 'ti_sdk_pause_' . sanitize_text_field( $_POST['key'] ), true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS );//phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 770 | + set_transient( 'ti_sdk_pause_' . $_POST['key'], true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS ); | |
| 772 | 771 | |
| 773 | 772 | } |
| 774 | 773 | |
| 775 | 774 | /** |
| @@ -779,14 +778,13 @@ | ||
| 779 | 778 | * |
| 780 | 779 | * @return bool Is the request succesfull? |
| 781 | 780 | */ |
| 782 | 781 | protected function call_api( $attributes ) { |
| 783 | - $slug = $this->product->get_slug(); | |
| 784 | - $version = $this->product->get_version(); | |
| 785 | - $attributes['slug'] = $slug; | |
| 786 | - $attributes['version'] = $version; | |
| 787 | - $attributes['url'] = get_site_url(); | |
| 788 | - $attributes['active_time'] = ( time() - $this->product->get_install_time() ); | |
| 782 | + $slug = $this->product->get_slug(); | |
| 783 | + $version = $this->product->get_version(); | |
| 784 | + $attributes['slug'] = $slug; | |
| 785 | + $attributes['version'] = $version; | |
| 786 | + $attributes['url'] = get_site_url(); | |
| 789 | 787 | |
| 790 | 788 | $response = wp_remote_post( |
| 791 | 789 | self::FEEDBACK_ENDPOINT, |
| 792 | 790 | array( |