PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 2.0.1
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v2.0.1
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / freemius / templates / account.php
embedpress / freemius / templates Last commit date
debug 9 years ago forms 9 years ago plugin-info 9 years ago account.php 9 years ago add-ons.php 9 years ago add-trial-to-pricing.php 9 years ago admin-notice.php 9 years ago ajax-loader.php 9 years ago all-admin-notice.php 9 years ago auto-installation.php 9 years ago billing.php 9 years ago checkout-legacy.php 9 years ago checkout.php 9 years ago connect.php 9 years ago contact.php 9 years ago debug.php 9 years ago email.php 9 years ago firewall-issues-js.php 9 years ago index.php 9 years ago plugin-icon.php 9 years ago powered-by.php 9 years ago pricing.php 9 years ago sticky-admin-notice-js.php 9 years ago
account.php
733 lines
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 );