← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+34
-36
3.10.3
→
3.4.11
View file →
| @@ -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, |
| @@ -413,9 +413,9 @@ | ||
| 413 | 413 | .ti-plugin-uninstall-feedback-popup.active { |
| 414 | 414 | display: block; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>"] .deactivate { | |
| 417 | + tr[data-plugin^="<?php echo $this->product->get_slug(); ?>"] .deactivate { | |
| 418 | 418 | position: relative; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | body.ti-feedback-open .ti-feedback-overlay { |
| @@ -474,22 +474,22 @@ | ||
| 474 | 474 | $('.ti-theme-uninstall-feedback-drawer input[type="radio"]').on('change', function () { |
| 475 | 475 | var radio = $(this); |
| 476 | 476 | if (radio.parent().find('textarea').length > 0 && |
| 477 | 477 | radio.parent().find('textarea').val().length === 0) { |
| 478 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 478 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 479 | 479 | radio.parent().find('textarea').on('keyup', function (e) { |
| 480 | 480 | if ($(this).val().length === 0) { |
| 481 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 481 | + $('#<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 482 | 482 | } else { |
| 483 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 483 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 484 | 484 | } |
| 485 | 485 | }); |
| 486 | 486 | } else { |
| 487 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 487 | + $('#<?php echo $key; ?>ti-deactivate-yes').removeAttr('disabled'); | |
| 488 | 488 | } |
| 489 | 489 | }); |
| 490 | 490 | |
| 491 | - $('#<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { | |
| 491 | + $('#<?php echo $key; ?>ti-deactivate-yes').on('click', function (e) { | |
| 492 | 492 | e.preventDefault(); |
| 493 | 493 | e.stopPropagation(); |
| 494 | 494 | |
| 495 | 495 | var selectedOption = $( |
| @@ -495,9 +495,9 @@ | ||
| 495 | 495 | var selectedOption = $( |
| 496 | 496 | '.ti-theme-uninstall-feedback-drawer input[name="ti-deactivate-option"]:checked'); |
| 497 | 497 | $.post(ajaxurl, { |
| 498 | 498 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 499 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 499 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 500 | 500 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 501 | 501 | 'msg': selectedOption.parent().find('textarea').val(), |
| 502 | 502 | 'type': 'theme', |
| 503 | 503 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -528,14 +528,14 @@ | ||
| 528 | 528 | <?php foreach ( $options as $title => $attributes ) { ?> |
| 529 | 529 | <li ti-option-id="<?php echo esc_attr( $attributes['id'] ); ?>"> |
| 530 | 530 | <input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 531 | 531 | <label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 532 | - <?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?> | |
| 532 | + <?php echo str_replace( '{theme}', $this->product->get_name(), $title ); ?> | |
| 533 | 533 | </label> |
| 534 | 534 | <?php |
| 535 | 535 | if ( array_key_exists( 'type', $attributes ) ) { |
| 536 | 536 | $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>'; | |
| 537 | + echo '<textarea width="100%" rows="' . $inputs_row_map[ $attributes['type'] ] . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>'; | |
| 538 | 538 | } |
| 539 | 539 | ?> |
| 540 | 540 | </li> |
| 541 | 541 | <?php } ?> |
| @@ -566,15 +566,15 @@ | ||
| 566 | 566 | <?php |
| 567 | 567 | echo wp_kses_post( $info_disclosure_link ); |
| 568 | 568 | echo wp_kses_post( $this->get_disclosure_labels() ); |
| 569 | 569 | echo '<div class="buttons">'; |
| 570 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 570 | + echo get_submit_button( | |
| 571 | 571 | $button_cancel, |
| 572 | 572 | 'secondary', |
| 573 | 573 | $this->product->get_key() . 'ti-deactivate-no', |
| 574 | 574 | false |
| 575 | 575 | ); |
| 576 | - echo get_submit_button( //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Function internals are escaped. | |
| 576 | + echo get_submit_button( | |
| 577 | 577 | $button_submit, |
| 578 | 578 | 'primary', |
| 579 | 579 | $this->product->get_key() . 'ti-deactivate-yes', |
| 580 | 580 | false, |
| @@ -601,9 +601,9 @@ | ||
| 601 | 601 | ?> |
| 602 | 602 | <script type="text/javascript" id="ti-deactivate-js"> |
| 603 | 603 | (function ($) { |
| 604 | 604 | $(document).ready(function () { |
| 605 | - var targetElement = 'tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>/"] span.deactivate a'; | |
| 605 | + var targetElement = 'tr[data-plugin^="<?php echo $this->product->get_slug(); ?>/"] span.deactivate a'; | |
| 606 | 606 | var redirectUrl = $(targetElement).attr('href'); |
| 607 | 607 | if ($('.ti-feedback-overlay').length === 0) { |
| 608 | 608 | $('body').prepend('<div class="ti-feedback-overlay"></div>'); |
| 609 | 609 | } |
| @@ -627,22 +627,22 @@ | ||
| 627 | 627 | $('<?php echo esc_attr( $popup_id ); ?> input[type="radio"]').on('change', function () { |
| 628 | 628 | var radio = $(this); |
| 629 | 629 | if (radio.parent().find('textarea').length > 0 && |
| 630 | 630 | 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'); | |
| 631 | + $('<?php echo esc_attr( $popup_id ); ?> #<?php echo $key; ?>ti-deactivate-yes').attr('disabled', 'disabled'); | |
| 632 | 632 | radio.parent().find('textarea').on('keyup', function (e) { |
| 633 | 633 | if ($(this).val().length === 0) { |
| 634 | - $('<?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'); | |
| 635 | 635 | } else { |
| 636 | - $('<?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'); | |
| 637 | 637 | } |
| 638 | 638 | }); |
| 639 | 639 | } else { |
| 640 | - $('<?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'); | |
| 641 | 641 | } |
| 642 | 642 | }); |
| 643 | 643 | |
| 644 | - $('<?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) { | |
| 645 | 645 | e.preventDefault(); |
| 646 | 646 | e.stopPropagation(); |
| 647 | 647 | $(targetElement).unbind('click'); |
| 648 | 648 | $('body').removeClass('ti-feedback-open'); |
| @@ -651,9 +651,9 @@ | ||
| 651 | 651 | location.href = redirectUrl; |
| 652 | 652 | } |
| 653 | 653 | }); |
| 654 | 654 | |
| 655 | - $('<?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) { | |
| 656 | 656 | e.preventDefault(); |
| 657 | 657 | e.stopPropagation(); |
| 658 | 658 | $(targetElement).unbind('click'); |
| 659 | 659 | var selectedOption = $( |
| @@ -659,9 +659,9 @@ | ||
| 659 | 659 | var selectedOption = $( |
| 660 | 660 | '<?php echo esc_attr( $popup_id ); ?> input[name="ti-deactivate-option"]:checked'); |
| 661 | 661 | var data = { |
| 662 | 662 | 'action': '<?php echo esc_attr( $key ) . '_uninstall_feedback'; ?>', |
| 663 | - 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 663 | + 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 664 | 664 | 'id': selectedOption.parent().attr('ti-option-id'), |
| 665 | 665 | 'msg': selectedOption.parent().find('textarea').val(), |
| 666 | 666 | 'type': 'plugin', |
| 667 | 667 | 'key': '<?php echo esc_attr( $key ); ?>' |
| @@ -700,13 +700,12 @@ | ||
| 700 | 700 | private function get_disclosure_labels() { |
| 701 | 701 | $disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product ); |
| 702 | 702 | $disclosure_labels = array_merge( |
| 703 | 703 | [ |
| 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.', | |
| 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.', | |
| 705 | 705 | 'items' => [ |
| 706 | 706 | sprintf( '%s %s version %s %s %s %s', '<strong>', ucwords( $this->product->get_type() ), '</strong>', '<code>', $this->product->get_version(), '</code>' ), |
| 707 | 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 | 708 | sprintf( '%s Uninstall reason %s %s Selected reason from the above survey %s ', '<strong>', '</strong>', '<i>', '</i>' ), |
| 710 | 709 | ], |
| 711 | 710 | ], |
| 712 | 711 | $disclosure_new_labels |
| @@ -725,9 +724,9 @@ | ||
| 725 | 724 | * Randomizes the options array. |
| 726 | 725 | * |
| 727 | 726 | * @param array $options The options array. |
| 728 | 727 | */ |
| 729 | - public function randomize_options( $options ) { | |
| 728 | + function randomize_options( $options ) { | |
| 730 | 729 | $new = array(); |
| 731 | 730 | $keys = array_keys( $options ); |
| 732 | 731 | shuffle( $keys ); |
| 733 | 732 | |
| @@ -740,9 +739,9 @@ | ||
| 740 | 739 | |
| 741 | 740 | /** |
| 742 | 741 | * Called when the deactivate button is clicked. |
| 743 | 742 | */ |
| 744 | - public function post_deactivate() { | |
| 743 | + function post_deactivate() { | |
| 745 | 744 | check_ajax_referer( (string) __CLASS__, 'nonce' ); |
| 746 | 745 | |
| 747 | 746 | $this->post_deactivate_or_cancel(); |
| 748 | 747 | |
| @@ -754,10 +753,10 @@ | ||
| 754 | 753 | } |
| 755 | 754 | $this->call_api( |
| 756 | 755 | array( |
| 757 | 756 | 'type' => 'deactivate', |
| 758 | - 'id' => sanitize_key( $_POST['id'] ), | |
| 759 | - 'comment' => isset( $_POST['msg'] ) ? sanitize_textarea_field( $_POST['msg'] ) : '', | |
| 757 | + 'id' => $_POST['id'], | |
| 758 | + 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', | |
| 760 | 759 | ) |
| 761 | 760 | ); |
| 762 | 761 | wp_send_json( [] ); |
| 763 | 762 | |
| @@ -766,16 +765,16 @@ | ||
| 766 | 765 | /** |
| 767 | 766 | * Called when the deactivate/cancel button is clicked. |
| 768 | 767 | */ |
| 769 | 768 | 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. | |
| 769 | + if ( ! isset( $_POST['type'] ) || ! isset( $_POST['key'] ) ) { | |
| 771 | 770 | return; |
| 772 | 771 | } |
| 773 | - if ( 'theme' !== $_POST['type'] ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing, Nonce already present in caller function. | |
| 772 | + if ( 'theme' !== $_POST['type'] ) { | |
| 774 | 773 | return; |
| 775 | 774 | } |
| 776 | 775 | |
| 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. | |
| 776 | + set_transient( 'ti_sdk_pause_' . $_POST['key'], true, self::PAUSE_DEACTIVATE_WINDOW_DAYS * DAY_IN_SECONDS ); | |
| 778 | 777 | |
| 779 | 778 | } |
| 780 | 779 | |
| 781 | 780 | /** |
| @@ -785,14 +784,13 @@ | ||
| 785 | 784 | * |
| 786 | 785 | * @return bool Is the request succesfull? |
| 787 | 786 | */ |
| 788 | 787 | 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() ); | |
| 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(); | |
| 795 | 793 | |
| 796 | 794 | $response = wp_remote_post( |
| 797 | 795 | self::FEEDBACK_ENDPOINT, |
| 798 | 796 | array( |