PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 3.6.0
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v3.6.0
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
← All changes | freemius/templates/account.php +1120 -733 1.13.6.0 View file →
@@ -1,733 +1,1120 @@
1 -<?php
2 - /**
3 - * @package Freemius
4 - * @copyright Copyright (c) 2015, Freemius, Inc.
5 - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6 - * @since 1.0.3
7 - */
8 -
9 - if ( ! defined( 'ABSPATH' ) ) {
10 - exit;
11 - }
12 -
13 - /**
14 - * @var array $VARS
15 - */
16 - $slug = $VARS['slug'];
17 - /**
18 - * @var Freemius $fs
19 - */
20 - $fs = freemius( $slug );
21 -
22 - /**
23 - * @var FS_Plugin_Tag $update
24 - */
25 - $update = $fs->get_update( false, false );
26 -
27 - $is_paying = $fs->is_paying();
28 - $user = $fs->get_user();
29 - $site = $fs->get_site();
30 - $name = $user->get_name();
31 - $license = $fs->_get_license();
32 - $subscription = $fs->_get_subscription();
33 - $plan = $fs->get_plan();
34 - $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
35 - $is_paid_trial = $fs->is_paid_trial();
36 - $show_upgrade = ( $fs->has_paid_plan() && ! $is_paying && ! $is_paid_trial );
37 -
38 - if ( $fs->has_paid_plan() ) {
39 - $fs->_add_license_activation_dialog_box();
40 - }
41 -
42 - if ( fs_request_get_bool( 'auto_install' ) ) {
43 - $fs->_add_auto_installation_dialog_box();
44 - }
45 -?>
46 - <div class="wrap">
47 - <h2 class="nav-tab-wrapper">
48 - <a href="<?php echo $fs->get_account_url() ?>"
49 - class="nav-tab nav-tab-active"><?php fs_echo( 'account', $slug ) ?></a>
50 - <?php if ( $fs->has_addons() ) : ?>
51 - <a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>"
52 - class="nav-tab"><?php fs_echo( 'add-ons', $slug ) ?></a>
53 - <?php endif ?>
54 - <?php if ( $show_upgrade ) : ?>
55 - <a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php fs_echo( 'upgrade', $slug ) ?></a>
56 - <?php if ( $fs->apply_filters( 'show_trial', true ) && ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
57 - <a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php fs_echo( 'free-trial', $slug ) ?></a>
58 - <?php endif ?>
59 - <?php endif ?>
60 - <?php if ( ! $plan->is_free() ) : ?>
61 - <a href="<?php echo $fs->get_account_tab_url( 'billing' ) ?>"
62 - class="nav-tab"><?php fs_echo( 'billing', $slug ) ?></a>
63 - <?php endif ?>
64 - </h2>
65 -
66 - <div id="poststuff">
67 - <div id="fs_account">
68 - <div class="has-sidebar has-right-sidebar">
69 - <div class="has-sidebar-content">
70 - <div class="postbox">
71 - <h3><?php fs_echo( 'account-details', $slug ) ?></h3>
72 -
73 - <div class="fs-header-actions">
74 - <ul>
75 - <?php if ( ! $is_paying ) : ?>
76 - <li>
77 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
78 - <input type="hidden" name="fs_action" value="delete_account">
79 - <?php wp_nonce_field( 'delete_account' ) ?>
80 - <a href="#" onclick="if (confirm('<?php
81 - if ( $is_active_subscription ) {
82 - echo esc_attr( sprintf( fs_text( 'delete-account-x-confirm', $slug ), $plan->title ) );
83 - } else {
84 - fs_echo( 'delete-account-confirm', $slug );
85 - }
86 - ?>')) this.parentNode.submit(); return false;"><i
87 - class="dashicons dashicons-no"></i> <?php fs_echo( 'delete-account', $slug ) ?></a>
88 - </form>
89 - </li>
90 - <li>&nbsp;&bull;&nbsp;</li>
91 - <?php endif ?>
92 - <?php if ( $is_paying ) : ?>
93 - <li>
94 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
95 - <input type="hidden" name="fs_action" value="deactivate_license">
96 - <?php wp_nonce_field( 'deactivate_license' ) ?>
97 - <a href="#"
98 - onclick="if (confirm('<?php fs_echo( 'deactivate-license-confirm', $slug ) ?>')) this.parentNode.submit(); return false;"><i
99 - class="dashicons dashicons-admin-network"></i> <?php fs_echo( 'deactivate-license', $slug ) ?>
100 - </a>
101 - </form>
102 - </li>
103 - <li>&nbsp;&bull;&nbsp;</li>
104 - <?php if ( ! $license->is_lifetime() &&
105 - $is_active_subscription
106 - ) : ?>
107 - <li>
108 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
109 - <input type="hidden" name="fs_action" value="downgrade_account">
110 - <?php wp_nonce_field( 'downgrade_account' ) ?>
111 - <a href="#"
112 - onclick="if (confirm('<?php printf( fs_text( 'downgrade-x-confirm', $slug ), $plan->title, human_time_diff( time(), strtotime( $license->expiration ) ) ) ?> <?php if ( ! $license->is_block_features ) {
113 - printf( fs_text( 'after-downgrade-non-blocking', $slug ), $plan->title );
114 - } else {
115 - printf( fs_text( 'after-downgrade-blocking', $slug ), $plan->title );
116 - }?> <?php fs_echo( 'proceed-confirmation', $slug ) ?>')) this.parentNode.submit(); return false;"><i class="dashicons dashicons-download"></i> <?php fs_echo( ( $fs->is_only_premium() ? 'cancel-subscription' : 'downgrade' ), $slug ) ?></a>
117 - </form>
118 - </li>
119 - <li>&nbsp;&bull;&nbsp;</li>
120 - <?php endif ?>
121 - <?php if ( ! $fs->is_single_plan() ) : ?>
122 - <li>
123 - <a href="<?php echo $fs->get_upgrade_url() ?>"><i
124 - class="dashicons dashicons-grid-view"></i> <?php fs_echo( 'change-plan', $slug ) ?></a>
125 - </li>
126 - <li>&nbsp;&bull;&nbsp;</li>
127 - <?php endif ?>
128 - <?php elseif ( $is_paid_trial ) : ?>
129 - <li>
130 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
131 - <input type="hidden" name="fs_action" value="cancel_trial">
132 - <?php wp_nonce_field( 'cancel_trial' ) ?>
133 - <a href="#"
134 - onclick="if (confirm('<?php fs_echo( 'cancel-trial-confirm' ) ?>')) this.parentNode.submit(); return false;"><i
135 - class="dashicons dashicons-download"></i> <?php fs_echo( 'cancel-trial', $slug ) ?></a>
136 - </form>
137 - </li>
138 - <li>&nbsp;&bull;&nbsp;</li>
139 - <?php endif ?>
140 - <li>
141 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
142 - <input type="hidden" name="fs_action" value="<?php echo $slug ?>_sync_license">
143 - <?php wp_nonce_field( $slug . '_sync_license' ) ?>
144 - <a href="#" onclick="this.parentNode.submit(); return false;"><i
145 - class="dashicons dashicons-image-rotate"></i> <?php fs_echo( 'sync', $slug ) ?></a>
146 - </form>
147 - </li>
148 -
149 - </ul>
150 - </div>
151 - <div class="inside">
152 - <table id="fs_account_details" cellspacing="0" class="fs-key-value-table">
153 - <?php
154 - $hide_license_key = $fs->apply_filters( 'hide_license_key', false );
155 -
156 - $profile = array();
157 - $profile[] = array(
158 - 'id' => 'user_name',
159 - 'title' => fs_text( 'name', $slug ),
160 - 'value' => $name
161 - );
162 - // if (isset($user->email) && false !== strpos($user->email, '@'))
163 - $profile[] = array(
164 - 'id' => 'email',
165 - 'title' => fs_text( 'email', $slug ),
166 - 'value' => $user->email
167 - );
168 -
169 - if ( is_numeric( $user->id ) ) {
170 - $profile[] = array(
171 - 'id' => 'user_id',
172 - 'title' => fs_text( 'user-id', $slug ),
173 - 'value' => $user->id
174 - );
175 - }
176 -
177 - $profile[] = array(
178 - 'id' => 'site_id',
179 - 'title' => fs_text( 'site-id', $slug ),
180 - 'value' => is_string( $site->id ) ?
181 - $site->id :
182 - fs_text( 'no-id', $slug )
183 - );
184 -
185 - $profile[] = array(
186 - 'id' => 'site_public_key',
187 - 'title' => fs_text( 'public-key', $slug ),
188 - 'value' => $site->public_key
189 - );
190 -
191 - $profile[] = array(
192 - 'id' => 'site_secret_key',
193 - 'title' => fs_text( 'secret-key', $slug ),
194 - 'value' => ( ( is_string( $site->secret_key ) ) ?
195 - $site->secret_key :
196 - fs_text( 'no-secret', $slug )
197 - )
198 - );
199 -
200 - $profile[] = array(
201 - 'id' => 'version',
202 - 'title' => fs_text( 'version', $slug ),
203 - 'value' => $fs->get_plugin_version()
204 - );
205 -
206 - if ( $fs->has_paid_plan() ) {
207 - if ( $fs->is_trial() ) {
208 - $trial_plan = $fs->get_trial_plan();
209 -
210 - $profile[] = array(
211 - 'id' => 'plan',
212 - 'title' => fs_text( 'plan', $slug ),
213 - 'value' => ( is_string( $trial_plan->name ) ?
214 - strtoupper( $trial_plan->title ) :
215 - fs_text( 'trial', $slug ) )
216 - );
217 - } else {
218 - $profile[] = array(
219 - 'id' => 'plan',
220 - 'title' => fs_text( 'plan', $slug ),
221 - 'value' => is_string( $site->plan->name ) ?
222 - strtoupper( $site->plan->title ) :
223 - strtoupper( fs_text( 'free', $slug ) )
224 - );
225 -
226 - if ( is_object( $license ) ) {
227 - if ( ! $hide_license_key ) {
228 - $profile[] = array(
229 - 'id' => 'license_key',
230 - 'title' => fs_text( 'License Key', $slug ),
231 - 'value' => $license->secret_key,
232 - );
233 - }
234 - }
235 - }
236 - }
237 - ?>
238 - <?php $odd = true;
239 - foreach ( $profile as $p ) : ?>
240 - <?php
241 - if ( 'plan' === $p['id'] && ! $fs->has_paid_plan() ) {
242 - // If plugin don't have any paid plans, there's no reason
243 - // to show current plan.
244 - continue;
245 - }
246 - ?>
247 - <tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
248 - <td>
249 - <nobr><?php echo $p['title'] ?>:</nobr>
250 - </td>
251 - <td<?php if ( 'plan' === $p['id'] ) { echo ' colspan="2"'; }?>>
252 - <?php if ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
253 - <code><?php echo htmlspecialchars( substr( $p['value'], 0, 6 ) ) . str_pad( '', 23 * 6, '&bull;' ) . htmlspecialchars( substr( $p['value'], - 3 ) ) ?></code>
254 - <input type="text" value="<?php echo htmlspecialchars( $p['value'] ) ?>" style="display: none"
255 - readonly/>
256 - <?php else : ?>
257 - <code><?php echo htmlspecialchars( $p['value'] ) ?></code>
258 - <?php endif ?>
259 - <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
260 - <label class="fs-tag fs-warn"><?php fs_esc_html_echo( 'not-verified', $slug ) ?></label>
261 - <?php endif ?>
262 - <?php if ( 'plan' === $p['id'] ) : ?>
263 - <?php if ( $fs->is_trial() ) : ?>
264 - <label class="fs-tag fs-success"><?php fs_esc_html_echo( 'trial', $slug ) ?></label>
265 - <?php endif ?>
266 - <?php if ( is_object( $license ) && ! $license->is_lifetime() ) : ?>
267 - <?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?>
268 - <label
269 - class="fs-tag fs-warn"><?php echo esc_html( sprintf( fs_text( 'expires-in', $slug ), human_time_diff( time(), strtotime( $license->expiration ) ) ) ) ?></label>
270 - <?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?>
271 - <label
272 - class="fs-tag fs-success"><?php echo esc_html( sprintf( fs_text( 'renews-in', $slug ), human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ) ?></label>
273 - <?php endif ?>
274 - <?php elseif ( $fs->is_trial() ) : ?>
275 - <label
276 - class="fs-tag fs-warn"><?php echo esc_html( sprintf( fs_text( 'expires-in', $slug ), human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ) ?></label>
277 - <?php endif ?>
278 - <div class="button-group">
279 - <?php $available_license = $fs->is_free_plan() ? $fs->_get_available_premium_license() : false ?>
280 - <?php if ( false !== $available_license && ( $available_license->left() > 0 || ( $site->is_localhost() && $available_license->is_free_localhost ) ) ) : ?>
281 - <?php $premium_plan = $fs->_get_plan_by_id( $available_license->plan_id ) ?>
282 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
283 - method="POST">
284 - <input type="hidden" name="fs_action" value="activate_license">
285 - <input type="hidden" name="license_id" value="<?php echo $available_license->id ?>">
286 - <?php wp_nonce_field( 'activate_license' ) ?>
287 - <input type="submit" class="button button-primary"
288 - value="<?php echo esc_attr( sprintf(
289 - fs_text( 'activate-x-plan', $slug ) . '%s',
290 - $premium_plan->title,
291 - ( $site->is_localhost() && $available_license->is_free_localhost ) ?
292 - ' [' . fs_text( 'localhost', $slug ) . ']' :
293 - ( $available_license->is_single_site() ?
294 - '' :
295 - ' [' . ( 1 < $available_license->left() ?
296 - sprintf( fs_text( 'x-left', $slug ), $available_license->left() ) :
297 - strtolower( fs_text( 'last-license', $slug ) ) ) . ']'
298 - )
299 - ) ) ?> ">
300 - </form>
301 - <?php else : ?>
302 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
303 - method="POST" class="button-group">
304 - <?php if ( $show_upgrade && $fs->is_premium() ) : ?>
305 - <a class="button activate-license-trigger <?php echo $slug ?>" href="#"><?php fs_esc_html_echo( 'activate-license', $slug ) ?></a>
306 - <?php endif ?>
307 - <input type="submit" class="button"
308 - value="<?php fs_esc_attr_echo( 'sync-license', $slug ) ?>">
309 - <input type="hidden" name="fs_action"
310 - value="<?php echo $slug ?>_sync_license">
311 - <?php wp_nonce_field( $slug . '_sync_license' ) ?>
312 - <?php if ( $show_upgrade || ! $fs->is_single_plan() ) : ?>
313 - <a href="<?php echo $fs->get_upgrade_url() ?>"
314 - class="button<?php
315 - echo $show_upgrade ?
316 - ' button-primary fs-upgrade' :
317 - ' fs-change-plan'; ?> button-upgrade"><i
318 - class="dashicons dashicons-cart"></i> <?php fs_esc_html_echo( $show_upgrade ? 'upgrade' : 'change-plan', $slug ) ?></a>
319 - <?php endif ?>
320 - </form>
321 - <?php endif ?>
322 - </div>
323 - <?php elseif ( 'version' === $p['id'] && $fs->has_paid_plan() ) : ?>
324 - <?php if ( $fs->has_premium_version() ) : ?>
325 - <?php if ( $fs->is_premium() ) : ?>
326 - <label
327 - class="fs-tag fs-<?php echo $fs->can_use_premium_code() ? 'success' : 'warn' ?>"><?php fs_esc_html_echo( 'premium-version', $slug ) ?></label>
328 - <?php elseif ( $fs->can_use_premium_code() ) : ?>
329 - <label class="fs-tag fs-warn"><?php fs_esc_html_echo( 'free-version', $slug ) ?></label>
330 - <?php endif ?>
331 - <?php endif ?>
332 - <?php endif ?>
333 - </td>
334 - <?php if ( 'plan' !== $p['id'] ) : ?>
335 - <td class="fs-right">
336 - <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
337 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
338 - <input type="hidden" name="fs_action" value="verify_email">
339 - <?php wp_nonce_field( 'verify_email' ) ?>
340 - <input type="submit" class="button button-small"
341 - value="<?php fs_esc_attr_echo( 'verify-email', $slug ) ?>">
342 - </form>
343 - <?php endif ?>
344 - <?php if ( 'version' === $p['id'] ) : ?>
345 - <?php if ( $fs->has_release_on_freemius() ) : ?>
346 - <div class="button-group">
347 - <?php if ( $is_paying || $fs->is_trial() ) : ?>
348 - <?php if ( ! $fs->is_allowed_to_install() ) : ?>
349 - <a target="_blank" class="button button-primary"
350 - href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php echo sprintf( fs_text( 'download-x-version', $slug ), ( $fs->is_trial() ? $trial_plan->title : $site->plan->title ) ) . ( is_object( $update ) ? ' [' . $update->version . ']' : '' ) ?></a>
351 - <?php elseif ( is_object( $update ) ) : ?>
352 - <a class="button button-primary"
353 - href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $fs->get_plugin_basename() ), 'upgrade-plugin_' . $fs->get_plugin_basename() ) ?>"><?php echo fs_esc_html( 'install-update-now', $slug ) . ' [' . $update->version . ']' ?></a>
354 - <?php endif ?>
355 - <?php endif; ?>
356 - </div>
357 - <?php endif ?>
358 - <?php
359 - elseif ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
360 - <button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo( 'show', $slug ) ?></button>
361 - <?php if ('license_key' === $p['id']) : ?>
362 - <button class="button button-small activate-license-trigger <?php echo $slug ?>"><?php fs_esc_html_echo( 'change-license', $slug ) ?></button>
363 - <?php endif ?>
364 - <?php
365 - elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/
366 - ( is_string( $user->secret_key ) && in_array( $p['id'], array(
367 - 'email',
368 - 'user_name'
369 - ) ) )
370 - ) : ?>
371 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
372 - onsubmit="var val = prompt('<?php echo esc_attr( sprintf( fs_text( 'what-is-your-x', $slug ), $p['title'] ) ) ?>', '<?php echo $p['value'] ?>'); if (null == val || '' === val) return false; jQuery('input[name=fs_<?php echo $p['id'] ?>_<?php echo $slug ?>]').val(val); return true;">
373 - <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
374 - <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $slug ?>"
375 - value="">
376 - <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
377 - <input type="submit" class="button button-small"
378 - value="<?php fs_esc_attr_echo( 'edit', $slug ) ?>">
379 - </form>
380 - <?php endif ?>
381 - </td>
382 - <?php endif ?>
383 - </tr>
384 - <?php $odd = ! $odd;
385 - endforeach ?>
386 - </table>
387 - </div>
388 - </div>
389 - <script type="text/javascript">
390 - (function ($) {
391 - $('.fs-toggle-visibility').click(function () {
392 - var
393 - $this = $(this),
394 - $parent = $this.closest('tr'),
395 - $input = $parent.find('input');
396 -
397 - $parent.find('code').toggle();
398 - $input.toggle();
399 -
400 - if ($input.is(':visible')) {
401 - $this.html(<?php fs_json_encode_echo( 'hide', $slug ) ?>);
402 - setTimeout(function () {
403 - $input.select().focus();
404 - }, 100);
405 - }
406 - else {
407 - $this.html(<?php fs_json_encode_echo( 'show', $slug ) ?>);
408 - }
409 - });
410 - }(jQuery));
411 -
412 - </script>
413 -
414 - <?php
415 - $account_addons = $fs->get_account_addons();
416 - if ( ! is_array( $account_addons ) ) {
417 - $account_addons = array();
418 - }
419 -
420 - $installed_addons = $fs->get_installed_addons();
421 - $installed_addons_ids = array();
422 - foreach ( $installed_addons as $fs_addon ) {
423 - $installed_addons_ids[] = $fs_addon->get_id();
424 - }
425 -
426 - $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
427 - ?>
428 - <?php if ( 0 < count( $addons_to_show ) ) : ?>
429 - <!-- Add-Ons -->
430 - <div class="postbox">
431 - <div class="">
432 - <!-- <div class="inside">-->
433 - <table id="fs_addons" class="widefat">
434 - <thead>
435 - <tr>
436 - <th><h3><?php fs_esc_html_echo( 'add-ons', $slug ) ?></h3></th>
437 - <th><?php fs_esc_html_echo( 'id', $slug ) ?></th>
438 - <th><?php fs_esc_html_echo( 'version', $slug ) ?></th>
439 - <th><?php fs_esc_html_echo( 'plan', $slug ) ?></th>
440 - <th><?php fs_esc_html_echo( 'license', $slug ) ?></th>
441 - <th></th>
442 - <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
443 - <th></th>
444 - <?php endif ?>
445 - </tr>
446 - </thead>
447 - <tbody>
448 - <?php $odd = true;
449 - foreach ( $addons_to_show as $addon_id ) : ?>
450 - <?php
451 - $addon = $fs->get_addon( $addon_id );
452 - $is_addon_activated = $fs->is_addon_activated( $addon->slug );
453 - $is_addon_connected = $fs->is_addon_connected( $addon->slug );
454 -
455 - $fs_addon = $is_addon_connected ? freemius( $addon->slug ) : false;
456 - if ( is_object( $fs_addon ) ) {
457 - $is_paying = $fs_addon->is_paying();
458 - $user = $fs_addon->get_user();
459 - $site = $fs_addon->get_site();
460 - $license = $fs_addon->_get_license();
461 - $subscription = $fs_addon->_get_subscription();
462 - $plan = $fs_addon->get_plan();
463 - $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
464 - $is_paid_trial = $fs_addon->is_paid_trial();
465 - $show_upgrade = ( ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() );
466 - $is_current_license_expired = is_object( $license ) && $license->is_expired();
467 - }
468 -
469 - // var_dump( $is_paid_trial, $license, $site, $subscription );
470 -
471 - ?>
472 - <tr<?php if ( $odd ) {
473 - echo ' class="alternate"';
474 - } ?>>
475 - <td>
476 - <!-- Title -->
477 - <?php echo $addon->title ?>
478 - </td>
479 - <?php if ( $is_addon_connected ) : ?>
480 - <?php // Add-on Installed ?>
481 - <?php $addon_site = $fs_addon->get_site(); ?>
482 - <td>
483 - <!-- ID -->
484 - <?php echo $addon_site->id ?>
485 - </td>
486 - <td>
487 - <!-- Version -->
488 - <?php echo $fs_addon->get_plugin_version() ?>
489 - </td>
490 - <td>
491 - <!-- Plan Title -->
492 - <?php echo is_string( $addon_site->plan->name ) ? strtoupper( $addon_site->plan->title ) : 'FREE' ?>
493 - </td>
494 - <td>
495 - <!-- Expiration -->
496 - <?php
497 - $tags = array();
498 -
499 - if ( $fs_addon->is_trial() ) {
500 - $tags[] = array( 'label' => fs_text( 'trial', $slug ), 'type' => 'success' );
501 -
502 - $tags[] = array(
503 - 'label' => sprintf( fs_text( ( $is_paid_trial ? 'renews-in' : 'expires-in' ), $slug ), human_time_diff( time(), strtotime( $site->trial_ends ) ) ),
504 - 'type' => ( $is_paid_trial ? 'success' : 'warn' )
505 - );
506 - } else {
507 - if ( is_object( $license ) ) {
508 - if ( $license->is_cancelled ) {
509 - $tags[] = array(
510 - 'label' => fs_text( 'cancelled', $slug ),
511 - 'type' => 'error'
512 - );
513 - } else if ( $license->is_expired() ) {
514 - $tags[] = array(
515 - 'label' => fs_text( 'expired', $slug ),
516 - 'type' => 'error'
517 - );
518 - } else if ( $license->is_lifetime() ) {
519 - $tags[] = array(
520 - 'label' => fs_text( 'no-expiration', $slug ),
521 - 'type' => 'success'
522 - );
523 - } else if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) {
524 - $tags[] = array(
525 - 'label' => sprintf( fs_text( 'expires-in', $slug ), human_time_diff( time(), strtotime( $license->expiration ) ) ),
526 - 'type' => 'warn'
527 - );
528 - } else if ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) {
529 - $tags[] = array(
530 - 'label' => sprintf( fs_text( 'renews-in', $slug ), human_time_diff( time(), strtotime( $subscription->next_payment ) ) ),
531 - 'type' => 'success'
532 - );
533 - }
534 - }
535 - }
536 -
537 - foreach ( $tags as $t ) {
538 - printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] );
539 - }
540 - ?>
541 - </td>
542 - <?php
543 - $buttons = array();
544 - if ( $is_addon_activated ) {
545 - if ( $is_paying ) {
546 - $buttons[] = fs_ui_get_action_button(
547 - $slug,
548 - 'account',
549 - 'deactivate_license',
550 - fs_text( 'deactivate-license', $slug ),
551 - array( 'plugin_id' => $addon_id ),
552 - false
553 - );
554 -
555 - $human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) );
556 - $downgrade_confirmation_message = sprintf( fs_text( 'downgrade-x-confirm', $slug ),
557 - $plan->title,
558 - $human_readable_license_expiration );
559 -
560 - $after_downgrade_message_id = ( ! $license->is_block_features ?
561 - 'after-downgrade-non-blocking' :
562 - 'after-downgrade-blocking' );
563 -
564 - $after_downgrade_message = sprintf( fs_text( $after_downgrade_message_id, $slug ), $plan->title );
565 -
566 - if ( ! $license->is_lifetime() && $is_active_subscription ) {
567 - $buttons[] = fs_ui_get_action_button(
568 - $slug,
569 - 'account',
570 - 'downgrade_account',
571 - fs_text( 'downgrade', $slug ),
572 - array( 'plugin_id' => $addon_id ),
573 - false,
574 - false,
575 - ( $downgrade_confirmation_message . ' ' . $after_downgrade_message ),
576 - 'POST'
577 - );
578 - }
579 - } else if ( $is_paid_trial ) {
580 - $buttons[] = fs_ui_get_action_button(
581 - $slug,
582 - 'account',
583 - 'cancel_trial',
584 - fs_text( 'cancel-trial', $slug ),
585 - array( 'plugin_id' => $addon_id ),
586 - false,
587 - 'dashicons dashicons-download',
588 - fs_text( 'cancel-trial-confirm', $slug ),
589 - 'POST'
590 - );
591 - } else {
592 - $premium_license = $fs_addon->_get_available_premium_license();
593 -
594 - if ( is_object( $premium_license ) ) {
595 - $site = $fs_addon->get_site();
596 -
597 - $buttons[] = fs_ui_get_action_button(
598 - $slug,
599 - 'account',
600 - 'activate_license',
601 - sprintf( fs_text( 'activate-x-plan', $slug ), $fs_addon->get_plan_title(), ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ),
602 - array(
603 - 'plugin_id' => $addon_id,
604 - 'license_id' => $premium_license->id,
605 - )
606 - );
607 - }
608 - }
609 -
610 - if ( 0 == count( $buttons ) ) {
611 - // Add sync license only if non of the other CTAs are visible.
612 - $buttons[] = fs_ui_get_action_button(
613 - $slug,
614 - 'account',
615 - $slug . '_sync_license',
616 - fs_text( 'sync-license', $slug ),
617 - array( 'plugin_id' => $addon_id ),
618 - false
619 - );
620 -
621 - }
622 - } else if ( ! $show_upgrade ) {
623 - if ( $fs->is_addon_installed( $addon->slug ) ) {
624 - $addon_file = $fs->get_addon_basename( $addon->slug );
625 - $buttons[] = sprintf(
626 - '<a class="button button-primary edit" href="%s" title="%s">%s</a>',
627 - wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ),
628 - fs_esc_attr( 'activate-this-addon', $slug ),
629 - fs_text( 'activate', $slug )
630 - );
631 - } else {
632 - if ( $fs->is_allowed_to_install() ) {
633 - $buttons[] = sprintf(
634 - '<a class="button button-primary edit" href="%s">%s</a>',
635 - wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ),
636 - fs_text( 'install-now', $slug )
637 - );
638 - } else {
639 - $buttons[] = sprintf(
640 - '<a target="_blank" class="button button-primary edit" href="%s">%s</a>',
641 - $fs->_get_latest_download_local_url( $addon_id ),
642 - fs_text( 'download-latest', $slug )
643 - );
644 - }
645 - }
646 - }
647 -
648 - if ( $show_upgrade ) {
649 - $buttons[] = sprintf( '<a href="%s" class="thickbox button button-primary" aria-label="%s" data-title="%s"><i class="dashicons dashicons-cart"></i> %s</a>',
650 - esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
651 - '&TB_iframe=true&width=600&height=550' ) ),
652 - esc_attr( sprintf( fs_text( 'more-information-about-x', $slug ), $addon->title ) ),
653 - esc_attr( $addon->title ),
654 - fs_text( ( $fs_addon->has_free_plan() ? 'upgrade' : 'purchase' ), $slug )
655 - );
656 - }
657 -
658 - $buttons_count = count( $buttons );
659 - ?>
660 -
661 - <td>
662 - <!-- Actions -->
663 - <?php if ($buttons_count > 1) : ?>
664 - <div class="button-group">
665 - <?php endif ?>
666 - <?php foreach ( $buttons as $button ) : ?>
667 - <?php echo $button ?>
668 - <?php endforeach ?>
669 - <?php if ($buttons_count > 1) : ?>
670 - </div>
671 - <?php endif ?>
672 - </td>
673 - <?php else : ?>
674 - <?php // Add-on NOT Installed or was never connected.
675 - ?>
676 - <td colspan="4">
677 - <!-- Action -->
678 - <?php if ( $fs->is_addon_installed( $addon->slug ) ) : ?>
679 - <?php $addon_file = $fs->get_addon_basename( $addon->slug ) ?>
680 - <a class="button button-primary"
681 - href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
682 - title="<?php fs_esc_attr_echo( 'activate-this-addon', $slug ) ?>"
683 - class="edit"><?php fs_esc_html_echo( 'activate', $slug ) ?></a>
684 - <?php else : ?>
685 - <?php if ( $fs->is_allowed_to_install() ) : ?>
686 - <a class="button button-primary"
687 - 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( 'install-now', $slug ) ?></a>
688 - <?php else : ?>
689 - <a target="_blank" class="button button-primary"
690 - href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php fs_esc_html_echo( 'download-latest', $slug ) ?></a>
691 - <?php endif ?>
692 - <?php endif ?>
693 - </td>
694 - <?php endif ?>
695 - <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
696 - <td>
697 - <!-- Optional Delete Action -->
698 - <?php
699 - if ( $is_addon_activated ) {
700 - fs_ui_action_button(
701 - $slug, 'account',
702 - 'delete_account',
703 - fs_text( 'delete', $slug ),
704 - array( 'plugin_id' => $addon_id ),
705 - false
706 - );
707 - }
708 - ?>
709 - </td>
710 - <?php endif ?>
711 - </tr>
712 - <?php $odd = ! $odd;
713 - endforeach ?>
714 - </tbody>
715 - </table>
716 - </div>
717 - </div>
718 - <?php endif ?>
719 -
720 - <?php $fs->do_action( 'after_account_details' ) ?>
721 - </div>
722 - </div>
723 - </div>
724 - </div>
725 - </div>
726 -<?php
727 - $params = array(
728 - 'page' => 'account',
729 - 'module_id' => $fs->get_id(),
730 - 'module_slug' => $slug,
731 - 'module_version' => $fs->get_plugin_version(),
732 - );
733 - fs_require_template( 'powered-by.php', $params );
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->has_release_on_freemius() ?
25 + $fs->get_update( false, false ) :
26 + null;
27 +
28 + if ( is_object($update) ) {
29 + /**
30 + * This logic is particularly required for multisite environment.
31 + * If a module is site activated (not network) and not on the main site,
32 + * the module will NOT be executed on the network level, therefore, the
33 + * custom updates logic will not be executed as well, so unless we force
34 + * the injection of the update into the updates transient, premium updates
35 + * will not work.
36 + *
37 + * @author Vova Feldman (@svovaf)
38 + * @since 2.0.0
39 + */
40 + $updater = FS_Plugin_Updater::instance( $fs );
41 + $updater->set_update_data( $update );
42 + }
43 +
44 + $is_paying = $fs->is_paying();
45 + $user = $fs->get_user();
46 + $site = $fs->get_site();
47 + $name = $user->get_name();
48 + $license = $fs->_get_license();
49 + $is_license_foreign = ( is_object( $license ) && $user->id != $license->user_id );
50 + $is_data_debug_mode = $fs->is_data_debug_mode();
51 + $is_whitelabeled = $fs->is_whitelabeled();
52 + $subscription = ( is_object( $license ) ?
53 + $fs->_get_subscription( $license->id ) :
54 + null );
55 + $plan = $fs->get_plan();
56 + $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
57 + $is_paid_trial = $fs->is_paid_trial();
58 + $has_paid_plan = $fs->apply_filters( 'has_paid_plan_account', $fs->has_paid_plan() );
59 + $show_upgrade = ( ! $is_whitelabeled && $has_paid_plan && ! $is_paying && ! $is_paid_trial );
60 + $trial_plan = $fs->get_trial_plan();
61 +
62 + $is_plan_change_supported = (
63 + ! $fs->is_single_plan() &&
64 + ! $fs->apply_filters( 'hide_plan_change', false )
65 + );
66 +
67 + if ( $has_paid_plan ) {
68 + $fs->_add_license_activation_dialog_box();
69 + }
70 +
71 + if ( $fs->should_handle_user_change() ) {
72 + $fs->_add_email_address_update_dialog_box();
73 + }
74 +
75 + $ids_of_installs_activated_with_foreign_licenses = $fs->should_handle_user_change() ?
76 + $fs->get_installs_ids_with_foreign_licenses() :
77 + array();
78 +
79 + if ( ! empty( $ids_of_installs_activated_with_foreign_licenses ) ) {
80 + $fs->_add_user_change_dialog_box( $ids_of_installs_activated_with_foreign_licenses );
81 + }
82 +
83 + if ( $fs->is_whitelabeled( true ) || $fs->is_data_debug_mode() ) {
84 + $fs->_add_data_debug_mode_dialog_box();
85 + }
86 +
87 + if ( fs_request_get_bool( 'auto_install' ) ) {
88 + $fs->_add_auto_installation_dialog_box();
89 + }
90 +
91 + if ( fs_request_get_bool( 'activate_license' ) ) {
92 + // Open the license activation dialog box on the account page.
93 + add_action( 'admin_footer', array(
94 + &$fs,
95 + '_open_license_activation_dialog_box'
96 + ) );
97 + }
98 +
99 + $show_billing = ( ! $is_whitelabeled && ! $fs->apply_filters( 'hide_billing_and_payments_info', false ) );
100 + if ( $show_billing ) {
101 + $payments = $fs->_fetch_payments();
102 +
103 + $show_billing = ( is_array( $payments ) && 0 < count( $payments ) );
104 + }
105 +
106 +
107 + $has_tabs = $fs->_add_tabs_before_content();
108 +
109 + // Aliases.
110 + $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
111 + $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
112 + $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
113 + /* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */
114 + $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 );
115 + $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 );
116 + $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 );
117 + $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 );
118 + $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 );
119 + /* translators: %s: Plan title (e.g. "Professional") */
120 + $activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug );
121 + $version_text = fs_text_x_inline( 'Version', 'product version', 'version', $slug );
122 + /* translators: %s: Time period (e.g. Auto renews in "2 months") */
123 + $renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug );
124 + /* translators: %s: Time period (e.g. Expires in "2 months") */
125 + $expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug );
126 + $sync_license_text = fs_text_x_inline( 'Sync License', 'as synchronize license', 'sync-license', $slug );
127 + $cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug );
128 + $change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug );
129 + $upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug );
130 + $addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug );
131 + $downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug );
132 + $trial_text = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug );
133 + $free_text = fs_text_inline( 'Free', 'free', $slug );
134 + $activate_text = fs_text_inline( 'Activate', 'activate', $slug );
135 + $plan_text = fs_text_x_inline( 'Plan', 'as product pricing plan', 'plan', $slug );
136 + $bundle_plan_text = fs_text_inline( 'Bundle Plan', 'bundle-plan', $slug );
137 +
138 + $show_plan_row = true;
139 + $show_license_row = is_object( $license );
140 +
141 + $site_view_params = array();
142 +
143 + if ( fs_is_network_admin() ) {
144 + $sites = Freemius::get_sites();
145 + $all_installs_plan_id = null;
146 + $all_installs_license_id = ( $show_license_row ? $license->id : null );
147 + foreach ( $sites as $s ) {
148 + $site_info = $fs->get_site_info( $s );
149 + $install = $fs->get_install_by_blog_id( $site_info['blog_id'] );
150 + $view_params = array(
151 + 'freemius' => $fs,
152 + 'user' => $fs->get_user(),
153 + 'license' => $license,
154 + 'site' => $site_info,
155 + 'install' => $install,
156 + );
157 +
158 + $site_view_params[] = $view_params;
159 +
160 + if ( empty( $install ) ) {
161 + continue;
162 + }
163 +
164 + if ( $show_plan_row ) {
165 + if ( is_null( $all_installs_plan_id ) ) {
166 + $all_installs_plan_id = $install->plan_id;
167 + } else if ( $all_installs_plan_id != $install->plan_id ) {
168 + $show_plan_row = false;
169 + }
170 + }
171 +
172 + if ( $show_license_row && $all_installs_license_id != $install->license_id ) {
173 + $show_license_row = false;
174 + }
175 + }
176 + }
177 +
178 + $has_bundle_license = false;
179 +
180 + if ( is_object( $license ) &&
181 + FS_Plugin_License::is_valid_id( $license->parent_license_id )
182 + ) {
183 + // Context license has a parent license, therefore, the account has a bundle license.
184 + $has_bundle_license = true;
185 + }
186 +
187 + $bundle_subscription = null;
188 + $is_bundle_first_payment_pending = false;
189 +
190 + if (
191 + $show_plan_row &&
192 + is_object( $license ) &&
193 + $has_bundle_license
194 + ) {
195 + $bundle_plan_title = strtoupper( $license->parent_plan_title );
196 + $bundle_subscription = $fs->_get_subscription( $license->parent_license_id );
197 + $is_bundle_first_payment_pending = $license->is_first_payment_pending();
198 + }
199 +
200 + $fs_blog_id = ( is_multisite() && ! is_network_admin() ) ?
201 + get_current_blog_id() :
202 + 0;
203 +
204 + $active_plugins_directories_map = Freemius::get_active_plugins_directories_map( $fs_blog_id );
205 +
206 + $is_premium = $fs->is_premium();
207 +
208 + $account_addons = $fs->get_updated_account_addons();
209 + $installed_addons = $fs->get_installed_addons();
210 + $installed_addons_ids = array();
211 +
212 + /**
213 + * Store the installed add-ons' IDs into a collection which will be used in determining the add-ons to show on the "Account" page, and at the same time try to find an add-on that is activated with a bundle license if the core product is not.
214 + *
215 + * @author Leo Fajardo
216 + *
217 + * @since 2.4.0
218 + */
219 + foreach ( $installed_addons as $fs_addon ) {
220 + $installed_addons_ids[] = $fs_addon->get_id();
221 +
222 + if ( $has_bundle_license ) {
223 + // We already have the context bundle license details, skip.
224 + continue;
225 + }
226 +
227 + if (
228 + $show_plan_row &&
229 + $fs_addon->has_active_valid_license()
230 + ) {
231 + $addon_license = $fs_addon->_get_license();
232 +
233 + if ( FS_Plugin_License::is_valid_id( $addon_license->parent_license_id ) ) {
234 + // Add-on's license is associated with a parent/bundle license.
235 + $has_bundle_license = true;
236 +
237 + $bundle_plan_title = strtoupper( $addon_license->parent_plan_title );
238 + $bundle_subscription = $fs_addon->_get_subscription( $addon_license->parent_license_id );
239 + $is_bundle_first_payment_pending = $addon_license->is_first_payment_pending();
240 + }
241 + }
242 + }
243 +
244 + $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
245 +
246 + $is_active_bundle_subscription = ( is_object( $bundle_subscription ) && $bundle_subscription->is_active() );
247 +
248 + $available_license = ( $fs->is_free_plan() && ! fs_is_network_admin() ) ?
249 + $fs->_get_available_premium_license( $site->is_localhost() ) :
250 + null;
251 +
252 + $available_license_paid_plan = is_object( $available_license ) ?
253 + $fs->_get_plan_by_id( $available_license->plan_id ) :
254 + null;
255 +?>
256 + <div class="wrap fs-section">
257 + <?php if ( ! $has_tabs && ! $fs->apply_filters( 'hide_account_tabs', false ) ) : ?>
258 + <h2 class="nav-tab-wrapper">
259 + <a href="<?php echo esc_url( $fs->get_account_url() ) ?>"
260 + class="nav-tab nav-tab-active"><?php fs_esc_html_echo_inline( 'Account', 'account', $slug ) ?></a>
261 + <?php if ( $fs->has_addons() ) : ?>
262 + <a href="<?php echo esc_url( $fs->_get_admin_page_url( 'addons' ) ) ?>"
263 + class="nav-tab"><?php echo esc_html( $addons_text ) ?></a>
264 + <?php endif ?>
265 + <?php if ( $show_upgrade ) : ?>
266 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>" class="nav-tab"><?php echo esc_html( $upgrade_text ) ?></a>
267 + <?php if ( $fs->apply_filters( 'show_trial', true ) && ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
268 + <a href="<?php echo esc_url( $fs->get_trial_url() ) ?>" class="nav-tab"><?php fs_esc_html_echo_inline( 'Free Trial', 'free-trial', $slug ) ?></a>
269 + <?php endif ?>
270 + <?php endif ?>
271 + </h2>
272 + <?php endif ?>
273 +
274 + <div id="poststuff">
275 + <div id="fs_account">
276 + <div class="has-sidebar has-right-sidebar">
277 + <div class="has-sidebar-content">
278 + <div class="postbox">
279 + <h3><span class="dashicons dashicons-businessman"></span> <?php fs_esc_html_echo_inline( 'Account Details', 'account-details', $slug ) ?></h3>
280 + <div class="fs-header-actions">
281 + <ul>
282 + <?php if ( $fs->is_whitelabeled( true ) ) : ?>
283 + <li>
284 + <a href="#" class="debug-license-trigger"><i class="dashicons dashicons-<?php echo $is_whitelabeled ? 'editor-code' : 'controls-pause' ?>"></i> <span><?php
285 + if ( $is_whitelabeled ) {
286 + fs_esc_html_echo_inline( 'Start Debug', 'start-debug-license', $slug );
287 + } else {
288 + fs_esc_html_echo_inline( 'Stop Debug', 'stop-debug-license', $slug );
289 + }
290 + ?></span></a>
291 + </li>
292 + <li>&nbsp;&bull;&nbsp;</li>
293 + <?php endif ?>
294 + <?php if ( $show_billing ) : ?>
295 + <li><a href="#fs_billing"><i class="dashicons dashicons-portfolio"></i> <?php fs_esc_html_echo_inline( 'Billing & Invoices', 'billing-invoices', $slug ) ?></a></li>
296 + <li>&nbsp;&bull;&nbsp;</li>
297 + <?php endif ?>
298 + <?php if ( ! $is_whitelabeled ) : ?>
299 + <?php if ( ! $is_paying ) : ?>
300 + <li>
301 + <?php
302 + $view_params = array(
303 + 'freemius' => $fs,
304 + 'license' => $available_license,
305 + 'license_paid_plan' => $available_license_paid_plan,
306 + );
307 + fs_require_template( 'account/partials/disconnect-button.php', $view_params ); ?>
308 + </li>
309 + <li>&nbsp;&bull;&nbsp;</li>
310 + <?php endif ?>
311 + <?php if ( $is_paying ) : ?>
312 + <?php if ( ! fs_is_network_admin() ) : ?>
313 + <li>
314 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
315 + <input type="hidden" name="fs_action" value="deactivate_license">
316 + <?php wp_nonce_field( 'deactivate_license' ) ?>
317 + <a href="#" class="fs-deactivate-license"><i
318 + class="dashicons dashicons-admin-network"></i> <?php fs_echo_inline( 'Deactivate License', 'deactivate-license', $slug ) ?>
319 + </a>
320 + </form>
321 + </li>
322 + <li>&nbsp;&bull;&nbsp;</li>
323 + <?php endif ?>
324 + <?php if ( ! $license->is_lifetime() &&
325 + $is_active_subscription
326 + ) : ?>
327 + <li>
328 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
329 + <input type="hidden" name="fs_action" value="downgrade_account">
330 + <?php wp_nonce_field( 'downgrade_account' ) ?>
331 + <a href="#"
332 + onclick="if ( confirm('<?php echo esc_attr( sprintf(
333 + $downgrade_x_confirm_text,
334 + ( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
335 + $plan->title,
336 + human_time_diff( time(), strtotime( $license->expiration ) )
337 + ) ) ?> <?php if ( ! $license->is_block_features ) {
338 + echo esc_attr( sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) );
339 + } else {
340 + echo esc_attr( sprintf( $after_downgrade_blocking_text, $plan->title ) );
341 + }?> <?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>
342 + </form>
343 + </li>
344 + <li>&nbsp;&bull;&nbsp;</li>
345 + <?php endif ?>
346 + <?php if ( $is_plan_change_supported ) : ?>
347 + <li>
348 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>"><i
349 + class="dashicons dashicons-grid-view"></i> <?php echo esc_html( $change_plan_text ) ?></a>
350 + </li>
351 + <li>&nbsp;&bull;&nbsp;</li>
352 + <?php endif ?>
353 + <?php elseif ( $is_paid_trial ) : ?>
354 + <li>
355 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
356 + <input type="hidden" name="fs_action" value="cancel_trial">
357 + <?php wp_nonce_field( 'cancel_trial' ) ?>
358 + <a href="#" class="fs-cancel-trial"><i
359 + class="dashicons dashicons-download"></i> <?php echo esc_html( $cancel_trial_text ) ?></a>
360 + </form>
361 + </li>
362 + <li>&nbsp;&bull;&nbsp;</li>
363 + <?php endif ?>
364 + <?php endif ?>
365 + <li>
366 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
367 + <input type="hidden" name="fs_action" value="<?php echo esc_attr( $fs->get_unique_affix() ) ?>_sync_license">
368 + <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
369 + <a href="#" onclick="this.parentNode.submit(); return false;"><i
370 + class="dashicons dashicons-image-rotate"></i> <?php fs_esc_html_echo_x_inline( 'Sync', 'as synchronize', 'sync', $slug ) ?></a>
371 + </form>
372 + </li>
373 + </ul>
374 + </div>
375 + <div class="inside">
376 + <table id="fs_account_details" cellspacing="0" class="fs-key-value-table">
377 + <?php
378 + $hide_license_key = ( ! $show_license_row || $fs->apply_filters( 'hide_license_key', false ) );
379 +
380 + $profile = array();
381 +
382 + if ( ! $is_whitelabeled ) {
383 + $profile[] = array(
384 + 'id' => 'user_name',
385 + 'title' => fs_text_inline( 'Name', 'name', $slug ),
386 + 'value' => $name
387 + );
388 + // if (isset($user->email) && false !== strpos($user->email, '@'))
389 + $profile[] = array(
390 + 'id' => 'email',
391 + 'title' => fs_text_inline( 'Email', 'email', $slug ),
392 + 'value' => $user->email
393 + );
394 +
395 + if ( is_numeric( $user->id ) ) {
396 + $profile[] = array(
397 + 'id' => 'user_id',
398 + 'title' => fs_text_inline( 'User ID', 'user-id', $slug ),
399 + 'value' => $user->id
400 + );
401 + }
402 + }
403 +
404 + $profile[] = array(
405 + 'id' => 'product',
406 + 'title' => ( $fs->is_plugin() ?
407 + fs_text_inline( 'Plugin', 'plugin', $slug ) :
408 + fs_text_inline( 'Theme', 'theme', $slug ) ),
409 + 'value' => $fs->get_plugin_title()
410 + );
411 +
412 + $profile[] = array(
413 + 'id' => 'product_id',
414 + 'title' => ( $fs->is_plugin() ?
415 + fs_text_inline( 'Plugin', 'plugin', $slug ) :
416 + fs_text_inline( 'Theme', 'theme', $slug ) ) . ' ' . fs_text_inline( 'ID', 'id', $slug ),
417 + 'value' => $fs->get_id()
418 + );
419 +
420 + if ( ! fs_is_network_admin()) {
421 + $profile[] = array(
422 + 'id' => 'site_id',
423 + 'title' => fs_text_inline( 'Site ID', 'site-id', $slug ),
424 + 'value' => is_string( $site->id ) ?
425 + $site->id :
426 + fs_text_inline( 'No ID', 'no-id', $slug )
427 + );
428 +
429 + $profile[] = array(
430 + 'id' => 'site_public_key',
431 + 'title' => fs_text_inline( 'Public Key', 'public-key', $slug ),
432 + 'value' => $site->public_key
433 + );
434 +
435 + $profile[] = array(
436 + 'id' => 'site_secret_key',
437 + 'title' => fs_text_inline( 'Secret Key', 'secret-key', $slug ),
438 + 'value' => ( ( is_string( $site->secret_key ) ) ?
439 + $site->secret_key :
440 + fs_text_x_inline( 'No Secret', 'as secret encryption key missing', 'no-secret', $slug )
441 + )
442 + );
443 + }
444 +
445 + $profile[] = array(
446 + 'id' => 'version',
447 + 'title' => $version_text,
448 + 'value' => $fs->get_plugin_version()
449 + );
450 +
451 + if ( ! fs_is_network_admin() && $is_premium ) {
452 + $profile[] = array(
453 + 'id' => 'beta_program',
454 + 'title' => '',
455 + 'value' => $site->is_beta
456 + );
457 + }
458 +
459 + if ( $has_paid_plan || $has_bundle_license ) {
460 + if ( $fs->is_trial() ) {
461 + if ( $show_plan_row ) {
462 + $profile[] = array(
463 + 'id' => 'plan',
464 + 'title' => $plan_text,
465 + 'value' => ( is_string( $trial_plan->name ) ?
466 + strtoupper( $trial_plan->title ) :
467 + fs_text_inline( 'Trial', 'trial', $slug ) )
468 + );
469 + }
470 + } else {
471 + if ( $show_plan_row ) {
472 + $profile[] = array(
473 + 'id' => 'plan',
474 + 'title' => ( $has_bundle_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text,
475 + 'value' => strtoupper( is_string( $plan->name ) ?
476 + $plan->title :
477 + strtoupper( $free_text )
478 + )
479 + );
480 +
481 + if ( $has_bundle_license ) {
482 + $profile[] = array(
483 + 'id' => 'bundle_plan',
484 + 'title' => $bundle_plan_text,
485 + 'value' => $bundle_plan_title
486 + );
487 + }
488 + }
489 +
490 + if ( is_object( $license ) ) {
491 + if ( ! $hide_license_key ) {
492 + $profile[] = array(
493 + 'id' => 'license_key',
494 + 'title' => fs_text_inline( 'License Key', $slug ),
495 + 'value' => $license->secret_key,
496 + );
497 + }
498 + }
499 + }
500 + }
501 + ?>
502 + <?php $odd = true;
503 + foreach ( $profile as $p ) : ?>
504 + <?php
505 + if ( 'plan' === $p['id'] && ! $has_paid_plan ) {
506 + // If plugin don't have any paid plans, there's no reason
507 + // to show current plan.
508 + continue;
509 + }
510 + ?>
511 + <tr class="fs-field-<?php echo esc_attr( $p['id'] ) ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
512 + <td>
513 + <nobr><?php echo esc_html( $p['title'] ) ?><?php echo ( ! empty( $p['title'] ) ) ? ':' : '' ?></nobr>
514 + </td>
515 + <td<?php if ( 'plan' === $p['id'] || 'bundle_plan' === $p['id'] ) { echo ' colspan="2"'; }?>>
516 + <?php if ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
517 + <code><?php echo FS_Plugin_License::mask_secret_key_for_html( $p['value'] ) ?></code>
518 + <?php if ( ! $is_whitelabeled ) : ?>
519 + <input type="text" value="<?php echo htmlspecialchars( $p['value'] ) ?>" style="display: none"
520 + readonly/>
521 + <?php endif ?>
522 + <?php elseif ( 'beta_program' === $p['id'] ) : ?>
523 + <label>
524 + <input type="checkbox" class="fs-toggle-beta-mode" <?php checked( true, $p['value'] ) ?>/><span><?php
525 + fs_esc_html_echo_inline( 'Join the Beta program', 'join-beta', $slug )
526 + ?></span></label>
527 + <?php else : ?>
528 + <code><?php echo htmlspecialchars( $p['value'] ) ?></code>
529 + <?php endif ?>
530 + <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
531 + <label class="fs-tag fs-warn"><?php fs_esc_html_echo_inline( 'not verified', 'not-verified', $slug ) ?></label>
532 + <?php endif ?>
533 + <?php if ( 'plan' === $p['id'] ) : ?>
534 + <?php if ( $fs->is_trial() ) : ?>
535 + <label class="fs-tag fs-success"><?php echo esc_html( $trial_text ) ?></label>
536 + <?php endif ?>
537 + <?php if ( is_object( $license ) && ! $license->is_lifetime() ) : ?>
538 + <?php if ( ! $is_active_subscription && ! $is_active_bundle_subscription && ! $license->is_first_payment_pending() ) : ?>
539 + <?php $is_license_expired = $license->is_expired() ?>
540 + <?php $expired_ago_text = ( fs_text_inline( 'Expired', 'expired', $slug ) . ' ' . fs_text_x_inline( '%s ago', 'x-ago', $slug ) ) ?>
541 + <label
542 + class="fs-tag <?php echo $is_license_expired ? 'fs-error' : 'fs-warn' ?>"><?php
543 + echo esc_html( sprintf( $is_license_expired ? $expired_ago_text : $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ) )
544 + ?></label>
545 + <?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?>
546 + <label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ) ?></label>
547 + <?php endif ?>
548 + <?php elseif ( $fs->is_trial() ) : ?>
549 + <label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ) ?></label>
550 + <?php endif ?>
551 + <?php if ( ! $is_whitelabeled ) : ?>
552 + <div class="button-group">
553 + <?php if ( is_object( $available_license ) ) : ?>
554 + <?php
555 + $view_params = array(
556 + 'freemius' => $fs,
557 + 'slug' => $slug,
558 + 'license' => $available_license,
559 + 'plan' => $available_license_paid_plan,
560 + 'is_localhost' => $site->is_localhost(),
561 + 'install_id' => $site->id,
562 + 'class' => 'button-primary',
563 + );
564 + fs_require_template( 'account/partials/activate-license-button.php', $view_params ); ?>
565 + <?php else : ?>
566 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>"
567 + method="POST" class="button-group">
568 + <?php if ( $show_upgrade && $is_premium ) : ?>
569 + <a class="button activate-license-trigger <?php echo esc_attr( $fs->get_unique_affix() ) ?>" href="#"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a>
570 + <?php endif ?>
571 + <input type="submit" class="button"
572 + value="<?php echo esc_attr( $sync_license_text ) ?>">
573 + <input type="hidden" name="fs_action"
574 + value="<?php echo esc_attr( $fs->get_unique_affix() ) ?>_sync_license">
575 + <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
576 + <?php if ( $show_upgrade || $is_plan_change_supported ) : ?>
577 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>"
578 + class="button<?php
579 + echo $show_upgrade ?
580 + ' button-primary fs-upgrade' :
581 + ' fs-change-plan'; ?> button-upgrade"><i
582 + class="dashicons dashicons-cart"></i> <?php echo esc_html( $show_upgrade ? $upgrade_text : $change_plan_text ) ?></a>
583 + <?php endif ?>
584 + </form>
585 + <?php endif ?>
586 + </div>
587 + <?php endif ?>
588 + <?php elseif ( 'bundle_plan' === $p['id'] ) : ?>
589 + <?php if ( is_object( $bundle_subscription ) ) : ?>
590 + <?php if ( $is_active_bundle_subscription && ! $is_bundle_first_payment_pending ) : ?>
591 + <label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $bundle_subscription->next_payment ) ) ) ) ?></label>
592 + <?php endif ?>
593 + <?php endif ?>
594 + <?php elseif ( 'version' === $p['id'] && $has_paid_plan ) : ?>
595 + <?php if ( $fs->has_premium_version() ) : ?>
596 + <?php if ( $is_premium ) : ?>
597 + <label
598 + 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>
599 + <?php elseif ( $fs->can_use_premium_code() ) : ?>
600 + <label class="fs-tag fs-warn"><?php fs_esc_html_echo_inline( 'Free version', 'free-version', $slug ) ?></label>
601 + <?php endif ?>
602 + <?php endif ?>
603 + <?php endif ?>
604 + </td>
605 + <?php if ( 'plan' !== $p['id'] && 'bundle_plan' !== $p['id'] ) : ?>
606 + <td class="fs-right">
607 + <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
608 + <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
609 + <input type="hidden" name="fs_action" value="verify_email">
610 + <?php wp_nonce_field( 'verify_email' ) ?>
611 + <input type="submit" class="button button-small"
612 + value="<?php fs_esc_attr_echo_inline( 'Verify Email', 'verify-email', $slug ) ?>">
613 + </form>
614 + <?php endif ?>
615 + <?php if ( 'version' === $p['id'] ) : ?>
616 + <?php if ( $fs->has_release_on_freemius() ) : ?>
617 + <div class="button-group">
618 + <?php if ( $is_paying || $fs->is_trial() ) : ?>
619 + <?php if ( ! $fs->is_allowed_to_install() ) : ?>
620 + <a target="_blank" rel="noopener" class="button button-primary"
621 + href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php
622 + $download_version_text_suffix = ( is_object( $update ) ? ' [' . $update->version . ']' : '' );
623 +
624 + $download_version_text = sprintf(
625 + /* translators: %s: plan name (e.g. Download "Professional" Version) */
626 + fs_text_inline( 'Download %s Version', 'download-x-version', $slug ),
627 + ( $fs->is_trial() ? $trial_plan->title : $plan->title )
628 + ) .
629 + $download_version_text_suffix;
630 +
631 + $download_version_text_length = function_exists( 'mb_strlen' ) ?
632 + mb_strlen( $download_version_text ) :
633 + strlen( $download_version_text );
634 +
635 + if ( $download_version_text_length > 31 ) {
636 + /**
637 + * Try to limit the number of characters to 31 for now.
638 + *
639 + * @author Leo Fajardo (@leorw)
640 + * @aince 2.3.2
641 + */
642 + $download_version_text = fs_text_inline( 'Download Paid Version', 'download-paid-version', $slug ) . $download_version_text_suffix;
643 + }
644 +
645 + echo $download_version_text;
646 + ?></a>
647 + <?php elseif ( is_object( $update ) ) : ?>
648 + <?php
649 + $module_type = $fs->get_module_type();
650 + ?>
651 + <a class="button button-primary"
652 + 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>
653 + <?php endif ?>
654 + <?php endif; ?>
655 + </div>
656 + <?php endif ?>
657 + <?php
658 + elseif ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
659 + <?php if ( ! $is_whitelabeled && ( 'site_secret_key' === $p['id'] || ! $is_license_foreign ) ) : ?>
660 + <button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button>
661 + <?php endif ?>
662 + <?php if ('license_key' === $p['id']) : ?>
663 + <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>
664 + <?php endif ?>
665 + <?php
666 + elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/
667 + ( is_string( $user->secret_key ) && in_array( $p['id'], array(
668 + 'email',
669 + 'user_name'
670 + ) ) )
671 + ) : ?>
672 + <?php if ( 'email' !== $p['id'] || ! fs_is_network_admin() ) : ?>
673 + <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
674 + onsubmit="var val = prompt('<?php echo esc_attr( sprintf(
675 + /* translators: %s: User's account property (e.g. name, email) */
676 + fs_text_inline( 'What is your %s?', 'what-is-your-x', $slug ),
677 + $p['title']
678 + ) ) ?>', '<?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;">
679 + <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
680 + <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $fs->get_unique_affix() ?>"
681 + value="">
682 + <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
683 + <input type="submit" class="button button-small <?php if ( 'email' === $p['id'] ) echo 'button-edit-email-address' ?>"
684 + value="<?php echo fs_esc_attr_x_inline( 'Edit', 'verb', 'edit', $slug ) ?>">
685 + </form>
686 + <?php endif ?>
687 + <?php elseif ( 'user_id' === $p['id'] && ! empty( $ids_of_installs_activated_with_foreign_licenses ) ) : ?>
688 + <input id="fs_change_user" type="submit" class="button button-small"
689 + value="<?php echo fs_esc_attr_inline( 'Change User', 'change-user', $slug ) ?>">
690 + <?php endif ?>
691 + </td>
692 + <?php endif ?>
693 + </tr>
694 + <?php
695 + if ( 'version' === $p['id'] && $is_premium ) {
696 + /**
697 + * If there's a row for the beta program, keep its background color
698 + * the same as the version info row.
699 + *
700 + * @author Leo Fajardo (@leorw)
701 + * @since 2.3.0
702 + */
703 + continue;
704 + }
705 +
706 + $odd = ! $odd;
707 + endforeach ?>
708 + </table>
709 + </div>
710 + </div>
711 + <?php if ( fs_is_network_admin() ) : ?>
712 + <div id="fs_sites" class="postbox">
713 + <h3><span class="dashicons dashicons-networking"></span> <?php fs_esc_html_echo_inline( 'Sites', 'sites', $slug ) ?></h3>
714 + <div class="fs-header-actions">
715 + <?php if ( ! $is_whitelabeled ) : ?>
716 + <?php $has_license = is_object( $license ) ?>
717 + <?php if ( $has_license || ( $show_upgrade && $is_premium ) ) : ?>
718 + <?php
719 + $activate_license_button_text = $has_license ?
720 + fs_esc_html_inline( 'Change License', 'change-license', $slug ) :
721 + fs_esc_html_inline( 'Activate License', 'activate-license', $slug );
722 + ?>
723 + <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>
724 + <?php endif ?>
725 + <?php endif ?>
726 + <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>
727 + </div>
728 + <div class="inside">
729 + <div id="" class="fs-scrollable-table">
730 + <div class="fs-table-head">
731 + <table class="widefat">
732 + <thead>
733 + <tr>
734 + <td><?php fs_esc_html_echo_inline('ID', 'id', $slug) ?></td>
735 + <td><?php fs_esc_html_echo_inline('Address', 'address', $slug) ?></td>
736 + <td><?php fs_esc_html_echo_inline('License', 'license', $slug) ?></td>
737 + <td><?php fs_esc_html_echo_inline('Plan', 'plan', $slug) ?></td>
738 + <td></td>
739 + </tr>
740 + </thead>
741 + </table>
742 + </div>
743 + <div class="fs-table-body">
744 + <table class="widefat">
745 + <?php
746 + $current_blog_id = get_current_blog_id();
747 +
748 + foreach ( $site_view_params as $view_params ) {
749 + fs_require_template(
750 + 'account/partials/site.php',
751 + $view_params
752 + );
753 + }
754 +
755 + /**
756 + * It's possible for the `Freemius::switch_to_blog()` method to be called within the `site.php` template and this changes the Freemius instance's context, so this check is for restoring the previous context based on the previously retrieved site.
757 + *
758 + * @author Leo Fajardo (@leorw)
759 + * @since 2.5.0
760 + */
761 + $current_install = $fs->get_site();
762 +
763 + if (
764 + is_object( $site ) &&
765 + ( ! is_object( $current_install ) || $current_install->id != $site->id )
766 + ) {
767 + $fs->switch_to_blog( $current_blog_id, $site, true );
768 + }
769 + ?>
770 + </table>
771 + </div>
772 + </div>
773 + </div>
774 + </div>
775 + <?php endif ?>
776 + <?php if ( 0 < count( $addons_to_show ) ) : ?>
777 + <!-- Add-Ons -->
778 + <div class="postbox">
779 + <div class="">
780 + <!-- <div class="inside">-->
781 + <table id="fs_addons" class="widefat">
782 + <thead>
783 + <tr>
784 + <th><h3><?php echo esc_html( $addons_text ) ?></h3></th>
785 + <th><?php fs_esc_html_echo_inline( 'ID', 'id', $slug ) ?></th>
786 + <th><?php echo esc_html( $version_text ) ?></th>
787 + <th><?php echo esc_html( $plan_text ) ?></th>
788 + <th><?php fs_esc_html_echo_x_inline( 'License', 'as software license', 'license', $slug ) ?></th>
789 + <th></th>
790 + <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
791 + <th></th>
792 + <?php endif ?>
793 + </tr>
794 + </thead>
795 + <tbody>
796 + <?php
797 + $odd = true;
798 +
799 + $installed_addons_ids_map = array_flip( $installed_addons_ids );
800 +
801 + $addon_info_by_id = array();
802 + $hide_all_addons_data = false;
803 +
804 + if ( $fs->is_whitelabeled_by_flag() ) {
805 + $hide_all_addons_data = true;
806 +
807 + foreach ( $addons_to_show as $addon_id ) {
808 + $is_addon_installed = isset( $installed_addons_ids_map[ $addon_id ] );
809 + $addon_info = $fs->_get_addon_info( $addon_id, $is_addon_installed );
810 + $is_addon_connected = $addon_info['is_connected'];
811 +
812 + $fs_addon = ( $is_addon_connected && $is_addon_installed ) ?
813 + freemius( $addon_id ) :
814 + null;
815 +
816 + $is_whitelabeled = is_object( $fs_addon ) ?
817 + $fs_addon->is_whitelabeled( true ) :
818 + $addon_info['is_whitelabeled'];
819 +
820 + if ( ! $is_whitelabeled ) {
821 + $hide_all_addons_data = false;
822 + }
823 +
824 + if ( $is_data_debug_mode ) {
825 + $is_whitelabeled = false;
826 + }
827 +
828 + $addon_info_by_id[ $addon_id ] = $addon_info;
829 + }
830 + }
831 +
832 + foreach ( $addons_to_show as $addon_id ) {
833 + $is_addon_installed = isset( $installed_addons_ids_map[ $addon_id ] );
834 +
835 + if (
836 + $hide_all_addons_data &&
837 + ! $is_addon_installed &&
838 + ! file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $fs->get_addon_basename( $addon_id ) ) )
839 + ) {
840 + continue;
841 + }
842 +
843 + $addon_view_params = array(
844 + 'parent_fs' => $fs,
845 + 'addon_id' => $addon_id,
846 + 'odd' => $odd,
847 + 'fs_blog_id' => $fs_blog_id,
848 + 'active_plugins_directories_map' => &$active_plugins_directories_map,
849 + 'is_addon_installed' => $is_addon_installed,
850 + 'addon_info' => isset( $addon_info_by_id[ $addon_id ] ) ?
851 + $addon_info_by_id[ $addon_id ] :
852 + $fs->_get_addon_info( $addon_id, $is_addon_installed ),
853 + 'is_whitelabeled' => ( $is_whitelabeled && ! $is_data_debug_mode )
854 + );
855 +
856 + fs_require_template(
857 + 'account/partials/addon.php',
858 + $addon_view_params
859 + );
860 +
861 + $odd = ! $odd;
862 + } ?>
863 + </tbody>
864 + </table>
865 + </div>
866 + </div>
867 + <?php endif ?>
868 +
869 + <?php $fs->do_action( 'after_account_details' ) ?>
870 +
871 + <?php
872 + if ( $show_billing ) {
873 + $view_params = array( 'id' => $VARS['id'], 'payments' => $payments );
874 + fs_require_once_template( 'account/billing.php', $view_params );
875 + fs_require_once_template( 'account/payments.php', $view_params );
876 + }
877 + ?>
878 + </div>
879 + </div>
880 + </div>
881 + </div>
882 + </div>
883 + <?php
884 + $subscription_cancellation_dialog_box_template_params = $fs->_get_subscription_cancellation_dialog_box_template_params( true );
885 + if ( ! empty( $subscription_cancellation_dialog_box_template_params ) ) {
886 + fs_require_template( 'forms/subscription-cancellation.php', $subscription_cancellation_dialog_box_template_params );
887 + }
888 + ?>
889 + <script type="text/javascript">
890 + (function ($) {
891 + var setLoading = function ($this, label) {
892 + // Set loading mode.
893 + $(document.body).css({'cursor': 'wait'});
894 +
895 + $this.css({'cursor': 'wait'});
896 +
897 + if ($this.is('input'))
898 + $this.val(label);
899 + else
900 + $this.html(label);
901 +
902 + setTimeout(function () {
903 + $this.attr('disabled', 'disabled');
904 + }, 200);
905 + };
906 +
907 + $('.fs-toggle-visibility').click(function () {
908 + var
909 + $this = $(this),
910 + $parent = $this.closest('tr'),
911 + $input = $parent.find('input');
912 +
913 + $parent.find('code').toggle();
914 + $input.toggle();
915 +
916 + if ($input.is(':visible')) {
917 + $this.html('<?php fs_esc_js_echo_x_inline( 'Hide', 'verb', 'hide', $slug ) ?>');
918 + setTimeout(function () {
919 + $input.select().focus();
920 + }, 100);
921 + }
922 + else {
923 + $this.html( '<?php fs_esc_js_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?>' );
924 + }
925 + });
926 +
927 + $('.fs-toggle-tracking').click(function () {
928 + setLoading(
929 + $(this),
930 + ($(this).data('is-disconnected') ?
931 + '<?php fs_esc_js_echo_inline('Opting in', 'opting-in' ) ?>' :
932 + '<?php fs_esc_js_echo_inline('Opting out', 'opting-out' ) ?>') +
933 + '...'
934 + );
935 + });
936 +
937 + <?php
938 + $plugin_title = $fs->get_plugin_title();
939 + $processing_text = fs_esc_js_inline( 'Processing', 'processing' );
940 + $confirmation_message = sprintf(
941 + '%s %s',
942 + sprintf( fs_esc_attr_inline( 'Get updates for bleeding edge Beta versions of %s.', 'get-beta-versions', $slug ), $plugin_title ),
943 + 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 )
944 + );
945 + ?>
946 +
947 + $( '.fs-toggle-beta-mode' ).click( function () {
948 + var $checkbox = $( this ),
949 + isChecked = $checkbox.is( ':checked' );
950 +
951 + if ( ! isChecked || confirm( '<?php echo $confirmation_message ?>' ) ) {
952 + $.ajax( {
953 + url : <?php echo Freemius::ajax_url() ?>,
954 + method: 'POST',
955 + data : {
956 + action : '<?php echo $fs->get_ajax_action( 'set_beta_mode' ) ?>',
957 + security : '<?php echo $fs->get_ajax_security( 'set_beta_mode' ) ?>',
958 + is_beta : isChecked,
959 + module_id: <?php echo $fs->get_id() ?>
960 + },
961 + beforeSend: function () {
962 + $checkbox.prop( 'disabled', true );
963 + $checkbox.parent().find( 'span' ).text( '<?php echo $processing_text ?>' + '...' );
964 + },
965 + complete: function () {
966 + $checkbox.prop( 'disabled', false );
967 + $checkbox.parent().find( 'span' ).text( '<?php fs_esc_js_echo_inline( 'Join the Beta Program', 'join-beta', $slug ) ?>' );
968 + }
969 + } );
970 +
971 + return true;
972 + }
973 +
974 + return false;
975 + });
976 +
977 + $('.fs-opt-in').click(function () {
978 + setLoading($(this), '<?php fs_esc_js_echo_inline('Opting in', 'opting-in' ) ?>...');
979 + });
980 +
981 + $( '#fs_downgrade' ).submit(function( event ) {
982 + event.preventDefault();
983 +
984 + setLoading( $( this ).find( '.button' ), '<?php fs_esc_js_echo_inline( 'Downgrading', 'downgrading' ) ?>...' );
985 + });
986 +
987 + $('.fs-activate-license').click(function () {
988 + setLoading($(this), '<?php fs_esc_js_echo_inline('Activating', 'activating' ) ?>...');
989 + });
990 +
991 + var $deactivateLicenseOrCancelTrial = $( '.fs-deactivate-license, .fs-cancel-trial' ),
992 + $subscriptionCancellationModal = $( '.fs-modal-subscription-cancellation-<?php echo $fs->get_id() ?>' );
993 +
994 + if ( 0 !== $subscriptionCancellationModal.length ) {
995 + $subscriptionCancellationModal.on( '<?php echo $fs->get_action_tag( 'subscription_cancellation_action' ) ?>', function( evt, cancelSubscription ) {
996 + setLoading(
997 + $deactivateLicenseOrCancelTrial,
998 + ( ! $deactivateLicenseOrCancelTrial.hasClass( 'fs-cancel-trial' ) ?
999 + '<?php fs_esc_js_echo_inline( 'Deactivating', 'deactivating', $slug ) ?>' :
1000 + '<?php echo esc_html( sprintf( fs_text_inline( 'Cancelling %s', 'cancelling-x', $slug ), fs_text_inline( 'trial', 'trial', $slug ) ) ) ?>' ) + '...'
1001 + );
1002 +
1003 + $subscriptionCancellationModal.find( '.fs-modal-footer .button' ).addClass( 'disabled' );
1004 + $deactivateLicenseOrCancelTrial.unbind( 'click' );
1005 +
1006 + if ( false === cancelSubscription || $deactivateLicenseOrCancelTrial.hasClass( 'fs-cancel-trial' ) ) {
1007 + $subscriptionCancellationModal.find( '.fs-modal-footer .button-primary' ).text( $deactivateLicenseOrCancelTrial.text() );
1008 +
1009 + $deactivateLicenseOrCancelTrial[0].parentNode.submit();
1010 + } else {
1011 + var $form = $( 'input[value="downgrade_account"],input[value="cancel_trial"]' ).parent();
1012 + $form.prepend( '<input type="hidden" name="deactivate_license" value="true" />' );
1013 +
1014 + $subscriptionCancellationModal.find( '.fs-modal-footer .button-primary' ).text( '<?php echo esc_js( sprintf(
1015 + fs_text_inline( 'Cancelling %s...', 'cancelling-x' , $slug ),
1016 + $is_paid_trial ?
1017 + fs_text_inline( 'trial', 'trial', $slug ) :
1018 + fs_text_inline( 'subscription', 'subscription', $slug )
1019 + ) ) ?>' );
1020 +
1021 + $form.submit();
1022 + }
1023 + });
1024 + }
1025 +
1026 + $deactivateLicenseOrCancelTrial.click(function() {
1027 + var $this = $( this );
1028 + if ( $this.hasClass( 'fs-cancel-trial' ) ) {
1029 + $subscriptionCancellationModal.find( '.fs-modal-panel' ).find( 'ul.subscription-actions, .fs-price-increase-warning' ).remove();
1030 + $subscriptionCancellationModal.find( '.fs-modal-panel > p' ).text( <?php echo json_encode( $cancel_trial_confirm_text ) ?> );
1031 + $subscriptionCancellationModal.trigger( 'showModal' );
1032 + } 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 ) ?>')) {
1033 + var $this = $(this);
1034 +
1035 + if ( 0 !== $subscriptionCancellationModal.length ) {
1036 + $subscriptionCancellationModal.trigger( 'showModal' );
1037 + } else {
1038 + setLoading( $this, '<?php fs_esc_js_echo_inline( 'Deactivating', 'deactivating', $slug ) ?>...' );
1039 + $this[0].parentNode.submit();
1040 + }
1041 + }
1042 +
1043 + return false;
1044 + });
1045 +
1046 + var $sitesSection = $('#fs_sites'),
1047 + $sitesTable = $sitesSection.find('.fs-scrollable-table'),
1048 + $sitesTableRows = $sitesTable.find('.fs-site-details');
1049 +
1050 + $('.fs-show-install-details').click(function(){
1051 + var installID = $(this).parents('.fs-site-details').attr('data-install-id');
1052 + $sitesSection.find('.fs-install-details[data-install-id=' + installID + ']').toggle();
1053 + });
1054 +
1055 +
1056 + var adjustColumnWidth = function($table) {
1057 + var $headerColumns = $table.find('.fs-table-head td'),
1058 + $bodyColumns = $table.find('.fs-table-body tr:first > td');
1059 +
1060 + for (var i = 0, len = $headerColumns.length; i < len; i++) {
1061 + $($headerColumns[i]).width($($bodyColumns[i]).width());
1062 + }
1063 + for (i = 0, len = $headerColumns.length; i < len; i++) {
1064 + $($bodyColumns[i]).width($($headerColumns[i]).width());
1065 + }
1066 + };
1067 +
1068 + adjustColumnWidth($sitesTable);
1069 +
1070 + $sitesSection.find('.fs-search').keyup(function(){
1071 + var search = $(this).val().trim();
1072 +
1073 + if ('' === search){
1074 + // Show all.
1075 + $sitesTableRows.show();
1076 + return;
1077 + }
1078 +
1079 + var url;
1080 +
1081 + $sitesTableRows.each(function(index){
1082 + url = $(this).find('.fs-field-url').html();
1083 +
1084 + if (-1 < url.indexOf(search)){
1085 + $(this).show();
1086 + } else {
1087 + $(this).hide();
1088 + }
1089 + });
1090 + });
1091 +
1092 + $( '.fs-toggle-whitelabel-mode' ).click( function () {
1093 + var $toggleLink = $( this );
1094 +
1095 + $.ajax( {
1096 + url : <?php echo Freemius::ajax_url() ?>,
1097 + method: 'POST',
1098 + data : {
1099 + action : '<?php echo $fs->get_ajax_action( 'toggle_whitelabel_mode' ) ?>',
1100 + security : '<?php echo $fs->get_ajax_security( 'toggle_whitelabel_mode' ) ?>',
1101 + module_id: <?php echo $fs->get_id() ?>
1102 + },
1103 + beforeSend: function () {
1104 + $toggleLink.parent().text( '<?php
1105 + $is_whitelabeled ?
1106 + fs_esc_html_echo_inline( 'Disabling white-label mode', 'disabling-whitelabel-mode' ) :
1107 + fs_esc_html_echo_inline( 'Enabling white-label mode', 'enabling-whitelabel-mode' )
1108 + ?>' + '...' );
1109 + },
1110 + complete: function () {
1111 + location.reload();
1112 + }
1113 + } );
1114 + });
1115 + })(jQuery);
1116 + </script>
1117 +<?php
1118 + if ( $has_tabs ) {
1119 + $fs->_add_tabs_after_content();
1120 + }