← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+111
-99
3.10.13
→
3.4.2
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' ) ) { |
| @@ -40,9 +39,9 @@ | ||
| 40 | 39 | * Where to send the data. |
| 41 | 40 | * |
| 42 | 41 | * @var string Endpoint url. |
| 43 | 42 | */ |
| 44 | - const FEEDBACK_ENDPOINT = 'https://api.themeisle.com/tracking/uninstall'; | |
| 43 | + const FEEDBACK_ENDPOINT = 'http://feedback.themeisle.com/wordpress/wp-json/__pirate_feedback_/v1/feedback'; | |
| 45 | 44 | |
| 46 | 45 | /** |
| 47 | 46 | * Default options for plugins. |
| 48 | 47 | * |
| @@ -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 | ?> |
| @@ -150,9 +177,9 @@ | ||
| 150 | 177 | <?php |
| 151 | 178 | echo wp_kses_post( $info_disclosure_link ); |
| 152 | 179 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 153 | 180 | echo '<div class="buttons">'; |
| 154 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function has an internal sanitization. | |
| 181 | + echo get_submit_button( | |
| 155 | 182 | $button_submit, |
| 156 | 183 | 'secondary', |
| 157 | 184 | $this->product->get_key() . 'ti-deactivate-yes', |
| 158 | 185 | false, |
| @@ -208,9 +235,9 @@ | ||
| 208 | 235 | font-size: 13px; |
| 209 | 236 | } |
| 210 | 237 | |
| 211 | 238 | .ti-feedback .popup--form input[type="radio"] { |
| 212 | - <?php echo is_rtl() ? 'margin: 0 0 0 10px;' : 'margin: 0 10px 0 0;'; ?> | |
| 239 | + margin: 0 10px 0 0; | |
| 213 | 240 | } |
| 214 | 241 | |
| 215 | 242 | .ti-feedback .popup--form input[type="radio"]:checked ~ textarea { |
| 216 | 243 | display: block; |
| @@ -286,9 +313,9 @@ | ||
| 286 | 313 | width: 100%; |
| 287 | 314 | } |
| 288 | 315 | |
| 289 | 316 | .ti-feedback .buttons input:last-child { |
| 290 | - <?php echo is_rtl() ? 'margin-right: auto;' : 'margin-left: auto;'; ?> | |
| 317 | + margin-left: auto; | |
| 291 | 318 | } |
| 292 | 319 | |
| 293 | 320 | .ti-theme-uninstall-feedback-drawer { |
| 294 | 321 | border-top-left-radius: 5px; |
| @@ -338,21 +365,15 @@ | ||
| 338 | 365 | .ti-plugin-uninstall-feedback-popup .popup--header:before { |
| 339 | 366 | content: ""; |
| 340 | 367 | display: block; |
| 341 | 368 | position: absolute; |
| 369 | + border: 20px solid #23A1CE; | |
| 370 | + left: -10px; | |
| 342 | 371 | top: 50%; |
| 372 | + border-top: 20px solid transparent; | |
| 373 | + border-bottom: 20px solid transparent; | |
| 374 | + border-left: 0; | |
| 343 | 375 | transform: translateY(-50%); |
| 344 | - <?php | |
| 345 | - echo is_rtl() ? | |
| 346 | - 'right: -10px; | |
| 347 | - border-top: 20px solid transparent; | |
| 348 | - border-left: 20px solid #23A1CE; | |
| 349 | - border-bottom: 20px solid transparent;' : | |
| 350 | - 'left: -10px; | |
| 351 | - border-top: 20px solid transparent; | |
| 352 | - border-right: 20px solid #23A1CE; | |
| 353 | - border-bottom: 20px solid transparent;'; | |
| 354 | - ?> | |
| 355 | 376 | } |
| 356 | 377 | |
| 357 | 378 | .ti-plugin-uninstall-feedback-popup { |
| 358 | 379 | display: none; |
| @@ -358,9 +379,10 @@ | ||
| 358 | 379 | display: none; |
| 359 | 380 | position: absolute; |
| 360 | 381 | white-space: normal; |
| 361 | 382 | width: 400px; |
| 362 | - <?php echo is_rtl() ? 'right: calc( 100% + 15px );' : 'left: calc( 100% + 15px );'; ?> top: -15px; | |
| 383 | + left: 100%; | |
| 384 | + top: -15px; | |
| 363 | 385 | } |
| 364 | 386 | |
| 365 | 387 | .ti-plugin-uninstall-feedback-popup.sending-feedback .popup--body i { |
| 366 | 388 | animation: rotation 2s infinite linear; |
| @@ -385,9 +407,9 @@ | ||
| 385 | 407 | .ti-plugin-uninstall-feedback-popup.active { |
| 386 | 408 | display: block; |
| 387 | 409 | } |
| 388 | 410 | |
| 389 | - tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>"] .deactivate { | |
| 411 | + tr[data-plugin^="<?php echo $this->product->get_slug(); ?>"] .deactivate { | |
| 390 | 412 | position: relative; |
| 391 | 413 | } |
| 392 | 414 | |
| 393 | 415 | body.ti-feedback-open .ti-feedback-overlay { |
| @@ -446,22 +468,22 @@ | ||
| 446 | 468 | $('.ti-theme-uninstall-feedback-drawer input[type="radio"]').on('change', function () { |
| 447 | 469 | var radio = $(this); |
| 448 | 470 | if (radio.parent().find('textarea').length > 0 && |
| 449 | 471 | radio.parent().find('textarea').val().length === 0) { |
| 450 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 472 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 451 | 473 | radio.parent().find('textarea').on('keyup', function (e) { |
| 452 | 474 | if ($(this).val().length === 0) { |
| 453 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 475 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 454 | 476 | } else { |
| 455 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 477 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 456 | 478 | } |
| 457 | 479 | }); |
| 458 | 480 | } else { |
| 459 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 481 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 460 | 482 | } |
| 461 | 483 | }); |
| 462 | 484 | |
| 463 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { | |
| 485 | + $('#<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) { | |
| 464 | 486 | e.preventDefault(); |
| 465 | 487 | e.stopPropagation(); |
| 466 | 488 | |
| 467 | 489 | var selectedOption = $( |
| @@ -467,9 +489,9 @@ | ||
| 467 | 489 | var selectedOption = $( |
| 468 | 490 | '.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked'); |
| 469 | 491 | $.post(ajaxurl, { |
| 470 | 492 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 471 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 493 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 472 | 494 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 473 | 495 | 'msg': selectedOption.parent().find('textarea').val(), |
| 474 | 496 | 'type': 'theme', |
| 475 | 497 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -496,23 +518,18 @@ | ||
| 496 | 518 | 'textarea' => 2, |
| 497 | 519 | ]; |
| 498 | 520 | ?> |
| 499 | 521 | <ul class="popup--form"> |
| 500 | - <?php | |
| 501 | - foreach ( $options as $idx => $attributes ) { | |
| 502 | - $title = Loader::$labels['uninstall']['options'][ $idx ]['title']; | |
| 503 | - $placeholder = array_key_exists( 'placeholder', Loader::$labels['uninstall']['options'][ $idx ] ) ? Loader::$labels['uninstall']['options'][ $idx ]['placeholder'] : ''; | |
| 504 | - ?> | |
| 522 | + <?php foreach ( $options as $title => $attributes ) { ?> | |
| 505 | 523 | <li ti-option-id="<?php echo esc_attr( $attributes['id'] ); ?>"> |
| 506 | - <input type="radio" name="ti-deactivate-option" | |
| 507 | - id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> | |
| 524 | + <input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> | |
| 508 | 525 | <label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 509 | - <?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?> | |
| 526 | + <?php echo str_replace( '{theme}', $this->product->get_name(), $title ); ?> | |
| 510 | 527 | </label> |
| 511 | 528 | <?php |
| 512 | 529 | if ( array_key_exists( 'type', $attributes ) ) { |
| 513 | - | |
| 514 | - 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>'; | |
| 515 | 532 | } |
| 516 | 533 | ?> |
| 517 | 534 | </li> |
| 518 | 535 | <?php } ?> |
| @@ -523,19 +540,18 @@ | ||
| 523 | 540 | /** |
| 524 | 541 | * Render plugin feedback popup. |
| 525 | 542 | */ |
| 526 | 543 | private function render_plugin_feedback_popup() { |
| 527 | - $button_cancel = apply_filters( $this->product->get_key() . '_feedback_deactivate_button_cancel', Loader::$labels['uninstall']['button_cancel'] ); | |
| 528 | - $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 ); | |
| 529 | 546 | $options = $this->randomize_options( apply_filters( $this->product->get_key() . '_feedback_deactivate_options', $this->options_plugin ) ); |
| 530 | - $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>'; | |
| 531 | 548 | |
| 532 | 549 | $options += $this->other; |
| 533 | 550 | ?> |
| 534 | - <div class="ti-plugin-uninstall-feedback-popup ti-feedback" | |
| 535 | - 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' ); ?>"> | |
| 536 | 552 | <div class="popup--header"> |
| 537 | - <h5><?php echo wp_kses( Loader::$labels['uninstall']['heading_plugin'], array( 'span' => true ) ); ?> </h5> | |
| 553 | + <h5><?php echo wp_kses( $this->heading_plugin, array( 'span' => true ) ); ?> </h5> | |
| 538 | 554 | </div><!--/.popup--header--> |
| 539 | 555 | <div class="popup--body"> |
| 540 | 556 | <?php $this->render_options_list( $options ); ?> |
| 541 | 557 | </div><!--/.popup--body--> |
| @@ -544,15 +560,15 @@ | ||
| 544 | 560 | <?php |
| 545 | 561 | echo wp_kses_post( $info_disclosure_link ); |
| 546 | 562 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 547 | 563 | echo '<div class="buttons">'; |
| 548 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 564 | + echo get_submit_button( | |
| 549 | 565 | $button_cancel, |
| 550 | 566 | 'secondary', |
| 551 | 567 | $this->product->get_key() . 'ti-deactivate-no', |
| 552 | 568 | false |
| 553 | 569 | ); |
| 554 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 570 | + echo get_submit_button( | |
| 555 | 571 | $button_submit, |
| 556 | 572 | 'primary', |
| 557 | 573 | $this->product->get_key() . 'ti-deactivate-yes', |
| 558 | 574 | false, |
| @@ -579,9 +595,9 @@ | ||
| 579 | 595 | ?> |
| 580 | 596 | <script type="text/javascript" id="ti-deactivate-js"> |
| 581 | 597 | (function ($) { |
| 582 | 598 | $(document).ready(function () { |
| 583 | - var targetElement = 'tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>/"] span.deactivate a'; | |
| 599 | + var targetElement = 'tr[data-plugin^="<?php echo $this->product->get_slug(); ?>/"] span.deactivate a'; | |
| 584 | 600 | var redirectUrl = $(targetElement).attr('href'); |
| 585 | 601 | if ($('.ti-feedback-overlay').length === 0) { |
| 586 | 602 | $('body').prepend('<div class="ti-feedback-overlay"></div>'); |
| 587 | 603 | } |
| @@ -605,22 +621,22 @@ | ||
| 605 | 621 | $('<?php echo esc_attr( $popup_id ); ?> input[type="radio"]').on('change', function () { |
| 606 | 622 | var radio = $(this); |
| 607 | 623 | if (radio.parent().find('textarea').length > 0 && |
| 608 | 624 | radio.parent().find('textarea').val().length === 0) { |
| 609 | - $('<?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'); | |
| 610 | 626 | radio.parent().find('textarea').on('keyup', function (e) { |
| 611 | 627 | if ($(this).val().length === 0) { |
| 612 | - $('<?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'); | |
| 613 | 629 | } else { |
| 614 | - $('<?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'); | |
| 615 | 631 | } |
| 616 | 632 | }); |
| 617 | 633 | } else { |
| 618 | - $('<?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'); | |
| 619 | 635 | } |
| 620 | 636 | }); |
| 621 | 637 | |
| 622 | - $('<?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) { | |
| 623 | 639 | e.preventDefault(); |
| 624 | 640 | e.stopPropagation(); |
| 625 | 641 | $(targetElement).unbind('click'); |
| 626 | 642 | $('body').removeClass('ti-feedback-open'); |
| @@ -629,9 +645,9 @@ | ||
| 629 | 645 | location.href = redirectUrl; |
| 630 | 646 | } |
| 631 | 647 | }); |
| 632 | 648 | |
| 633 | - $('<?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) { | |
| 634 | 650 | e.preventDefault(); |
| 635 | 651 | e.stopPropagation(); |
| 636 | 652 | $(targetElement).unbind('click'); |
| 637 | 653 | var selectedOption = $( |
| @@ -637,9 +653,9 @@ | ||
| 637 | 653 | var selectedOption = $( |
| 638 | 654 | '<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked'); |
| 639 | 655 | var data = { |
| 640 | 656 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 641 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 657 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 642 | 658 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 643 | 659 | 'msg': selectedOption.parent().find('textarea').val(), |
| 644 | 660 | 'type': 'plugin', |
| 645 | 661 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -678,14 +694,12 @@ | ||
| 678 | 694 | private function get_disclosure_labels() { |
| 679 | 695 | $disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product ); |
| 680 | 696 | $disclosure_labels = array_merge( |
| 681 | 697 | [ |
| 682 | - '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.', | |
| 683 | 699 | 'items' => [ |
| 684 | - sprintf( Loader::$labels['uninstall']['disclosure']['version'], '<strong>', ucwords( $this->product->get_type() ), '</strong>', '<code>', $this->product->get_version(), '</code>' ), | |
| 685 | - sprintf( Loader::$labels['uninstall']['disclosure']['website'], '<strong>', '</strong>', '<code>', get_site_url(), '</code>' ), | |
| 686 | - sprintf( Loader::$labels['uninstall']['disclosure']['usage'], '<strong>', '</strong>', '<code>', ( time() - $this->product->get_install_time() ), 's</code>' ), | |
| 687 | - 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( '%s Uninstall reason %s %s Selected reason from the above survey %s ', '<strong>', '</strong>', '<i>', '</i>' ), | |
| 688 | 702 | ], |
| 689 | 703 | ], |
| 690 | 704 | $disclosure_new_labels |
| 691 | 705 | ); |
| @@ -703,9 +717,9 @@ | ||
| 703 | 717 | * Randomizes the options array. |
| 704 | 718 | * |
| 705 | 719 | * @param array $options The options array. |
| 706 | 720 | */ |
| 707 | - public function randomize_options( $options ) { | |
| 721 | + function randomize_options( $options ) { | |
| 708 | 722 | $new = array(); |
| 709 | 723 | $keys = array_keys( $options ); |
| 710 | 724 | shuffle( $keys ); |
| 711 | 725 | |
| @@ -718,9 +732,9 @@ | ||
| 718 | 732 | |
| 719 | 733 | /** |
| 720 | 734 | * Called when the deactivate button is clicked. |
| 721 | 735 | */ |
| 722 | - public function post_deactivate() { | |
| 736 | + function post_deactivate() { | |
| 723 | 737 | check_ajax_referer( (string) __CLASS__, 'nonce' ); |
| 724 | 738 | |
| 725 | 739 | $this->post_deactivate_or_cancel(); |
| 726 | 740 | |
| @@ -732,10 +746,10 @@ | ||
| 732 | 746 | } |
| 733 | 747 | $this->call_api( |
| 734 | 748 | array( |
| 735 | 749 | 'type' => 'deactivate', |
| 736 | - 'id' => sanitize_key( $_POST['id'] ), | |
| 737 | - 'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '', | |
| 750 | + 'id' => $_POST['id'], | |
| 751 | + 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', | |
| 738 | 752 | ) |
| 739 | 753 | ); |
| 740 | 754 | wp_send_json( [] ); |
| 741 | 755 | |
| @@ -744,16 +758,16 @@ | ||
| 744 | 758 | /** |
| 745 | 759 | * Called when the deactivate/cancel button is clicked. |
| 746 | 760 | */ |
| 747 | 761 | private function post_deactivate_or_cancel() { |
| 748 | - if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 762 | + if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { | |
| 749 | 763 | return; |
| 750 | 764 | } |
| 751 | - if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 765 | + if ( 'theme' !== $_POST['type'] ) { | |
| 752 | 766 | return; |
| 753 | 767 | } |
| 754 | 768 | |
| 755 | - 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. | |
| 769 | + set_transient( 'ti_sdk_pause_' . $_POST['key'], true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS ); | |
| 756 | 770 | |
| 757 | 771 | } |
| 758 | 772 | |
| 759 | 773 | /** |
| @@ -763,14 +777,12 @@ | ||
| 763 | 777 | * |
| 764 | 778 | * @return bool Is the request succesfull? |
| 765 | 779 | */ |
| 766 | 780 | protected function call_api( $attributes ) { |
| 767 | - $slug = $this->product->get_slug(); | |
| 768 | - $version = $this->product->get_version(); | |
| 769 | - $attributes['slug'] = $slug; | |
| 770 | - $attributes['version'] = $version; | |
| 771 | - $attributes['url'] = get_site_url(); | |
| 772 | - $attributes['active_time'] = ( time() - $this->product->get_install_time() ); | |
| 781 | + $slug = $this->product->get_slug(); | |
| 782 | + $version = $this->product->get_version(); | |
| 783 | + $attributes['slug'] = $slug; | |
| 784 | + $attributes['version'] = $version; | |
| 773 | 785 | |
| 774 | 786 | $response = wp_remote_post( |
| 775 | 787 | self::FEEDBACK_ENDPOINT, |
| 776 | 788 | array( |