← All changes
|
libraries/freemius/templates/forms/license-activation.php
+25
-17
2.1.7
→
3.4
View file →
| @@ -51,10 +51,11 @@ | ||
| 51 | 51 | $sites_details = array(); |
| 52 | 52 | if ( $is_network_activation ) { |
| 53 | 53 | $all_sites = Freemius::get_sites(); |
| 54 | 54 | |
| 55 | - $subsite_data_by_install_id = array(); | |
| 56 | - $install_url_by_install_id = array(); | |
| 55 | + $all_site_details = array(); | |
| 56 | + $subsite_url_by_install_id = array(); | |
| 57 | + $install_url_by_install_id = array(); | |
| 57 | 58 | |
| 58 | 59 | foreach ( $all_sites as $site ) { |
| 59 | 60 | $site_details = $fs->get_site_info( $site ); |
| 60 | 61 | |
| @@ -65,11 +66,11 @@ | ||
| 65 | 66 | $blog_id = Freemius::get_site_blog_id( $site ); |
| 66 | 67 | $install = $fs->get_install_by_blog_id($blog_id); |
| 67 | 68 | |
| 68 | 69 | if ( is_object( $install ) ) { |
| 69 | - if ( isset( $subsite_data_by_install_id[ $install->id ] ) ) { | |
| 70 | - $clone_subsite_data = $subsite_data_by_install_id[ $install->id ]; | |
| 71 | - $clone_install_url = $install_url_by_install_id[ $install->id ]; | |
| 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 ]; | |
| 72 | 73 | |
| 73 | 74 | if ( |
| 74 | 75 | /** |
| 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. |
| @@ -76,9 +77,9 @@ | ||
| 76 | 77 | * |
| 77 | 78 | * @author Leo Fajardo (@leorw) |
| 78 | 79 | * @since 2.5.0 |
| 79 | 80 | */ |
| 80 | - fs_strip_url_protocol( untrailingslashit( $clone_install_url ) ) === fs_strip_url_protocol( untrailingslashit( $clone_subsite_data['url'] ) ) || | |
| 81 | + fs_strip_url_protocol( untrailingslashit( $clone_install_url ) ) === fs_strip_url_protocol( untrailingslashit( $clone_subsite_url ) ) || | |
| 81 | 82 | fs_strip_url_protocol( untrailingslashit( $install->url ) ) !== fs_strip_url_protocol( untrailingslashit( $site_details['url'] ) ) |
| 82 | 83 | ) { |
| 83 | 84 | continue; |
| 84 | 85 | } |
| @@ -87,17 +88,19 @@ | ||
| 87 | 88 | if ( FS_Plugin_License::is_valid_id( $install->license_id ) ) { |
| 88 | 89 | $site_details['license_id'] = $install->license_id; |
| 89 | 90 | } |
| 90 | 91 | |
| 91 | - $subsite_data_by_install_id[ $install->id ] = $site_details; | |
| 92 | - $install_url_by_install_id[ $install->id ] = $install->url; | |
| 92 | + $subsite_url_by_install_id[ $install->id ] = $site_details['url']; | |
| 93 | + $install_url_by_install_id[ $install->id ] = $install->url; | |
| 93 | 94 | } |
| 95 | + | |
| 96 | + $all_site_details[] = $site_details; | |
| 94 | 97 | } |
| 95 | 98 | |
| 96 | 99 | if ( $is_network_activation ) { |
| 97 | 100 | $vars = array( |
| 98 | 101 | 'id' => $fs->get_id(), |
| 99 | - 'sites' => array_values( $subsite_data_by_install_id ), | |
| 102 | + 'sites' => $all_site_details, | |
| 100 | 103 | 'require_license_key' => true |
| 101 | 104 | ); |
| 102 | 105 | |
| 103 | 106 | $network_activation_html = fs_get_template( 'partials/network-activation.php', $vars ); |
| @@ -147,9 +150,9 @@ | ||
| 147 | 150 | ( is_object( $plan ) ? $plan->title : '' ), |
| 148 | 151 | $license->get_html_escaped_masked_secret_key() |
| 149 | 152 | ); |
| 150 | 153 | |
| 151 | - $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>"; | |
| 152 | 155 | } |
| 153 | 156 | |
| 154 | 157 | $license_input_html .= '</select>'; |
| 155 | 158 | } else { |
| @@ -174,9 +177,8 @@ | ||
| 174 | 177 | class="fs-available-license-key" |
| 175 | 178 | type="text" |
| 176 | 179 | value="{$value}" |
| 177 | 180 | data-id="{$available_license->id}" |
| 178 | - data-license-key="{$available_license->secret_key}" | |
| 179 | 181 | data-left="{$available_license->left()}" |
| 180 | 182 | readonly /> |
| 181 | 183 | HTML; |
| 182 | 184 | } |
| @@ -306,8 +308,9 @@ | ||
| 306 | 308 | * @since 2.3.2 |
| 307 | 309 | */ |
| 308 | 310 | afterLicenseUserDataLoaded = function () { |
| 309 | 311 | if ( |
| 312 | + false !== otherLicenseOwnerID && | |
| 310 | 313 | null !== otherLicenseOwnerID && |
| 311 | 314 | otherLicenseOwnerID != <?php echo $fs->is_registered() ? $fs->get_user()->id : 'null' ?> |
| 312 | 315 | ) { |
| 313 | 316 | $ownershipChangeOptionContainer.show(); |
| @@ -558,10 +561,10 @@ | ||
| 558 | 561 | if ($(this).hasClass('disabled')) { |
| 559 | 562 | return; |
| 560 | 563 | } |
| 561 | 564 | |
| 562 | - var | |
| 563 | - licenseKey = ''; | |
| 565 | + var licenseKey = '', | |
| 566 | + licenseID = ''; | |
| 564 | 567 | |
| 565 | 568 | if ( hasLicenseTypes ) { |
| 566 | 569 | if ( isOtherLicenseKeySelected() ) { |
| 567 | 570 | licenseKey = $otherLicenseKey.val(); |
| @@ -566,11 +569,11 @@ | ||
| 566 | 569 | if ( isOtherLicenseKeySelected() ) { |
| 567 | 570 | licenseKey = $otherLicenseKey.val(); |
| 568 | 571 | } else { |
| 569 | 572 | if ( ! hasLicensesDropdown ) { |
| 570 | - licenseKey = $availableLicenseKey.data( 'license-key' ); | |
| 573 | + licenseID = $availableLicenseKey.data( 'id' ).toString(); | |
| 571 | 574 | } else { |
| 572 | - licenseKey = $licensesDropdown.val(); | |
| 575 | + licenseID = $licensesDropdown.val(); | |
| 573 | 576 | } |
| 574 | 577 | } |
| 575 | 578 | } else { |
| 576 | 579 | licenseKey = $licenseKeyInput.val().trim(); |
| @@ -577,9 +580,9 @@ | ||
| 577 | 580 | } |
| 578 | 581 | |
| 579 | 582 | disableActivateLicenseButton(); |
| 580 | 583 | |
| 581 | - if (0 === licenseKey.length) { | |
| 584 | + if ( 0 === licenseID.length && 0 === licenseKey.length ) { | |
| 582 | 585 | return; |
| 583 | 586 | } |
| 584 | 587 | |
| 585 | 588 | var data = { |
| @@ -584,11 +587,16 @@ | ||
| 584 | 587 | |
| 585 | 588 | var data = { |
| 586 | 589 | action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>', |
| 587 | 590 | security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>', |
| 588 | - license_key: licenseKey, | |
| 589 | 591 | module_id : '<?php echo $fs->get_id() ?>' |
| 590 | 592 | }; |
| 593 | + | |
| 594 | + if ( licenseID.length > 0 ) { | |
| 595 | + data.license_id = licenseID; | |
| 596 | + } else { | |
| 597 | + data.license_key = licenseKey; | |
| 598 | + } | |
| 591 | 599 | |
| 592 | 600 | if ( isNetworkActivation ) { |
| 593 | 601 | var |
| 594 | 602 | sites = []; |