| @@ -29,19 +29,12 @@ | ||
| 29 | 29 | |
| 30 | 30 | if ( $fs->is_registered() ) { |
| 31 | 31 | $activate_button_text = $header_title; |
| 32 | 32 | } else { |
| 33 | - $freemius_site_url = $fs->has_paid_plan() ? | |
| 34 | - 'https://freemius.com/' : | |
| 35 | - // Insights platform information. | |
| 36 | - $fs->get_usage_tracking_terms_url(); | |
| 37 | - | |
| 38 | - $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" rel="noopener" tabindex="0">freemius.com</a>'; | |
| 39 | - | |
| 40 | 33 | $message_below_input_field = sprintf( |
| 41 | - fs_text_inline( 'The %1$s will be periodically sending data to %2$s to check for security and feature updates, and verify the validity of your license.', 'license-sync-disclaimer', $slug ), | |
| 34 | + fs_text_inline( 'The %1$s will be periodically sending essential license data to %2$s to check for security and feature updates, and verify the validity of your license.', 'license-sync-disclaimer', $slug ), | |
| 42 | 35 | $fs->get_module_label( true ), |
| 43 | - $freemius_link | |
| 36 | + "<b>{$fs->get_plugin_title()}</b>" | |
| 44 | 37 | ); |
| 45 | 38 | |
| 46 | 39 | $activate_button_text = fs_text_inline( 'Agree & Activate License', 'agree-activate-license', $slug ); |
| 47 | 40 | } |
| @@ -58,25 +51,56 @@ | ||
| 58 | 51 | $sites_details = array(); |
| 59 | 52 | if ( $is_network_activation ) { |
| 60 | 53 | $all_sites = Freemius::get_sites(); |
| 61 | 54 | |
| 55 | + $all_site_details = array(); | |
| 56 | + $subsite_url_by_install_id = array(); | |
| 57 | + $install_url_by_install_id = array(); | |
| 58 | + | |
| 62 | 59 | foreach ( $all_sites as $site ) { |
| 63 | 60 | $site_details = $fs->get_site_info( $site ); |
| 64 | 61 | |
| 62 | + if ( FS_Clone_Manager::instance()->is_temporary_duplicate_by_blog_id( $site_details['blog_id'] ) ) { | |
| 63 | + continue; | |
| 64 | + } | |
| 65 | + | |
| 65 | 66 | $blog_id = Freemius::get_site_blog_id( $site ); |
| 66 | 67 | $install = $fs->get_install_by_blog_id($blog_id); |
| 67 | 68 | |
| 68 | - if ( is_object( $install ) && FS_Plugin_License::is_valid_id( $install->license_id ) ) { | |
| 69 | - $site_details['license_id'] = $install->license_id; | |
| 69 | + if ( is_object( $install ) ) { | |
| 70 | + if ( isset( $subsite_url_by_install_id[ $install->id ] ) ) { | |
| 71 | + $clone_subsite_url = $subsite_url_by_install_id[ $install->id ]; | |
| 72 | + $clone_install_url = $install_url_by_install_id[ $install->id ]; | |
| 73 | + | |
| 74 | + if ( | |
| 75 | + /** | |
| 76 | + * If we already have an install with the same URL as the subsite it's stored in, skip the current subsite. Otherwise, replace the existing install's data with the current subsite's install's data if the URLs match. | |
| 77 | + * | |
| 78 | + * @author Leo Fajardo (@leorw) | |
| 79 | + * @since 2.5.0 | |
| 80 | + */ | |
| 81 | + fs_strip_url_protocol( untrailingslashit( $clone_install_url ) ) === fs_strip_url_protocol( untrailingslashit( $clone_subsite_url ) ) || | |
| 82 | + fs_strip_url_protocol( untrailingslashit( $install->url ) ) !== fs_strip_url_protocol( untrailingslashit( $site_details['url'] ) ) | |
| 83 | + ) { | |
| 84 | + continue; | |
| 85 | + } | |
| 86 | + } | |
| 87 | + | |
| 88 | + if ( FS_Plugin_License::is_valid_id( $install->license_id ) ) { | |
| 89 | + $site_details['license_id'] = $install->license_id; | |
| 90 | + } | |
| 91 | + | |
| 92 | + $subsite_url_by_install_id[ $install->id ] = $site_details['url']; | |
| 93 | + $install_url_by_install_id[ $install->id ] = $install->url; | |
| 70 | 94 | } |
| 71 | 95 | |
| 72 | - $sites_details[] = $site_details; | |
| 96 | + $all_site_details[] = $site_details; | |
| 73 | 97 | } |
| 74 | 98 | |
| 75 | 99 | if ( $is_network_activation ) { |
| 76 | 100 | $vars = array( |
| 77 | 101 | 'id' => $fs->get_id(), |
| 78 | - 'sites' => $sites_details, | |
| 102 | + 'sites' => $all_site_details, | |
| 79 | 103 | 'require_license_key' => true |
| 80 | 104 | ); |
| 81 | 105 | |
| 82 | 106 | $network_activation_html = fs_get_template( 'partials/network-activation.php', $vars ); |
| @@ -126,9 +150,9 @@ | ||
| 126 | 150 | ( is_object( $plan ) ? $plan->title : '' ), |
| 127 | 151 | $license->get_html_escaped_masked_secret_key() |
| 128 | 152 | ); |
| 129 | 153 | |
| 130 | - $license_input_html .= "<option data-id='{$license->id}' value='{$license->secret_key}' data-left='{$license->left()}'>{$label}</option>"; | |
| 154 | + $license_input_html .= "<option data-id='{$license->id}' value='{$license->id}' data-left='{$license->left()}'>{$label}</option>"; | |
| 131 | 155 | } |
| 132 | 156 | |
| 133 | 157 | $license_input_html .= '</select>'; |
| 134 | 158 | } else { |
| @@ -153,9 +177,8 @@ | ||
| 153 | 177 | class="fs-available-license-key" |
| 154 | 178 | type="text" |
| 155 | 179 | value="{$value}" |
| 156 | 180 | data-id="{$available_license->id}" |
| 157 | - data-license-key="{$available_license->secret_key}" | |
| 158 | 181 | data-left="{$available_license->left()}" |
| 159 | 182 | readonly /> |
| 160 | 183 | HTML; |
| 161 | 184 | } |
| @@ -285,8 +308,9 @@ | ||
| 285 | 308 | * @since 2.3.2 |
| 286 | 309 | */ |
| 287 | 310 | afterLicenseUserDataLoaded = function () { |
| 288 | 311 | if ( |
| 312 | + false !== otherLicenseOwnerID && | |
| 289 | 313 | null !== otherLicenseOwnerID && |
| 290 | 314 | otherLicenseOwnerID != <?php echo $fs->is_registered() ? $fs->get_user()->id : 'null' ?> |
| 291 | 315 | ) { |
| 292 | 316 | $ownershipChangeOptionContainer.show(); |
| @@ -340,9 +364,9 @@ | ||
| 340 | 364 | $activateLicenseButton.attr( 'disabled', 'disabled' ); |
| 341 | 365 | $activateLicenseButton.html( '<?php fs_esc_js_echo_inline( 'Please wait', 'please-wait', $slug ) ?>...' ); |
| 342 | 366 | |
| 343 | 367 | $.ajax( { |
| 344 | - url : ajaxurl, | |
| 368 | + url : <?php echo Freemius::ajax_url() ?>, | |
| 345 | 369 | method : 'POST', |
| 346 | 370 | data : { |
| 347 | 371 | action : '<?php echo $fs->get_ajax_action( 'fetch_is_marketing_required_flag_value' ) ?>', |
| 348 | 372 | security : '<?php echo $fs->get_ajax_security( 'fetch_is_marketing_required_flag_value' ) ?>', |
| @@ -537,10 +561,10 @@ | ||
| 537 | 561 | if ($(this).hasClass('disabled')) { |
| 538 | 562 | return; |
| 539 | 563 | } |
| 540 | 564 | |
| 541 | - var | |
| 542 | - licenseKey = ''; | |
| 565 | + var licenseKey = '', | |
| 566 | + licenseID = ''; | |
| 543 | 567 | |
| 544 | 568 | if ( hasLicenseTypes ) { |
| 545 | 569 | if ( isOtherLicenseKeySelected() ) { |
| 546 | 570 | licenseKey = $otherLicenseKey.val(); |
| @@ -545,11 +569,11 @@ | ||
| 545 | 569 | if ( isOtherLicenseKeySelected() ) { |
| 546 | 570 | licenseKey = $otherLicenseKey.val(); |
| 547 | 571 | } else { |
| 548 | 572 | if ( ! hasLicensesDropdown ) { |
| 549 | - licenseKey = $availableLicenseKey.data( 'license-key' ); | |
| 573 | + licenseID = $availableLicenseKey.data( 'id' ).toString(); | |
| 550 | 574 | } else { |
| 551 | - licenseKey = $licensesDropdown.val(); | |
| 575 | + licenseID = $licensesDropdown.val(); | |
| 552 | 576 | } |
| 553 | 577 | } |
| 554 | 578 | } else { |
| 555 | 579 | licenseKey = $licenseKeyInput.val().trim(); |
| @@ -556,9 +580,9 @@ | ||
| 556 | 580 | } |
| 557 | 581 | |
| 558 | 582 | disableActivateLicenseButton(); |
| 559 | 583 | |
| 560 | - if (0 === licenseKey.length) { | |
| 584 | + if ( 0 === licenseID.length && 0 === licenseKey.length ) { | |
| 561 | 585 | return; |
| 562 | 586 | } |
| 563 | 587 | |
| 564 | 588 | var data = { |
| @@ -563,12 +587,17 @@ | ||
| 563 | 587 | |
| 564 | 588 | var data = { |
| 565 | 589 | action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>', |
| 566 | 590 | security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>', |
| 567 | - license_key: licenseKey, | |
| 568 | 591 | module_id : '<?php echo $fs->get_id() ?>' |
| 569 | 592 | }; |
| 570 | 593 | |
| 594 | + if ( licenseID.length > 0 ) { | |
| 595 | + data.license_id = licenseID; | |
| 596 | + } else { | |
| 597 | + data.license_key = licenseKey; | |
| 598 | + } | |
| 599 | + | |
| 571 | 600 | if ( isNetworkActivation ) { |
| 572 | 601 | var |
| 573 | 602 | sites = []; |
| 574 | 603 | |
| @@ -588,9 +617,8 @@ | ||
| 588 | 617 | uid : $this.find( '.uid' ).val(), |
| 589 | 618 | url : $this.find( '.url' ).val(), |
| 590 | 619 | title : $this.find( '.title' ).val(), |
| 591 | 620 | language: $this.find( '.language' ).val(), |
| 592 | - charset : $this.find( '.charset' ).val(), | |
| 593 | 621 | blog_id : $this.find( '.blog-id' ).find( 'span' ).text() |
| 594 | 622 | }; |
| 595 | 623 | |
| 596 | 624 | sites.push( site ); |
| @@ -606,9 +634,9 @@ | ||
| 606 | 634 | data.user_id = otherLicenseOwnerID; |
| 607 | 635 | } |
| 608 | 636 | |
| 609 | 637 | $.ajax({ |
| 610 | - url: ajaxurl, | |
| 638 | + url: <?php echo Freemius::ajax_url() ?>, | |
| 611 | 639 | method: 'POST', |
| 612 | 640 | data: data, |
| 613 | 641 | beforeSend: function () { |
| 614 | 642 | $activateLicenseButton.text( '<?php fs_esc_js_echo_inline( 'Activating license', 'activating-license', $slug ) ?>...' ); |
| @@ -866,5 +894,7 @@ | ||
| 866 | 894 | $licenseActivationMessage.show(); |
| 867 | 895 | } |
| 868 | 896 | }); |
| 869 | 897 | })( jQuery ); |
| 870 | -</script> | |
| 898 | +</script> | |
| 899 | +<?php | |
| 900 | + fs_require_once_template( 'api-connectivity-message-js.php' ); | |