PluginProbe
Tiered Pricing Table for WooCommerce / 2.3.0
Tiered Pricing Table for WooCommerce v2.3.0
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.php

account.php in Tiered Pricing Table for WooCommerce 2.3.0, at freemius/templates/account.php

932 lines 49.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 1.0.3
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 * @var Freemius $fs
16 */
17 $fs = freemius( $VARS['id'] );
18
19 $slug = $fs->get_slug();
20
21 /**
22 * @var FS_Plugin_Tag $update
23 */
24 $update = $fs->get_update( false, false, WP_FS__TIME_24_HOURS_IN_SEC / 24 );
25
26 if ( is_object($update) ) {
27 /**
28 * This logic is particularly required for multisite environment.
29 * If a module is site activated (not network) and not on the main site,
30 * the module will NOT be executed on the network level, therefore, the
31 * custom updates logic will not be executed as well, so unless we force
32 * the injection of the update into the updates transient, premium updates
33 * will not work.
34 *
35 * @author Vova Feldman (@svovaf)
36 * @since 2.0.0
37 */
38 $updater = FS_Plugin_Updater::instance( $fs );
39 $updater->set_update_data( $update );
40 }
41
42 $is_paying = $fs->is_paying();
43 $user = $fs->get_user();
44 $site = $fs->get_site();
45 $name = $user->get_name();
46 $license = $fs->_get_license();
47 $subscription = ( is_object( $license ) ?
48 $fs->_get_subscription( $license->id ) :
49 null );
50 $plan = $fs->get_plan();
51 $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
52 $is_paid_trial = $fs->is_paid_trial();
53 $has_paid_plan = $fs->has_paid_plan();
54 $show_upgrade = ( $has_paid_plan && ! $is_paying && ! $is_paid_trial );
55 $trial_plan = $fs->get_trial_plan();
56
57 if ( $has_paid_plan ) {
58 $fs->_add_license_activation_dialog_box();
59 }
60
61 if ( fs_request_get_bool( 'auto_install' ) ) {
62 $fs->_add_auto_installation_dialog_box();
63 }
64
65 if ( fs_request_get_bool( 'activate_license' ) ) {
66 // Open the license activation dialog box on the account page.
67 add_action( 'admin_footer', array(
68 &$fs,
69 '_open_license_activation_dialog_box'
70 ) );
71 }
72
73 $payments = $fs->_fetch_payments();
74
75 $show_billing = ( is_array( $payments ) && 0 < count( $payments ) );
76
77
78 $has_tabs = $fs->_add_tabs_before_content();
79
80 if ( $has_tabs ) {
81 $query_params['tabs'] = 'true';
82 }
83
84 // Aliases.
85 $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
86 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
87 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
88 /* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
89 $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 );
90 $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 );
91 $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 );
92 $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 );
93 $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 );
94 /* translators: %s: Plan title (e.g. "Professional") */
95 $activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug );
96 $version_text = fs_text_x_inline( 'Version', 'product version', 'version', $slug );
97 /* translators: %s: Time period (e.g. Auto renews in "2 months") */
98 $renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
99 /* translators: %s: Time period (e.g. Expires in "2 months") */
100 $expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug );
101 $sync_license_text = fs_text_x_inline( 'Sync License', 'as synchronize license', 'sync-license', $slug );
102 $cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug );
103 $change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug );
104 $upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug );
105 $addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug );
106 $downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
107 $trial_text = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
108 $free_text = fs_text_inline( 'Free', 'free', $slug );
109 $activate_text = fs_text_inline( 'Activate', 'activate', $slug );
110 $plan_text = fs_text_x_inline( 'Plan', 'as product pricing plan', 'plan', $slug );
111 $bundle_plan_text = fs_text_inline( 'Bundle Plan', 'bundle-plan', $slug );
112
113 $show_plan_row = true;
114 $show_license_row = is_object( $license );
115
116 $site_view_params = array();
117
118 if ( fs_is_network_admin() ) {
119 $sites = Freemius::get_sites();
120 $all_installs_plan_id = null;
121 $all_installs_license_id = ( $show_license_row ? $license->id : null );
122 foreach ( $sites as $s ) {
123 $site_info = $fs->get_site_info( $s );
124 $install = $fs->get_install_by_blog_id( $site_info['blog_id'] );
125 $view_params = array(
126 'freemius' => $fs,
127 'license' => $license,
128 'site' => $site_info,
129 'install' => $install,
130 );
131
132 $site_view_params[] = $view_params;
133
134 if ( empty( $install ) ) {
135 continue;
136 }
137
138 if ( $show_plan_row ) {
139 if ( is_null( $all_installs_plan_id ) ) {
140 $all_installs_plan_id = $install->plan_id;
141 } else if ( $all_installs_plan_id != $install->plan_id ) {
142 $show_plan_row = false;
143 }
144 }
145
146 if ( $show_license_row && $all_installs_license_id != $install->license_id ) {
147 $show_license_row = false;
148 }
149 }
150 }
151
152 $is_child_license = ( is_object( $license ) && FS_Plugin_License::is_valid_id( $license->parent_license_id ) );
153 $bundle_subscription = null;
154
155 if (
156 $show_plan_row &&
157 is_object( $license ) &&
158 FS_Plugin_License::is_valid_id( $license->parent_license_id )
159 ) {
160 $bundle_subscription = $fs->_get_subscription( $license->parent_license_id );
161 }
162
163 $is_active_bundle_subscription = ( is_object( $bundle_subscription ) && $bundle_subscription->is_active() );
164
165 $fs_blog_id = ( is_multisite() && ! is_network_admin() ) ?
166 get_current_blog_id() :
167 0;
168
169 $active_plugins_directories_map = Freemius::get_active_plugins_directories_map( $fs_blog_id );
170
171 $is_premium = $fs->is_premium();
172 ?>
173 <div class="wrap fs-section">
174 <?php if ( ! $has_tabs && ! $fs->apply_filters( 'hide_account_tabs', false ) ) : ?>
175 <h2 class="nav-tab-wrapper">
176 <a href="<?php echo $fs->get_account_url() ?>"
177 class="nav-tab nav-tab-active"><?php fs_esc_html_echo_inline( 'Account', 'account', $slug ) ?></a>
178 <?php if ( $fs->has_addons() ) : ?>
179 <a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>"
180 class="nav-tab"><?php echo esc_html( $addons_text ) ?></a>
181 <?php endif ?>
182 <?php if ( $show_upgrade ) : ?>
183 <a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php echo esc_html( $upgrade_text ) ?></a>
184 <?php if ( $fs->apply_filters( 'show_trial', true ) && ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
185 <a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php fs_esc_html_echo_inline( 'Free Trial', 'free-trial', $slug ) ?></a>
186 <?php endif ?>
187 <?php endif ?>
188 </h2>
189 <?php endif ?>
190
191 <div id="poststuff">
192 <div id="fs_account">
193 <div class="has-sidebar has-right-sidebar">
194 <div class="has-sidebar-content">
195 <div class="postbox">
196 <h3><span class="dashicons dashicons-businessman"></span> <?php fs_esc_html_echo_inline( 'Account Details', 'account-details', $slug ) ?></h3>
197 <div class="fs-header-actions">
198 <ul>
199 <?php if ( $show_billing ) : ?>
200 <li><a href="#fs_billing"><i class="dashicons dashicons-portfolio"></i> <?php fs_esc_html_echo_inline( 'Billing & Invoices', 'billing-invoices', $slug ) ?></li>
201 <li>&nbsp;&bull;&nbsp;</li>
202 <?php endif ?>
203 <?php if ( ! $is_paying ) : ?>
204 <li>
205 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
206 <input type="hidden" name="fs_action" value="delete_account">
207 <?php wp_nonce_field( 'delete_account' ) ?>
208 <a class="fs-delete-account" href="#" onclick="if (confirm('<?php
209 if ( $is_active_subscription ) {
210 echo esc_attr( sprintf( fs_text_inline( 'Deleting the account will automatically deactivate your %s plan license so you can use it on other sites. If you want to terminate the recurring payments as well, click the "Cancel" button, and first "Downgrade" your account. Are you sure you would like to continue with the deletion?', 'delete-account-x-confirm', $slug ), $plan->title ) );
211 } else {
212 echo esc_attr( sprintf( fs_text_inline( 'Deletion is not temporary. Only delete if you no longer want to use this %s anymore. Are you sure you would like to continue with the deletion?', 'delete-account-confirm', $slug ), $fs->get_module_label( true ) ) );
213 }
214 ?>')) this.parentNode.submit(); return false;"><i
215 class="dashicons dashicons-no"></i> <?php fs_esc_html_echo_inline( 'Delete Account', 'delete-account', $slug ) ?></a>
216 </form>
217 </li>
218 <li>&nbsp;&bull;&nbsp;</li>
219 <?php endif ?>
220 <?php if ( $is_paying ) : ?>
221 <?php if ( ! fs_is_network_admin() ) : ?>
222 <li>
223 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
224 <input type="hidden" name="fs_action" value="deactivate_license">
225 <?php wp_nonce_field( 'deactivate_license' ) ?>
226 <a href="#" class="fs-deactivate-license"><i
227 class="dashicons dashicons-admin-network"></i> <?php fs_echo_inline( 'Deactivate License', 'deactivate-license', $slug ) ?>
228 </a>
229 </form>
230 </li>
231 <li>&nbsp;&bull;&nbsp;</li>
232 <?php endif ?>
233 <?php if ( ! $license->is_lifetime() &&
234 $is_active_subscription
235 ) : ?>
236 <li>
237 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
238 <input type="hidden" name="fs_action" value="downgrade_account">
239 <?php wp_nonce_field( 'downgrade_account' ) ?>
240 <a href="#"
241 onclick="if ( confirm('<?php echo esc_attr( sprintf(
242 $downgrade_x_confirm_text,
243 ( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
244 $plan->title,
245 human_time_diff( time(), strtotime( $license->expiration ) )
246 ) ) ?> <?php if ( ! $license->is_block_features ) {
247 echo esc_attr( sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) );
248 } else {
249 echo esc_attr( sprintf( $after_downgrade_blocking_text, $plan->title ) );
250 }?> <?php echo esc_attr( $prices_increase_text ) ?> <?php fs_esc_attr_echo_inline( 'Are you sure you want to proceed?', 'proceed-confirmation', $slug ) ?>') ) this.parentNode.submit(); return false;"><i class="dashicons dashicons-download"></i> <?php echo esc_html( $fs->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ) ?></a>
251 </form>
252 </li>
253 <li>&nbsp;&bull;&nbsp;</li>
254 <?php endif ?>
255 <?php if ( ! $fs->is_single_plan() ) : ?>
256 <li>
257 <a href="<?php echo $fs->get_upgrade_url() ?>"><i
258 class="dashicons dashicons-grid-view"></i> <?php echo esc_html( $change_plan_text ) ?></a>
259 </li>
260 <li>&nbsp;&bull;&nbsp;</li>
261 <?php endif ?>
262 <?php elseif ( $is_paid_trial ) : ?>
263 <li>
264 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
265 <input type="hidden" name="fs_action" value="cancel_trial">
266 <?php wp_nonce_field( 'cancel_trial' ) ?>
267 <a href="#" class="fs-cancel-trial"><i
268 class="dashicons dashicons-download"></i> <?php echo esc_html( $cancel_trial_text ) ?></a>
269 </form>
270 </li>
271 <li>&nbsp;&bull;&nbsp;</li>
272 <?php endif ?>
273 <li>
274 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
275 <input type="hidden" name="fs_action" value="<?php echo $fs->get_unique_affix() ?>_sync_license">
276 <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
277 <a href="#" onclick="this.parentNode.submit(); return false;"><i
278 class="dashicons dashicons-image-rotate"></i> <?php fs_esc_html_echo_x_inline( 'Sync', 'as synchronize', 'sync', $slug ) ?></a>
279 </form>
280 </li>
281
282 </ul>
283 </div>
284 <div class="inside">
285 <table id="fs_account_details" cellspacing="0" class="fs-key-value-table">
286 <?php
287 $hide_license_key = ( ! $show_license_row || $fs->apply_filters( 'hide_license_key', false ) );
288
289 $profile = array();
290 $profile[] = array(
291 'id' => 'user_name',
292 'title' => fs_text_inline( 'Name', 'name', $slug ),
293 'value' => $name
294 );
295 // if (isset($user->email) && false !== strpos($user->email, '@'))
296 $profile[] = array(
297 'id' => 'email',
298 'title' => fs_text_inline( 'Email', 'email', $slug ),
299 'value' => $user->email
300 );
301
302 if ( is_numeric( $user->id ) ) {
303 $profile[] = array(
304 'id' => 'user_id',
305 'title' => fs_text_inline( 'User ID', 'user-id', $slug ),
306 'value' => $user->id
307 );
308 }
309
310 $profile[] = array(
311 'id' => 'product',
312 'title' => ( $fs->is_plugin() ?
313 fs_text_inline( 'Plugin', 'plugin', $slug ) :
314 fs_text_inline( 'Theme', 'theme', $slug ) ),
315 'value' => $fs->get_plugin_title()
316 );
317
318 $profile[] = array(
319 'id' => 'product_id',
320 'title' => ( $fs->is_plugin() ?
321 fs_text_inline( 'Plugin', 'plugin', $slug ) :
322 fs_text_inline( 'Theme', 'theme', $slug ) ) . ' ' . fs_text_inline( 'ID', 'id', $slug ),
323 'value' => $fs->get_id()
324 );
325
326 if ( ! fs_is_network_admin()) {
327 $profile[] = array(
328 'id' => 'site_id',
329 'title' => fs_text_inline( 'Site ID', 'site-id', $slug ),
330 'value' => is_string( $site->id ) ?
331 $site->id :
332 fs_text_inline( 'No ID', 'no-id', $slug )
333 );
334
335 $profile[] = array(
336 'id' => 'site_public_key',
337 'title' => fs_text_inline( 'Public Key', 'public-key', $slug ),
338 'value' => $site->public_key
339 );
340
341 $profile[] = array(
342 'id' => 'site_secret_key',
343 'title' => fs_text_inline( 'Secret Key', 'secret-key', $slug ),
344 'value' => ( ( is_string( $site->secret_key ) ) ?
345 $site->secret_key :
346 fs_text_x_inline( 'No Secret', 'as secret encryption key missing', 'no-secret', $slug )
347 )
348 );
349 }
350
351 $profile[] = array(
352 'id' => 'version',
353 'title' => $version_text,
354 'value' => $fs->get_plugin_version()
355 );
356
357 if ( $is_premium ) {
358 $profile[] = array(
359 'id' => 'beta_program',
360 'title' => '',
361 'value' => $user->is_beta
362 );
363 }
364
365 if ( $has_paid_plan ) {
366 if ( $fs->is_trial() ) {
367 if ( $show_plan_row ) {
368 $profile[] = array(
369 'id' => 'plan',
370 'title' => $plan_text,
371 'value' => ( is_string( $trial_plan->name ) ?
372 strtoupper( $trial_plan->title ) :
373 fs_text_inline( 'Trial', 'trial', $slug ) )
374 );
375 }
376 } else {
377 if ( $show_plan_row ) {
378 $profile[] = array(
379 'id' => 'plan',
380 'title' => ( $is_child_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text,
381 'value' => strtoupper( is_string( $plan->name ) ?
382 $plan->title :
383 strtoupper( $free_text )
384 )
385 );
386
387 if ( $is_child_license ) {
388 $profile[] = array(
389 'id' => 'bundle_plan',
390 'title' => $bundle_plan_text,
391 'value' => strtoupper( $license->parent_plan_title )
392 );
393 }
394 }
395
396 if ( is_object( $license ) ) {
397 if ( ! $hide_license_key ) {
398 $profile[] = array(
399 'id' => 'license_key',
400 'title' => fs_text_inline( 'License Key', $slug ),
401 'value' => $license->secret_key,
402 );
403 }
404 }
405 }
406 }
407 ?>
408 <?php $odd = true;
409 foreach ( $profile as $p ) : ?>
410 <?php
411 if ( 'plan' === $p['id'] && ! $has_paid_plan ) {
412 // If plugin don't have any paid plans, there's no reason
413 // to show current plan.
414 continue;
415 }
416 ?>
417 <tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
418 <td>
419 <nobr><?php echo $p['title'] ?><?php echo ( ! empty( $p['title'] ) ) ? ':' : '' ?></nobr>
420 </td>
421 <td<?php if ( 'plan' === $p['id'] || 'bundle_plan' === $p['id'] ) { echo ' colspan="2"'; }?>>
422 <?php if ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
423 <code><?php echo htmlspecialchars( substr( $p['value'], 0, 6 ) ) . str_pad( '', 23 * 6, '&bull;' ) . htmlspecialchars( substr( $p['value'], - 3 ) ) ?></code>
424 <input type="text" value="<?php echo htmlspecialchars( $p['value'] ) ?>" style="display: none"
425 readonly/>
426 <?php elseif ( 'beta_program' === $p['id'] ) : ?>
427 <label>
428 <input type="checkbox" class="fs-toggle-beta-mode" <?php checked( true, $p['value'] ) ?>/><span><?php
429 fs_esc_html_echo_inline( 'Join the Beta program', 'join-beta', $slug )
430 ?></span></label>
431 <?php else : ?>
432 <code><?php echo htmlspecialchars( $p['value'] ) ?></code>
433 <?php endif ?>
434 <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
435 <label class="fs-tag fs-warn"><?php fs_esc_html_echo_inline( 'not verified', 'not-verified', $slug ) ?></label>
436 <?php endif ?>
437 <?php if ( 'plan' === $p['id'] ) : ?>
438 <?php if ( $fs->is_trial() ) : ?>
439 <label class="fs-tag fs-success"><?php echo esc_html( $trial_text ) ?></label>
440 <?php endif ?>
441 <?php if ( is_object( $license ) && ! $license->is_lifetime() ) : ?>
442 <?php if ( ! $is_active_subscription && ! $is_active_bundle_subscription && ! $license->is_first_payment_pending() ) : ?>
443 <?php $is_license_expired = $license->is_expired() ?>
444 <?php $expired_ago_text = ( fs_text_inline( 'Expired', 'expired', $slug ) . ' ' . fs_text_x_inline( '%s ago', 'x-ago', $slug ) ) ?>
445 <label
446 class="fs-tag <?php echo $is_license_expired ? 'fs-error' : 'fs-warn' ?>"><?php
447 echo esc_html( sprintf( $is_license_expired ? $expired_ago_text : $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ) )
448 ?></label>
449 <?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?>
450 <label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ) ?></label>
451 <?php endif ?>
452 <?php elseif ( $fs->is_trial() ) : ?>
453 <label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ) ?></label>
454 <?php endif ?>
455 <div class="button-group">
456 <?php $available_license = $fs->is_free_plan() && ! fs_is_network_admin() ? $fs->_get_available_premium_license( $site->is_localhost() ) : false ?>
457 <?php if ( is_object( $available_license ) ) : ?>
458 <?php $premium_plan = $fs->_get_plan_by_id( $available_license->plan_id ) ?>
459 <?php
460 $view_params = array(
461 'freemius' => $fs,
462 'slug' => $slug,
463 'license' => $available_license,
464 'plan' => $premium_plan,
465 'is_localhost' => $site->is_localhost(),
466 'install_id' => $site->id,
467 'class' => 'button-primary',
468 );
469 fs_require_template( 'account/partials/activate-license-button.php', $view_params ); ?>
470 <?php else : ?>
471 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
472 method="POST" class="button-group">
473 <?php if ( $show_upgrade && $is_premium ) : ?>
474 <a class="button activate-license-trigger <?php echo $fs->get_unique_affix() ?>" href="#"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a>
475 <?php endif ?>
476 <input type="submit" class="button"
477 value="<?php echo esc_attr( $sync_license_text ) ?>">
478 <input type="hidden" name="fs_action"
479 value="<?php echo $fs->get_unique_affix() ?>_sync_license">
480 <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
481 <?php if ( $show_upgrade || ! $fs->is_single_plan() ) : ?>
482 <a href="<?php echo $fs->get_upgrade_url() ?>"
483 class="button<?php
484 echo $show_upgrade ?
485 ' button-primary fs-upgrade' :
486 ' fs-change-plan'; ?> button-upgrade"><i
487 class="dashicons dashicons-cart"></i> <?php echo esc_html( $show_upgrade ? $upgrade_text : $change_plan_text ) ?></a>
488 <?php endif ?>
489 </form>
490 <?php endif ?>
491 </div>
492 <?php elseif ( 'bundle_plan' === $p['id'] ) : ?>
493 <?php if ( is_object( $bundle_subscription ) ) : ?>
494 <?php if ( $is_active_bundle_subscription && ! $license->is_first_payment_pending() ) : ?>
495 <label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $bundle_subscription->next_payment ) ) ) ) ?></label>
496 <?php endif ?>
497 <?php endif ?>
498 <?php elseif ( 'version' === $p['id'] && $has_paid_plan ) : ?>
499 <?php if ( $fs->has_premium_version() ) : ?>
500 <?php if ( $is_premium ) : ?>
501 <label
502 class="fs-tag fs-<?php echo $fs->can_use_premium_code() ? 'success' : 'warn' ?>"><?php fs_esc_html_echo_inline( 'Premium version', 'premium-version', $slug ) ?></label>
503 <?php elseif ( $fs->can_use_premium_code() ) : ?>
504 <label class="fs-tag fs-warn"><?php fs_esc_html_echo_inline( 'Free version', 'free-version', $slug ) ?></label>
505 <?php endif ?>
506 <?php endif ?>
507 <?php endif ?>
508 </td>
509 <?php if ( 'plan' !== $p['id'] && 'bundle_plan' !== $p['id'] ) : ?>
510 <td class="fs-right">
511 <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
512 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
513 <input type="hidden" name="fs_action" value="verify_email">
514 <?php wp_nonce_field( 'verify_email' ) ?>
515 <input type="submit" class="button button-small"
516 value="<?php fs_esc_attr_echo_inline( 'Verify Email', 'verify-email', $slug ) ?>">
517 </form>
518 <?php endif ?>
519 <?php if ( 'version' === $p['id'] ) : ?>
520 <?php if ( $fs->has_release_on_freemius() ) : ?>
521 <div class="button-group">
522 <?php if ( $is_paying || $fs->is_trial() ) : ?>
523 <?php if ( ! $fs->is_allowed_to_install() ) : ?>
524 <a target="_blank" class="button button-primary"
525 href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php echo sprintf(
526 /* translators: %s: plan name (e.g. Download "Professional" Version) */
527 fs_text_inline( 'Download %s Version', 'download-x-version', $slug ),
528 ( $fs->is_trial() ? $trial_plan->title : $plan->title ) ) . ( is_object( $update ) ? ' [' . $update->version . ']' : '' ) ?></a>
529 <?php elseif ( is_object( $update ) ) : ?>
530 <?php
531 $module_type = $fs->get_module_type();
532 ?>
533 <a class="button button-primary"
534 href="<?php echo wp_nonce_url( self_admin_url( "update.php?action=upgrade-{$module_type}&{$module_type}=" . $fs->get_plugin_basename() ), "upgrade-{$module_type}_" . $fs->get_plugin_basename() ) ?>"><?php echo fs_esc_html_inline( 'Install Update Now', 'install-update-now', $slug ) . ' [' . $update->version . ']' ?></a>
535 <?php endif ?>
536 <?php endif; ?>
537 </div>
538 <?php endif ?>
539 <?php
540 elseif ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
541 <button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button>
542 <?php if ('license_key' === $p['id']) : ?>
543 <button class="button button-small activate-license-trigger <?php echo $fs->get_unique_affix() ?>"><?php fs_esc_html_echo_inline( 'Change License', 'change-license', $slug ) ?></button>
544 <?php endif ?>
545 <?php
546 elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/
547 ( is_string( $user->secret_key ) && in_array( $p['id'], array(
548 'email',
549 'user_name'
550 ) ) )
551 ) : ?>
552 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
553 onsubmit="var val = prompt('<?php echo esc_attr( sprintf(
554 /* translators: %s: User's account property (e.g. name, email) */
555 fs_text_inline( 'What is your %s?', 'what-is-your-x', $slug ),
556 $p['title']
557 ) ) ?>', '<?php echo $p['value'] ?>'); if (null == val || '' === val) return false; jQuery('input[name=fs_<?php echo $p['id'] ?>_<?php echo $fs->get_unique_affix() ?>]').val(val); return true;">
558 <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
559 <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $fs->get_unique_affix() ?>"
560 value="">
561 <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
562 <input type="submit" class="button button-small"
563 value="<?php echo fs_esc_attr_x_inline( 'Edit', 'verb', 'edit', $slug ) ?>">
564 </form>
565 <?php endif ?>
566 </td>
567 <?php endif ?>
568 </tr>
569 <?php
570 if ( 'version' === $p['id'] && $is_premium ) {
571 /**
572 * If there's a row for the beta program, keep its background color
573 * the same as the version info row.
574 *
575 * @author Leo Fajardo (@leorw)
576 * @since 2.3.0
577 */
578 continue;
579 }
580
581 $odd = ! $odd;
582 endforeach ?>
583 </table>
584 </div>
585 </div>
586 <?php if ( fs_is_network_admin() ) : ?>
587 <div id="fs_sites" class="postbox">
588 <h3><span class="dashicons dashicons-networking"></span> <?php fs_esc_html_echo_inline( 'Sites', 'sites', $slug ) ?></h3>
589 <div class="fs-header-actions">
590 <?php $has_license = is_object( $license ) ?>
591 <?php if ( $has_license || ( $show_upgrade && $is_premium ) ) : ?>
592 <?php
593 $activate_license_button_text = $has_license ?
594 fs_esc_html_inline( 'Change License', 'change-license', $slug ) :
595 fs_esc_html_inline( 'Activate License', 'activate-license', $slug );
596 ?>
597 <a class="button<?php echo ( ! $has_license ? ' button-primary' : '' ) ?> activate-license-trigger <?php echo $fs->get_unique_affix() ?>" href="#"><?php echo $activate_license_button_text ?></a>
598 <?php endif ?>
599 <input class="fs-search" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Search by address', 'search-by-address', $slug ) ?>..."><span class="dashicons dashicons-search"></span>
600 </div>
601
602 <div class="inside">
603 <div id="" class="fs-scrollable-table">
604 <div class="fs-table-head">
605 <table class="widefat">
606 <thead>
607 <tr>
608 <td><?php fs_esc_html_echo_inline('ID', 'id', $slug) ?></td>
609 <td><?php fs_esc_html_echo_inline('Address', 'address', $slug) ?></td>
610 <td><?php fs_esc_html_echo_inline('License', 'license', $slug) ?></td>
611 <td><?php fs_esc_html_echo_inline('Plan', 'plan', $slug) ?></td>
612 <td></td>
613 </tr>
614 </thead>
615 </table>
616 </div>
617 <div class="fs-table-body">
618 <table class="widefat">
619 <?php
620 foreach ( $site_view_params as $view_params ) {
621 fs_require_template(
622 'account/partials/site.php',
623 $view_params
624 );
625 } ?>
626 </table>
627 </div>
628 </div>
629 </div>
630 </div>
631 <?php endif ?>
632
633 <?php
634 $account_addons = $fs->get_updated_account_addons();
635
636 $installed_addons = $fs->get_installed_addons();
637 $installed_addons_ids = array();
638 foreach ( $installed_addons as $fs_addon ) {
639 $installed_addons_ids[] = $fs_addon->get_id();
640 }
641
642 $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
643 ?>
644 <?php if ( 0 < count( $addons_to_show ) ) : ?>
645 <!-- Add-Ons -->
646 <div class="postbox">
647 <div class="">
648 <!-- <div class="inside">-->
649 <table id="fs_addons" class="widefat">
650 <thead>
651 <tr>
652 <th><h3><?php echo esc_html( $addons_text ) ?></h3></th>
653 <th><?php fs_esc_html_echo_inline( 'ID', 'id', $slug ) ?></th>
654 <th><?php echo esc_html( $version_text ) ?></th>
655 <th><?php echo esc_html( $plan_text ) ?></th>
656 <th><?php fs_esc_html_echo_x_inline( 'License', 'as software license', 'license', $slug ) ?></th>
657 <th></th>
658 <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
659 <th></th>
660 <?php endif ?>
661 </tr>
662 </thead>
663 <tbody>
664 <?php
665 $odd = true;
666
667 $installed_addons_ids_map = array_flip( $installed_addons_ids );
668
669 foreach ( $addons_to_show as $addon_id ) {
670 $is_addon_installed = isset( $installed_addons_ids_map[ $addon_id ] );
671
672 $addon_view_params = array(
673 'parent_fs' => $fs,
674 'addon_id' => $addon_id,
675 'odd' => $odd,
676 'fs_blog_id' => $fs_blog_id,
677 'active_plugins_directories_map' => &$active_plugins_directories_map,
678 'is_addon_installed' => $is_addon_installed,
679 'addon_info' => $fs->_get_addon_info( $addon_id, $is_addon_installed )
680 );
681
682 fs_require_template(
683 'account/partials/addon.php',
684 $addon_view_params
685 );
686
687 $odd = ! $odd;
688 } ?>
689 </tbody>
690 </table>
691 </div>
692 </div>
693 <?php endif ?>
694
695 <?php $fs->do_action( 'after_account_details' ) ?>
696
697 <?php
698 if ( $show_billing ) {
699 $view_params = array( 'id' => $VARS['id'] );
700 fs_require_once_template( 'account/billing.php', $view_params );
701 fs_require_once_template( 'account/payments.php', $view_params );
702 }
703 ?>
704 </div>
705 </div>
706 </div>
707 </div>
708 </div>
709 <?php
710 $subscription_cancellation_dialog_box_template_params = $fs->_get_subscription_cancellation_dialog_box_template_params( true );
711 if ( ! empty( $subscription_cancellation_dialog_box_template_params ) ) {
712 fs_require_template( 'forms/subscription-cancellation.php', $subscription_cancellation_dialog_box_template_params );
713 }
714 ?>
715 <script type="text/javascript">
716 (function ($) {
717 var setLoading = function ($this, label) {
718 // Set loading mode.
719 $(document.body).css({'cursor': 'wait'});
720
721 $this.css({'cursor': 'wait'});
722
723 if ($this.is('input'))
724 $this.val(label);
725 else
726 $this.html(label);
727
728 setTimeout(function () {
729 $this.attr('disabled', 'disabled');
730 }, 200);
731 };
732
733 $('.fs-toggle-visibility').click(function () {
734 var
735 $this = $(this),
736 $parent = $this.closest('tr'),
737 $input = $parent.find('input');
738
739 $parent.find('code').toggle();
740 $input.toggle();
741
742 if ($input.is(':visible')) {
743 $this.html('<?php fs_esc_js_echo_x_inline( 'Hide', 'verb', 'hide', $slug ) ?>');
744 setTimeout(function () {
745 $input.select().focus();
746 }, 100);
747 }
748 else {
749 $this.html( '<?php fs_esc_js_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?>' );
750 }
751 });
752
753 $('.fs-toggle-tracking').click(function () {
754 setLoading(
755 $(this),
756 ($(this).data('is-disconnected') ?
757 '<?php fs_esc_js_echo_inline('Opting in', 'opting-in' ) ?>' :
758 '<?php fs_esc_js_echo_inline('Opting out', 'opting-out' ) ?>') +
759 '...'
760 );
761 });
762
763 <?php
764 $plugin_title = $fs->get_plugin_title();
765 $processing_text = fs_esc_js_inline( 'Processing', 'processing' );
766 $confirmation_message = sprintf(
767 '%s %s',
768 sprintf( fs_esc_attr_inline( 'Get updates for bleeding edge Beta versions of %s.', 'get-beta-versions', $slug ), $plugin_title ),
769 sprintf( fs_esc_attr_inline( 'An update to a Beta version will replace your installed version of %s with the latest Beta release - use with caution, and not on production sites. You have been warned.', 'beta-version-update-caution', $slug ), $plugin_title )
770 );
771 ?>
772
773 $( '.fs-toggle-beta-mode' ).click( function () {
774 var $checkbox = $( this ),
775 isChecked = $checkbox.is( ':checked' );
776
777 if ( ! isChecked || confirm( '<?php echo $confirmation_message ?>' ) ) {
778 $.ajax( {
779 url : ajaxurl,
780 method: 'POST',
781 data : {
782 action : '<?php echo $fs->get_ajax_action( 'set_beta_mode' ) ?>',
783 security : '<?php echo $fs->get_ajax_security( 'set_beta_mode' ) ?>',
784 is_beta : isChecked,
785 module_id: <?php echo $fs->get_id() ?>
786 },
787 beforeSend: function () {
788 $checkbox.prop( 'disabled', true );
789 $checkbox.parent().find( 'span' ).text( '<?php echo $processing_text ?>' + '...' );
790 },
791 complete: function () {
792 $checkbox.prop( 'disabled', false );
793 $checkbox.parent().find( 'span' ).text( '<?php fs_esc_js_echo_inline( 'Join the Beta Program', 'join-beta', $slug ) ?>' );
794 }
795 } );
796
797 return true;
798 }
799
800 return false;
801 });
802
803 $('.fs-opt-in').click(function () {
804 setLoading($(this), '<?php fs_esc_js_echo_inline('Opting in', 'opting-in' ) ?>...');
805 });
806
807 $( '#fs_downgrade' ).submit(function( event ) {
808 event.preventDefault();
809
810 setLoading( $( this ).find( '.button' ), '<?php fs_esc_js_echo_inline( 'Downgrading', 'downgrading' ) ?>...' );
811 });
812
813 $('.fs-activate-license').click(function () {
814 setLoading($(this), '<?php fs_esc_js_echo_inline('Activating', 'activating' ) ?>...');
815 });
816
817 var $deactivateLicenseOrCancelTrial = $( '.fs-deactivate-license, .fs-cancel-trial' ),
818 $subscriptionCancellationModal = $( '.fs-modal-subscription-cancellation-<?php echo $fs->get_id() ?>' );
819
820 if ( 0 !== $subscriptionCancellationModal.length ) {
821 $subscriptionCancellationModal.on( '<?php echo $fs->get_action_tag( 'subscription_cancellation_action' ) ?>', function( evt, cancelSubscription ) {
822 setLoading(
823 $deactivateLicenseOrCancelTrial,
824 ( ! $deactivateLicenseOrCancelTrial.hasClass( 'fs-cancel-trial' ) ?
825 '<?php fs_esc_js_echo_inline( 'Deactivating', 'deactivating', $slug ) ?>' :
826 '<?php echo esc_html( sprintf( fs_text_inline( 'Cancelling %s', 'cancelling-x', $slug ), fs_text_inline( 'trial', 'trial', $slug ) ) ) ?>' ) + '...'
827 );
828
829 $subscriptionCancellationModal.find( '.fs-modal-footer .button' ).addClass( 'disabled' );
830 $deactivateLicenseOrCancelTrial.unbind( 'click' );
831
832 if ( false === cancelSubscription || $deactivateLicenseOrCancelTrial.hasClass( 'fs-cancel-trial' ) ) {
833 $subscriptionCancellationModal.find( '.fs-modal-footer .button-primary' ).text( $deactivateLicenseOrCancelTrial.text() );
834
835 $deactivateLicenseOrCancelTrial[0].parentNode.submit();
836 } else {
837 var $form = $( 'input[value="downgrade_account"],input[value="cancel_trial"]' ).parent();
838 $form.prepend( '<input type="hidden" name="deactivate_license" value="true" />' );
839
840 $subscriptionCancellationModal.find( '.fs-modal-footer .button-primary' ).text( '<?php echo esc_js( sprintf(
841 fs_text_inline( 'Cancelling %s...', 'cancelling-x' , $slug ),
842 $is_paid_trial ?
843 fs_text_inline( 'trial', 'trial', $slug ) :
844 fs_text_inline( 'subscription', 'subscription', $slug )
845 ) ) ?>' );
846
847 $form.submit();
848 }
849 });
850 }
851
852 $deactivateLicenseOrCancelTrial.click(function() {
853 var $this = $( this );
854 if ( $this.hasClass( 'fs-cancel-trial' ) ) {
855 $subscriptionCancellationModal.find( '.fs-modal-panel' ).find( 'ul.subscription-actions, .fs-price-increase-warning' ).remove();
856 $subscriptionCancellationModal.find( '.fs-modal-panel > p' ).text( <?php echo json_encode( $cancel_trial_confirm_text ) ?> );
857 $subscriptionCancellationModal.trigger( 'showModal' );
858 } else if (confirm('<?php fs_esc_attr_echo_inline( 'Deactivating your license will block all premium features, but will enable activating the license on another site. Are you sure you want to proceed?', 'deactivate-license-confirm', $slug ) ?>')) {
859 var $this = $(this);
860
861 if ( 0 !== $subscriptionCancellationModal.length ) {
862 $subscriptionCancellationModal.trigger( 'showModal' );
863 } else {
864 setLoading( $this, '<?php fs_esc_js_echo_inline( 'Deactivating', 'deactivating', $slug ) ?>...' );
865 $this[0].parentNode.submit();
866 }
867 }
868
869 return false;
870 });
871
872 var $sitesSection = $('#fs_sites'),
873 $sitesTable = $sitesSection.find('.fs-scrollable-table'),
874 $sitesTableRows = $sitesTable.find('.fs-site-details');
875
876 $('.fs-show-install-details').click(function(){
877 var installID = $(this).parents('.fs-site-details').attr('data-install-id');
878 $sitesSection.find('.fs-install-details[data-install-id=' + installID + ']').toggle();
879 });
880
881
882 var adjustColumnWidth = function($table) {
883 var $headerColumns = $table.find('.fs-table-head td'),
884 $bodyColumns = $table.find('.fs-table-body tr:first > td');
885
886 for (var i = 0, len = $headerColumns.length; i < len; i++) {
887 $($headerColumns[i]).width($($bodyColumns[i]).width());
888 }
889 for (i = 0, len = $headerColumns.length; i < len; i++) {
890 $($bodyColumns[i]).width($($headerColumns[i]).width());
891 }
892 };
893
894 adjustColumnWidth($sitesTable);
895
896 $sitesSection.find('.fs-search').keyup(function(){
897 var search = $(this).val().trim();
898
899 if ('' === search){
900 // Show all.
901 $sitesTableRows.show();
902 return;
903 }
904
905 var url;
906
907 $sitesTableRows.each(function(index){
908 url = $(this).find('.fs-field-url').html();
909
910 if (-1 < url.indexOf(search)){
911 $(this).show();
912 } else {
913 $(this).hide();
914 }
915 });
916 });
917
918 })(jQuery);
919 </script>
920 <?php
921 if ( $has_tabs ) {
922 $fs->_add_tabs_after_content();
923 }
924
925 $params = array(
926 'page' => 'account',
927 'module_id' => $fs->get_id(),
928 'module_type' => $fs->get_module_type(),
929 'module_slug' => $slug,
930 'module_version' => $fs->get_plugin_version(),
931 );
932 fs_require_template( 'powered-by.php', $params );