← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+43
-53
3.10.11
→
3.4.2
View file →
| @@ -39,9 +39,9 @@ | ||
| 39 | 39 | * Where to send the data. |
| 40 | 40 | * |
| 41 | 41 | * @var string Endpoint url. |
| 42 | 42 | */ |
| 43 | - const FEEDBACK_ENDPOINT = 'https://api.themeisle.com/tracking/uninstall'; | |
| 43 | + const FEEDBACK_ENDPOINT = 'http://feedback.themeisle.com/wordpress/wp-json/__pirate_feedback_/v1/feedback'; | |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Default options for plugins. |
| 47 | 47 | * |
| @@ -108,9 +108,9 @@ | ||
| 108 | 108 | * Default heading for plugin. |
| 109 | 109 | * |
| 110 | 110 | * @var string $heading_plugin The heading of the modal |
| 111 | 111 | */ |
| 112 | - private $heading_plugin = 'What\'s wrong?'; | |
| 112 | + private $heading_plugin = 'What’s wrong?'; | |
| 113 | 113 | /** |
| 114 | 114 | * Default heading for theme. |
| 115 | 115 | * |
| 116 | 116 | * @var string $heading_theme The heading of the modal |
| @@ -131,9 +131,9 @@ | ||
| 131 | 131 | |
| 132 | 132 | /** |
| 133 | 133 | * Loads the additional resources |
| 134 | 134 | */ |
| 135 | - public function load_resources() { | |
| 135 | + function load_resources() { | |
| 136 | 136 | $screen = get_current_screen(); |
| 137 | 137 | |
| 138 | 138 | if ( ! $screen || ! in_array( $screen->id, array( 'theme-install', 'plugins' ) ) ) { |
| 139 | 139 | return; |
| @@ -177,9 +177,9 @@ | ||
| 177 | 177 | <?php |
| 178 | 178 | echo wp_kses_post( $info_disclosure_link ); |
| 179 | 179 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 180 | 180 | echo '<div class="buttons">'; |
| 181 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function has an internal sanitization. | |
| 181 | + echo get_submit_button( | |
| 182 | 182 | $button_submit, |
| 183 | 183 | 'secondary', |
| 184 | 184 | $this->product->get_key() . 'ti-deactivate-yes', |
| 185 | 185 | false, |
| @@ -235,9 +235,9 @@ | ||
| 235 | 235 | font-size: 13px; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | .ti-feedback .popup--form input[type="radio"] { |
| 239 | - <?php echo is_rtl() ? 'margin: 0 0 0 10px;' : 'margin: 0 10px 0 0;'; ?> | |
| 239 | + margin: 0 10px 0 0; | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | .ti-feedback .popup--form input[type="radio"]:checked ~ textarea { |
| 243 | 243 | display: block; |
| @@ -313,9 +313,9 @@ | ||
| 313 | 313 | width: 100%; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | .ti-feedback .buttons input:last-child { |
| 317 | - <?php echo is_rtl() ? 'margin-right: auto;' : 'margin-left: auto;'; ?> | |
| 317 | + margin-left: auto; | |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | .ti-theme-uninstall-feedback-drawer { |
| 321 | 321 | border-top-left-radius: 5px; |
| @@ -365,21 +365,15 @@ | ||
| 365 | 365 | .ti-plugin-uninstall-feedback-popup .popup--header:before { |
| 366 | 366 | content: ""; |
| 367 | 367 | display: block; |
| 368 | 368 | position: absolute; |
| 369 | + border: 20px solid #23A1CE; | |
| 370 | + left: -10px; | |
| 369 | 371 | top: 50%; |
| 372 | + border-top: 20px solid transparent; | |
| 373 | + border-bottom: 20px solid transparent; | |
| 374 | + border-left: 0; | |
| 370 | 375 | transform: translateY(-50%); |
| 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 | - ?> | |
| 382 | 376 | } |
| 383 | 377 | |
| 384 | 378 | .ti-plugin-uninstall-feedback-popup { |
| 385 | 379 | display: none; |
| @@ -385,9 +379,9 @@ | ||
| 385 | 379 | display: none; |
| 386 | 380 | position: absolute; |
| 387 | 381 | white-space: normal; |
| 388 | 382 | width: 400px; |
| 389 | - <?php echo is_rtl() ? 'right: calc( 100% + 15px );' : 'left: calc( 100% + 15px );'; ?> | |
| 383 | + left: 100%; | |
| 390 | 384 | top: -15px; |
| 391 | 385 | } |
| 392 | 386 | |
| 393 | 387 | .ti-plugin-uninstall-feedback-popup.sending-feedback .popup--body i { |
| @@ -413,9 +407,9 @@ | ||
| 413 | 407 | .ti-plugin-uninstall-feedback-popup.active { |
| 414 | 408 | display: block; |
| 415 | 409 | } |
| 416 | 410 | |
| 417 | - tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>"] .deactivate { | |
| 411 | + tr[data-plugin^="<?php echo $this->product->get_slug(); ?>"] .deactivate { | |
| 418 | 412 | position: relative; |
| 419 | 413 | } |
| 420 | 414 | |
| 421 | 415 | body.ti-feedback-open .ti-feedback-overlay { |
| @@ -474,22 +468,22 @@ | ||
| 474 | 468 | $('.ti-theme-uninstall-feedback-drawer input[type="radio"]').on('change', function () { |
| 475 | 469 | var radio = $(this); |
| 476 | 470 | if (radio.parent().find('textarea').length > 0 && |
| 477 | 471 | radio.parent().find('textarea').val().length === 0) { |
| 478 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 472 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 479 | 473 | radio.parent().find('textarea').on('keyup', function (e) { |
| 480 | 474 | if ($(this).val().length === 0) { |
| 481 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 475 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 482 | 476 | } else { |
| 483 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 477 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 484 | 478 | } |
| 485 | 479 | }); |
| 486 | 480 | } else { |
| 487 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 481 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 488 | 482 | } |
| 489 | 483 | }); |
| 490 | 484 | |
| 491 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { | |
| 485 | + $('#<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) { | |
| 492 | 486 | e.preventDefault(); |
| 493 | 487 | e.stopPropagation(); |
| 494 | 488 | |
| 495 | 489 | var selectedOption = $( |
| @@ -495,9 +489,9 @@ | ||
| 495 | 489 | var selectedOption = $( |
| 496 | 490 | '.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked'); |
| 497 | 491 | $.post(ajaxurl, { |
| 498 | 492 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 499 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 493 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 500 | 494 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 501 | 495 | 'msg': selectedOption.parent().find('textarea').val(), |
| 502 | 496 | 'type': 'theme', |
| 503 | 497 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -528,14 +522,14 @@ | ||
| 528 | 522 | <?php foreach ( $options as $title => $attributes ) { ?> |
| 529 | 523 | <li ti-option-id="<?php echo esc_attr( $attributes['id'] ); ?>"> |
| 530 | 524 | <input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 531 | 525 | <label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 532 | - <?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?> | |
| 526 | + <?php echo str_replace( '{theme}', $this->product->get_name(), $title ); ?> | |
| 533 | 527 | </label> |
| 534 | 528 | <?php |
| 535 | 529 | if ( array_key_exists( 'type', $attributes ) ) { |
| 536 | 530 | $placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : ''; |
| 537 | - echo '<textarea width="100%" rows="' . esc_attr( $inputs_row_map[ $attributes['type'] ] ) . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>'; | |
| 531 | + echo '<textarea width="100%" rows="' . $inputs_row_map[ $attributes['type'] ] . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>'; | |
| 538 | 532 | } |
| 539 | 533 | ?> |
| 540 | 534 | </li> |
| 541 | 535 | <?php } ?> |
| @@ -566,15 +560,15 @@ | ||
| 566 | 560 | <?php |
| 567 | 561 | echo wp_kses_post( $info_disclosure_link ); |
| 568 | 562 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 569 | 563 | echo '<div class="buttons">'; |
| 570 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 564 | + echo get_submit_button( | |
| 571 | 565 | $button_cancel, |
| 572 | 566 | 'secondary', |
| 573 | 567 | $this->product->get_key() . 'ti-deactivate-no', |
| 574 | 568 | false |
| 575 | 569 | ); |
| 576 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 570 | + echo get_submit_button( | |
| 577 | 571 | $button_submit, |
| 578 | 572 | 'primary', |
| 579 | 573 | $this->product->get_key() . 'ti-deactivate-yes', |
| 580 | 574 | false, |
| @@ -601,9 +595,9 @@ | ||
| 601 | 595 | ?> |
| 602 | 596 | <script type="text/javascript" id="ti-deactivate-js"> |
| 603 | 597 | (function ($) { |
| 604 | 598 | $(document).ready(function () { |
| 605 | - 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'; | |
| 606 | 600 | var redirectUrl = $(targetElement).attr('href'); |
| 607 | 601 | if ($('.ti-feedback-overlay').length === 0) { |
| 608 | 602 | $('body').prepend('<div class="ti-feedback-overlay"></div>'); |
| 609 | 603 | } |
| @@ -627,22 +621,22 @@ | ||
| 627 | 621 | $('<?php echo esc_attr( $popup_id ); ?> input[type="radio"]').on('change', function () { |
| 628 | 622 | var radio = $(this); |
| 629 | 623 | if (radio.parent().find('textarea').length > 0 && |
| 630 | 624 | radio.parent().find('textarea').val().length === 0) { |
| 631 | - $('<?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'); | |
| 632 | 626 | radio.parent().find('textarea').on('keyup', function (e) { |
| 633 | 627 | if ($(this).val().length === 0) { |
| 634 | - $('<?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'); | |
| 635 | 629 | } else { |
| 636 | - $('<?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'); | |
| 637 | 631 | } |
| 638 | 632 | }); |
| 639 | 633 | } else { |
| 640 | - $('<?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'); | |
| 641 | 635 | } |
| 642 | 636 | }); |
| 643 | 637 | |
| 644 | - $('<?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) { | |
| 645 | 639 | e.preventDefault(); |
| 646 | 640 | e.stopPropagation(); |
| 647 | 641 | $(targetElement).unbind('click'); |
| 648 | 642 | $('body').removeClass('ti-feedback-open'); |
| @@ -651,9 +645,9 @@ | ||
| 651 | 645 | location.href = redirectUrl; |
| 652 | 646 | } |
| 653 | 647 | }); |
| 654 | 648 | |
| 655 | - $('<?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) { | |
| 656 | 650 | e.preventDefault(); |
| 657 | 651 | e.stopPropagation(); |
| 658 | 652 | $(targetElement).unbind('click'); |
| 659 | 653 | var selectedOption = $( |
| @@ -659,9 +653,9 @@ | ||
| 659 | 653 | var selectedOption = $( |
| 660 | 654 | '<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked'); |
| 661 | 655 | var data = { |
| 662 | 656 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 663 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 657 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 664 | 658 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 665 | 659 | 'msg': selectedOption.parent().find('textarea').val(), |
| 666 | 660 | 'type': 'plugin', |
| 667 | 661 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -700,13 +694,11 @@ | ||
| 700 | 694 | private function get_disclosure_labels() { |
| 701 | 695 | $disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product ); |
| 702 | 696 | $disclosure_labels = array_merge( |
| 703 | 697 | [ |
| 704 | - 'title' => 'Below is a detailed view of all data that ThemeIsle will receive if you fill in this survey. No email address or IP addresses are transmitted after you submit the survey.', | |
| 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.', | |
| 705 | 699 | 'items' => [ |
| 706 | 700 | 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( '%sUsage time:%s %s %s%s', '<strong>', '</strong>', '<code>', ( time() - $this->product->get_install_time() ), 's</code>' ), | |
| 709 | 701 | sprintf( '%s Uninstall reason %s %s Selected reason from the above survey %s ', '<strong>', '</strong>', '<i>', '</i>' ), |
| 710 | 702 | ], |
| 711 | 703 | ], |
| 712 | 704 | $disclosure_new_labels |
| @@ -725,9 +717,9 @@ | ||
| 725 | 717 | * Randomizes the options array. |
| 726 | 718 | * |
| 727 | 719 | * @param array $options The options array. |
| 728 | 720 | */ |
| 729 | - public function randomize_options( $options ) { | |
| 721 | + function randomize_options( $options ) { | |
| 730 | 722 | $new = array(); |
| 731 | 723 | $keys = array_keys( $options ); |
| 732 | 724 | shuffle( $keys ); |
| 733 | 725 | |
| @@ -740,9 +732,9 @@ | ||
| 740 | 732 | |
| 741 | 733 | /** |
| 742 | 734 | * Called when the deactivate button is clicked. |
| 743 | 735 | */ |
| 744 | - public function post_deactivate() { | |
| 736 | + function post_deactivate() { | |
| 745 | 737 | check_ajax_referer( (string) __CLASS__, 'nonce' ); |
| 746 | 738 | |
| 747 | 739 | $this->post_deactivate_or_cancel(); |
| 748 | 740 | |
| @@ -754,10 +746,10 @@ | ||
| 754 | 746 | } |
| 755 | 747 | $this->call_api( |
| 756 | 748 | array( |
| 757 | 749 | 'type' => 'deactivate', |
| 758 | - 'id' => sanitize_key( $_POST['id'] ), | |
| 759 | - 'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '', | |
| 750 | + 'id' => $_POST['id'], | |
| 751 | + 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', | |
| 760 | 752 | ) |
| 761 | 753 | ); |
| 762 | 754 | wp_send_json( [] ); |
| 763 | 755 | |
| @@ -766,16 +758,16 @@ | ||
| 766 | 758 | /** |
| 767 | 759 | * Called when the deactivate/cancel button is clicked. |
| 768 | 760 | */ |
| 769 | 761 | private function post_deactivate_or_cancel() { |
| 770 | - 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'] ) ) { | |
| 771 | 763 | return; |
| 772 | 764 | } |
| 773 | - if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 765 | + if ( 'theme' !== $_POST['type'] ) { | |
| 774 | 766 | return; |
| 775 | 767 | } |
| 776 | 768 | |
| 777 | - 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 ); | |
| 778 | 770 | |
| 779 | 771 | } |
| 780 | 772 | |
| 781 | 773 | /** |
| @@ -785,14 +777,12 @@ | ||
| 785 | 777 | * |
| 786 | 778 | * @return bool Is the request succesfull? |
| 787 | 779 | */ |
| 788 | 780 | protected function call_api( $attributes ) { |
| 789 | - $slug = $this->product->get_slug(); | |
| 790 | - $version = $this->product->get_version(); | |
| 791 | - $attributes['slug'] = $slug; | |
| 792 | - $attributes['version'] = $version; | |
| 793 | - $attributes['url'] = get_site_url(); | |
| 794 | - $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; | |
| 795 | 785 | |
| 796 | 786 | $response = wp_remote_post( |
| 797 | 787 | self::FEEDBACK_ENDPOINT, |
| 798 | 788 | array( |