PluginProbe
Tiered Pricing Table for WooCommerce / 2.3.2
Tiered Pricing Table for WooCommerce v2.3.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 2.3.3 2.3.4 All 90 releases
tier-pricing-table / freemius / templates / account / partials / addon.php

addon.php in Tiered Pricing Table for WooCommerce 2.3.2, at freemius/templates/account/partials/addon.php

407 lines 19.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @var array $VARS
4 * @var Freemius $fs
5 */
6 $fs = $VARS['parent_fs'];
7 $addon_id = $VARS['addon_id'];
8 $odd = $VARS['odd'];
9 $slug = $fs->get_slug();
10
11 $fs_blog_id = $VARS['fs_blog_id'];
12
13 $active_plugins_directories_map = $VARS['active_plugins_directories_map'];
14
15 $addon_info = $VARS['addon_info'];
16 $is_addon_activated = $fs->is_addon_activated( $addon_id );
17 $is_addon_connected = $addon_info['is_connected'];
18 $is_addon_installed = $VARS['is_addon_installed'];
19
20 $fs_addon = ( $is_addon_connected && $is_addon_installed ) ?
21 freemius( $addon_id ) :
22 false;
23
24 // Aliases.
25 $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
26 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
27 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
28 /* 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 );
30 $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 $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 $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 $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 );
34 /* translators: %s: Plan title (e.g. "Professional") */
35 $activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug );
36 $version_text = fs_text_x_inline( 'Version', 'product version', 'version', $slug );
37 /* translators: %s: Time period (e.g. Auto renews in "2 months") */
38 $renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
39 /* translators: %s: Time period (e.g. Expires in "2 months") */
40 $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 $cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug );
43 $change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug );
44 $upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug );
45 $addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug );
46 $downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
47 $trial_text = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
48 $free_text = fs_text_inline( 'Free', 'free', $slug );
49 $activate_text = fs_text_inline( 'Activate', 'activate', $slug );
50 $plan_text = fs_text_x_inline( 'Plan', 'as product pricing plan', 'plan', $slug );
51
52 // Defaults.
53 $plan = null;
54 $is_paid_trial = false;
55 /**
56 * @var FS_Plugin_License $license
57 */
58 $license = null;
59 $site = null;
60 $is_active_subscription = false;
61 $subscription = null;
62 $is_paying = false;
63 $show_upgrade = false;
64
65 if ( is_object( $fs_addon ) ) {
66 $is_paying = $fs_addon->is_paying();
67 $user = $fs_addon->get_user();
68 $site = $fs_addon->get_site();
69 $license = $fs_addon->_get_license();
70 $subscription = ( is_object( $license ) ?
71 $fs_addon->_get_subscription( $license->id ) :
72 null );
73 $plan = $fs_addon->get_plan();
74 $plan_name = $plan->name;
75 $plan_title = $plan->title;
76 $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 $version = $fs_addon->get_plugin_version();
79 } else if ( $is_addon_connected ) {
80 if (
81 empty( $addon_info ) ||
82 ! isset( $addon_info['site'] )
83 ) {
84 $is_addon_connected = false;
85 } else {
86 /**
87 * @var FS_Site $site
88 */
89 $site = $addon_info['site'];
90 $version = $addon_info['version'];
91
92 $plan_name = isset( $addon_info['plan_name'] ) ?
93 $addon_info['plan_name'] :
94 '';
95
96 $plan_title = isset( $addon_info['plan_title'] ) ?
97 $addon_info['plan_title'] :
98 '';
99
100 if ( isset( $addon_info['license'] ) ) {
101 $license = $addon_info['license'];
102 }
103
104 if ( isset( $addon_info['subscription'] ) ) {
105 $subscription = $addon_info['subscription'];
106 }
107
108 $has_valid_and_active_license = (
109 is_object( $license ) &&
110 $license->is_active() &&
111 $license->is_valid()
112 );
113
114 $is_paid_trial = (
115 $site->is_trial() &&
116 $has_valid_and_active_license &&
117 ( $site->trial_plan_id == $license->plan_id )
118 );
119 }
120 }
121
122 $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
123 ?>
124 <tr<?php if ( $odd ) {
125 echo ' class="alternate"';
126 } ?>>
127 <td>
128 <!-- Title -->
129 <?php echo $addon_info['title'] ?>
130 </td>
131 <?php if ( $is_addon_connected ) : ?>
132 <!-- ID -->
133 <td><?php echo $site->id ?></td>
134 <!--/ ID -->
135
136 <!-- Version -->
137 <td><?php echo $version ?></td>
138 <!--/ Version -->
139
140 <!-- Plan Title -->
141 <td><?php echo strtoupper( is_string( $plan_name ) ? $plan_title : $free_text ) ?></td>
142 <!--/ Plan Title -->
143
144 <?php if ( $site->is_trial() || is_object( $license ) ) : ?>
145
146 <!-- Expiration -->
147 <td>
148 <?php
149 $tags = array();
150
151 if ( $site->is_trial() ) {
152 $tags[] = array( 'label' => $trial_text, 'type' => 'success' );
153
154 $tags[] = array(
155 'label' => sprintf(
156 ( $is_paid_trial ?
157 $renews_in_text :
158 $expires_in_text ),
159 human_time_diff( time(), strtotime( $site->trial_ends ) )
160 ),
161 'type' => ( $is_paid_trial ? 'success' : 'warn' )
162 );
163 } else {
164 if ( is_object( $license ) ) {
165 if ( $license->is_cancelled ) {
166 $tags[] = array(
167 'label' => fs_text_inline( 'Cancelled', 'cancelled', $slug ),
168 'type' => 'error'
169 );
170 } else if ( $license->is_expired() ) {
171 $tags[] = array(
172 'label' => fs_text_inline( 'Expired', 'expired', $slug ),
173 'type' => 'error'
174 );
175 } else if ( $license->is_lifetime() ) {
176 $tags[] = array(
177 'label' => fs_text_inline( 'No expiration', 'no-expiration', $slug ),
178 'type' => 'success'
179 );
180 } else if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) {
181 $tags[] = array(
182 'label' => sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ),
183 'type' => 'warn'
184 );
185 } else if ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) {
186 $tags[] = array(
187 'label' => sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ),
188 'type' => 'success'
189 );
190 }
191 }
192 }
193
194 foreach ( $tags as $t ) {
195 printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] );
196 }
197 ?>
198 </td>
199 <!--/ Expiration -->
200
201 <?php endif ?>
202
203 <?php
204 $buttons = array();
205 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 );
216
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 );
224
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 );
228
229 if ( ! $license->is_lifetime() && $is_active_subscription ) {
230 $buttons[] = fs_ui_get_action_button(
231 $fs->get_id(),
232 'account',
233 'downgrade_account',
234 esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ),
235 '',
236 array( 'plugin_id' => $addon_id ),
237 false,
238 false,
239 false,
240 ( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ),
241 'POST'
242 );
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();
260
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();
264
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 );
276 }
277 }
278
279 if ( 0 == count( $buttons ) ) {
280 if ( $show_upgrade && $fs_addon->is_premium() ) {
281 $fs_addon->_add_license_activation_dialog_box();
282
283 $buttons[] = fs_ui_get_action_button(
284 $fs->get_id(),
285 'account',
286 'activate_license',
287 fs_esc_html_inline( 'Activate License', 'activate-license', $slug ),
288 'activate-license-trigger ' . $fs_addon->get_unique_affix(),
289 array(
290 'plugin_id' => $addon_id,
291 ),
292 false,
293 true
294 );
295 }
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 }
310 } else if ( ! $show_upgrade ) {
311 if ( $fs->is_addon_installed( $addon_id ) ) {
312 $addon_file = $fs->get_addon_basename( $addon_id );
313
314 if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) {
315 $buttons[] = sprintf(
316 '<a class="button button-primary edit" href="%s" title="%s">%s</a>',
317 wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ),
318 fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $slug ),
319 $activate_text
320 );
321 }
322 } else {
323 if ( $fs->is_allowed_to_install() ) {
324 $buttons[] = sprintf(
325 '<a class="button button-primary edit" href="%s">%s</a>',
326 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'] ),
327 fs_text_inline( 'Install Now', 'install-now', $slug )
328 );
329 } else {
330 $buttons[] = sprintf(
331 '<a target="_blank" class="button button-primary edit" href="%s">%s</a>',
332 $fs->_get_latest_download_local_url( $addon_id ),
333 esc_html( $download_latest_text )
334 );
335 }
336 }
337 }
338
339 if ( $show_upgrade ) {
340 $buttons[] = sprintf( '<a href="%s" class="thickbox button button-small button-primary" aria-label="%s" data-title="%s"><i class="dashicons dashicons-cart"></i> %s</a>',
341 esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true' . ( ! empty( $fs_blog_id ) ? '&fs_blog_id=' . $fs_blog_id : '' ) . '&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon_info['slug'] .
342 '&TB_iframe=true&width=600&height=550' ) ),
343 esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon_info['title'] ) ),
344 esc_attr( $addon_info['title'] ),
345 ( $fs_addon->has_free_plan() ?
346 $upgrade_text :
347 fs_text_x_inline( 'Purchase', 'verb', 'purchase', $slug ) )
348 );
349 }
350
351 $buttons_count = count( $buttons );
352 ?>
353
354 <!-- Actions -->
355 <td><?php if ( $buttons_count > 1 ) : ?>
356 <div class="button-group"><?php endif ?>
357 <?php foreach ( $buttons as $button ) {
358 echo $button;
359 } ?>
360 <?php if ( $buttons_count > 1 ) : ?></div><?php endif ?></td>
361 <!--/ Actions -->
362
363 <?php else : ?>
364 <?php // Add-on NOT Installed or was never connected.
365 ?>
366 <!-- Action -->
367 <td colspan="4">
368 <?php if ( $fs->is_addon_installed( $addon_id ) ) : ?>
369 <?php $addon_file = $fs->get_addon_basename( $addon_id ) ?>
370 <?php if ( ! isset( $active_plugins_directories_map[ dirname( $addon_file ) ] ) ) : ?>
371 <a class="button button-primary"
372 href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
373 title="<?php fs_esc_attr_echo_inline( 'Activate this add-on', 'activate-this-addon', $slug ) ?>"
374 class="edit"><?php echo esc_html( $activate_text ) ?></a>
375 <?php endif ?>
376 <?php else : ?>
377 <?php if ( $fs->is_allowed_to_install() ) : ?>
378 <a class="button button-primary"
379 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 <?php else : ?>
381 <a target="_blank" class="button button-primary"
382 href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php echo esc_html( $download_latest_text ) ?></a>
383 <?php endif ?>
384 <?php endif ?>
385 </td>
386 <!--/ Action -->
387 <?php endif ?>
388 <?php if ( ! $is_paying && WP_FS__DEV_MODE ) : ?>
389 <!-- Optional Delete Action -->
390 <td>
391 <?php
392 if ( $is_addon_activated ) {
393 fs_ui_action_button(
394 $fs->get_id(), 'account',
395 'delete_account',
396 fs_text_x_inline( 'Delete', 'verb', 'delete', $slug ),
397 '',
398 array( 'plugin_id' => $addon_id ),
399 false,
400 $show_upgrade
401 );
402 }
403 ?>
404 </td>
405 <!--/ Optional Delete Action -->
406 <?php endif ?>
407 </tr>