← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+124
-135
4.0.7
→
3.4.9
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 | + <?php echo is_rtl() ? 'margin: 0 0 0 10px;' : '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 | + <?php echo is_rtl() ? 'margin-right: auto;' : 'margin-left: auto;'; ?> | |
| 292 | 318 | } |
| 293 | 319 | |
| 294 | 320 | .ti-theme-uninstall-feedback-drawer { |
| 295 | 321 | border-top-left-radius: 5px; |
| @@ -341,19 +367,19 @@ | ||
| 341 | 367 | display: block; |
| 342 | 368 | position: absolute; |
| 343 | 369 | top: 50%; |
| 344 | 370 | 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 | - ?> | |
| 371 | + <?php | |
| 372 | + echo is_rtl() ? | |
| 373 | + 'right: -10px; | |
| 374 | + border-top: 20px solid transparent; | |
| 375 | + border-left: 20px solid #23A1CE; | |
| 376 | + border-bottom: 20px solid transparent;' : | |
| 377 | + 'left: -10px; | |
| 378 | + border-top: 20px solid transparent; | |
| 379 | + border-right: 20px solid #23A1CE; | |
| 380 | + border-bottom: 20px solid transparent;'; | |
| 381 | + ?> | |
| 356 | 382 | } |
| 357 | 383 | |
| 358 | 384 | .ti-plugin-uninstall-feedback-popup { |
| 359 | 385 | display: none; |
| @@ -359,9 +385,10 @@ | ||
| 359 | 385 | display: none; |
| 360 | 386 | position: absolute; |
| 361 | 387 | white-space: normal; |
| 362 | 388 | width: 400px; |
| 363 | - <?php echo is_rtl() ? 'right: calc( 100% + 15px );' : 'left: calc( 100% + 15px );'; ?> top: -15px; | |
| 389 | + <?php echo is_rtl() ? 'right: calc( 100% + 15px );' : 'left: calc( 100% + 15px );'; ?> | |
| 390 | + top: -15px; | |
| 364 | 391 | } |
| 365 | 392 | |
| 366 | 393 | .ti-plugin-uninstall-feedback-popup.sending-feedback .popup--body i { |
| 367 | 394 | animation: rotation 2s infinite linear; |
| @@ -386,9 +413,9 @@ | ||
| 386 | 413 | .ti-plugin-uninstall-feedback-popup.active { |
| 387 | 414 | display: block; |
| 388 | 415 | } |
| 389 | 416 | |
| 390 | - tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>"] .deactivate { | |
| 417 | + tr[data-plugin^="<?php echo $this->product->get_slug(); ?>"] .deactivate { | |
| 391 | 418 | position: relative; |
| 392 | 419 | } |
| 393 | 420 | |
| 394 | 421 | body.ti-feedback-open .ti-feedback-overlay { |
| @@ -447,22 +474,22 @@ | ||
| 447 | 474 | $('.ti-theme-uninstall-feedback-drawer input[type="radio"]').on('change', function () { |
| 448 | 475 | var radio = $(this); |
| 449 | 476 | if (radio.parent().find('textarea').length > 0 && |
| 450 | 477 | radio.parent().find('textarea').val().length === 0) { |
| 451 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 478 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 452 | 479 | radio.parent().find('textarea').on('keyup', function (e) { |
| 453 | 480 | if ($(this).val().length === 0) { |
| 454 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 481 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 455 | 482 | } else { |
| 456 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 483 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 457 | 484 | } |
| 458 | 485 | }); |
| 459 | 486 | } else { |
| 460 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 487 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 461 | 488 | } |
| 462 | 489 | }); |
| 463 | 490 | |
| 464 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { | |
| 491 | + $('#<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) { | |
| 465 | 492 | e.preventDefault(); |
| 466 | 493 | e.stopPropagation(); |
| 467 | 494 | |
| 468 | 495 | var selectedOption = $( |
| @@ -468,9 +495,9 @@ | ||
| 468 | 495 | var selectedOption = $( |
| 469 | 496 | '.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked'); |
| 470 | 497 | $.post(ajaxurl, { |
| 471 | 498 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 472 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 499 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 473 | 500 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 474 | 501 | 'msg': selectedOption.parent().find('textarea').val(), |
| 475 | 502 | 'type': 'theme', |
| 476 | 503 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -485,21 +512,8 @@ | ||
| 485 | 512 | do_action( $this->product->get_key() . '_uninstall_feedback_after_js' ); |
| 486 | 513 | } |
| 487 | 514 | |
| 488 | 515 | /** |
| 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 | 516 | * Render the options list. |
| 503 | 517 | * |
| 504 | 518 | * @param array $options the options for the feedback form. |
| 505 | 519 | */ |
| @@ -510,23 +524,18 @@ | ||
| 510 | 524 | 'textarea' => 2, |
| 511 | 525 | ]; |
| 512 | 526 | ?> |
| 513 | 527 | <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 | - ?> | |
| 528 | + <?php foreach ( $options as $title => $attributes ) { ?> | |
| 519 | 529 | <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'] ); ?>"> | |
| 530 | + <input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> | |
| 522 | 531 | <label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 523 | - <?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?> | |
| 532 | + <?php echo str_replace( '{theme}', $this->product->get_name(), $title ); ?> | |
| 524 | 533 | </label> |
| 525 | 534 | <?php |
| 526 | 535 | 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>'; | |
| 536 | + $placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : ''; | |
| 537 | + echo '<textarea width="100%" rows="' . $inputs_row_map[ $attributes['type'] ] . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>'; | |
| 529 | 538 | } |
| 530 | 539 | ?> |
| 531 | 540 | </li> |
| 532 | 541 | <?php } ?> |
| @@ -537,20 +546,18 @@ | ||
| 537 | 546 | /** |
| 538 | 547 | * Render plugin feedback popup. |
| 539 | 548 | */ |
| 540 | 549 | 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'] ); | |
| 550 | + $button_cancel = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_cancel', $this->button_cancel ); | |
| 551 | + $button_submit = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_submit', $this->button_submit ); | |
| 543 | 552 | $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>'; | |
| 553 | + $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 | 554 | |
| 546 | 555 | $options += $this->other; |
| 547 | 556 | ?> |
| 548 | - <div class="ti-plugin-uninstall-feedback-popup ti-feedback" | |
| 549 | - id="<?php echo esc_attr( $this->product->get_slug() . '_uninstall_feedback_popup' ); ?>"> | |
| 557 | + <div class="ti-plugin-uninstall-feedback-popup ti-feedback" id="<?php echo esc_attr( $this->product->get_slug() . '_uninstall_feedback_popup' ); ?>"> | |
| 550 | 558 | <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' ); ?> | |
| 559 | + <h5><?php echo wp_kses( $this->heading_plugin, array( 'span' => true ) ); ?> </h5> | |
| 553 | 560 | </div><!--/.popup--header--> |
| 554 | 561 | <div class="popup--body"> |
| 555 | 562 | <?php $this->render_options_list( $options ); ?> |
| 556 | 563 | </div><!--/.popup--body--> |
| @@ -559,15 +566,15 @@ | ||
| 559 | 566 | <?php |
| 560 | 567 | echo wp_kses_post( $info_disclosure_link ); |
| 561 | 568 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 562 | 569 | echo '<div class="buttons">'; |
| 563 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 570 | + echo get_submit_button( | |
| 564 | 571 | $button_cancel, |
| 565 | 572 | 'secondary', |
| 566 | 573 | $this->product->get_key() . 'ti-deactivate-no', |
| 567 | 574 | false |
| 568 | 575 | ); |
| 569 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 576 | + echo get_submit_button( | |
| 570 | 577 | $button_submit, |
| 571 | 578 | 'primary', |
| 572 | 579 | $this->product->get_key() . 'ti-deactivate-yes', |
| 573 | 580 | false, |
| @@ -594,17 +601,16 @@ | ||
| 594 | 601 | ?> |
| 595 | 602 | <script type="text/javascript" id="ti-deactivate-js"> |
| 596 | 603 | (function ($) { |
| 597 | 604 | $(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'); | |
| 605 | + var targetElement = 'tr[data-plugin^="<?php echo $this->product->get_slug(); ?>/"] span.deactivate a'; | |
| 606 | + var redirectUrl = $(targetElement).attr('href'); | |
| 601 | 607 | if ($('.ti-feedback-overlay').length === 0) { |
| 602 | 608 | $('body').prepend('<div class="ti-feedback-overlay"></div>'); |
| 603 | 609 | } |
| 604 | - $('<?php echo esc_attr( $popup_id ); ?> ').appendTo($deactivateLink.parent()); | |
| 610 | + $('<?php echo esc_attr( $popup_id ); ?> ').appendTo($(targetElement).parent()); | |
| 605 | 611 | |
| 606 | - $deactivateLink.on('click', function (e) { | |
| 612 | + $(targetElement).on('click', function (e) { | |
| 607 | 613 | e.preventDefault(); |
| 608 | 614 | $('<?php echo esc_attr( $popup_id ); ?> ').addClass('active'); |
| 609 | 615 | $('body').addClass('ti-feedback-open'); |
| 610 | 616 | $('.ti-feedback-overlay').on('click', function () { |
| @@ -621,25 +627,25 @@ | ||
| 621 | 627 | $('<?php echo esc_attr( $popup_id ); ?> input[type="radio"]').on('change', function () { |
| 622 | 628 | var radio = $(this); |
| 623 | 629 | if (radio.parent().find('textarea').length > 0 && |
| 624 | 630 | 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'); | |
| 631 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 626 | 632 | radio.parent().find('textarea').on('keyup', function (e) { |
| 627 | 633 | if ($(this).val().length === 0) { |
| 628 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 634 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 629 | 635 | } else { |
| 630 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 636 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 631 | 637 | } |
| 632 | 638 | }); |
| 633 | 639 | } else { |
| 634 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 640 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 635 | 641 | } |
| 636 | 642 | }); |
| 637 | 643 | |
| 638 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-no').on('click', function (e) { | |
| 644 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-no').on('click', function (e) { | |
| 639 | 645 | e.preventDefault(); |
| 640 | 646 | e.stopPropagation(); |
| 641 | - $deactivateLink.unbind('click'); | |
| 647 | + $(targetElement).unbind('click'); | |
| 642 | 648 | $('body').removeClass('ti-feedback-open'); |
| 643 | 649 | $('<?php echo esc_attr( $popup_id ); ?>').remove(); |
| 644 | 650 | if (redirectUrl !== '') { |
| 645 | 651 | location.href = redirectUrl; |
| @@ -645,17 +651,17 @@ | ||
| 645 | 651 | location.href = redirectUrl; |
| 646 | 652 | } |
| 647 | 653 | }); |
| 648 | 654 | |
| 649 | - $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { | |
| 655 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) { | |
| 650 | 656 | e.preventDefault(); |
| 651 | 657 | e.stopPropagation(); |
| 652 | - $deactivateLink.unbind('click'); | |
| 658 | + $(targetElement).unbind('click'); | |
| 653 | 659 | var selectedOption = $( |
| 654 | 660 | '<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked'); |
| 655 | 661 | var data = { |
| 656 | 662 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 657 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 663 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 658 | 664 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 659 | 665 | 'msg': selectedOption.parent().find('textarea').val(), |
| 660 | 666 | 'type': 'plugin', |
| 661 | 667 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -694,15 +700,13 @@ | ||
| 694 | 700 | private function get_disclosure_labels() { |
| 695 | 701 | $disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product ); |
| 696 | 702 | $disclosure_labels = array_merge( |
| 697 | 703 | [ |
| 698 | - 'title' => Loader::$labels['uninstall']['disclosure']['title'], | |
| 704 | + '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 | 705 | '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>' ), | |
| 704 | - sprintf( Loader::$labels['uninstall']['disclosure']['diagnostics'], '<strong>', '</strong>' ), | |
| 706 | + sprintf( '%s %s version %s %s %s %s', '<strong>', ucwords( $this->product->get_type() ), '</strong>', '<code>', $this->product->get_version(), '</code>' ), | |
| 707 | + sprintf( '%sCurrent website:%s %s %s %s', '<strong>', '</strong>', '<code>', get_site_url(), '</code>' ), | |
| 708 | + sprintf( '%s Uninstall reason %s %s Selected reason from the above survey %s ', '<strong>', '</strong>', '<i>', '</i>' ), | |
| 705 | 709 | ], |
| 706 | 710 | ], |
| 707 | 711 | $disclosure_new_labels |
| 708 | 712 | ); |
| @@ -720,9 +724,9 @@ | ||
| 720 | 724 | * Randomizes the options array. |
| 721 | 725 | * |
| 722 | 726 | * @param array $options The options array. |
| 723 | 727 | */ |
| 724 | - public function randomize_options( $options ) { | |
| 728 | + function randomize_options( $options ) { | |
| 725 | 729 | $new = array(); |
| 726 | 730 | $keys = array_keys( $options ); |
| 727 | 731 | shuffle( $keys ); |
| 728 | 732 | |
| @@ -735,9 +739,9 @@ | ||
| 735 | 739 | |
| 736 | 740 | /** |
| 737 | 741 | * Called when the deactivate button is clicked. |
| 738 | 742 | */ |
| 739 | - public function post_deactivate() { | |
| 743 | + function post_deactivate() { | |
| 740 | 744 | check_ajax_referer( (string) __CLASS__, 'nonce' ); |
| 741 | 745 | |
| 742 | 746 | $this->post_deactivate_or_cancel(); |
| 743 | 747 | |
| @@ -749,10 +753,10 @@ | ||
| 749 | 753 | } |
| 750 | 754 | $this->call_api( |
| 751 | 755 | array( |
| 752 | 756 | 'type' => 'deactivate', |
| 753 | - 'id' => sanitize_key( $_POST['id'] ), | |
| 754 | - 'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '', | |
| 757 | + 'id' => $_POST['id'], | |
| 758 | + 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', | |
| 755 | 759 | ) |
| 756 | 760 | ); |
| 757 | 761 | wp_send_json( [] ); |
| 758 | 762 | |
| @@ -761,16 +765,16 @@ | ||
| 761 | 765 | /** |
| 762 | 766 | * Called when the deactivate/cancel button is clicked. |
| 763 | 767 | */ |
| 764 | 768 | private function post_deactivate_or_cancel() { |
| 765 | - if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 769 | + if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { | |
| 766 | 770 | return; |
| 767 | 771 | } |
| 768 | - if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 772 | + if ( 'theme' !== $_POST['type'] ) { | |
| 769 | 773 | return; |
| 770 | 774 | } |
| 771 | 775 | |
| 772 | - 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. | |
| 776 | + set_transient( 'ti_sdk_pause_' . $_POST['key'], true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS ); | |
| 773 | 777 | |
| 774 | 778 | } |
| 775 | 779 | |
| 776 | 780 | /** |
| @@ -780,28 +784,13 @@ | ||
| 780 | 784 | * |
| 781 | 785 | * @return bool Is the request succesfull? |
| 782 | 786 | */ |
| 783 | 787 | protected function call_api( $attributes ) { |
| 784 | - $slug = $this->product->get_slug(); | |
| 785 | - $version = $this->product->get_version(); | |
| 786 | - $attributes['slug'] = $slug; | |
| 787 | - $attributes['version'] = $version; | |
| 788 | - $attributes['url'] = get_site_url(); | |
| 789 | - $attributes['active_time'] = ( time() - $this->product->get_install_time() ); | |
| 790 | - | |
| 791 | - /** | |
| 792 | - * Piggyback the compact crash summary on the same request, regardless | |
| 793 | - * of the logging consent — disclosed in the survey data collection | |
| 794 | - * notice. Only crashes attributed to this product are ever stored. | |
| 795 | - */ | |
| 796 | - if ( class_exists( 'ThemeisleSDK\Modules\Crash_Reporter' ) ) { | |
| 797 | - $crashes = Crash_Reporter::get_uninstall_summary( $this->product ); | |
| 798 | - if ( ! empty( $crashes ) ) { | |
| 799 | - $attributes['crashes'] = wp_json_encode( $crashes ); | |
| 800 | - } | |
| 801 | - } | |
| 802 | - | |
| 803 | - $attributes = apply_filters( 'themeisle_sdk_uninstall_feedback_data', $attributes, $this->product ); | |
| 788 | + $slug = $this->product->get_slug(); | |
| 789 | + $version = $this->product->get_version(); | |
| 790 | + $attributes['slug'] = $slug; | |
| 791 | + $attributes['version'] = $version; | |
| 792 | + $attributes['url'] = get_site_url(); | |
| 804 | 793 | |
| 805 | 794 | $response = wp_remote_post( |
| 806 | 795 | self::FEEDBACK_ENDPOINT, |
| 807 | 796 | array( |