| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Freemius |
| 4 |
* @copyright Copyright (c) 2015, Freemius, Inc. |
| 5 |
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
| 6 |
* @since 1.0.3 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* @var array $VARS |
| 15 |
* @var Freemius $fs |
| 16 |
*/ |
| 17 |
$fs = freemius( $VARS['id'] ); |
| 18 |
|
| 19 |
$slug = $fs->get_slug(); |
| 20 |
|
| 21 |
/** |
| 22 |
* @var FS_Plugin_Tag $update |
| 23 |
*/ |
| 24 |
$update = $fs->get_update( false, false, WP_FS__TIME_24_HOURS_IN_SEC / 24 ); |
| 25 |
|
| 26 |
$is_paying = $fs->is_paying(); |
| 27 |
$user = $fs->get_user(); |
| 28 |
$site = $fs->get_site(); |
| 29 |
$name = $user->get_name(); |
| 30 |
$license = $fs->_get_license(); |
| 31 |
$subscription = $fs->_get_subscription(); |
| 32 |
$plan = $fs->get_plan(); |
| 33 |
$is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() ); |
| 34 |
$is_paid_trial = $fs->is_paid_trial(); |
| 35 |
$show_upgrade = ( $fs->has_paid_plan() && ! $is_paying && ! $is_paid_trial ); |
| 36 |
|
| 37 |
if ( $fs->has_paid_plan() ) { |
| 38 |
$fs->_add_license_activation_dialog_box(); |
| 39 |
} |
| 40 |
|
| 41 |
if ( fs_request_get_bool( 'auto_install' ) ) { |
| 42 |
$fs->_add_auto_installation_dialog_box(); |
| 43 |
} |
| 44 |
|
| 45 |
$has_tabs = $fs->_add_tabs_before_content(); |
| 46 |
|
| 47 |
if ( $has_tabs ) { |
| 48 |
$query_params['tabs'] = 'true'; |
| 49 |
} |
| 50 |
|
| 51 |
// Aliases. |
| 52 |
$download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug ); |
| 53 |
$downgrade_x_confirm_text = fs_text_inline( 'Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'downgrade-x-confirm', $slug ); |
| 54 |
$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 ); |
| 55 |
$after_downgrade_non_blocking_text = fs_text_inline( 'You can still enjoy all %s features but you will not have access to %s updates and support.', 'after-downgrade-non-blocking', $slug ); |
| 56 |
$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 ); |
| 57 |
/* translators: %s: Plan title (e.g. "Professional") */ |
| 58 |
$activate_plan_text = fs_text_inline( 'Activate %s Plan', 'activate-x-plan', $slug ); |
| 59 |
$version_text = fs_text_x_inline( 'Version', 'product version', 'version', $slug ); |
| 60 |
/* translators: %s: Time period (e.g. Auto renews in "2 months") */ |
| 61 |
$renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug ); |
| 62 |
/* translators: %s: Time period (e.g. Expires in "2 months") */ |
| 63 |
$expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug ); |
| 64 |
$sync_license_text = fs_text_x_inline( 'Sync License', 'as synchronize license', 'sync-license', $slug ); |
| 65 |
$cancel_trial_text = fs_text_inline( 'Cancel Trial', 'cancel-trial', $slug ); |
| 66 |
$change_plan_text = fs_text_inline( 'Change Plan', 'change-plan', $slug ); |
| 67 |
$upgrade_text = fs_text_x_inline( 'Upgrade', 'verb', 'upgrade', $slug ); |
| 68 |
$addons_text = fs_text_inline( 'Add-Ons', 'add-ons', $slug ); |
| 69 |
$downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug ); |
| 70 |
$trial_text = fs_text_x_inline( 'Trial', 'trial period', 'trial', $slug ); |
| 71 |
$free_text = fs_text_inline( 'Free', 'free', $slug ); |
| 72 |
$activate_text = fs_text_inline( 'Activate', 'activate', $slug ); |
| 73 |
$plan_text = fs_text_x_inline( 'Plan', 'as product pricing plan', 'plan', $slug ); |
| 74 |
?> |
| 75 |
<div class="wrap fs-section"> |
| 76 |
<?php if ( ! $has_tabs && ! $fs->apply_filters( 'hide_account_tabs', false ) ) : ?> |
| 77 |
<h2 class="nav-tab-wrapper"> |
| 78 |
<a href="<?php echo $fs->get_account_url() ?>" |
| 79 |
class="nav-tab nav-tab-active"><?php fs_esc_html_echo_inline( 'Account', 'account', $slug ) ?></a> |
| 80 |
<?php if ( $fs->has_addons() ) : ?> |
| 81 |
<a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>" |
| 82 |
class="nav-tab"><?php echo esc_html( $addons_text ) ?></a> |
| 83 |
<?php endif ?> |
| 84 |
<?php if ( $show_upgrade ) : ?> |
| 85 |
<a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php echo esc_html( $upgrade_text ) ?></a> |
| 86 |
<?php if ( $fs->apply_filters( 'show_trial', true ) && ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?> |
| 87 |
<a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php fs_esc_html_echo_inline( 'Free Trial', 'free-trial', $slug ) ?></a> |
| 88 |
<?php endif ?> |
| 89 |
<?php endif ?> |
| 90 |
</h2> |
| 91 |
<?php endif ?> |
| 92 |
|
| 93 |
<div id="poststuff"> |
| 94 |
<div id="fs_account"> |
| 95 |
<div class="has-sidebar has-right-sidebar"> |
| 96 |
<div class="has-sidebar-content"> |
| 97 |
<div class="postbox"> |
| 98 |
<h3><span class="dashicons dashicons-businessman"></span> <?php fs_esc_html_echo_inline( 'Account Details', 'account-details', $slug ) ?></h3> |
| 99 |
<div class="fs-header-actions"> |
| 100 |
<ul> |
| 101 |
<?php if ( ! $is_paying ) : ?> |
| 102 |
<li> |
| 103 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 104 |
<input type="hidden" name="fs_action" value="delete_account"> |
| 105 |
<?php wp_nonce_field( 'delete_account' ) ?> |
| 106 |
<a href="#" onclick="if (confirm('<?php |
| 107 |
if ( $is_active_subscription ) { |
| 108 |
echo esc_attr( sprintf( fs_text_inline( 'Deleting the account will automatically deactivate your %s plan license so you can use it on other sites. If you want to terminate the recurring payments as well, click the "Cancel" button, and first "Downgrade" your account. Are you sure you would like to continue with the deletion?', 'delete-account-x-confirm', $slug ), $plan->title ) ); |
| 109 |
} else { |
| 110 |
echo esc_attr( sprintf( fs_text_inline( 'Deletion is not temporary. Only delete if you no longer want to use this %s anymore. Are you sure you would like to continue with the deletion?', 'delete-account-confirm', $slug ), $fs->get_module_label( true ) ) ); |
| 111 |
} |
| 112 |
?>')) this.parentNode.submit(); return false;"><i |
| 113 |
class="dashicons dashicons-no"></i> <?php fs_esc_html_echo_inline( 'Delete Account', 'delete-account', $slug ) ?></a> |
| 114 |
</form> |
| 115 |
</li> |
| 116 |
<li> • </li> |
| 117 |
<?php endif ?> |
| 118 |
<?php if ( $is_paying ) : ?> |
| 119 |
<li> |
| 120 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 121 |
<input type="hidden" name="fs_action" value="deactivate_license"> |
| 122 |
<?php wp_nonce_field( 'deactivate_license' ) ?> |
| 123 |
<a href="#" |
| 124 |
onclick="if (confirm('<?php fs_esc_attr_echo_inline( 'Deactivating your license will block all premium features, but will enable you to activate the license on another site. Are you sure you want to proceed?', 'deactivate-license-confirm', $slug ) ?>')) this.parentNode.submit(); return false;"><i |
| 125 |
class="dashicons dashicons-admin-network"></i> <?php fs_echo_inline( 'Deactivate License', 'deactivate-license', $slug ) ?> |
| 126 |
</a> |
| 127 |
</form> |
| 128 |
</li> |
| 129 |
<li> • </li> |
| 130 |
<?php if ( ! $license->is_lifetime() && |
| 131 |
$is_active_subscription |
| 132 |
) : ?> |
| 133 |
<li> |
| 134 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 135 |
<input type="hidden" name="fs_action" value="downgrade_account"> |
| 136 |
<?php wp_nonce_field( 'downgrade_account' ) ?> |
| 137 |
<a href="#" |
| 138 |
onclick="if ( confirm('<?php echo esc_attr( sprintf( $downgrade_x_confirm_text, $plan->title, human_time_diff( time(), strtotime( $license->expiration ) ) ) ) ?> <?php if ( ! $license->is_block_features ) { |
| 139 |
echo esc_attr( sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) ); |
| 140 |
} else { |
| 141 |
echo esc_attr( sprintf( $after_downgrade_blocking_text, $plan->title ) ); |
| 142 |
}?> <?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> |
| 143 |
</form> |
| 144 |
</li> |
| 145 |
<li> • </li> |
| 146 |
<?php endif ?> |
| 147 |
<?php if ( ! $fs->is_single_plan() ) : ?> |
| 148 |
<li> |
| 149 |
<a href="<?php echo $fs->get_upgrade_url() ?>"><i |
| 150 |
class="dashicons dashicons-grid-view"></i> <?php echo esc_html( $change_plan_text ) ?></a> |
| 151 |
</li> |
| 152 |
<li> • </li> |
| 153 |
<?php endif ?> |
| 154 |
<?php elseif ( $is_paid_trial ) : ?> |
| 155 |
<li> |
| 156 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 157 |
<input type="hidden" name="fs_action" value="cancel_trial"> |
| 158 |
<?php wp_nonce_field( 'cancel_trial' ) ?> |
| 159 |
<a href="#" |
| 160 |
onclick="if (confirm('<?php echo esc_attr( $cancel_trial_confirm_text ) ?>')) this.parentNode.submit(); return false;"><i |
| 161 |
class="dashicons dashicons-download"></i> <?php echo esc_html( $cancel_trial_text ) ?></a> |
| 162 |
</form> |
| 163 |
</li> |
| 164 |
<li> • </li> |
| 165 |
<?php endif ?> |
| 166 |
<li> |
| 167 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 168 |
<input type="hidden" name="fs_action" value="<?php echo $fs->get_unique_affix() ?>_sync_license"> |
| 169 |
<?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?> |
| 170 |
<a href="#" onclick="this.parentNode.submit(); return false;"><i |
| 171 |
class="dashicons dashicons-image-rotate"></i> <?php fs_esc_html_echo_x_inline( 'Sync', 'as synchronize', 'sync', $slug ) ?></a> |
| 172 |
</form> |
| 173 |
</li> |
| 174 |
|
| 175 |
</ul> |
| 176 |
</div> |
| 177 |
<div class="inside"> |
| 178 |
<table id="fs_account_details" cellspacing="0" class="fs-key-value-table"> |
| 179 |
<?php |
| 180 |
$hide_license_key = $fs->apply_filters( 'hide_license_key', false ); |
| 181 |
|
| 182 |
$profile = array(); |
| 183 |
$profile[] = array( |
| 184 |
'id' => 'user_name', |
| 185 |
'title' => fs_text_inline( 'Name', 'name', $slug ), |
| 186 |
'value' => $name |
| 187 |
); |
| 188 |
// if (isset($user->email) && false !== strpos($user->email, '@')) |
| 189 |
$profile[] = array( |
| 190 |
'id' => 'email', |
| 191 |
'title' => fs_text_inline( 'Email', 'email', $slug ), |
| 192 |
'value' => $user->email |
| 193 |
); |
| 194 |
|
| 195 |
if ( is_numeric( $user->id ) ) { |
| 196 |
$profile[] = array( |
| 197 |
'id' => 'user_id', |
| 198 |
'title' => fs_text_inline( 'User ID', 'user-id', $slug ), |
| 199 |
'value' => $user->id |
| 200 |
); |
| 201 |
} |
| 202 |
|
| 203 |
$profile[] = array( |
| 204 |
'id' => 'site_id', |
| 205 |
'title' => fs_text_inline( 'Site ID', 'site-id', $slug ), |
| 206 |
'value' => is_string( $site->id ) ? |
| 207 |
$site->id : |
| 208 |
fs_text_inline( 'No ID', 'no-id', $slug ) |
| 209 |
); |
| 210 |
|
| 211 |
$profile[] = array( |
| 212 |
'id' => 'site_public_key', |
| 213 |
'title' => fs_text_inline( 'Public Key', 'public-key', $slug ), |
| 214 |
'value' => $site->public_key |
| 215 |
); |
| 216 |
|
| 217 |
$profile[] = array( |
| 218 |
'id' => 'site_secret_key', |
| 219 |
'title' => fs_text_inline( 'Secret Key', 'secret-key', $slug ), |
| 220 |
'value' => ( ( is_string( $site->secret_key ) ) ? |
| 221 |
$site->secret_key : |
| 222 |
fs_text_x_inline( 'No Secret', 'as secret encryption key missing', 'no-secret', $slug ) |
| 223 |
) |
| 224 |
); |
| 225 |
|
| 226 |
$profile[] = array( |
| 227 |
'id' => 'version', |
| 228 |
'title' => $version_text, |
| 229 |
'value' => $fs->get_plugin_version() |
| 230 |
); |
| 231 |
|
| 232 |
if ( $fs->has_paid_plan() ) { |
| 233 |
if ( $fs->is_trial() ) { |
| 234 |
$trial_plan = $fs->get_trial_plan(); |
| 235 |
|
| 236 |
$profile[] = array( |
| 237 |
'id' => 'plan', |
| 238 |
'title' => $plan_text, |
| 239 |
'value' => ( is_string( $trial_plan->name ) ? |
| 240 |
strtoupper( $trial_plan->title ) : |
| 241 |
fs_text_inline( 'Trial', 'trial', $slug ) ) |
| 242 |
); |
| 243 |
} else { |
| 244 |
$profile[] = array( |
| 245 |
'id' => 'plan', |
| 246 |
'title' => $plan_text, |
| 247 |
'value' => strtoupper( is_string( $site->plan->name ) ? |
| 248 |
$site->plan->title : |
| 249 |
strtoupper( $free_text ) |
| 250 |
) |
| 251 |
); |
| 252 |
|
| 253 |
if ( is_object( $license ) ) { |
| 254 |
if ( ! $hide_license_key ) { |
| 255 |
$profile[] = array( |
| 256 |
'id' => 'license_key', |
| 257 |
'title' => fs_text_inline( 'License Key', $slug ), |
| 258 |
'value' => $license->secret_key, |
| 259 |
); |
| 260 |
} |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
?> |
| 265 |
<?php $odd = true; |
| 266 |
foreach ( $profile as $p ) : ?> |
| 267 |
<?php |
| 268 |
if ( 'plan' === $p['id'] && ! $fs->has_paid_plan() ) { |
| 269 |
// If plugin don't have any paid plans, there's no reason |
| 270 |
// to show current plan. |
| 271 |
continue; |
| 272 |
} |
| 273 |
?> |
| 274 |
<tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>"> |
| 275 |
<td> |
| 276 |
<nobr><?php echo $p['title'] ?>:</nobr> |
| 277 |
</td> |
| 278 |
<td<?php if ( 'plan' === $p['id'] ) { echo ' colspan="2"'; }?>> |
| 279 |
<?php if ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?> |
| 280 |
<code><?php echo htmlspecialchars( substr( $p['value'], 0, 6 ) ) . str_pad( '', 23 * 6, '•' ) . htmlspecialchars( substr( $p['value'], - 3 ) ) ?></code> |
| 281 |
<input type="text" value="<?php echo htmlspecialchars( $p['value'] ) ?>" style="display: none" |
| 282 |
readonly/> |
| 283 |
<?php else : ?> |
| 284 |
<code><?php echo htmlspecialchars( $p['value'] ) ?></code> |
| 285 |
<?php endif ?> |
| 286 |
<?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?> |
| 287 |
<label class="fs-tag fs-warn"><?php fs_esc_html_echo_inline( 'not verified', 'not-verified', $slug ) ?></label> |
| 288 |
<?php endif ?> |
| 289 |
<?php if ( 'plan' === $p['id'] ) : ?> |
| 290 |
<?php if ( $fs->is_trial() ) : ?> |
| 291 |
<label class="fs-tag fs-success"><?php echo esc_html( $trial_text ) ?></label> |
| 292 |
<?php endif ?> |
| 293 |
<?php if ( is_object( $license ) && ! $license->is_lifetime() ) : ?> |
| 294 |
<?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?> |
| 295 |
<label |
| 296 |
class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ) ) ?></label> |
| 297 |
<?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?> |
| 298 |
<label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ) ?></label> |
| 299 |
<?php endif ?> |
| 300 |
<?php elseif ( $fs->is_trial() ) : ?> |
| 301 |
<label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ) ?></label> |
| 302 |
<?php endif ?> |
| 303 |
<div class="button-group"> |
| 304 |
<?php $available_license = $fs->is_free_plan() ? $fs->_get_available_premium_license() : false ?> |
| 305 |
<?php if ( false !== $available_license && ( $available_license->left() > 0 || ( $site->is_localhost() && $available_license->is_free_localhost ) ) ) : ?> |
| 306 |
<?php $premium_plan = $fs->_get_plan_by_id( $available_license->plan_id ) ?> |
| 307 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" |
| 308 |
method="POST"> |
| 309 |
<input type="hidden" name="fs_action" value="activate_license"> |
| 310 |
<input type="hidden" name="license_id" value="<?php echo $available_license->id ?>"> |
| 311 |
<?php wp_nonce_field( 'activate_license' ) ?> |
| 312 |
<input type="submit" class="button button-primary" |
| 313 |
value="<?php echo esc_attr( sprintf( |
| 314 |
$activate_plan_text . '%s', |
| 315 |
$premium_plan->title, |
| 316 |
( $site->is_localhost() && $available_license->is_free_localhost ) ? |
| 317 |
' [' . fs_text_inline( 'Localhost', 'localhost', $slug ) . ']' : |
| 318 |
( $available_license->is_single_site() ? |
| 319 |
'' : |
| 320 |
' [' . ( 1 < $available_license->left() ? |
| 321 |
sprintf( fs_text_x_inline( '%s left', 'as 5 licenses left', 'x-left', $slug ), $available_license->left() ) : |
| 322 |
strtolower( fs_text_inline( 'Last license', 'last-license', $slug ) ) ) . ']' |
| 323 |
) |
| 324 |
) ) ?> "> |
| 325 |
</form> |
| 326 |
<?php else : ?> |
| 327 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" |
| 328 |
method="POST" class="button-group"> |
| 329 |
<?php if ( $show_upgrade && $fs->is_premium() ) : ?> |
| 330 |
<a class="button activate-license-trigger <?php echo $fs->get_unique_affix() ?>" href="#"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a> |
| 331 |
<?php endif ?> |
| 332 |
<input type="submit" class="button" |
| 333 |
value="<?php echo esc_attr( $sync_license_text ) ?>"> |
| 334 |
<input type="hidden" name="fs_action" |
| 335 |
value="<?php echo $fs->get_unique_affix() ?>_sync_license"> |
| 336 |
<?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?> |
| 337 |
<?php if ( $show_upgrade || ! $fs->is_single_plan() ) : ?> |
| 338 |
<a href="<?php echo $fs->get_upgrade_url() ?>" |
| 339 |
class="button<?php |
| 340 |
echo $show_upgrade ? |
| 341 |
' button-primary fs-upgrade' : |
| 342 |
' fs-change-plan'; ?> button-upgrade"><i |
| 343 |
class="dashicons dashicons-cart"></i> <?php echo esc_html( $show_upgrade ? $upgrade_text : $change_plan_text ) ?></a> |
| 344 |
<?php endif ?> |
| 345 |
</form> |
| 346 |
<?php endif ?> |
| 347 |
</div> |
| 348 |
<?php elseif ( 'version' === $p['id'] && $fs->has_paid_plan() ) : ?> |
| 349 |
<?php if ( $fs->has_premium_version() ) : ?> |
| 350 |
<?php if ( $fs->is_premium() ) : ?> |
| 351 |
<label |
| 352 |
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> |
| 353 |
<?php elseif ( $fs->can_use_premium_code() ) : ?> |
| 354 |
<label class="fs-tag fs-warn"><?php fs_esc_html_echo_inline( 'Free version', 'free-version', $slug ) ?></label> |
| 355 |
<?php endif ?> |
| 356 |
<?php endif ?> |
| 357 |
<?php endif ?> |
| 358 |
</td> |
| 359 |
<?php if ( 'plan' !== $p['id'] ) : ?> |
| 360 |
<td class="fs-right"> |
| 361 |
<?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?> |
| 362 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 363 |
<input type="hidden" name="fs_action" value="verify_email"> |
| 364 |
<?php wp_nonce_field( 'verify_email' ) ?> |
| 365 |
<input type="submit" class="button button-small" |
| 366 |
value="<?php fs_esc_attr_echo_inline( 'Verify Email', 'verify-email', $slug ) ?>"> |
| 367 |
</form> |
| 368 |
<?php endif ?> |
| 369 |
<?php if ( 'version' === $p['id'] ) : ?> |
| 370 |
<?php if ( $fs->has_release_on_freemius() ) : ?> |
| 371 |
<div class="button-group"> |
| 372 |
<?php if ( $is_paying || $fs->is_trial() ) : ?> |
| 373 |
<?php if ( ! $fs->is_allowed_to_install() ) : ?> |
| 374 |
<a target="_blank" class="button button-primary" |
| 375 |
href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php echo sprintf( |
| 376 |
/* translators: %s: plan name (e.g. Download "Professional" Version) */ |
| 377 |
fs_text_inline( 'Download %s Version', 'download-x-version', $slug ), |
| 378 |
( $fs->is_trial() ? $trial_plan->title : $site->plan->title ) ) . ( is_object( $update ) ? ' [' . $update->version . ']' : '' ) ?></a> |
| 379 |
<?php elseif ( is_object( $update ) ) : ?> |
| 380 |
<?php |
| 381 |
$module_type = $fs->get_module_type(); |
| 382 |
?> |
| 383 |
<a class="button button-primary" |
| 384 |
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> |
| 385 |
<?php endif ?> |
| 386 |
<?php endif; ?> |
| 387 |
</div> |
| 388 |
<?php endif ?> |
| 389 |
<?php |
| 390 |
elseif ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?> |
| 391 |
<button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button> |
| 392 |
<?php if ('license_key' === $p['id']) : ?> |
| 393 |
<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> |
| 394 |
<?php endif ?> |
| 395 |
<?php |
| 396 |
elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/ |
| 397 |
( is_string( $user->secret_key ) && in_array( $p['id'], array( |
| 398 |
'email', |
| 399 |
'user_name' |
| 400 |
) ) ) |
| 401 |
) : ?> |
| 402 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST" |
| 403 |
onsubmit="var val = prompt('<?php echo esc_attr( sprintf( |
| 404 |
/* translators: %s: User's account property (e.g. name, email) */ |
| 405 |
fs_text_inline( 'What is your %s?', 'what-is-your-x', $slug ), |
| 406 |
$p['title'] |
| 407 |
) ) ?>', '<?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;"> |
| 408 |
<input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>"> |
| 409 |
<input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $fs->get_unique_affix() ?>" |
| 410 |
value=""> |
| 411 |
<?php wp_nonce_field( 'update_' . $p['id'] ) ?> |
| 412 |
<input type="submit" class="button button-small" |
| 413 |
value="<?php echo fs_esc_attr_x_inline( 'Edit', 'verb', 'edit', $slug ) ?>"> |
| 414 |
</form> |
| 415 |
<?php endif ?> |
| 416 |
</td> |
| 417 |
<?php endif ?> |
| 418 |
</tr> |
| 419 |
<?php $odd = ! $odd; |
| 420 |
endforeach ?> |
| 421 |
</table> |
| 422 |
</div> |
| 423 |
</div> |
| 424 |
<script type="text/javascript"> |
| 425 |
(function ($) { |
| 426 |
$('.fs-toggle-visibility').click(function () { |
| 427 |
var |
| 428 |
$this = $(this), |
| 429 |
$parent = $this.closest('tr'), |
| 430 |
$input = $parent.find('input'); |
| 431 |
|
| 432 |
$parent.find('code').toggle(); |
| 433 |
$input.toggle(); |
| 434 |
|
| 435 |
if ($input.is(':visible')) { |
| 436 |
$this.html('<?php fs_esc_js_echo_x_inline( 'Hide', 'verb', 'hide', $slug ) ?>'); |
| 437 |
setTimeout(function () { |
| 438 |
$input.select().focus(); |
| 439 |
}, 100); |
| 440 |
} |
| 441 |
else { |
| 442 |
$this.html( '<?php fs_esc_js_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?>' ); |
| 443 |
} |
| 444 |
}); |
| 445 |
}(jQuery)); |
| 446 |
|
| 447 |
</script> |
| 448 |
|
| 449 |
<?php |
| 450 |
$account_addons = $fs->get_account_addons(); |
| 451 |
if ( ! is_array( $account_addons ) ) { |
| 452 |
$account_addons = array(); |
| 453 |
} |
| 454 |
|
| 455 |
$installed_addons = $fs->get_installed_addons(); |
| 456 |
$installed_addons_ids = array(); |
| 457 |
foreach ( $installed_addons as $fs_addon ) { |
| 458 |
$installed_addons_ids[] = $fs_addon->get_id(); |
| 459 |
} |
| 460 |
|
| 461 |
$addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) ); |
| 462 |
?> |
| 463 |
<?php if ( 0 < count( $addons_to_show ) ) : ?> |
| 464 |
<!-- Add-Ons --> |
| 465 |
<div class="postbox"> |
| 466 |
<div class=""> |
| 467 |
<!-- <div class="inside">--> |
| 468 |
<table id="fs_addons" class="widefat"> |
| 469 |
<thead> |
| 470 |
<tr> |
| 471 |
<th><h3><?php echo esc_html( $addons_text ) ?></h3></th> |
| 472 |
<th><?php fs_esc_html_echo_inline( 'ID', 'id', $slug ) ?></th> |
| 473 |
<th><?php echo esc_html( $version_text ) ?></th> |
| 474 |
<th><?php echo esc_html( $plan_text ) ?></th> |
| 475 |
<th><?php fs_esc_html_echo_x_inline( 'License', 'as software license', 'license', $slug ) ?></th> |
| 476 |
<th></th> |
| 477 |
<?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?> |
| 478 |
<th></th> |
| 479 |
<?php endif ?> |
| 480 |
</tr> |
| 481 |
</thead> |
| 482 |
<tbody> |
| 483 |
<?php $odd = true; |
| 484 |
foreach ( $addons_to_show as $addon_id ) : ?> |
| 485 |
<?php |
| 486 |
$addon = $fs->get_addon( $addon_id ); |
| 487 |
$is_addon_activated = $fs->is_addon_activated( $addon_id ); |
| 488 |
$is_addon_connected = $fs->is_addon_connected( $addon_id ); |
| 489 |
|
| 490 |
$fs_addon = $is_addon_connected ? freemius( $addon_id ) : false; |
| 491 |
if ( is_object( $fs_addon ) ) { |
| 492 |
$is_paying = $fs_addon->is_paying(); |
| 493 |
$user = $fs_addon->get_user(); |
| 494 |
$site = $fs_addon->get_site(); |
| 495 |
$license = $fs_addon->_get_license(); |
| 496 |
$subscription = $fs_addon->_get_subscription(); |
| 497 |
$plan = $fs_addon->get_plan(); |
| 498 |
$is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() ); |
| 499 |
$is_paid_trial = $fs_addon->is_paid_trial(); |
| 500 |
$show_upgrade = ( ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() ); |
| 501 |
$is_current_license_expired = is_object( $license ) && $license->is_expired(); |
| 502 |
} |
| 503 |
|
| 504 |
// var_dump( $is_paid_trial, $license, $site, $subscription ); |
| 505 |
|
| 506 |
?> |
| 507 |
<tr<?php if ( $odd ) { |
| 508 |
echo ' class="alternate"'; |
| 509 |
} ?>> |
| 510 |
<td> |
| 511 |
<!-- Title --> |
| 512 |
<?php echo $addon->title ?> |
| 513 |
</td> |
| 514 |
<?php if ( $is_addon_connected ) : ?> |
| 515 |
<?php // Add-on Installed ?> |
| 516 |
<?php $addon_site = $fs_addon->get_site(); ?> |
| 517 |
<td> |
| 518 |
<!-- ID --> |
| 519 |
<?php echo $addon_site->id ?> |
| 520 |
</td> |
| 521 |
<td> |
| 522 |
<!-- Version --> |
| 523 |
<?php echo $fs_addon->get_plugin_version() ?> |
| 524 |
</td> |
| 525 |
<td> |
| 526 |
<!-- Plan Title --> |
| 527 |
<?php echo strtoupper( is_string( $addon_site->plan->name ) ? $addon_site->plan->title : $free_text ) ?> |
| 528 |
</td> |
| 529 |
<td> |
| 530 |
<!-- Expiration --> |
| 531 |
<?php |
| 532 |
$tags = array(); |
| 533 |
|
| 534 |
if ( $fs_addon->is_trial() ) { |
| 535 |
$tags[] = array( 'label' => $trial_text, 'type' => 'success' ); |
| 536 |
|
| 537 |
$tags[] = array( |
| 538 |
'label' => sprintf( |
| 539 |
( $is_paid_trial ? |
| 540 |
$renews_in_text : |
| 541 |
$expires_in_text ), |
| 542 |
human_time_diff( time(), strtotime( $site->trial_ends ) ) |
| 543 |
), |
| 544 |
'type' => ( $is_paid_trial ? 'success' : 'warn' ) |
| 545 |
); |
| 546 |
} else { |
| 547 |
if ( is_object( $license ) ) { |
| 548 |
if ( $license->is_cancelled ) { |
| 549 |
$tags[] = array( |
| 550 |
'label' => fs_text_inline( 'Cancelled', 'cancelled', $slug ), |
| 551 |
'type' => 'error' |
| 552 |
); |
| 553 |
} else if ( $license->is_expired() ) { |
| 554 |
$tags[] = array( |
| 555 |
'label' => fs_text_inline( 'Expired', 'expired', $slug ), |
| 556 |
'type' => 'error' |
| 557 |
); |
| 558 |
} else if ( $license->is_lifetime() ) { |
| 559 |
$tags[] = array( |
| 560 |
'label' => fs_text_inline( 'No expiration', 'no-expiration', $slug ), |
| 561 |
'type' => 'success' |
| 562 |
); |
| 563 |
} else if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) { |
| 564 |
$tags[] = array( |
| 565 |
'label' => sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ), |
| 566 |
'type' => 'warn' |
| 567 |
); |
| 568 |
} else if ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) { |
| 569 |
$tags[] = array( |
| 570 |
'label' => sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ), |
| 571 |
'type' => 'success' |
| 572 |
); |
| 573 |
} |
| 574 |
} |
| 575 |
} |
| 576 |
|
| 577 |
foreach ( $tags as $t ) { |
| 578 |
printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] ); |
| 579 |
} |
| 580 |
?> |
| 581 |
</td> |
| 582 |
<?php |
| 583 |
$buttons = array(); |
| 584 |
if ( $is_addon_activated ) { |
| 585 |
if ( $is_paying ) { |
| 586 |
$buttons[] = fs_ui_get_action_button( |
| 587 |
$fs->get_id(), |
| 588 |
'account', |
| 589 |
'deactivate_license', |
| 590 |
fs_text_inline( 'Deactivate License', 'deactivate-license', $slug ), |
| 591 |
array( 'plugin_id' => $addon_id ), |
| 592 |
false |
| 593 |
); |
| 594 |
|
| 595 |
$human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) ); |
| 596 |
$downgrade_confirmation_message = sprintf( |
| 597 |
$downgrade_x_confirm_text, |
| 598 |
$plan->title, |
| 599 |
$human_readable_license_expiration |
| 600 |
); |
| 601 |
|
| 602 |
$after_downgrade_message = ! $license->is_block_features ? |
| 603 |
sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs_addon->get_module_label( true ) ) : |
| 604 |
sprintf( $after_downgrade_blocking_text, $plan->title ); |
| 605 |
|
| 606 |
if ( ! $license->is_lifetime() && $is_active_subscription ) { |
| 607 |
$buttons[] = fs_ui_get_action_button( |
| 608 |
$fs->get_id(), |
| 609 |
'account', |
| 610 |
'downgrade_account', |
| 611 |
$downgrade_text, |
| 612 |
array( 'plugin_id' => $addon_id ), |
| 613 |
false, |
| 614 |
false, |
| 615 |
( $downgrade_confirmation_message . ' ' . $after_downgrade_message ), |
| 616 |
'POST' |
| 617 |
); |
| 618 |
} |
| 619 |
} else if ( $is_paid_trial ) { |
| 620 |
$buttons[] = fs_ui_get_action_button( |
| 621 |
$fs->get_id(), |
| 622 |
'account', |
| 623 |
'cancel_trial', |
| 624 |
$cancel_trial_text, |
| 625 |
array( 'plugin_id' => $addon_id ), |
| 626 |
false, |
| 627 |
'dashicons dashicons-download', |
| 628 |
$cancel_trial_confirm_text, |
| 629 |
'POST' |
| 630 |
); |
| 631 |
} else { |
| 632 |
$premium_license = $fs_addon->_get_available_premium_license(); |
| 633 |
|
| 634 |
if ( is_object( $premium_license ) ) { |
| 635 |
$site = $fs_addon->get_site(); |
| 636 |
|
| 637 |
$buttons[] = fs_ui_get_action_button( |
| 638 |
$fs->get_id(), |
| 639 |
'account', |
| 640 |
'activate_license', |
| 641 |
sprintf( $activate_plan_text, $fs_addon->get_plan_title(), ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ), |
| 642 |
array( |
| 643 |
'plugin_id' => $addon_id, |
| 644 |
'license_id' => $premium_license->id, |
| 645 |
) |
| 646 |
); |
| 647 |
} |
| 648 |
} |
| 649 |
|
| 650 |
if ( 0 == count( $buttons ) ) { |
| 651 |
// Add sync license only if non of the other CTAs are visible. |
| 652 |
$buttons[] = fs_ui_get_action_button( |
| 653 |
$fs->get_id(), |
| 654 |
'account', |
| 655 |
$fs->get_unique_affix() . '_sync_license', |
| 656 |
$sync_license_text, |
| 657 |
array( 'plugin_id' => $addon_id ), |
| 658 |
false |
| 659 |
); |
| 660 |
|
| 661 |
} |
| 662 |
} else if ( ! $show_upgrade ) { |
| 663 |
if ( $fs->is_addon_installed( $addon_id ) ) { |
| 664 |
$addon_file = $fs->get_addon_basename( $addon_id ); |
| 665 |
$buttons[] = sprintf( |
| 666 |
'<a class="button button-primary edit" href="%s" title="%s">%s</a>', |
| 667 |
wp_nonce_url( 'plugins.php?action=activate&plugin=' . $addon_file, 'activate-plugin_' . $addon_file ), |
| 668 |
fs_esc_attr_inline( 'Activate this add-on', 'activate-this-addon', $slug ), |
| 669 |
$activate_text |
| 670 |
); |
| 671 |
} else { |
| 672 |
if ( $fs->is_allowed_to_install() ) { |
| 673 |
$buttons[] = sprintf( |
| 674 |
'<a class="button button-primary edit" href="%s">%s</a>', |
| 675 |
wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ), |
| 676 |
fs_text_inline( 'Install Now', 'install-now', $slug ) |
| 677 |
); |
| 678 |
} else { |
| 679 |
$buttons[] = sprintf( |
| 680 |
'<a target="_blank" class="button button-primary edit" href="%s">%s</a>', |
| 681 |
$fs->_get_latest_download_local_url( $addon_id ), |
| 682 |
esc_html( $download_latest_text ) |
| 683 |
); |
| 684 |
} |
| 685 |
} |
| 686 |
} |
| 687 |
|
| 688 |
if ( $show_upgrade ) { |
| 689 |
$buttons[] = sprintf( '<a href="%s" class="thickbox button button-primary" aria-label="%s" data-title="%s"><i class="dashicons dashicons-cart"></i> %s</a>', |
| 690 |
esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug . |
| 691 |
'&TB_iframe=true&width=600&height=550' ) ), |
| 692 |
esc_attr( sprintf( fs_text_inline( 'More information about %s', 'more-information-about-x', $slug ), $addon->title ) ), |
| 693 |
esc_attr( $addon->title ), |
| 694 |
( $fs_addon->has_free_plan() ? |
| 695 |
$upgrade_text : |
| 696 |
fs_text_x_inline( 'Purchase', 'verb', 'purchase', $slug ) ) |
| 697 |
); |
| 698 |
} |
| 699 |
|
| 700 |
$buttons_count = count( $buttons ); |
| 701 |
?> |
| 702 |
|
| 703 |
<td> |
| 704 |
<!-- Actions --> |
| 705 |
<?php if ($buttons_count > 1) : ?> |
| 706 |
<div class="button-group"> |
| 707 |
<?php endif ?> |
| 708 |
<?php foreach ( $buttons as $button ) : ?> |
| 709 |
<?php echo $button ?> |
| 710 |
<?php endforeach ?> |
| 711 |
<?php if ($buttons_count > 1) : ?> |
| 712 |
</div> |
| 713 |
<?php endif ?> |
| 714 |
</td> |
| 715 |
<?php else : ?> |
| 716 |
<?php // Add-on NOT Installed or was never connected. |
| 717 |
?> |
| 718 |
<td colspan="4"> |
| 719 |
<!-- Action --> |
| 720 |
<?php if ( $fs->is_addon_installed( $addon_id ) ) : ?> |
| 721 |
<?php $addon_file = $fs->get_addon_basename( $addon_id ) ?> |
| 722 |
<a class="button button-primary" |
| 723 |
href="<?php echo wp_nonce_url( 'plugins.php?action=activate&plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>" |
| 724 |
title="<?php fs_esc_attr_echo_inline( 'Activate this add-on', 'activate-this-addon', $slug ) ?>" |
| 725 |
class="edit"><?php echo esc_html( $activate_text ) ?></a> |
| 726 |
<?php else : ?> |
| 727 |
<?php if ( $fs->is_allowed_to_install() ) : ?> |
| 728 |
<a class="button button-primary" |
| 729 |
href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ) ?>"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></a> |
| 730 |
<?php else : ?> |
| 731 |
<a target="_blank" class="button button-primary" |
| 732 |
href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php echo esc_html( $download_latest_text ) ?></a> |
| 733 |
<?php endif ?> |
| 734 |
<?php endif ?> |
| 735 |
</td> |
| 736 |
<?php endif ?> |
| 737 |
<?php if ( ! $is_paying && defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?> |
| 738 |
<td> |
| 739 |
<!-- Optional Delete Action --> |
| 740 |
<?php |
| 741 |
if ( $is_addon_activated ) { |
| 742 |
fs_ui_action_button( |
| 743 |
$fs->get_id(), 'account', |
| 744 |
'delete_account', |
| 745 |
fs_text_x_inline( 'Delete', 'verb', 'delete', $slug ), |
| 746 |
array( 'plugin_id' => $addon_id ), |
| 747 |
false |
| 748 |
); |
| 749 |
} |
| 750 |
?> |
| 751 |
</td> |
| 752 |
<?php endif ?> |
| 753 |
</tr> |
| 754 |
<?php $odd = ! $odd; |
| 755 |
endforeach ?> |
| 756 |
</tbody> |
| 757 |
</table> |
| 758 |
</div> |
| 759 |
</div> |
| 760 |
<?php endif ?> |
| 761 |
|
| 762 |
<?php $fs->do_action( 'after_account_details' ) ?> |
| 763 |
|
| 764 |
<?php |
| 765 |
$view_params = array( 'id' => $VARS['id'] ); |
| 766 |
fs_require_once_template( 'account/billing.php', $view_params ); |
| 767 |
fs_require_once_template( 'account/payments.php', $view_params ); |
| 768 |
?> |
| 769 |
</div> |
| 770 |
</div> |
| 771 |
</div> |
| 772 |
</div> |
| 773 |
</div> |
| 774 |
<?php |
| 775 |
if ( $has_tabs ) { |
| 776 |
$fs->_add_tabs_after_content(); |
| 777 |
} |
| 778 |
|
| 779 |
$params = array( |
| 780 |
'page' => 'account', |
| 781 |
'module_id' => $fs->get_id(), |
| 782 |
'module_type' => $fs->get_module_type(), |
| 783 |
'module_slug' => $slug, |
| 784 |
'module_version' => $fs->get_plugin_version(), |
| 785 |
); |
| 786 |
fs_require_template( 'powered-by.php', $params ); |