← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+37
-6
4.2.5
→
trunk
View file →
| @@ -138,9 +138,10 @@ | ||
| 138 | 138 | |
| 139 | 139 | ?> |
| 140 | 140 | <div class="ti-theme-uninstall-feedback-drawer ti-feedback"> |
| 141 | 141 | <div class="popup--header"> |
| 142 | - <h5><?php echo wp_kses( $heading, array( 'span' => true ) ); ?> </h5> | |
| 142 | + <h5><?php echo wp_kses( $heading, array( 'span' => true ) ); ?></h5> | |
| 143 | + <?php $this->do_popup_header_after_heading_action( 'theme' ); ?> | |
| 143 | 144 | <button class="toggle"><span>×</span></button> |
| 144 | 145 | </div><!--/.popup--header--> |
| 145 | 146 | <div class="popup--body"> |
| 146 | 147 | <?php $this->render_options_list( $options ); ?> |
| @@ -484,8 +485,21 @@ | ||
| 484 | 485 | do_action( $this->product->get_key() . '_uninstall_feedback_after_js' ); |
| 485 | 486 | } |
| 486 | 487 | |
| 487 | 488 | /** |
| 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 | + /** | |
| 488 | 502 | * Render the options list. |
| 489 | 503 | * |
| 490 | 504 | * @param array $options the options for the feedback form. |
| 491 | 505 | */ |
| @@ -534,8 +548,9 @@ | ||
| 534 | 548 | <div class="ti-plugin-uninstall-feedback-popup ti-feedback" |
| 535 | 549 | id="<?php echo esc_attr( $this->product->get_slug() . '_uninstall_feedback_popup' ); ?>"> |
| 536 | 550 | <div class="popup--header"> |
| 537 | 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' ); ?> | |
| 538 | 553 | </div><!--/.popup--header--> |
| 539 | 554 | <div class="popup--body"> |
| 540 | 555 | <?php $this->render_options_list( $options ); ?> |
| 541 | 556 | </div><!--/.popup--body--> |
| @@ -580,15 +595,16 @@ | ||
| 580 | 595 | <script type="text/javascript" id="ti-deactivate-js"> |
| 581 | 596 | (function ($) { |
| 582 | 597 | $(document).ready(function () { |
| 583 | 598 | var targetElement = 'tr[data-plugin^="<?php echo esc_attr( $this->product->get_slug() ); ?>/"] span.deactivate a'; |
| 584 | - var redirectUrl = $(targetElement).attr('href'); | |
| 599 | + var $deactivateLink = $(targetElement); | |
| 600 | + var redirectUrl = $deactivateLink.attr('href'); | |
| 585 | 601 | if ($('.ti-feedback-overlay').length === 0) { |
| 586 | 602 | $('body').prepend('<div class="ti-feedback-overlay"></div>'); |
| 587 | 603 | } |
| 588 | - $('<?php echo esc_attr( $popup_id ); ?> ').appendTo($(targetElement).parent()); | |
| 604 | + $('<?php echo esc_attr( $popup_id ); ?> ').appendTo($deactivateLink.parent()); | |
| 589 | 605 | |
| 590 | - $(targetElement).on('click', function (e) { | |
| 606 | + $deactivateLink.on('click', function (e) { | |
| 591 | 607 | e.preventDefault(); |
| 592 | 608 | $('<?php echo esc_attr( $popup_id ); ?> ').addClass('active'); |
| 593 | 609 | $('body').addClass('ti-feedback-open'); |
| 594 | 610 | $('.ti-feedback-overlay').on('click', function () { |
| @@ -621,9 +637,9 @@ | ||
| 621 | 637 | |
| 622 | 638 | $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-no').on('click', function (e) { |
| 623 | 639 | e.preventDefault(); |
| 624 | 640 | e.stopPropagation(); |
| 625 | - $(targetElement).unbind('click'); | |
| 641 | + $deactivateLink.unbind('click'); | |
| 626 | 642 | $('body').removeClass('ti-feedback-open'); |
| 627 | 643 | $('<?php echo esc_attr( $popup_id ); ?>').remove(); |
| 628 | 644 | if (redirectUrl !== '') { |
| 629 | 645 | location.href = redirectUrl; |
| @@ -632,9 +648,9 @@ | ||
| 632 | 648 | |
| 633 | 649 | $('<?php echo esc_attr( $popup_id ); ?> #<?php echo esc_attr( $key ); ?>ti-deactivate-yes').on('click', function (e) { |
| 634 | 650 | e.preventDefault(); |
| 635 | 651 | e.stopPropagation(); |
| 636 | - $(targetElement).unbind('click'); | |
| 652 | + $deactivateLink.unbind('click'); | |
| 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'; ?>', |
| @@ -684,8 +700,9 @@ | ||
| 684 | 700 | sprintf( Loader::$labels['uninstall']['disclosure']['version'], '<strong>', ucwords( $this->product->get_type() ), '</strong>', '<code>', $this->product->get_version(), '</code>' ), |
| 685 | 701 | sprintf( Loader::$labels['uninstall']['disclosure']['website'], '<strong>', '</strong>', '<code>', get_site_url(), '</code>' ), |
| 686 | 702 | sprintf( Loader::$labels['uninstall']['disclosure']['usage'], '<strong>', '</strong>', '<code>', ( time() - $this->product->get_install_time() ), 's</code>' ), |
| 687 | 703 | sprintf( Loader::$labels['uninstall']['disclosure']['reason'], '<strong>', '</strong>', '<i>', '</i>' ), |
| 704 | + sprintf( Loader::$labels['uninstall']['disclosure']['diagnostics'], '<strong>', '</strong>' ), | |
| 688 | 705 | ], |
| 689 | 706 | ], |
| 690 | 707 | $disclosure_new_labels |
| 691 | 708 | ); |
| @@ -769,8 +786,22 @@ | ||
| 769 | 786 | $attributes['slug'] = $slug; |
| 770 | 787 | $attributes['version'] = $version; |
| 771 | 788 | $attributes['url'] = get_site_url(); |
| 772 | 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 ); | |
| 773 | 804 | |
| 774 | 805 | $response = wp_remote_post( |
| 775 | 806 | self::FEEDBACK_ENDPOINT, |
| 776 | 807 | array( |