| @@ -162,21 +162,30 @@ | ||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $is_child_license = ( is_object( $license ) && FS_Plugin_License::is_valid_id( $license->parent_license_id ) ); | |
| 167 | - $bundle_subscription = null; | |
| 166 | + $has_bundle_license = false; | |
| 168 | 167 | |
| 168 | + if ( is_object( $license ) && | |
| 169 | + FS_Plugin_License::is_valid_id( $license->parent_license_id ) | |
| 170 | + ) { | |
| 171 | + // Context license has a parent license, therefore, the account has a bundle license. | |
| 172 | + $has_bundle_license = true; | |
| 173 | + } | |
| 174 | + | |
| 175 | + $bundle_subscription = null; | |
| 176 | + $is_bundle_first_payment_pending = false; | |
| 177 | + | |
| 169 | 178 | if ( |
| 170 | 179 | $show_plan_row && |
| 171 | 180 | is_object( $license ) && |
| 172 | - FS_Plugin_License::is_valid_id( $license->parent_license_id ) | |
| 181 | + $has_bundle_license | |
| 173 | 182 | ) { |
| 174 | - $bundle_subscription = $fs->_get_subscription( $license->parent_license_id ); | |
| 183 | + $bundle_plan_title = strtoupper( $license->parent_plan_title ); | |
| 184 | + $bundle_subscription = $fs->_get_subscription( $license->parent_license_id ); | |
| 185 | + $is_bundle_first_payment_pending = $license->is_first_payment_pending(); | |
| 175 | 186 | } |
| 176 | 187 | |
| 177 | - $is_active_bundle_subscription = ( is_object( $bundle_subscription ) && $bundle_subscription->is_active() ); | |
| 178 | - | |
| 179 | 188 | $fs_blog_id = ( is_multisite() && ! is_network_admin() ) ? |
| 180 | 189 | get_current_blog_id() : |
| 181 | 190 | 0; |
| 182 | 191 | |
| @@ -182,8 +191,48 @@ | ||
| 182 | 191 | |
| 183 | 192 | $active_plugins_directories_map = Freemius::get_active_plugins_directories_map( $fs_blog_id ); |
| 184 | 193 | |
| 185 | 194 | $is_premium = $fs->is_premium(); |
| 195 | + | |
| 196 | + $account_addons = $fs->get_updated_account_addons(); | |
| 197 | + $installed_addons = $fs->get_installed_addons(); | |
| 198 | + $installed_addons_ids = array(); | |
| 199 | + | |
| 200 | + /** | |
| 201 | + * 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. | |
| 202 | + * | |
| 203 | + * @author Leo Fajardo | |
| 204 | + * | |
| 205 | + * @since 2.4.0 | |
| 206 | + */ | |
| 207 | + foreach ( $installed_addons as $fs_addon ) { | |
| 208 | + $installed_addons_ids[] = $fs_addon->get_id(); | |
| 209 | + | |
| 210 | + if ( $has_bundle_license ) { | |
| 211 | + // We already have the context bundle license details, skip. | |
| 212 | + continue; | |
| 213 | + } | |
| 214 | + | |
| 215 | + if ( | |
| 216 | + $show_plan_row && | |
| 217 | + $fs_addon->has_active_valid_license() | |
| 218 | + ) { | |
| 219 | + $addon_license = $fs_addon->_get_license(); | |
| 220 | + | |
| 221 | + if ( FS_Plugin_License::is_valid_id( $addon_license->parent_license_id ) ) { | |
| 222 | + // Add-on's license is associated with a parent/bundle license. | |
| 223 | + $has_bundle_license = true; | |
| 224 | + | |
| 225 | + $bundle_plan_title = strtoupper( $addon_license->parent_plan_title ); | |
| 226 | + $bundle_subscription = $fs_addon->_get_subscription( $addon_license->parent_license_id ); | |
| 227 | + $is_bundle_first_payment_pending = $addon_license->is_first_payment_pending(); | |
| 228 | + } | |
| 229 | + } | |
| 230 | + } | |
| 231 | + | |
| 232 | + $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) ); | |
| 233 | + | |
| 234 | + $is_active_bundle_subscription = ( is_object( $bundle_subscription ) && $bundle_subscription->is_active() ); | |
| 186 | 235 | ?> |
| 187 | 236 | <div class="wrap fs-section"> |
| 188 | 237 | <?php if ( ! $has_tabs && ! $fs->apply_filters( 'hide_account_tabs', false ) ) : ?> |
| 189 | 238 | <h2 class="nav-tab-wrapper"> |
| @@ -391,9 +440,9 @@ | ||
| 391 | 440 | 'value' => $user->is_beta |
| 392 | 441 | ); |
| 393 | 442 | } |
| 394 | 443 | |
| 395 | - if ( $has_paid_plan ) { | |
| 444 | + if ( $has_paid_plan || $has_bundle_license ) { | |
| 396 | 445 | if ( $fs->is_trial() ) { |
| 397 | 446 | if ( $show_plan_row ) { |
| 398 | 447 | $profile[] = array( |
| 399 | 448 | 'id' => 'plan', |
| @@ -406,9 +455,9 @@ | ||
| 406 | 455 | } else { |
| 407 | 456 | if ( $show_plan_row ) { |
| 408 | 457 | $profile[] = array( |
| 409 | 458 | 'id' => 'plan', |
| 410 | - 'title' => ( $is_child_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text, | |
| 459 | + 'title' => ( $has_bundle_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text, | |
| 411 | 460 | 'value' => strtoupper( is_string( $plan->name ) ? |
| 412 | 461 | $plan->title : |
| 413 | 462 | strtoupper( $free_text ) |
| 414 | 463 | ) |
| @@ -413,13 +462,13 @@ | ||
| 413 | 462 | strtoupper( $free_text ) |
| 414 | 463 | ) |
| 415 | 464 | ); |
| 416 | 465 | |
| 417 | - if ( $is_child_license ) { | |
| 466 | + if ( $has_bundle_license ) { | |
| 418 | 467 | $profile[] = array( |
| 419 | 468 | 'id' => 'bundle_plan', |
| 420 | 469 | 'title' => $bundle_plan_text, |
| 421 | - 'value' => strtoupper( $license->parent_plan_title ) | |
| 470 | + 'value' => $bundle_plan_title | |
| 422 | 471 | ); |
| 423 | 472 | } |
| 424 | 473 | } |
| 425 | 474 | |
| @@ -524,9 +573,9 @@ | ||
| 524 | 573 | </div> |
| 525 | 574 | <?php endif ?> |
| 526 | 575 | <?php elseif ( 'bundle_plan' === $p['id'] ) : ?> |
| 527 | 576 | <?php if ( is_object( $bundle_subscription ) ) : ?> |
| 528 | - <?php if ( $is_active_bundle_subscription && ! $license->is_first_payment_pending() ) : ?> | |
| 577 | + <?php if ( $is_active_bundle_subscription && ! $is_bundle_first_payment_pending ) : ?> | |
| 529 | 578 | <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 | 579 | <?php endif ?> |
| 531 | 580 | <?php endif ?> |
| 532 | 581 | <?php elseif ( 'version' === $p['id'] && $has_paid_plan ) : ?> |
| @@ -554,9 +603,9 @@ | ||
| 554 | 603 | <?php if ( $fs->has_release_on_freemius() ) : ?> |
| 555 | 604 | <div class="button-group"> |
| 556 | 605 | <?php if ( $is_paying || $fs->is_trial() ) : ?> |
| 557 | 606 | <?php if ( ! $fs->is_allowed_to_install() ) : ?> |
| 558 | - <a target="_blank" class="button button-primary" | |
| 607 | + <a target="_blank" rel="noopener" class="button button-primary" | |
| 559 | 608 | href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php |
| 560 | 609 | $download_version_text_suffix = ( is_object( $update ) ? ' [' . $update->version . ']' : '' ); |
| 561 | 610 | |
| 562 | 611 | $download_version_text = sprintf( |
| @@ -690,20 +739,8 @@ | ||
| 690 | 739 | </div> |
| 691 | 740 | </div> |
| 692 | 741 | </div> |
| 693 | 742 | <?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 | 743 | <?php if ( 0 < count( $addons_to_show ) ) : ?> |
| 707 | 744 | <!-- Add-Ons --> |
| 708 | 745 | <div class="postbox"> |
| 709 | 746 | <div class=""> |
| @@ -1018,8 +1055,31 @@ | ||
| 1018 | 1055 | } |
| 1019 | 1056 | }); |
| 1020 | 1057 | }); |
| 1021 | 1058 | |
| 1059 | + $( '.fs-toggle-whitelabel-mode' ).click( function () { | |
| 1060 | + var $toggleLink = $( this ); | |
| 1061 | + | |
| 1062 | + $.ajax( { | |
| 1063 | + url : ajaxurl, | |
| 1064 | + method: 'POST', | |
| 1065 | + data : { | |
| 1066 | + action : '<?php echo $fs->get_ajax_action( 'toggle_whitelabel_mode' ) ?>', | |
| 1067 | + security : '<?php echo $fs->get_ajax_security( 'toggle_whitelabel_mode' ) ?>', | |
| 1068 | + module_id: <?php echo $fs->get_id() ?> | |
| 1069 | + }, | |
| 1070 | + beforeSend: function () { | |
| 1071 | + $toggleLink.parent().text( '<?php | |
| 1072 | + $is_whitelabeled ? | |
| 1073 | + fs_esc_html_echo_inline( 'Disabling white-label mode', 'disabling-whitelabel-mode' ) : | |
| 1074 | + fs_esc_html_echo_inline( 'Enabling white-label mode', 'enabling-whitelabel-mode' ) | |
| 1075 | + ?>' + '...' ); | |
| 1076 | + }, | |
| 1077 | + complete: function () { | |
| 1078 | + location.reload(); | |
| 1079 | + } | |
| 1080 | + } ); | |
| 1081 | + }); | |
| 1022 | 1082 | })(jQuery); |
| 1023 | 1083 | </script> |
| 1024 | 1084 | <?php |
| 1025 | 1085 | if ( $has_tabs ) { |