| 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 2.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* @var array $VARS |
| 15 |
* @var Freemius $fs |
| 16 |
* @var FS_Plugin_License $main_license |
| 17 |
*/ |
| 18 |
$fs = $VARS['freemius']; |
| 19 |
$slug = $fs->get_slug(); |
| 20 |
$site = $VARS['site']; |
| 21 |
$main_license = $VARS['license']; |
| 22 |
$is_data_debug_mode = $fs->is_data_debug_mode(); |
| 23 |
$is_whitelabeled = $fs->is_whitelabeled(); |
| 24 |
$has_paid_plan = $fs->has_paid_plan(); |
| 25 |
$is_premium = $fs->is_premium(); |
| 26 |
$main_user = $fs->get_user(); |
| 27 |
$blog_id = $site['blog_id']; |
| 28 |
|
| 29 |
$install = $VARS['install']; |
| 30 |
$is_registered = ! empty( $install ); |
| 31 |
$license = null; |
| 32 |
$trial_plan = $fs->get_trial_plan(); |
| 33 |
$free_text = fs_text_inline( 'Free', 'free', $slug ); |
| 34 |
|
| 35 |
if ( $is_whitelabeled && $fs->is_delegated_connection( $blog_id ) ) { |
| 36 |
$is_whitelabeled = $fs->is_whitelabeled( true, $blog_id ); |
| 37 |
} |
| 38 |
?> |
| 39 |
<tr class="fs-site-details" data-blog-id="<?php echo $blog_id ?>"<?php if ( $is_registered ) : ?> data-install-id="<?php echo $install->id ?>"<?php endif ?>> |
| 40 |
<!-- Install ID or Opt-in option --> |
| 41 |
<td><?php if ( $is_registered ) : ?> |
| 42 |
<?php echo $install->id ?> |
| 43 |
<?php else : ?> |
| 44 |
<?php $action = 'opt_in' ?> |
| 45 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 46 |
<input type="hidden" name="fs_action" value="<?php echo $action ?>"> |
| 47 |
<?php wp_nonce_field( trim( "{$action}:{$blog_id}", ':' ) ) ?> |
| 48 |
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>"> |
| 49 |
<button class="fs-opt-in button button-small"><?php fs_esc_html_echo_inline( 'Opt In', 'opt-in', $slug ) ?></button> |
| 50 |
</form> |
| 51 |
<?php endif ?> |
| 52 |
</td> |
| 53 |
<!--/ Install ID or Opt-in option --> |
| 54 |
|
| 55 |
<!-- Site URL --> |
| 56 |
<td class="fs-field-url fs-main-column"><?php echo fs_strip_url_protocol( $site['url'] ) ?></td> |
| 57 |
<!--/ Site URL --> |
| 58 |
|
| 59 |
<!-- License Activation / Deactivation --> |
| 60 |
<td><?php if ( $has_paid_plan ) { |
| 61 |
$view_params = array( |
| 62 |
'freemius' => $fs, |
| 63 |
'slug' => $slug, |
| 64 |
'blog_id' => $blog_id, |
| 65 |
'class' => 'button-small', |
| 66 |
); |
| 67 |
|
| 68 |
$license = null; |
| 69 |
if ( $is_registered ) { |
| 70 |
$view_params['install_id'] = $install->id; |
| 71 |
$view_params['is_localhost'] = $install->is_localhost(); |
| 72 |
|
| 73 |
$has_license = FS_Plugin_License::is_valid_id( $install->license_id ); |
| 74 |
$license = $has_license ? |
| 75 |
$fs->_get_license_by_id( $install->license_id ) : |
| 76 |
null; |
| 77 |
} else { |
| 78 |
$view_params['is_localhost'] = FS_Site::is_localhost_by_address( $site['url'] ); |
| 79 |
} |
| 80 |
|
| 81 |
if ( ! $is_whitelabeled ) { |
| 82 |
if ( is_object( $license ) ) { |
| 83 |
$view_params['license'] = $license; |
| 84 |
|
| 85 |
// Show license deactivation button. |
| 86 |
fs_require_template( 'account/partials/deactivate-license-button.php', $view_params ); |
| 87 |
} else { |
| 88 |
if ( is_object( $main_license ) && $main_license->can_activate( $view_params['is_localhost'] ) ) { |
| 89 |
// Main license is available for activation. |
| 90 |
$available_license = $main_license; |
| 91 |
} else { |
| 92 |
// Try to find any available license for activation. |
| 93 |
$available_license = $fs->_get_available_premium_license( $view_params['is_localhost'] ); |
| 94 |
} |
| 95 |
|
| 96 |
if ( is_object( $available_license ) ) { |
| 97 |
$premium_plan = $fs->_get_plan_by_id( $available_license->plan_id ); |
| 98 |
|
| 99 |
$view_params['license'] = $available_license; |
| 100 |
$view_params['class'] .= ' button-primary'; |
| 101 |
$view_params['plan'] = $premium_plan; |
| 102 |
|
| 103 |
fs_require_template( 'account/partials/activate-license-button.php', $view_params ); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
} ?></td> |
| 108 |
<!--/ License Activation / Deactivation --> |
| 109 |
|
| 110 |
<!-- Plan --> |
| 111 |
<td><?php if ( $is_registered ) : ?> |
| 112 |
<?php |
| 113 |
if ( ! $has_paid_plan ) { |
| 114 |
$plan_title = $free_text; |
| 115 |
} else { |
| 116 |
if ( $install->is_trial() ) { |
| 117 |
if ( is_object( $trial_plan ) && $trial_plan->id == $install->trial_plan_id ) { |
| 118 |
$plan_title = is_string( $trial_plan->name ) ? |
| 119 |
strtoupper( $trial_plan->title ) : |
| 120 |
fs_text_inline( 'Trial', 'trial', $slug ); |
| 121 |
} else { |
| 122 |
$plan_title = fs_text_inline( 'Trial', 'trial', $slug ); |
| 123 |
} |
| 124 |
} else { |
| 125 |
$plan = $fs->_get_plan_by_id( $install->plan_id ); |
| 126 |
$plan_title = strtoupper( is_string( $plan->title ) ? |
| 127 |
$plan->title : |
| 128 |
strtoupper( $free_text ) |
| 129 |
); |
| 130 |
} |
| 131 |
} |
| 132 |
?> |
| 133 |
<code><?php echo $plan_title ?></code> |
| 134 |
<?php endif ?></td> |
| 135 |
<!--/ Plan --> |
| 136 |
|
| 137 |
<!-- More details button --> |
| 138 |
<td><?php if ( $is_registered ) : ?> |
| 139 |
<button class="fs-show-install-details button button-small">More details <i |
| 140 |
class="dashicons dashicons-arrow-right-alt2"></i> |
| 141 |
</button><?php endif ?></td> |
| 142 |
<!--/ More details button --> |
| 143 |
</tr> |
| 144 |
<?php if ( $is_registered ) : ?> |
| 145 |
<!-- More details --> |
| 146 |
<tr class="fs-install-details" data-install-id="<?php echo $install->id ?>" style="display: none"> |
| 147 |
<td colspan="5"> |
| 148 |
<table class="widefat fs-key-value-table"> |
| 149 |
<tbody> |
| 150 |
<?php $row_index = 0 ?> |
| 151 |
<!-- Blog ID --> |
| 152 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 153 |
echo ' class="alternate"'; |
| 154 |
} ?>> |
| 155 |
<td> |
| 156 |
<nobr><?php fs_esc_html_echo_inline( 'Blog ID', 'blog-id', $slug ) ?>:</nobr> |
| 157 |
</td> |
| 158 |
<td><code><?php echo $blog_id ?></code></td> |
| 159 |
<td><?php if ( ! FS_Plugin_License::is_valid_id( $install->license_id ) ) : ?> |
| 160 |
<!-- Toggle Usage Tracking --> |
| 161 |
<?php $action = 'toggle_tracking' ?> |
| 162 |
<form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 163 |
<input type="hidden" name="fs_action" value="<?php echo $action ?>"> |
| 164 |
<?php wp_nonce_field( trim( "{$action}:{$blog_id}:{$install->id}", ':' ) ) ?> |
| 165 |
<input type="hidden" name="install_id" value="<?php echo $install->id ?>"> |
| 166 |
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>"> |
| 167 |
<button class="fs-toggle-tracking button button-small<?php if ( $install->is_disconnected ) { |
| 168 |
echo ' button-primary'; |
| 169 |
} ?>" data-is-disconnected="<?php echo $install->is_disconnected ? 'true' : 'false' ?>"><?php $install->is_disconnected ? fs_esc_html_echo_inline( 'Opt In', 'opt-in', $slug ) : fs_esc_html_echo_inline( 'Opt Out', 'opt-out', $slug ) ?></button> |
| 170 |
</form> |
| 171 |
<!--/ Toggle Usage Tracking --> |
| 172 |
<?php endif ?></td> |
| 173 |
</tr> |
| 174 |
<?php $row_index ++ ?> |
| 175 |
<!--/ Blog ID --> |
| 176 |
|
| 177 |
<?php if ( $is_registered && $install->user_id != $main_user->id ) : ?> |
| 178 |
<?php |
| 179 |
/** |
| 180 |
* @var FS_User $user |
| 181 |
*/ |
| 182 |
$user = Freemius::_get_user_by_id( $install->user_id ) ?> |
| 183 |
<?php if ( is_object( $user ) ) : ?> |
| 184 |
<!-- User Name --> |
| 185 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 186 |
echo ' class="alternate"'; |
| 187 |
} ?>> |
| 188 |
<td> |
| 189 |
<nobr><?php fs_esc_html_echo_inline( 'Owner Name', 'owner-name', $slug ) ?>:</nobr> |
| 190 |
</td> |
| 191 |
<td colspan="2"><code><?php echo htmlspecialchars( $user->get_name() ) ?></code></td> |
| 192 |
</tr> |
| 193 |
<?php $row_index ++ ?> |
| 194 |
<!--/ User Name --> |
| 195 |
|
| 196 |
<!-- User Email --> |
| 197 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 198 |
echo ' class="alternate"'; |
| 199 |
} ?>> |
| 200 |
<td> |
| 201 |
<nobr><?php fs_esc_html_echo_inline( 'Owner Email', 'owner-email', $slug ) ?>:</nobr> |
| 202 |
</td> |
| 203 |
<td colspan="2"><code><?php echo htmlspecialchars( $user->email ) ?></code></td> |
| 204 |
</tr> |
| 205 |
<?php $row_index ++ ?> |
| 206 |
<!--/ User Email --> |
| 207 |
|
| 208 |
<!-- User ID --> |
| 209 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 210 |
echo ' class="alternate"'; |
| 211 |
} ?>> |
| 212 |
<td> |
| 213 |
<nobr><?php fs_esc_html_echo_inline( 'Owner ID', 'owner-id', $slug ) ?>:</nobr> |
| 214 |
</td> |
| 215 |
<td colspan="2"><code><?php echo $user->id ?></code></td> |
| 216 |
</tr> |
| 217 |
<?php $row_index ++ ?> |
| 218 |
<!--/ User ID --> |
| 219 |
<?php endif ?> |
| 220 |
<?php endif ?> |
| 221 |
|
| 222 |
<!-- Public Key --> |
| 223 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 224 |
echo ' class="alternate"'; |
| 225 |
} ?>> |
| 226 |
<td> |
| 227 |
<nobr><?php fs_esc_html_echo_inline( 'Public Key', 'public-key', $slug ) ?>:</nobr> |
| 228 |
</td> |
| 229 |
<td colspan="2"><code><?php echo htmlspecialchars( $install->public_key ) ?></code></td> |
| 230 |
</tr> |
| 231 |
<?php $row_index ++ ?> |
| 232 |
<!--/ Public Key --> |
| 233 |
|
| 234 |
<!-- Secret Key --> |
| 235 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 236 |
echo ' class="alternate"'; |
| 237 |
} ?>> |
| 238 |
<td> |
| 239 |
<nobr><?php fs_esc_html_echo_inline( 'Secret Key', 'secret-key', $slug ) ?>:</nobr> |
| 240 |
</td> |
| 241 |
<td> |
| 242 |
<code><?php echo FS_Plugin_License::mask_secret_key_for_html( $install->secret_key ) ?></code> |
| 243 |
<?php if ( ! $is_whitelabeled ) : ?> |
| 244 |
<input type="text" value="<?php echo htmlspecialchars( $install->secret_key ) ?>" |
| 245 |
style="display: none" readonly/></td> |
| 246 |
<?php endif ?> |
| 247 |
<?php if ( ! $is_whitelabeled ) : ?> |
| 248 |
<td><button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button></td> |
| 249 |
<?php endif ?> |
| 250 |
</tr> |
| 251 |
<?php $row_index ++ ?> |
| 252 |
<!--/ Secret Key --> |
| 253 |
|
| 254 |
<?php if ( is_object( $license ) ) : ?> |
| 255 |
<!-- License Key --> |
| 256 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 257 |
echo ' class="alternate"'; |
| 258 |
} ?>> |
| 259 |
<td> |
| 260 |
<nobr><?php fs_esc_html_echo_inline( 'License Key', 'license-key', $slug ) ?>:</nobr> |
| 261 |
</td> |
| 262 |
<td> |
| 263 |
<code><?php echo $license->get_html_escaped_masked_secret_key() ?></code> |
| 264 |
<?php if ( ! $is_whitelabeled ) : ?> |
| 265 |
<input type="text" value="<?php echo htmlspecialchars( $license->secret_key ) ?>" |
| 266 |
style="display: none" readonly/></td> |
| 267 |
<?php endif ?> |
| 268 |
<?php if ( ! $is_whitelabeled ) : ?> |
| 269 |
<td> |
| 270 |
<button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button> |
| 271 |
<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> |
| 272 |
</td> |
| 273 |
<?php endif ?> |
| 274 |
</tr> |
| 275 |
<?php $row_index ++ ?> |
| 276 |
<!--/ License Key --> |
| 277 |
|
| 278 |
<?php if ( ! is_object( $main_license ) || $main_license->id != $license->id ) : ?> |
| 279 |
<?php $subscription = $fs->_get_subscription( $license->id ) ?> |
| 280 |
<?php if ( ! $license->is_lifetime() && is_object( $subscription ) ) : ?> |
| 281 |
<!-- Subscription --> |
| 282 |
<tr <?php if ( 1 == $row_index % 2 ) { |
| 283 |
echo ' class="alternate"'; |
| 284 |
} ?>> |
| 285 |
<td> |
| 286 |
<nobr><?php fs_esc_html_echo_inline( 'Subscription', 'subscription', $slug ) ?>:</nobr> |
| 287 |
</td> |
| 288 |
<?php |
| 289 |
$is_active_subscription = $subscription->is_active(); |
| 290 |
|
| 291 |
$renews_in_text = fs_text_inline( 'Auto renews in %s', 'renews-in', $slug ); |
| 292 |
/* translators: %s: Time period (e.g. Expires in "2 months") */ |
| 293 |
$expires_in_text = fs_text_inline( 'Expires in %s', 'expires-in', $slug ); |
| 294 |
?> |
| 295 |
<td> |
| 296 |
<code><?php echo $subscription->id ?> - <?php |
| 297 |
echo ( 12 == $subscription->billing_cycle ? |
| 298 |
_fs_text_inline( 'Annual', 'annual', $slug ) : |
| 299 |
_fs_text_inline( 'Monthly', 'monthly', $slug ) |
| 300 |
); |
| 301 |
?> |
| 302 |
</code> |
| 303 |
<?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?> |
| 304 |
<label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $license->expiration ) ) ) ) ?></label> |
| 305 |
<?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?> |
| 306 |
<label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ) ?></label> |
| 307 |
<?php endif ?> |
| 308 |
</td> |
| 309 |
<td><?php if ( $is_active_subscription ) : ?> |
| 310 |
<?php |
| 311 |
$downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug ); |
| 312 |
$cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug ); |
| 313 |
/* translators: %1$s: Either 'Downgrading your plan' or 'Cancelling the subscription' */ |
| 314 |
$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 ); |
| 315 |
$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 ); |
| 316 |
$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 ); |
| 317 |
$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 ); |
| 318 |
$downgrade_text = fs_text_x_inline( 'Downgrade', 'verb', 'downgrade', $slug ); |
| 319 |
|
| 320 |
$human_readable_license_expiration = human_time_diff( time(), strtotime( $license->expiration ) ); |
| 321 |
$downgrade_confirmation_message = sprintf( |
| 322 |
$downgrade_x_confirm_text, |
| 323 |
( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ), |
| 324 |
$plan->title, |
| 325 |
$human_readable_license_expiration |
| 326 |
); |
| 327 |
|
| 328 |
$after_downgrade_message = ! $license->is_block_features ? |
| 329 |
sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) : |
| 330 |
sprintf( $after_downgrade_blocking_text, $plan->title ); |
| 331 |
?> |
| 332 |
<?php $action = 'downgrade_account' ?> |
| 333 |
<form id="fs_downgrade" action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"> |
| 334 |
<input type="hidden" name="fs_action" value="<?php echo $action ?>"> |
| 335 |
<?php wp_nonce_field( trim( "{$action}:{$blog_id}", ':' ) ) ?> |
| 336 |
<input type="hidden" name="blog_id" value="<?php echo $blog_id ?>"> |
| 337 |
<button class="button button-small" onclick="if (confirm('<?php echo esc_attr( $downgrade_confirmation_message . ' ' . $after_downgrade_message . ' ' . $prices_increase_text ) ?>')) { this.parentNode.submit(); } else { return false; }"><?php echo $downgrade_text ?></button> |
| 338 |
</form> |
| 339 |
<?php endif ?></td> |
| 340 |
</tr> |
| 341 |
<?php $row_index ++ ?> |
| 342 |
<?php endif ?> |
| 343 |
<!--/ Subscription --> |
| 344 |
<?php endif ?> |
| 345 |
<?php endif ?> |
| 346 |
|
| 347 |
</tbody> |
| 348 |
</table> |
| 349 |
</td> |
| 350 |
</tr> |
| 351 |
<!--/ More details --> |
| 352 |
<?php endif ?> |