PluginProbe ʕ •ᴥ•ʔ
Auto Post Cleaner / 3.13.1
Auto Post Cleaner v3.13.1
3.12.0 3.13.1 3.2.4 3.2.5 3.3.0 3.3.10 3.3.11 3.3.8 3.4.2 3.5.3 3.6.0 3.7.0 3.7.1 3.7.2 3.7.3 3.7.5 3.7.6 3.8.0 3.9.0 3.9.4 3.9.6 3.9.7 trunk 3.0.0 3.1.0 3.10.1 3.10.2 3.11.4
delete-old-posts-programmatically / freemius / templates / forms / subscription-cancellation.php
delete-old-posts-programmatically / freemius / templates / forms Last commit date
deactivation 3 years ago affiliation.php 1 year ago data-debug-mode.php 3 years ago email-address-update.php 3 years ago index.php 5 years ago license-activation.php 11 months ago optout.php 3 years ago premium-versions-upgrade-handler.php 5 years ago premium-versions-upgrade-metadata.php 5 years ago resend-key.php 3 years ago subscription-cancellation.php 8 months ago trial-start.php 3 years ago user-change.php 3 years ago
subscription-cancellation.php
283 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 2.2.1
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 */
16 $fs = freemius( $VARS['id'] );
17 $slug = $fs->get_slug();
18
19 /**
20 * @var FS_Plugin_License $license
21 */
22 $license = $VARS['license'];
23
24 $has_trial = $VARS['has_trial'];
25
26 $subscription_cancellation_context = $has_trial ?
27 fs_text_inline( 'trial', 'trial', $slug ) :
28 fs_text_inline( 'subscription', 'subscription', $slug );
29
30 $plan = $fs->get_plan();
31 $module_label = $fs->get_module_label( true );
32
33 if ( $VARS['is_license_deactivation'] ) {
34 $subscription_cancellation_text = '';
35 } else {
36 $subscription_cancellation_text = sprintf(
37 ( $fs->is_theme() ?
38 fs_text_inline(
39 "Deactivating or uninstalling the %s will automatically disable the license, which you'll be able to use on another site.",
40 'deactivation-or-uninstall-message',
41 $slug
42 ) :
43 fs_text_inline(
44 "Uninstalling the %s will automatically disable the license, which you'll be able to use on another site.",
45 'uninstall-message',
46 $slug
47 ) ),
48 $module_label
49 ) . ' ';
50 }
51
52 $subscription_cancellation_text .= sprintf(
53 fs_text_inline(
54 'In case you are NOT planning on using this %s on this site (or any other site) - would you like to cancel the %s as well?',
55 'cancel-subscription-message',
56 $slug
57 ),
58 ( $VARS['is_license_deactivation'] ? fs_text_inline( 'license', 'license', $slug ) : $module_label ),
59 $subscription_cancellation_context
60 );
61
62 $cancel_subscription_action_label = sprintf(
63 fs_esc_html_inline(
64 "Cancel %s - I no longer need any security & feature updates, nor support for %s because I'm not planning to use the %s on this, or any other site.",
65 'cancel-x',
66 $slug
67 ),
68 esc_html( $subscription_cancellation_context ),
69 sprintf( '<strong>%s</strong>', esc_html( $fs->get_plugin_title() ) ),
70 esc_html( $module_label )
71 );
72
73 $keep_subscription_active_action_label = esc_html( sprintf(
74 fs_text_inline(
75 "Don't cancel %s - I'm still interested in getting security & feature updates, as well as be able to contact support.",
76 'dont-cancel-x',
77 $slug
78 ),
79 $subscription_cancellation_context
80 ) );
81
82 $subscription_cancellation_text = esc_html( $subscription_cancellation_text );
83
84 $subscription_cancellation_html = <<< HTML
85 <div class="notice notice-error inline"><p></p></div><p>{$subscription_cancellation_text}</p>
86 <ul class="subscription-actions">
87 <li>
88 <label>
89 <input type="radio" name="cancel-subscription" value="false"/>
90 <span>{$keep_subscription_active_action_label}</span>
91 </label>
92 </li>
93 <li>
94 <label>
95 <input type="radio" name="cancel-subscription" value="true"/>
96 <span>{$cancel_subscription_action_label}</span>
97 </label>
98 </li>
99 </ul>
100 HTML;
101
102 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
103 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
104 /* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
105 $downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %2$s plan license will expire in %3$s.', 'downgrade-x-confirm', $slug );
106 $prices_increase_text = fs_text_inline( 'Please note that we will not be able to grandfather outdated pricing for renewals/new subscriptions after a cancellation. If you choose to renew the subscription manually in the future, after a price increase, which typically occurs once a year, you will be charged the updated price.', 'pricing-increase-warning', $slug );
107 $after_downgrade_non_blocking_text = fs_text_inline( 'You can still enjoy all %s features but you will not have access to %s security & feature updates, nor support.', 'after-downgrade-non-blocking', $slug );
108 $after_downgrade_blocking_text = fs_text_inline( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.', 'after-downgrade-blocking', $slug );
109 $after_downgrade_blocking_text_premium_only = fs_text_inline( 'Once your license expires you will no longer be able to use the %s, unless you activate it again with a valid premium license.', 'after-downgrade-blocking-premium-only', $slug );
110
111 $subscription_cancellation_confirmation_message = $has_trial ?
112 fs_text_inline( 'Cancelling the trial will immediately block access to all premium features. Are you sure?', 'cancel-trial-confirm', $slug ) :
113 sprintf(
114 '%s %s %s %s',
115 sprintf(
116 $downgrade_x_confirm_text,
117 ($fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
118 $plan->title,
119 human_time_diff( time(), strtotime( $license->expiration ) )
120 ),
121 (
122 $license->is_block_features ?
123 (
124 $fs->is_only_premium() ?
125 sprintf( $after_downgrade_blocking_text_premium_only, $module_label ) :
126 sprintf( $after_downgrade_blocking_text, $plan->title )
127 ) :
128 sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) )
129 ),
130 $prices_increase_text,
131 fs_esc_attr_inline( 'Are you sure you want to proceed?', 'proceed-confirmation', $slug )
132 );
133
134 fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
135 ?>
136 <script type="text/javascript">
137 (function( $ ) {
138 var modalHtml =
139 '<div class="fs-modal fs-modal-subscription-cancellation fs-modal-subscription-cancellation-<?php echo $fs->get_id() ?>">'
140 + ' <div class="fs-modal-dialog">'
141 + ' <div class="fs-modal-header">'
142 + ' <h4><?php echo esc_html( sprintf( fs_text_inline( 'Cancel %s?', 'cancel-x', $slug ), ucfirst( $subscription_cancellation_context ) ) ) ?></h4>'
143 + ' </div>'
144 + ' <div class="fs-modal-body">'
145 + ' <div class="fs-modal-panel active">' + <?php echo json_encode( $subscription_cancellation_html ) ?> + '<p class="fs-price-increase-warning" style="display: none;">' + <?php echo json_encode( $prices_increase_text ) ?> + '</p></div>'
146 + ' </div>'
147 + ' <div class="fs-modal-footer">'
148 + ' <a href="#" class="button button-secondary button-close"><?php fs_esc_attr_echo_inline( 'Cancel', 'cancel', $slug ) ?></a>'
149 + ' <a href="#" class="button button-primary button-deactivate disabled"><?php fs_esc_attr_echo_inline( 'Proceed', 'proceed', $slug ) ?></a>'
150 + ' </div>'
151 + ' </div>'
152 + '</div>',
153 $modal = $(modalHtml);
154
155 $modal.appendTo($('body'));
156
157 registerEventHandlers();
158
159 function registerEventHandlers() {
160 $modal.on( 'showModal', function() {
161 showModal();
162 });
163
164 $modal.on( 'closeModal', function() {
165 closeModal();
166 });
167
168 $modal.on('click', '.fs-modal-footer .button', function (evt) {
169 evt.preventDefault();
170
171 if ($(this).hasClass('disabled')) {
172 return;
173 }
174
175 var _this = $(this),
176 subscriptionCancellationActionEventName = <?php echo json_encode( $fs->get_action_tag( 'subscription_cancellation_action' ) ) ?>;
177
178 if ( _this.hasClass( 'button-primary' ) ) {
179 if ( 'true' !== $modal.find( 'input[name="cancel-subscription"]:checked' ).val() ) {
180 $modal.trigger( subscriptionCancellationActionEventName, false );
181 } else {
182 if ( confirm( <?php echo json_encode( $subscription_cancellation_confirmation_message ) ?> ) ) {
183 $modal.trigger( subscriptionCancellationActionEventName, true );
184 }
185 }
186 }
187 });
188
189 $modal.on('click', 'input[type="radio"]', function () {
190 var
191 $selectedOption = $( this ),
192 $primaryButton = $modal.find( '.button-primary' ),
193 isSelected = ( 'true' === $selectedOption.val() );
194
195 if ( isSelected ) {
196 $primaryButton.html( <?php echo json_encode( sprintf(
197 fs_text_inline( 'Cancel %s & Proceed', 'cancel-x-and-proceed', $slug ),
198 ucfirst( $subscription_cancellation_context )
199 ) ) ?> );
200
201 $modal.find('.fs-price-increase-warning').show();
202 } else {
203 $primaryButton.html( <?php fs_json_encode_echo_inline( 'Proceed', 'proceed', $slug ) ?> );
204 $modal.find('.fs-price-increase-warning').hide();
205 }
206
207 $primaryButton.toggleClass( 'warn', isSelected );
208 $primaryButton.removeClass( 'disabled' );
209 });
210
211 // If the user has clicked outside the window, cancel it.
212 $modal.on('click', function (evt) {
213 var $target = $(evt.target);
214
215 // If the user has clicked anywhere in the modal dialog, just return.
216 if ($target.hasClass('fs-modal-body') || $target.hasClass('fs-modal-footer')) {
217 return;
218 }
219
220 // If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
221 if (
222 ( ! $target.hasClass( 'button-close' ) ) &&
223 ( $target.parents( '.fs-modal-body' ).length > 0 || $target.parents( '.fs-modal-footer' ).length > 0 )
224 ) {
225 return;
226 }
227
228 closeModal();
229
230 return false;
231 });
232 }
233
234 function showModal() {
235 resetModal();
236
237 // Display the dialog box.
238 $modal.addClass('active');
239
240 $('body').addClass('has-fs-modal');
241 }
242
243 function closeModal() {
244 var activeModalsCount = $( '.fs-modal.active' ).length;
245
246 $modal.removeClass('active');
247
248 // If child modal, do not remove the "has-fs-modal" class of the <body> element to keep its scrollbars hidden.
249 if ( activeModalsCount > 1 ) {
250 return;
251 }
252
253 $('body').removeClass('has-fs-modal');
254 }
255
256 function resetModal() {
257 updateButtonLabels();
258
259 if ( 0 === $modal.find( '.subscription-actions' ).length ) {
260 $modal.find('.button-deactivate').removeClass('disabled');
261 } else {
262 $modal.find('.button-deactivate').addClass('disabled');
263 }
264
265 $modal.find('.fs-price-increase-warning').hide();
266
267 // Uncheck all radio buttons.
268 $modal.find('input[type="radio"]').prop('checked', false);
269
270 $modal.find('.message').hide();
271 }
272
273 function showMessage(message) {
274 $modal.find('.message').text(message).show();
275 }
276
277 function updateButtonLabels() {
278 $modal.find('.button-primary').text( <?php fs_json_encode_echo_inline( 'Proceed', 'proceed', $slug ) ?> );
279
280 $modal.find('.button-secondary').text( <?php fs_json_encode_echo_inline( 'Cancel', 'cancel', $slug ) ?> );
281 }
282 })( jQuery );
283 </script>