← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Uninstall_feedback.php
+90
-70
3.10.13
→
3.7.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' ) ) { |
| @@ -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,13 +97,38 @@ | ||
| 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 | */ |
| @@ -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 | ?> |
| @@ -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 | + <?php echo is_rtl() ? 'margin: 0 0 0 10px;' : '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 | + <?php echo is_rtl() ? 'margin-right: auto;' : 'margin-left: auto;'; ?> | |
| 291 | 318 | } |
| 292 | 319 | |
| 293 | 320 | .ti-theme-uninstall-feedback-drawer { |
| 294 | 321 | border-top-left-radius: 5px; |
| @@ -340,19 +367,19 @@ | ||
| 340 | 367 | display: block; |
| 341 | 368 | position: absolute; |
| 342 | 369 | top: 50%; |
| 343 | 370 | 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 | - ?> | |
| 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 | + ?> | |
| 355 | 382 | } |
| 356 | 383 | |
| 357 | 384 | .ti-plugin-uninstall-feedback-popup { |
| 358 | 385 | display: none; |
| @@ -358,9 +385,10 @@ | ||
| 358 | 385 | display: none; |
| 359 | 386 | position: absolute; |
| 360 | 387 | white-space: normal; |
| 361 | 388 | width: 400px; |
| 362 | - <?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; | |
| 363 | 391 | } |
| 364 | 392 | |
| 365 | 393 | .ti-plugin-uninstall-feedback-popup.sending-feedback .popup--body i { |
| 366 | 394 | animation: rotation 2s infinite linear; |
| @@ -496,22 +524,17 @@ | ||
| 496 | 524 | 'textarea' => 2, |
| 497 | 525 | ]; |
| 498 | 526 | ?> |
| 499 | 527 | <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 | - ?> | |
| 528 | + <?php foreach ( $options as $title => $attributes ) { ?> | |
| 505 | 529 | <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'] ); ?>"> | |
| 530 | + <input type="radio" name="ti-deactivate-option" id="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> | |
| 508 | 531 | <label for="<?php echo esc_attr( $key . $attributes['id'] ); ?>"> |
| 509 | 532 | <?php echo esc_attr( str_replace( '{theme}', $this->product->get_name(), $title ) ); ?> |
| 510 | 533 | </label> |
| 511 | 534 | <?php |
| 512 | 535 | if ( array_key_exists( 'type', $attributes ) ) { |
| 513 | - | |
| 536 | + $placeholder = array_key_exists( 'placeholder', $attributes ) ? $attributes['placeholder'] : ''; | |
| 514 | 537 | echo '<textarea width="100%" rows="' . esc_attr( $inputs_row_map[ $attributes['type'] ] ) . '" name="comments" placeholder="' . esc_attr( $placeholder ) . '"></textarea>'; |
| 515 | 538 | } |
| 516 | 539 | ?> |
| 517 | 540 | </li> |
| @@ -523,19 +546,18 @@ | ||
| 523 | 546 | /** |
| 524 | 547 | * Render plugin feedback popup. |
| 525 | 548 | */ |
| 526 | 549 | 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'] ); | |
| 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 ); | |
| 529 | 552 | $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>'; | |
| 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>'; | |
| 531 | 554 | |
| 532 | 555 | $options += $this->other; |
| 533 | 556 | ?> |
| 534 | - <div class="ti-plugin-uninstall-feedback-popup ti-feedback" | |
| 535 | - 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' ); ?>"> | |
| 536 | 558 | <div class="popup--header"> |
| 537 | - <h5><?php echo wp_kses( Loader::$labels['uninstall']['heading_plugin'], array( 'span' => true ) ); ?> </h5> | |
| 559 | + <h5><?php echo wp_kses( $this->heading_plugin, array( 'span' => true ) ); ?> </h5> | |
| 538 | 560 | </div><!--/.popup--header--> |
| 539 | 561 | <div class="popup--body"> |
| 540 | 562 | <?php $this->render_options_list( $options ); ?> |
| 541 | 563 | </div><!--/.popup--body--> |
| @@ -678,14 +700,13 @@ | ||
| 678 | 700 | private function get_disclosure_labels() { |
| 679 | 701 | $disclosure_new_labels = apply_filters( $this->product->get_slug() . '_themeisle_sdk_disclosure_content_labels', [], $this->product ); |
| 680 | 702 | $disclosure_labels = array_merge( |
| 681 | 703 | [ |
| 682 | - '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.', | |
| 683 | 705 | '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>' ), | |
| 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>' ), | |
| 688 | 709 | ], |
| 689 | 710 | ], |
| 690 | 711 | $disclosure_new_labels |
| 691 | 712 | ); |
| @@ -763,14 +784,13 @@ | ||
| 763 | 784 | * |
| 764 | 785 | * @return bool Is the request succesfull? |
| 765 | 786 | */ |
| 766 | 787 | 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() ); | |
| 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(); | |
| 773 | 793 | |
| 774 | 794 | $response = wp_remote_post( |
| 775 | 795 | self::FEEDBACK_ENDPOINT, |
| 776 | 796 | array( |