PluginProbe
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs / 5.0.1
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs v5.0.1
5.0.1 4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 All 39 releases
← All changes | freemius/templates/account.php +185 -89 1.2.2 → 5.0.1 View file →
@@ -20,9 +20,11 @@
20 20
21 21 /**
22 22 * @var FS_Plugin_Tag $update
23 23 */
24 - $update = $fs->get_update( false, false, WP_FS__TIME_24_HOURS_IN_SEC / 24 );
24 + $update = $fs->has_release_on_freemius() ?
25 + $fs->get_update( false, false ) :
26 + null;
25 27
26 28 if ( is_object($update) ) {
27 29 /**
28 30 * This logic is particularly required for multisite environment.
@@ -43,8 +45,9 @@
43 45 $user = $fs->get_user();
44 46 $site = $fs->get_site();
45 47 $name = $user->get_name();
46 48 $license = $fs->_get_license();
49 + $is_license_foreign = ( is_object( $license ) && $user->id != $license->user_id );
47 50 $is_data_debug_mode = $fs->is_data_debug_mode();
48 51 $is_whitelabeled = $fs->is_whitelabeled();
49 52 $subscription = ( is_object( $license ) ?
50 53 $fs->_get_subscription( $license->id ) :
@@ -55,12 +58,21 @@
55 58 $has_paid_plan = $fs->apply_filters( 'has_paid_plan_account', $fs->has_paid_plan() );
56 59 $show_upgrade = ( ! $is_whitelabeled && $has_paid_plan && ! $is_paying && ! $is_paid_trial );
57 60 $trial_plan = $fs->get_trial_plan();
58 61
62 + $is_plan_change_supported = (
63 + ! $fs->is_single_plan() &&
64 + ! $fs->apply_filters( 'hide_plan_change', false )
65 + );
66 +
59 67 if ( $has_paid_plan ) {
60 68 $fs->_add_license_activation_dialog_box();
61 69 }
62 70
71 + if ( $fs->should_handle_user_change() ) {
72 + $fs->_add_email_address_update_dialog_box();
73 + }
74 +
63 75 $ids_of_installs_activated_with_foreign_licenses = $fs->should_handle_user_change() ?
64 76 $fs->get_installs_ids_with_foreign_licenses() :
65 77 array();
66 78
@@ -83,19 +95,18 @@
83 95 '_open_license_activation_dialog_box'
84 96 ) );
85 97 }
86 98
87 - $payments = $fs->_fetch_payments();
99 + $show_billing = ( ! $is_whitelabeled && ! $fs->apply_filters( 'hide_billing_and_payments_info', false ) );
100 + if ( $show_billing ) {
101 + $payments = $fs->_fetch_payments();
88 102
89 - $show_billing = ( ! $is_whitelabeled && is_array( $payments ) && 0 < count( $payments ) );
103 + $show_billing = ( is_array( $payments ) && 0 < count( $payments ) );
104 + }
90 105
91 106
92 - $has_tabs = $fs->_add_tabs_before_content();
107 + $has_tabs = $fs->_add_tabs_before_content();
93 108
94 - if ( $has_tabs ) {
95 - $query_params['tabs'] = 'true';
96 - }
97 -
98 109 // Aliases.
99 110 $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
100 111 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
101 112 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
@@ -137,8 +148,9 @@
137 148 $site_info = $fs->get_site_info( $s );
138 149 $install = $fs->get_install_by_blog_id( $site_info['blog_id'] );
139 150 $view_params = array(
140 151 'freemius' => $fs,
152 + 'user' => $fs->get_user(),
141 153 'license' => $license,
142 154 'site' => $site_info,
143 155 'install' => $install,
144 156 );
@@ -162,21 +174,30 @@
162 174 }
163 175 }
164 176 }
165 177
166 - $is_child_license = ( is_object( $license ) && FS_Plugin_License::is_valid_id( $license->parent_license_id ) );
167 - $bundle_subscription = null;
178 + $has_bundle_license = false;
168 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 +
169 190 if (
170 191 $show_plan_row &&
171 192 is_object( $license ) &&
172 - FS_Plugin_License::is_valid_id( $license->parent_license_id )
193 + $has_bundle_license
173 194 ) {
174 - $bundle_subscription = $fs->_get_subscription( $license->parent_license_id );
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();
175 198 }
176 199
177 - $is_active_bundle_subscription = ( is_object( $bundle_subscription ) && $bundle_subscription->is_active() );
178 -
179 200 $fs_blog_id = ( is_multisite() && ! is_network_admin() ) ?
180 201 get_current_blog_id() :
181 202 0;
182 203
@@ -182,22 +203,72 @@
182 203
183 204 $active_plugins_directories_map = Freemius::get_active_plugins_directories_map( $fs_blog_id );
184 205
185 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 + $is_dev_mode = ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE );
186 257 ?>
187 258 <div class="wrap fs-section">
188 259 <?php if ( ! $has_tabs && ! $fs->apply_filters( 'hide_account_tabs', false ) ) : ?>
189 260 <h2 class="nav-tab-wrapper">
190 - <a href="<?php echo $fs->get_account_url() ?>"
261 + <a href="<?php echo esc_url( $fs->get_account_url() ) ?>"
191 262 class="nav-tab nav-tab-active"><?php fs_esc_html_echo_inline( 'Account', 'account', $slug ) ?></a>
192 263 <?php if ( $fs->has_addons() ) : ?>
193 - <a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>"
264 + <a href="<?php echo esc_url( $fs->_get_admin_page_url( 'addons' ) ) ?>"
194 265 class="nav-tab"><?php echo esc_html( $addons_text ) ?></a>
195 266 <?php endif ?>
196 267 <?php if ( $show_upgrade ) : ?>
197 - <a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php echo esc_html( $upgrade_text ) ?></a>
268 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>" class="nav-tab"><?php echo esc_html( $upgrade_text ) ?></a>
198 269 <?php if ( $fs->apply_filters( 'show_trial', true ) && ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
199 - <a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php fs_esc_html_echo_inline( 'Free Trial', 'free-trial', $slug ) ?></a>
270 + <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>
200 271 <?php endif ?>
201 272 <?php endif ?>
202 273 </h2>
203 274 <?php endif ?>
@@ -222,26 +293,21 @@
222 293 </li>
223 294 <li>&nbsp;&bull;&nbsp;</li>
224 295 <?php endif ?>
225 296 <?php if ( $show_billing ) : ?>
226 - <li><a href="#fs_billing"><i class="dashicons dashicons-portfolio"></i> <?php fs_esc_html_echo_inline( 'Billing & Invoices', 'billing-invoices', $slug ) ?></li>
297 + <li><a href="#fs_billing"><i class="dashicons dashicons-portfolio"></i> <?php fs_esc_html_echo_inline( 'Billing & Invoices', 'billing-invoices', $slug ) ?></a></li>
227 298 <li>&nbsp;&bull;&nbsp;</li>
228 299 <?php endif ?>
229 300 <?php if ( ! $is_whitelabeled ) : ?>
230 301 <?php if ( ! $is_paying ) : ?>
231 302 <li>
232 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
233 - <input type="hidden" name="fs_action" value="delete_account">
234 - <?php wp_nonce_field( 'delete_account' ) ?>
235 - <a class="fs-delete-account" href="#" onclick="if (confirm('<?php
236 - if ( $is_active_subscription ) {
237 - 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 ) );
238 - } else {
239 - 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 ) ) );
240 - }
241 - ?>')) this.parentNode.submit(); return false;"><i
242 - class="dashicons dashicons-no"></i> <?php fs_esc_html_echo_inline( 'Delete Account', 'delete-account', $slug ) ?></a>
243 - </form>
303 + <?php
304 + $view_params = array(
305 + 'freemius' => $fs,
306 + 'license' => $available_license,
307 + 'license_paid_plan' => $available_license_paid_plan,
308 + );
309 + fs_require_template( 'account/partials/disconnect-button.php', $view_params ); ?>
244 310 </li>
245 311 <li>&nbsp;&bull;&nbsp;</li>
246 312 <?php endif ?>
247 313 <?php if ( $is_paying ) : ?>
@@ -246,9 +312,9 @@
246 312 <?php endif ?>
247 313 <?php if ( $is_paying ) : ?>
248 314 <?php if ( ! fs_is_network_admin() ) : ?>
249 315 <li>
250 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
316 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
251 317 <input type="hidden" name="fs_action" value="deactivate_license">
252 318 <?php wp_nonce_field( 'deactivate_license' ) ?>
253 319 <a href="#" class="fs-deactivate-license"><i
254 320 class="dashicons dashicons-admin-network"></i> <?php fs_echo_inline( 'Deactivate License', 'deactivate-license', $slug ) ?>
@@ -260,15 +326,15 @@
260 326 <?php if ( ! $license->is_lifetime() &&
261 327 $is_active_subscription
262 328 ) : ?>
263 329 <li>
264 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
330 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
265 331 <input type="hidden" name="fs_action" value="downgrade_account">
266 332 <?php wp_nonce_field( 'downgrade_account' ) ?>
267 333 <a href="#"
268 334 onclick="if ( confirm('<?php echo esc_attr( sprintf(
269 335 $downgrade_x_confirm_text,
270 - ( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
336 + ( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
271 337 $plan->title,
272 338 human_time_diff( time(), strtotime( $license->expiration ) )
273 339 ) ) ?> <?php if ( ! $license->is_block_features ) {
274 340 echo esc_attr( sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) );
@@ -278,11 +344,11 @@
278 344 </form>
279 345 </li>
280 346 <li>&nbsp;&bull;&nbsp;</li>
281 347 <?php endif ?>
282 - <?php if ( ! $fs->is_single_plan() ) : ?>
348 + <?php if ( $is_plan_change_supported ) : ?>
283 349 <li>
284 - <a href="<?php echo $fs->get_upgrade_url() ?>"><i
350 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>"><i
285 351 class="dashicons dashicons-grid-view"></i> <?php echo esc_html( $change_plan_text ) ?></a>
286 352 </li>
287 353 <li>&nbsp;&bull;&nbsp;</li>
288 354 <?php endif ?>
@@ -287,9 +353,9 @@
287 353 <li>&nbsp;&bull;&nbsp;</li>
288 354 <?php endif ?>
289 355 <?php elseif ( $is_paid_trial ) : ?>
290 356 <li>
291 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
357 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
292 358 <input type="hidden" name="fs_action" value="cancel_trial">
293 359 <?php wp_nonce_field( 'cancel_trial' ) ?>
294 360 <a href="#" class="fs-cancel-trial"><i
295 361 class="dashicons dashicons-download"></i> <?php echo esc_html( $cancel_trial_text ) ?></a>
@@ -298,10 +364,10 @@
298 364 <li>&nbsp;&bull;&nbsp;</li>
299 365 <?php endif ?>
300 366 <?php endif ?>
301 367 <li>
302 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
303 - <input type="hidden" name="fs_action" value="<?php echo $fs->get_unique_affix() ?>_sync_license">
368 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
369 + <input type="hidden" name="fs_action" value="<?php echo esc_attr( $fs->get_unique_affix() ) ?>_sync_license">
304 370 <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
305 371 <a href="#" onclick="this.parentNode.submit(); return false;"><i
306 372 class="dashicons dashicons-image-rotate"></i> <?php fs_esc_html_echo_x_inline( 'Sync', 'as synchronize', 'sync', $slug ) ?></a>
307 373 </form>
@@ -314,9 +380,9 @@
314 380 $hide_license_key = ( ! $show_license_row || $fs->apply_filters( 'hide_license_key', false ) );
315 381
316 382 $profile = array();
317 383
318 - if ( ! $is_whitelabeled ) {
384 + if ( ! $is_whitelabeled ) {
319 385 $profile[] = array(
320 386 'id' => 'user_name',
321 387 'title' => fs_text_inline( 'Name', 'name', $slug ),
322 388 'value' => $name
@@ -383,17 +449,17 @@
383 449 'title' => $version_text,
384 450 'value' => $fs->get_plugin_version()
385 451 );
386 452
387 - if ( $is_premium && ! $is_whitelabeled ) {
453 + if ( ! fs_is_network_admin() && $is_premium ) {
388 454 $profile[] = array(
389 455 'id' => 'beta_program',
390 456 'title' => '',
391 - 'value' => $user->is_beta
457 + 'value' => $site->is_beta
392 458 );
393 459 }
394 460
395 - if ( $has_paid_plan ) {
461 + if ( $has_paid_plan || $has_bundle_license ) {
396 462 if ( $fs->is_trial() ) {
397 463 if ( $show_plan_row ) {
398 464 $profile[] = array(
399 465 'id' => 'plan',
@@ -406,9 +472,9 @@
406 472 } else {
407 473 if ( $show_plan_row ) {
408 474 $profile[] = array(
409 475 'id' => 'plan',
410 - 'title' => ( $is_child_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text,
476 + 'title' => ( $has_bundle_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text,
411 477 'value' => strtoupper( is_string( $plan->name ) ?
412 478 $plan->title :
413 479 strtoupper( $free_text )
414 480 )
@@ -413,13 +479,13 @@
413 479 strtoupper( $free_text )
414 480 )
415 481 );
416 482
417 - if ( $is_child_license ) {
483 + if ( $has_bundle_license ) {
418 484 $profile[] = array(
419 485 'id' => 'bundle_plan',
420 486 'title' => $bundle_plan_text,
421 - 'value' => strtoupper( $license->parent_plan_title )
487 + 'value' => $bundle_plan_title
422 488 );
423 489 }
424 490 }
425 491
@@ -443,11 +509,11 @@
443 509 // to show current plan.
444 510 continue;
445 511 }
446 512 ?>
447 - <tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
513 + <tr class="fs-field-<?php echo esc_attr( $p['id'] ) ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
448 514 <td>
449 - <nobr><?php echo $p['title'] ?><?php echo ( ! empty( $p['title'] ) ) ? ':' : '' ?></nobr>
515 + <nobr><?php echo esc_html( $p['title'] ) ?><?php echo ( ! empty( $p['title'] ) ) ? ':' : '' ?></nobr>
450 516 </td>
451 517 <td<?php if ( 'plan' === $p['id'] || 'bundle_plan' === $p['id'] ) { echo ' colspan="2"'; }?>>
452 518 <?php if ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
453 519 <code><?php echo FS_Plugin_License::mask_secret_key_for_html( $p['value'] ) ?></code>
@@ -485,17 +551,15 @@
485 551 <label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ) ?></label>
486 552 <?php endif ?>
487 553 <?php if ( ! $is_whitelabeled ) : ?>
488 554 <div class="button-group">
489 - <?php $available_license = $fs->is_free_plan() && ! fs_is_network_admin() ? $fs->_get_available_premium_license( $site->is_localhost() ) : false ?>
490 555 <?php if ( is_object( $available_license ) ) : ?>
491 - <?php $premium_plan = $fs->_get_plan_by_id( $available_license->plan_id ) ?>
492 556 <?php
493 557 $view_params = array(
494 558 'freemius' => $fs,
495 559 'slug' => $slug,
496 560 'license' => $available_license,
497 - 'plan' => $premium_plan,
561 + 'plan' => $available_license_paid_plan,
498 562 'is_localhost' => $site->is_localhost(),
499 563 'install_id' => $site->id,
500 564 'class' => 'button-primary',
501 565 );
@@ -500,20 +564,20 @@
500 564 'class' => 'button-primary',
501 565 );
502 566 fs_require_template( 'account/partials/activate-license-button.php', $view_params ); ?>
503 567 <?php else : ?>
504 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
568 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>"
505 569 method="POST" class="button-group">
506 570 <?php if ( $show_upgrade && $is_premium ) : ?>
507 - <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>
571 + <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>
508 572 <?php endif ?>
509 573 <input type="submit" class="button"
510 574 value="<?php echo esc_attr( $sync_license_text ) ?>">
511 575 <input type="hidden" name="fs_action"
512 - value="<?php echo $fs->get_unique_affix() ?>_sync_license">
576 + value="<?php echo esc_attr( $fs->get_unique_affix() ) ?>_sync_license">
513 577 <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
514 - <?php if ( $show_upgrade || ! $fs->is_single_plan() ) : ?>
515 - <a href="<?php echo $fs->get_upgrade_url() ?>"
578 + <?php if ( $show_upgrade || $is_plan_change_supported ) : ?>
579 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>"
516 580 class="button<?php
517 581 echo $show_upgrade ?
518 582 ' button-primary fs-upgrade' :
519 583 ' fs-change-plan'; ?> button-upgrade"><i
@@ -524,9 +588,9 @@
524 588 </div>
525 589 <?php endif ?>
526 590 <?php elseif ( 'bundle_plan' === $p['id'] ) : ?>
527 591 <?php if ( is_object( $bundle_subscription ) ) : ?>
528 - <?php if ( $is_active_bundle_subscription && ! $license->is_first_payment_pending() ) : ?>
592 + <?php if ( $is_active_bundle_subscription && ! $is_bundle_first_payment_pending ) : ?>
529 593 <label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $bundle_subscription->next_payment ) ) ) ) ?></label>
530 594 <?php endif ?>
531 595 <?php endif ?>
532 596 <?php elseif ( 'version' === $p['id'] && $has_paid_plan ) : ?>
@@ -554,9 +618,9 @@
554 618 <?php if ( $fs->has_release_on_freemius() ) : ?>
555 619 <div class="button-group">
556 620 <?php if ( $is_paying || $fs->is_trial() ) : ?>
557 621 <?php if ( ! $fs->is_allowed_to_install() ) : ?>
558 - <a target="_blank" class="button button-primary"
622 + <a target="_blank" rel="noopener" class="button button-primary"
559 623 href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php
560 624 $download_version_text_suffix = ( is_object( $update ) ? ' [' . $update->version . ']' : '' );
561 625
562 626 $download_version_text = sprintf(
@@ -593,9 +657,9 @@
593 657 </div>
594 658 <?php endif ?>
595 659 <?php
596 660 elseif ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
597 - <?php if ( ! $is_whitelabeled ) : ?>
661 + <?php if ( ! $is_whitelabeled && ( 'site_secret_key' === $p['id'] || ! $is_license_foreign ) ) : ?>
598 662 <button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button>
599 663 <?php endif ?>
600 664 <?php if ('license_key' === $p['id']) : ?>
601 665 <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>
@@ -606,8 +670,9 @@
606 670 'email',
607 671 'user_name'
608 672 ) ) )
609 673 ) : ?>
674 + <?php if ( 'email' !== $p['id'] || ! fs_is_network_admin() ) : ?>
610 675 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
611 676 onsubmit="var val = prompt('<?php echo esc_attr( sprintf(
612 677 /* translators: %s: User's account property (e.g. name, email) */
613 678 fs_text_inline( 'What is your %s?', 'what-is-your-x', $slug ),
@@ -616,11 +681,12 @@
616 681 <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
617 682 <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $fs->get_unique_affix() ?>"
618 683 value="">
619 684 <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
620 - <input type="submit" class="button button-small"
685 + <input type="submit" class="button button-small <?php if ( 'email' === $p['id'] ) echo 'button-edit-email-address' ?>"
621 686 value="<?php echo fs_esc_attr_x_inline( 'Edit', 'verb', 'edit', $slug ) ?>">
622 687 </form>
688 + <?php endif ?>
623 689 <?php elseif ( 'user_id' === $p['id'] && ! empty( $ids_of_installs_activated_with_foreign_licenses ) ) : ?>
624 690 <input id="fs_change_user" type="submit" class="button button-small"
625 691 value="<?php echo fs_esc_attr_inline( 'Change User', 'change-user', $slug ) ?>">
626 692 <?php endif ?>
@@ -678,14 +744,32 @@
678 744 </div>
679 745 <div class="fs-table-body">
680 746 <table class="widefat">
681 747 <?php
748 + $current_blog_id = get_current_blog_id();
749 +
682 750 foreach ( $site_view_params as $view_params ) {
683 751 fs_require_template(
684 752 'account/partials/site.php',
685 753 $view_params
686 754 );
687 - } ?>
755 + }
756 +
757 + /**
758 + * 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.
759 + *
760 + * @author Leo Fajardo (@leorw)
761 + * @since 2.5.0
762 + */
763 + $current_install = $fs->get_site();
764 +
765 + if (
766 + is_object( $site ) &&
767 + ( ! is_object( $current_install ) || $current_install->id != $site->id )
768 + ) {
769 + $fs->switch_to_blog( $current_blog_id, $site, true );
770 + }
771 + ?>
688 772 </table>
689 773 </div>
690 774 </div>
691 775 </div>
@@ -690,20 +774,8 @@
690 774 </div>
691 775 </div>
692 776 </div>
693 777 <?php endif ?>
694 -
695 - <?php
696 - $account_addons = $fs->get_updated_account_addons();
697 -
698 - $installed_addons = $fs->get_installed_addons();
699 - $installed_addons_ids = array();
700 - foreach ( $installed_addons as $fs_addon ) {
701 - $installed_addons_ids[] = $fs_addon->get_id();
702 - }
703 -
704 - $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
705 - ?>
706 778 <?php if ( 0 < count( $addons_to_show ) ) : ?>
707 779 <!-- Add-Ons -->
708 780 <div class="postbox">
709 781 <div class="">
@@ -716,9 +788,9 @@
716 788 <th><?php echo esc_html( $version_text ) ?></th>
717 789 <th><?php echo esc_html( $plan_text ) ?></th>
718 790 <th><?php fs_esc_html_echo_x_inline( 'License', 'as software license', 'license', $slug ) ?></th>
719 791 <th></th>
720 - <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
792 + <?php if ( $is_dev_mode ) : ?>
721 793 <th></th>
722 794 <?php endif ?>
723 795 </tr>
724 796 </thead>
@@ -782,12 +854,22 @@
782 854 $fs->_get_addon_info( $addon_id, $is_addon_installed ),
783 855 'is_whitelabeled' => ( $is_whitelabeled && ! $is_data_debug_mode )
784 856 );
785 857
786 - fs_require_template(
787 - 'account/partials/addon.php',
788 - $addon_view_params
789 - );
858 + if ( ! empty($addon_view_params['addon_info'] ) ) {
859 + fs_require_template(
860 + 'account/partials/addon.php',
861 + $addon_view_params
862 + );
863 + } else {
864 + // If we are here it means there is an activation of an unreleased add-on and yet the SDK is not in development mode.
865 + echo '<tr>';
866 + echo '<td style="text-align: right;">' . esc_html( $addon_id ) . '</td>';
867 + echo '<td colspan="' . ( $is_dev_mode ? 6 : 5 ) . '" style="text-align: left;">';
868 + echo 'The add-on you have activated is no longer <a href="https://freemius.com/help/documentation/wordpress/selling-add-ons-extensions/#preparing-the-add-on-for-sale" rel="noreferrer noopener" target="_blank">listed</a> by the product owner, or the SDK is not running in <a href="https://freemius.com/help/documentation/wordpress-sdk/testing/" rel="noreferrer noopener" target="_blank">test mode</a>. Please <a href="' . esc_url( $fs->contact_url() ) . '">contact support</a> if you need further assistance.';
869 + echo '</td>';
870 + echo '</tr>';
871 + }
790 872
791 873 $odd = ! $odd;
792 874 } ?>
793 875 </tbody>
@@ -799,9 +881,9 @@
799 881 <?php $fs->do_action( 'after_account_details' ) ?>
800 882
801 883 <?php
802 884 if ( $show_billing ) {
803 - $view_params = array( 'id' => $VARS['id'] );
885 + $view_params = array( 'id' => $VARS['id'], 'payments' => $payments );
804 886 fs_require_once_template( 'account/billing.php', $view_params );
805 887 fs_require_once_template( 'account/payments.php', $view_params );
806 888 }
807 889 ?>
@@ -879,9 +961,9 @@
879 961 isChecked = $checkbox.is( ':checked' );
880 962
881 963 if ( ! isChecked || confirm( '<?php echo $confirmation_message ?>' ) ) {
882 964 $.ajax( {
883 - url : ajaxurl,
965 + url : <?php echo Freemius::ajax_url() ?>,
884 966 method: 'POST',
885 967 data : {
886 968 action : '<?php echo $fs->get_ajax_action( 'set_beta_mode' ) ?>',
887 969 security : '<?php echo $fs->get_ajax_security( 'set_beta_mode' ) ?>',
@@ -1018,8 +1100,31 @@
1018 1100 }
1019 1101 });
1020 1102 });
1021 1103
1104 + $( '.fs-toggle-whitelabel-mode' ).click( function () {
1105 + var $toggleLink = $( this );
1106 +
1107 + $.ajax( {
1108 + url : <?php echo Freemius::ajax_url() ?>,
1109 + method: 'POST',
1110 + data : {
1111 + action : '<?php echo $fs->get_ajax_action( 'toggle_whitelabel_mode' ) ?>',
1112 + security : '<?php echo $fs->get_ajax_security( 'toggle_whitelabel_mode' ) ?>',
1113 + module_id: <?php echo $fs->get_id() ?>
1114 + },
1115 + beforeSend: function () {
1116 + $toggleLink.parent().text( '<?php
1117 + $is_whitelabeled ?
1118 + fs_esc_html_echo_inline( 'Disabling white-label mode', 'disabling-whitelabel-mode' ) :
1119 + fs_esc_html_echo_inline( 'Enabling white-label mode', 'enabling-whitelabel-mode' )
1120 + ?>' + '...' );
1121 + },
1122 + complete: function () {
1123 + location.reload();
1124 + }
1125 + } );
1126 + });
1022 1127 })(jQuery);
1023 1128 </script>
1024 1129 <?php
1025 1130 if ( $has_tabs ) {
@@ -1024,13 +1129,4 @@
1024 1129 <?php
1025 1130 if ( $has_tabs ) {
1026 1131 $fs->_add_tabs_after_content();
1027 1132 }
1028 -
1029 - $params = array(
1030 - 'page' => 'account',
1031 - 'module_id' => $fs->get_id(),
1032 - 'module_type' => $fs->get_module_type(),
1033 - 'module_slug' => $slug,
1034 - 'module_version' => $fs->get_plugin_version(),
1035 - );
1036 - fs_require_template( 'powered-by.php', $params );