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

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

350 lines 17.3 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
12 $addon = $fs->get_addon( $addon_id );
13 $is_addon_activated = $fs->is_addon_activated( $addon_id );
14 $is_addon_connected = $fs->is_addon_connected( $addon_id );
15
16 $fs_addon = $is_addon_connected ?
17 freemius( $addon_id ) :
18 false;
19
20 // Aliases.
21 $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
22 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
23 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
24 /* translators: %1s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
25 $downgrade_x_confirm_text = fs_text_inline( '%1s will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'downgrade-x-confirm', $slug );
26 $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 );
27 $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 );
28 $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 );
29 $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 );
30 /* translators: %s: Plan title (e.g. "Professional") */
31 $activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug );
32 $version_text = fs_text_x_inline( 'Version', 'product version', 'version', $slug );
33 /* translators: %s: Time period (e.g. Auto renews in "2 months") */
34 $renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
35 /* translators: %s: Time period (e.g. Expires in "2 months") */
36 $expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug );
37 $sync_license_text = fs_text_x_inline( 'Sync License', 'as synchronize license', 'sync-license', $slug );
38 $cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug );
39 $change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug );
40 $upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug );
41 $addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug );
42 $downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
43 $trial_text = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
44 $free_text = fs_text_inline( 'Free', 'free', $slug );
45 $activate_text = fs_text_inline( 'Activate', 'activate', $slug );
46 $plan_text = fs_text_x_inline( 'Plan', 'as product pricing plan', 'plan', $slug );
47
48 // Defaults.
49 $plan = null;
50 $is_paid_trial = false;
51 $license = null;
52 $site = null;
53 $is_active_subscription = false;
54 $subscription = null;
55 $is_paying = false;
56
57 if ( is_object( $fs_addon ) ) {
58 $is_paying = $fs_addon->is_paying();
59 $user = $fs_addon->get_user();
60 $site = $fs_addon->get_site();
61 $license = $fs_addon->_get_license();
62 $subscription = ( is_object( $license ) ?
63 $fs_addon->_get_subscription( $license->id ) :
64 null );
65 $plan = $fs_addon->get_plan();
66 $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
67 $is_paid_trial = $fs_addon->is_paid_trial();
68 $show_upgrade = ( $fs_addon->has_paid_plan() && ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() );
69 $is_current_license_expired = is_object( $license ) && $license->is_expired();
70 }
71 ?>
72 <tr<?php if ( $odd ) {
73 echo ' class="alternate"';
74 } ?>>
75 <td>
76 <!-- Title -->
77 <?php echo $addon->title ?>
78 </td>
79 <?php if ( $is_addon_connected ) : ?>
80 <!-- ID -->
81 <td><?php echo $site->id ?></td>
82 <!--/ ID -->
83
84 <!-- Version -->
85 <td><?php echo $fs_addon->get_plugin_version() ?></td>
86 <!--/ Version -->
87
88 <!-- Plan Title -->
89 <td><?php echo strtoupper( is_string( $plan->name ) ? $plan->title : $free_text ) ?></td>
90 <!--/ Plan Title -->
91
92 <?php if ( $fs_addon->is_trial() || is_object( $license ) ) : ?>
93
94 <!-- Expiration -->
95 <td>
96 <?php
97 $tags = array();
98
99 if ( $fs_addon->is_trial() ) {
100 $tags[] = array( 'label' => $trial_text, 'type' => 'success' );
101
102 $tags[] = array(
103 'label' => sprintf(
104 ( $is_paid_trial ?
105 $renews_in_text :
106 $expires_in_text ),
107 human_time_diff( time(), strtotime( $site->trial_ends ) )
108 ),
109 'type' => ( $is_paid_trial ? 'success' : 'warn' )
110 );
111 } else {
112 if ( is_object( $license ) ) {
113 if ( $license->is_cancelled ) {
114 $tags[] = array(
115 'label' => fs_text_inline( 'Cancelled', 'cancelled', $slug ),
116 'type' => 'error'
117 );
118 } else if ( $license->is_expired() ) {
119 $tags[] = array(
120 'label' => fs_text_inline( 'Expired', 'expired', $slug ),
121 'type' => 'error'
122 );
123 } else if ( $license->is_lifetime() ) {
124 $tags[] = array(
125 'label' => fs_text_inline( 'No expiration', 'no-expiration', $slug ),
126 'type' => 'success'
127 );
128 } else if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) {
129 $tags[] = array(
130 'label' => sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ),
131 'type' => 'warn'
132 );
133 } else if ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) {
134 $tags[] = array(
135 'label' => sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ),
136 'type' => 'success'
137 );
138 }
139 }
140 }
141
142 foreach ( $tags as $t ) {
143 printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] );
144 }
145 ?>
146 </td>
147 <!--/ Expiration -->
148
149 <?php endif ?>
150
151 <?php
152 $buttons = array();
153 if ( $is_addon_activated ) {
154 if ( $is_paying ) {
155 $buttons[] = fs_ui_get_action_button(
156 $fs->get_id(),
157 'account',
158 'deactivate_license',
159 fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ),
160 '',
161 array( 'plugin_id' => $addon_id ),
162 false
163 );
164
165 $human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) );
166 $downgrade_confirmation_message = sprintf(
167 $downgrade_x_confirm_text,
168 ( $fs_addon->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
169 $plan->title,
170 $human_readable_license_expiration
171 );
172
173 $after_downgrade_message = ! $license->is_block_features ?
174 sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) :
175 sprintf( $after_downgrade_blocking_text, $plan->title );
176
177 if ( ! $license->is_lifetime() && $is_active_subscription ) {
178 $buttons[] = fs_ui_get_action_button(
179 $fs->get_id(),
180 'account',
181 'downgrade_account',
182 esc_html( $fs_addon->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ),
183 '',
184 array( 'plugin_id' => $addon_id ),
185 false,
186 false,
187 false,
188 ( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ),
189 'POST'
190 );
191 }
192 } else if ( $is_paid_trial ) {
193 $buttons[] = fs_ui_get_action_button(
194 $fs->get_id(),
195 'account',
196 'cancel_trial',
197 esc_html( $cancel_trial_text ),
198 '',
199 array( 'plugin_id' => $addon_id ),
200 false,
201 false,
202 'dashicons dashicons-download',
203 $cancel_trial_confirm_text,
204 'POST'
205 );
206 } else {
207 $premium_license = $fs_addon->_get_available_premium_license();
208
209 if ( is_object( $premium_license ) ) {
210 $premium_plan = $fs_addon->_get_plan_by_id( $premium_license->plan_id );
211 $site = $fs_addon->get_site();
212
213 $buttons[] = fs_ui_get_action_button(
214 $fs->get_id(),
215 'account',
216 'activate_license',
217 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' : '' ) ) ),
218 '',
219 array(
220 'plugin_id' => $addon_id,
221 'license_id' => $premium_license->id,
222 )
223 );
224 }
225 }
226
227 if ( 0 == count( $buttons ) ) {
228 if ( $show_upgrade && $fs_addon->is_premium() ) {
229 $fs_addon->_add_license_activation_dialog_box();
230
231 $buttons[] = fs_ui_get_action_button(
232 $fs->get_id(),
233 'account',
234 'activate_license',
235 fs_esc_html_inline( 'Activate License', 'activate-license', $slug ),
236 'activate-license-trigger ' . $fs_addon->get_unique_affix(),
237 array(
238 'plugin_id' => $addon_id,
239 ),
240 false,
241 true
242 );
243 }
244
245 // Add sync license only if non of the other CTAs are visible.
246 $buttons[] = fs_ui_get_action_button(
247 $fs->get_id(),
248 'account',
249 $fs->get_unique_affix() . '_sync_license',
250 esc_html( $sync_license_text ),
251 '',
252 array( 'plugin_id' => $addon_id ),
253 false,
254 true
255 );
256
257 }
258 } else if ( ! $show_upgrade ) {
259 if ( $fs->is_addon_installed( $addon_id ) ) {
260 $addon_file = $fs->get_addon_basename( $addon_id );
261 $buttons[] = sprintf(
262 '<a class="button button-primary edit" href="%s" title="%s">%s</a>',
263 wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ),
264 fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $slug ),
265 $activate_text
266 );
267 } else {
268 if ( $fs->is_allowed_to_install() ) {
269 $buttons[] = sprintf(
270 '<a class="button button-primary edit" href="%s">%s</a>',
271 wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ),
272 fs_text_inline( 'Install Now', 'install-now', $slug )
273 );
274 } else {
275 $buttons[] = sprintf(
276 '<a target="_blank" class="button button-primary edit" href="%s">%s</a>',
277 $fs->_get_latest_download_local_url( $addon_id ),
278 esc_html( $download_latest_text )
279 );
280 }
281 }
282 }
283
284 if ( $show_upgrade ) {
285 $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>',
286 esc_url( network_admin_url( 'plugin-install.php?fs_allow_updater_and_dialog=true&tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
287 '&TB_iframe=true&width=600&height=550' ) ),
288 esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon->title ) ),
289 esc_attr( $addon->title ),
290 ( $fs_addon->has_free_plan() ?
291 $upgrade_text :
292 fs_text_x_inline( 'Purchase', 'verb', 'purchase', $slug ) )
293 );
294 }
295
296 $buttons_count = count( $buttons );
297 ?>
298
299 <!-- Actions -->
300 <td><?php if ( $buttons_count > 1 ) : ?>
301 <div class="button-group"><?php endif ?>
302 <?php foreach ( $buttons as $button ) {
303 echo $button;
304 } ?>
305 <?php if ( $buttons_count > 1 ) : ?></div><?php endif ?></td>
306 <!--/ Actions -->
307
308 <?php else : ?>
309 <?php // Add-on NOT Installed or was never connected.
310 ?>
311 <!-- Action -->
312 <td colspan="4">
313 <?php if ( $fs->is_addon_installed( $addon_id ) ) : ?>
314 <?php $addon_file = $fs->get_addon_basename( $addon_id ) ?>
315 <a class="button button-primary"
316 href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
317 title="<?php fs_esc_attr_echo_inline( 'Activate this add-on', 'activate-this-addon', $slug ) ?>"
318 class="edit"><?php echo esc_html( $activate_text ) ?></a>
319 <?php else : ?>
320 <?php if ( $fs->is_allowed_to_install() ) : ?>
321 <a class="button button-primary"
322 href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ) ?>"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></a>
323 <?php else : ?>
324 <a target="_blank" class="button button-primary"
325 href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php echo esc_html( $download_latest_text ) ?></a>
326 <?php endif ?>
327 <?php endif ?>
328 </td>
329 <!--/ Action -->
330 <?php endif ?>
331 <?php if ( ! $is_paying && WP_FS__DEV_MODE ) : ?>
332 <!-- Optional Delete Action -->
333 <td>
334 <?php
335 if ( $is_addon_activated ) {
336 fs_ui_action_button(
337 $fs->get_id(), 'account',
338 'delete_account',
339 fs_text_x_inline( 'Delete', 'verb', 'delete', $slug ),
340 '',
341 array( 'plugin_id' => $addon_id ),
342 false,
343 $show_upgrade
344 );
345 }
346 ?>
347 </td>
348 <!--/ Optional Delete Action -->
349 <?php endif ?>
350 </tr>