activate-license-button.php
2 years ago
addon.php
2 years ago
deactivate-license-button.php
2 years ago
disconnect-button.php
2 years ago
index.php
2 years ago
site.php
2 years ago
disconnect-button.php
104 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package Freemius |
| 4 | * @copyright Copyright (c) 2016, Freemius, Inc. |
| 5 | * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
| 6 | * @since 2.5.0 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * @var array $VARS |
| 15 | * @var Freemius $fs |
| 16 | */ |
| 17 | $fs = $VARS['freemius']; |
| 18 | |
| 19 | /** |
| 20 | * @var FS_Plugin_License $license |
| 21 | */ |
| 22 | $license = $VARS['license']; |
| 23 | /** |
| 24 | * @var FS_Plugin_Plan $license_paid_plan |
| 25 | */ |
| 26 | $license_paid_plan = $VARS['license_paid_plan']; |
| 27 | |
| 28 | $license_subscription = ( is_object( $license ) && is_object( $license_paid_plan ) ) ? |
| 29 | $fs->_get_subscription( $license->id ) : |
| 30 | null; |
| 31 | |
| 32 | $has_active_subscription = ( |
| 33 | is_object( $license_subscription ) && |
| 34 | $license_subscription->is_active() |
| 35 | ); |
| 36 | |
| 37 | $button_id = "fs_disconnect_button_{$fs->get_id()}"; |
| 38 | |
| 39 | $website_link = sprintf( '<a href="#" tabindex="-1">%s</a>', fs_strip_url_protocol( untrailingslashit( Freemius::get_unfiltered_site_url() ) ) ); |
| 40 | ?> |
| 41 | <script type="text/javascript"> |
| 42 | // Wrap in a IFFE to prevent leaking global variables. |
| 43 | ( function( $ ) { |
| 44 | $( document ).ready( function() { |
| 45 | var $modal = $( '#fs_modal_delete_site' ); |
| 46 | |
| 47 | $( '#<?php echo $button_id ?>' ).on( 'click', function( e ) { |
| 48 | // Prevent the form being submitted. |
| 49 | e.preventDefault(); |
| 50 | |
| 51 | $( document.body ).append( $modal ); |
| 52 | $modal.show(); |
| 53 | } ); |
| 54 | |
| 55 | $modal.on( 'click', '.button-close', function ( evt ) { |
| 56 | $modal.hide(); |
| 57 | } ); |
| 58 | |
| 59 | $modal.on( 'click', '.button-primary', function ( evt ) { |
| 60 | $( '#<?php echo $button_id ?>' ).closest( 'form' )[0].submit(); |
| 61 | } ); |
| 62 | } ); |
| 63 | } )( jQuery ); |
| 64 | </script> |
| 65 | <div id="fs_modal_delete_site" class="fs-modal active" style="display: none"> |
| 66 | <div class="fs-modal-dialog"> |
| 67 | <div class="fs-modal-header"> |
| 68 | <h4><?php echo $fs->esc_html_inline( 'Disconnect', 'disconnect' ) ?></h4> |
| 69 | </div> |
| 70 | <div class="fs-modal-body"> |
| 71 | <?php if ( ! is_object( $license ) ) : ?> |
| 72 | <p><?php echo |
| 73 | // translators: %1$s is replaced with the website's homepage address, %2$s is replaced with the plugin name. |
| 74 | sprintf( esc_html( $fs->get_text_inline( 'By disconnecting the website, previously shared diagnostic data about %1$s will be deleted and no longer visible to %2$s.', 'disconnect-intro-paid' ) ), $website_link, '<b>' . $fs->get_plugin_title() . '</b>' ) ?></p> |
| 75 | <?php else : ?> |
| 76 | <p><?php echo |
| 77 | // translators: %s is replaced with the website's homepage address. |
| 78 | sprintf( esc_html( $fs->get_text_inline( 'Disconnecting the website will permanently remove %s from your User Dashboard\'s account.', 'disconnect-intro-paid' ) ), $website_link ) ?></p> |
| 79 | <?php endif ?> |
| 80 | |
| 81 | <?php if ( $has_active_subscription ) : ?> |
| 82 | <p><?php echo |
| 83 | // translators: %1$s is replaced by the paid plan name, %2$s is replaced with an anchor link with the text "User Dashboard". |
| 84 | sprintf( esc_html( $fs->get_text_inline( 'If you wish to cancel your %1$s plan\'s subscription instead, please navigate to the %2$s and cancel it there.', 'disconnect-subscription-disclaimer' ) ), $license_paid_plan->title, sprintf( '<a href="https://users.freemius.com" target="_blank" rel="noreferrer noopener nofollow">%s</a>', $fs->get_text_inline( 'User Dashboard', 'user-dashboard' ) ) |
| 85 | ) ?></p> |
| 86 | <?php endif ?> |
| 87 | |
| 88 | <p><?php echo esc_html( $fs->get_text_inline( 'Are you sure you would like to proceed with the disconnection?', 'disconnect-confirm' ) ) ?></p> |
| 89 | </div> |
| 90 | <div class="fs-modal-footer"> |
| 91 | <button class="button button-primary<?php if ( is_object( $license ) ) : ?> warn<?php endif ?>" tabindex="2"><?php echo $fs->esc_html_inline( 'Yes', 'yes' ) . ' - ' . $fs->esc_html_inline( 'Disconnect', 'disconnect' ) ?></button> |
| 92 | <button class="button button-secondary button-close" tabindex="1"><?php echo esc_html( $fs->get_text_inline( 'Cancel', 'cancel' ) ) ?></button> |
| 93 | </div> |
| 94 | </div> |
| 95 | </div> |
| 96 | <form action="<?php echo esc_attr( $fs->_get_admin_page_url( 'account' ) ); ?>" method="POST"> |
| 97 | <input type="hidden" name="fs_action" value="delete_account"> |
| 98 | <?php wp_nonce_field( 'delete_account' ) ?> |
| 99 | |
| 100 | <a id="<?php echo $button_id ?>" href="#" class="fs-button-inline"> |
| 101 | <i class="dashicons dashicons-no"></i> |
| 102 | <?php echo $fs->esc_html_inline( 'Disconnect', 'disconnect' ) ?> |
| 103 | </a> |
| 104 | </form> |