PluginProbe
Tiered Pricing Table for WooCommerce / 8.1.0
Tiered Pricing Table for WooCommerce v8.1.0
8.1.0 8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 All 92 releases
← All changes | freemius/templates/account/partials/addon.php +131 -87 2.2.3 → 8.1.0 View file →
@@ -1,5 +1,10 @@
1 1 <?php
2 +
3 + if ( ! defined( 'ABSPATH' ) ) {
4 + exit;
5 + }
6 +
2 7 /**
3 8 * @var array $VARS
4 9 * @var Freemius $fs
5 10 */
@@ -25,9 +30,9 @@
25 30 $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
26 31 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
27 32 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
28 33 /* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
29 - $downgrade_x_confirm_text = fs_text_inline( '%1$s will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'downgrade-x-confirm', $slug );
34 + $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 );
30 35 $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 );
31 36 $cancel_trial_confirm_text = fs_text_inline( 'Cancelling the trial will immediately block access to all premium features. Are you sure?', 'cancel-trial-confirm', $slug );
32 37 $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 );
33 38 $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 );
@@ -37,9 +42,8 @@
37 42 /* translators: %s: Time period (e.g. Auto renews in "2 months") */
38 43 $renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
39 44 /* translators: %s: Time period (e.g. Expires in "2 months") */
40 45 $expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug );
41 - $sync_license_text = fs_text_x_inline( 'Sync License', 'as synchronize license', 'sync-license', $slug );
42 46 $cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug );
43 47 $change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug );
44 48 $upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug );
45 49 $addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug );
@@ -60,8 +64,9 @@
60 64 $is_active_subscription = false;
61 65 $subscription = null;
62 66 $is_paying = false;
63 67 $show_upgrade = false;
68 + $is_whitelabeled = $VARS['is_whitelabeled'];
64 69
65 70 if ( is_object( $fs_addon ) ) {
66 71 $is_paying = $fs_addon->is_paying();
67 72 $user = $fs_addon->get_user();
@@ -73,10 +78,20 @@
73 78 $plan = $fs_addon->get_plan();
74 79 $plan_name = $plan->name;
75 80 $plan_title = $plan->title;
76 81 $is_paid_trial = $fs_addon->is_paid_trial();
77 - $show_upgrade = ( $fs_addon->has_paid_plan() && ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() );
78 82 $version = $fs_addon->get_plugin_version();
83 + $is_whitelabeled = (
84 + $fs_addon->is_whitelabeled( true ) &&
85 + ! $fs_addon->get_parent_instance()->is_data_debug_mode()
86 + );
87 + $show_upgrade = (
88 + ! $is_whitelabeled &&
89 + $fs_addon->has_paid_plan() &&
90 + ! $is_paying &&
91 + ! $is_paid_trial &&
92 + ! $fs_addon->_has_premium_license()
93 + );
79 94 } else if ( $is_addon_connected ) {
80 95 if (
81 96 empty( $addon_info ) ||
82 97 ! isset( $addon_info['site'] )
@@ -115,12 +130,21 @@
115 130 $site->is_trial() &&
116 131 $has_valid_and_active_license &&
117 132 ( $site->trial_plan_id == $license->plan_id )
118 133 );
134 +
135 + $is_whitelabeled = $addon_info['is_whitelabeled'];
119 136 }
120 137 }
121 138
139 + $has_feature_enabled_license = (
140 + is_object( $license ) &&
141 + $license->is_features_enabled()
142 + );
143 +
122 144 $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
145 +
146 + $show_delete_install_button = ( ! $is_paying && WP_FS__DEV_MODE && ! $is_whitelabeled );
123 147 ?>
124 148 <tr<?php if ( $odd ) {
125 149 echo ' class="alternate"';
126 150 } ?>>
@@ -140,12 +164,11 @@
140 164 <!-- Plan Title -->
141 165 <td><?php echo strtoupper( is_string( $plan_name ) ? $plan_title : $free_text ) ?></td>
142 166 <!--/ Plan Title -->
143 167
144 - <?php if ( $site->is_trial() || is_object( $license ) ) : ?>
145 -
146 168 <!-- Expiration -->
147 169 <td>
170 + <?php if ( $site->is_trial() || is_object( $license ) ) : ?>
148 171 <?php
149 172 $tags = array();
150 173
151 174 if ( $site->is_trial() ) {
@@ -194,91 +217,106 @@
194 217 foreach ( $tags as $t ) {
195 218 printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] );
196 219 }
197 220 ?>
221 + <?php endif ?>
198 222 </td>
199 223 <!--/ Expiration -->
200 224
201 - <?php endif ?>
202 -
203 225 <?php
204 226 $buttons = array();
227 + $is_license_activation_added = false;
228 +
205 229 if ( $is_addon_activated ) {
206 - if ( $is_paying ) {
207 - $buttons[] = fs_ui_get_action_button(
208 - $fs->get_id(),
209 - 'account',
210 - 'deactivate_license',
211 - fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ),
212 - '',
213 - array( 'plugin_id' => $addon_id ),
214 - false
215 - );
230 + if ( ! $is_whitelabeled ) {
231 + if ( $is_paying ) {
232 + $buttons[] = fs_ui_get_action_button(
233 + $fs->get_id(),
234 + 'account',
235 + 'deactivate_license',
236 + fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ),
237 + '',
238 + array( 'plugin_id' => $addon_id ),
239 + false,
240 + true
241 + );
216 242
217 - $human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) );
218 - $downgrade_confirmation_message = sprintf(
219 - $downgrade_x_confirm_text,
220 - ( $fs_addon->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
221 - $plan->title,
222 - $human_readable_license_expiration
223 - );
243 + $after_downgrade_message = ! $license->is_block_features ?
244 + sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) :
245 + sprintf( $after_downgrade_blocking_text, $plan->title );
224 246
225 - $after_downgrade_message = ! $license->is_block_features ?
226 - sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) :
227 - sprintf( $after_downgrade_blocking_text, $plan->title );
247 + if ( ! $license->is_lifetime() && $is_active_subscription ) {
248 + $human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) );
249 + $downgrade_confirmation_message = sprintf(
250 + $downgrade_x_confirm_text,
251 + ( $fs_addon->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
252 + $plan->title,
253 + $human_readable_license_expiration
254 + );
228 255
229 - if ( ! $license->is_lifetime() && $is_active_subscription ) {
256 + $buttons[] = fs_ui_get_action_button(
257 + $fs->get_id(),
258 + 'account',
259 + 'downgrade_account',
260 + esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ),
261 + '',
262 + array( 'plugin_id' => $addon_id ),
263 + false,
264 + false,
265 + false,
266 + ( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ),
267 + 'POST'
268 + );
269 + }
270 + } else if ( $is_paid_trial ) {
230 271 $buttons[] = fs_ui_get_action_button(
231 272 $fs->get_id(),
232 273 'account',
233 - 'downgrade_account',
234 - esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ),
274 + 'cancel_trial',
275 + esc_html( $cancel_trial_text ),
235 276 '',
236 277 array( 'plugin_id' => $addon_id ),
237 278 false,
238 279 false,
239 - false,
240 - ( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ),
280 + 'dashicons dashicons-download',
281 + $cancel_trial_confirm_text,
241 282 'POST'
242 283 );
243 - }
244 - } else if ( $is_paid_trial ) {
245 - $buttons[] = fs_ui_get_action_button(
246 - $fs->get_id(),
247 - 'account',
248 - 'cancel_trial',
249 - esc_html( $cancel_trial_text ),
250 - '',
251 - array( 'plugin_id' => $addon_id ),
252 - false,
253 - false,
254 - 'dashicons dashicons-download',
255 - $cancel_trial_confirm_text,
256 - 'POST'
257 - );
258 - } else if ( ! is_object( $license ) || ! $license->is_features_enabled() ) {
259 - $premium_license = $fs_addon->_get_available_premium_license();
284 + } else if ( ! $has_feature_enabled_license ) {
285 + $premium_licenses = $fs_addon->get_available_premium_licenses();
260 286
261 - if ( is_object( $premium_license ) ) {
262 - $premium_plan = $fs_addon->_get_plan_by_id( $premium_license->plan_id );
263 - $site = $fs_addon->get_site();
287 + if ( ! empty( $premium_licenses ) ) {
288 + $premium_license = $premium_licenses[0];
289 + $has_multiple_premium_licenses = ( 1 < count( $premium_licenses ) );
264 290
265 - $buttons[] = fs_ui_get_action_button(
266 - $fs->get_id(),
267 - 'account',
268 - 'activate_license',
269 - esc_html( sprintf( $activate_plan_text, $premium_plan->title, ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ) ),
270 - '',
271 - array(
272 - 'plugin_id' => $addon_id,
273 - 'license_id' => $premium_license->id,
274 - )
275 - );
291 + if ( ! $has_multiple_premium_licenses ) {
292 + $premium_plan = $fs_addon->_get_plan_by_id( $premium_license->plan_id );
293 + $site = $fs_addon->get_site();
294 +
295 + $buttons[] = fs_ui_get_action_button(
296 + $fs->get_id(),
297 + 'account',
298 + 'activate_license',
299 + esc_html( sprintf( $activate_plan_text, $premium_plan->title, ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ) ),
300 + ($has_multiple_premium_licenses ?
301 + 'activate-license-trigger ' . $fs_addon->get_unique_affix() :
302 + ''),
303 + array(
304 + 'plugin_id' => $addon_id,
305 + 'license_id' => $premium_license->id,
306 + ),
307 + true,
308 + true
309 + );
310 +
311 + $is_license_activation_added = true;
312 + }
313 + }
276 314 }
277 315 }
278 316
279 - if ( 0 == count( $buttons ) ) {
280 - if ( $show_upgrade && $fs_addon->is_premium() ) {
317 +// if ( 0 == count( $buttons ) ) {
318 + if ( $fs_addon->is_premium() && ! $is_license_activation_added ) {
281 319 $fs_addon->_add_license_activation_dialog_box();
282 320
283 321 $buttons[] = fs_ui_get_action_button(
284 322 $fs->get_id(),
@@ -283,31 +321,36 @@
283 321 $buttons[] = fs_ui_get_action_button(
284 322 $fs->get_id(),
285 323 'account',
286 324 'activate_license',
287 - fs_esc_html_inline( 'Activate License', 'activate-license', $slug ),
325 + ( ! $has_feature_enabled_license ) ?
326 + fs_esc_html_inline( 'Activate License', 'activate-license', $slug ) :
327 + fs_esc_html_inline( 'Change License', 'change-license', $slug ),
288 328 'activate-license-trigger ' . $fs_addon->get_unique_affix(),
289 329 array(
290 330 'plugin_id' => $addon_id,
291 331 ),
332 + (! $has_feature_enabled_license),
333 + true
334 + );
335 +
336 + $is_license_activation_added = true;
337 + }
338 +
339 + if ( $fs_addon->has_paid_plan() ) {
340 + // Add sync license only if non of the other CTAs are visible.
341 + $buttons[] = fs_ui_get_action_button(
342 + $fs->get_id(),
343 + 'account',
344 + $fs->get_unique_affix() . '_sync_license',
345 + fs_esc_html_x_inline( 'Sync', 'as synchronize', 'sync', $slug ),
346 + '',
347 + array( 'plugin_id' => $addon_id ),
292 348 false,
293 349 true
294 350 );
295 351 }
296 -
297 - // Add sync license only if non of the other CTAs are visible.
298 - $buttons[] = fs_ui_get_action_button(
299 - $fs->get_id(),
300 - 'account',
301 - $fs->get_unique_affix() . '_sync_license',
302 - esc_html( $sync_license_text ),
303 - '',
304 - array( 'plugin_id' => $addon_id ),
305 - false,
306 - true
307 - );
308 -
309 - }
352 +// }
310 353 } else if ( ! $show_upgrade ) {
311 354 if ( $fs->is_addon_installed( $addon_id ) ) {
312 355 $addon_file = $fs->get_addon_basename( $addon_id );
313 356
@@ -327,9 +370,9 @@
327 370 fs_text_inline( 'Install Now', 'install-now', $slug )
328 371 );
329 372 } else {
330 373 $buttons[] = sprintf(
331 - '<a target="_blank" class="button button-primary edit" href="%s">%s</a>',
374 + '<a target="_blank" rel="noopener" class="button button-primary edit" href="%s">%s</a>',
332 375 $fs->_get_latest_download_local_url( $addon_id ),
333 376 esc_html( $download_latest_text )
334 377 );
335 378 }
@@ -361,12 +404,13 @@
361 404 <!--/ Actions -->
362 405
363 406 <?php else : ?>
364 407 <?php // Add-on NOT Installed or was never connected.
408 + $is_addon_installed_by_filesystem = $fs->is_addon_installed( $addon_id );
365 409 ?>
366 410 <!-- Action -->
367 - <td colspan="4">
368 - <?php if ( $fs->is_addon_installed( $addon_id ) ) : ?>
411 + <td colspan="<?php echo ( $is_addon_installed_by_filesystem || $show_delete_install_button ) ? '5' : '4' ?>">
412 + <?php if ( $is_addon_installed_by_filesystem ) : ?>
369 413 <?php $addon_file = $fs->get_addon_basename( $addon_id ) ?>
370 414 <?php if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) : ?>
371 415 <a class="button button-primary"
372 416 href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
@@ -377,9 +421,9 @@
377 421 <?php if ( $fs->is_allowed_to_install() ) : ?>
378 422 <a class="button button-primary"
379 423 href="<?php echo wp_nonce_url( self_admin_url( 'update.php?' . ( ( isset( $addon_info['has_paid_plan'] ) && $addon_info['has_paid_plan'] ) ? 'fs_allow_updater_and_dialog=true&' : '' ) . 'action=install-plugin&plugin=' . $addon_info['slug'] ), 'install-plugin_' . $addon_info['slug'] ) ?>"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></a>
380 424 <?php else : ?>
381 - <a target="_blank" class="button button-primary"
425 + <a target="_blank" rel="noopener" class="button button-primary"
382 426 href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php echo esc_html( $download_latest_text ) ?></a>
383 427 <?php endif ?>
384 428 <?php endif ?>
385 429 </td>
@@ -384,10 +428,10 @@
384 428 <?php endif ?>
385 429 </td>
386 430 <!--/ Action -->
387 431 <?php endif ?>
388 - <?php if ( ! $is_paying && WP_FS__DEV_MODE ) : ?>
389 - <!-- Optional Delete Action -->
432 + <?php if ( $show_delete_install_button ) : ?>
433 + <!-- Optional Delete Action -->
390 434 <td>
391 435 <?php
392 436 if ( $is_addon_activated ) {
393 437 fs_ui_action_button(
@@ -403,5 +447,5 @@
403 447 ?>
404 448 </td>
405 449 <!--/ Optional Delete Action -->
406 450 <?php endif ?>
407 -</tr>
451 +</tr>