| @@ -12,10 +12,11 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @var Freemius $fs |
| 15 | 15 | */ |
| 16 | - $fs = freemius( $VARS['id'] ); | |
| 17 | - $slug = $fs->get_slug(); | |
| 16 | + $fs = freemius( $VARS['id'] ); | |
| 17 | + $slug = $fs->get_slug(); | |
| 18 | + $unique_affix = $fs->get_unique_affix(); | |
| 18 | 19 | |
| 19 | 20 | $cant_find_license_key_text = fs_text_inline( "Can't find your license key?", 'cant-find-license-key', $slug ); |
| 20 | 21 | $message_above_input_field = fs_text_inline( 'Please enter the license key that you received in the email right after the purchase:', 'activate-license-message', $slug ); |
| 21 | 22 | $message_below_input_field = ''; |
| @@ -93,12 +94,12 @@ | ||
| 93 | 94 | |
| 94 | 95 | $total_available_licenses = count( $available_licenses ); |
| 95 | 96 | if ( $total_available_licenses > 0 ) { |
| 96 | 97 | $license_input_html = <<< HTML |
| 97 | - <div id="license_options_container"> | |
| 98 | + <div class="fs-license-options-container"> | |
| 98 | 99 | <table> |
| 99 | 100 | <tbody> |
| 100 | - <tr id="available_license_key_container"> | |
| 101 | + <tr class="fs-available-license-key-container"> | |
| 101 | 102 | <td><input type="radio" name="license_type" value="available"></td> |
| 102 | 103 | <td> |
| 103 | 104 | HTML; |
| 104 | 105 | |
| @@ -105,9 +106,9 @@ | ||
| 105 | 106 | if ( $total_available_licenses > 1 ) { |
| 106 | 107 | // Sort the licenses by number of activations left in descending order. |
| 107 | 108 | krsort( $available_licenses ); |
| 108 | 109 | |
| 109 | - $license_input_html .= '<select id="licenses">'; | |
| 110 | + $license_input_html .= '<select class="fs-licenses">'; | |
| 110 | 111 | |
| 111 | 112 | /** |
| 112 | 113 | * @var FS_Plugin_License $license |
| 113 | 114 | */ |
| @@ -115,9 +116,9 @@ | ||
| 115 | 116 | $label = sprintf( |
| 116 | 117 | "%s-Site %s License - %s", |
| 117 | 118 | ( 1 == $license->quota ? |
| 118 | 119 | 'Single' : |
| 119 | - $license->quota | |
| 120 | + ( $license->is_unlimited() ? 'Unlimited' : $license->quota ) | |
| 120 | 121 | ), |
| 121 | 122 | $fs->_get_plan_by_id( $license->plan_id )->title, |
| 122 | 123 | ( htmlspecialchars( substr( $license->secret_key, 0, 6 ) ) . |
| 123 | 124 | str_pad( '', 23 * 6, '•' ) . |
| @@ -148,9 +149,9 @@ | ||
| 148 | 149 | ); |
| 149 | 150 | |
| 150 | 151 | $license_input_html .= <<< HTML |
| 151 | 152 | <input |
| 152 | - id="available_license_key" | |
| 153 | + class="fs-available-license-key" | |
| 153 | 154 | type="text" |
| 154 | 155 | value="{$value}" |
| 155 | 156 | data-id="{$available_license->id}" |
| 156 | 157 | data-license-key="{$available_license->secret_key}" |
| @@ -163,12 +164,12 @@ | ||
| 163 | 164 | </td> |
| 164 | 165 | </tr> |
| 165 | 166 | <tr> |
| 166 | 167 | <td><input type="radio" name="license_type" value="other"></td> |
| 167 | - <td id="other_license_key_container"> | |
| 168 | - <label for="other_license_key">Other: </label> | |
| 168 | + <td class="fs-other-license-key-container"> | |
| 169 | + <label for="other_license_key_{$unique_affix}">Other: </label> | |
| 169 | 170 | <div> |
| 170 | - <input id="other_license_key" class="license_key" type="text" placeholder="Enter license key" tabindex="1"> | |
| 171 | + <input id="other_license_key_{$unique_affix}" class="fs-license-key" type="text" placeholder="Enter license key" tabindex="1"> | |
| 171 | 172 | </div> |
| 172 | 173 | </td> |
| 173 | 174 | </tr> |
| 174 | 175 | </tbody> |
| @@ -175,9 +176,9 @@ | ||
| 175 | 176 | </table> |
| 176 | 177 | </div> |
| 177 | 178 | HTML; |
| 178 | 179 | } else { |
| 179 | - $license_input_html = "<input class='license_key' type='text' placeholder='{$license_key_text}' tabindex='1' />"; | |
| 180 | + $license_input_html = "<input class='fs-license-key' type='text' placeholder='{$license_key_text}' tabindex='1' />"; | |
| 180 | 181 | } |
| 181 | 182 | |
| 182 | 183 | /** |
| 183 | 184 | * IMPORTANT: |
| @@ -200,9 +201,9 @@ | ||
| 200 | 201 | (function( $ ) { |
| 201 | 202 | $( document ).ready(function() { |
| 202 | 203 | var modalContentHtml = <?php echo json_encode($modal_content_html); ?>, |
| 203 | 204 | modalHtml = |
| 204 | - '<div class="fs-modal fs-modal-license-activation">' | |
| 205 | + '<div class="fs-modal fs-modal-license-activation fs-modal-license-activation-<?php echo $unique_affix ?>">' | |
| 205 | 206 | + ' <div class="fs-modal-dialog">' |
| 206 | 207 | + ' <div class="fs-modal-header">' |
| 207 | 208 | + ' <h4><?php echo esc_js($header_title) ?></h4>' |
| 208 | 209 | + ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'as close a window', 'dismiss', $slug ) ) ?>"></i></a>' |
| @@ -216,11 +217,11 @@ | ||
| 216 | 217 | + ' </div>' |
| 217 | 218 | + ' </div>' |
| 218 | 219 | + '</div>', |
| 219 | 220 | $modal = $(modalHtml), |
| 220 | - $activateLicenseLink = $('span.activate-license.<?php echo $fs->get_unique_affix() ?> a, .activate-license-trigger.<?php echo $fs->get_unique_affix() ?>'), | |
| 221 | + $activateLicenseLink = $('span.activate-license.<?php echo $unique_affix ?> a, .activate-license-trigger.<?php echo $unique_affix ?>'), | |
| 221 | 222 | $activateLicenseButton = $modal.find('.button-activate-license'), |
| 222 | - $licenseKeyInput = $modal.find('input.license_key'), | |
| 223 | + $licenseKeyInput = $modal.find( 'input.fs-license-key' ), | |
| 223 | 224 | $licenseActivationMessage = $modal.find( '.license-activation-message' ), |
| 224 | 225 | isNetworkActivation = <?php echo $is_network_activation ? 'true' : 'false' ?>; |
| 225 | 226 | |
| 226 | 227 | $modal.appendTo($('body')); |
| @@ -225,15 +226,15 @@ | ||
| 225 | 226 | |
| 226 | 227 | $modal.appendTo($('body')); |
| 227 | 228 | |
| 228 | 229 | var |
| 229 | - $licensesDropdown = $( '#licenses' ), | |
| 230 | - $licenseTypes = $( 'input[type="radio"][name="license_type"]' ), | |
| 231 | - $applyOnAllSites = $( '#apply_on_all_sites' ), | |
| 232 | - $sitesListContainer = $( '#sites_list_container' ), | |
| 233 | - $availableLicenseKey = $( '#available_license_key' ), | |
| 234 | - $otherLicenseKey = $( '#other_license_key' ), | |
| 235 | - $multisiteOptionsContainer = $( '#multisite_options_container' ), | |
| 230 | + $licensesDropdown = $modal.find( '.fs-licenses' ), | |
| 231 | + $licenseTypes = $modal.find( 'input[type="radio"][name="license_type"]' ), | |
| 232 | + $applyOnAllSites = $modal.find( '.fs-apply-on-all-sites-checkbox' ), | |
| 233 | + $sitesListContainer = $modal.find( '.fs-sites-list-container' ), | |
| 234 | + $availableLicenseKey = $modal.find( '.fs-available-license-key' ), | |
| 235 | + $otherLicenseKey = $modal.find( '#other_license_key_<?php echo $unique_affix ?>' ), | |
| 236 | + $multisiteOptionsContainer = $modal.find( '.fs-multisite-options-container' ), | |
| 236 | 237 | $activationsLeft = null, |
| 237 | 238 | hasLicensesDropdown = ( $licensesDropdown.length > 0 ), |
| 238 | 239 | hasLicenseTypes = ( $licenseTypes.length > 0 ), |
| 239 | 240 | maxSitesListHeight = null, |
| @@ -241,15 +242,15 @@ | ||
| 241 | 242 | singleBlogID = null; |
| 242 | 243 | |
| 243 | 244 | function registerEventHandlers() { |
| 244 | 245 | var |
| 245 | - $otherLicenseKeyContainer = $( '#other_license_key_container' ); | |
| 246 | + $otherLicenseKeyContainer = $modal.find( '.fs-other-license-key-container' ); | |
| 246 | 247 | |
| 247 | 248 | if ( isNetworkActivation ) { |
| 248 | 249 | $applyOnAllSites.click(function() { |
| 249 | 250 | var applyOnAllSites = $( this ).is( ':checked' ); |
| 250 | 251 | |
| 251 | - $multisiteOptionsContainer.toggleClass( 'apply-on-all-sites', applyOnAllSites ); | |
| 252 | + $multisiteOptionsContainer.toggleClass( 'fs-apply-on-all-sites', applyOnAllSites ); | |
| 252 | 253 | |
| 253 | 254 | showSites( ! applyOnAllSites ); |
| 254 | 255 | |
| 255 | 256 | if ( hasValidLicenseKey() && ( applyOnAllSites || hasSelectedSite() ) ) { |
| @@ -291,9 +292,9 @@ | ||
| 291 | 292 | |
| 292 | 293 | if ( hasLicenseTypes ) { |
| 293 | 294 | $licenseTypes.change(function() { |
| 294 | 295 | var |
| 295 | - licenseKey = $( 'input.license_key' ).val().trim(), | |
| 296 | + licenseKey = $modal.find( 'input.fs-license-key' ).val().trim(), | |
| 296 | 297 | otherLicenseKeySelected = isOtherLicenseKeySelected(); |
| 297 | 298 | |
| 298 | 299 | if ( ( licenseKey.length > 0 || ( hasLicenseTypes && ! otherLicenseKeySelected ) ) && |
| 299 | 300 | ( $modal.hasClass( 'is-single-site-activation' ) || ! isNetworkActivation || hasSelectedSite() ) |
| @@ -338,9 +339,9 @@ | ||
| 338 | 339 | |
| 339 | 340 | showModal( evt ); |
| 340 | 341 | }); |
| 341 | 342 | |
| 342 | - $modal.on('input propertychange', 'input.license_key', function () { | |
| 343 | + $modal.on('input propertychange', 'input.fs-license-key', function () { | |
| 343 | 344 | |
| 344 | 345 | var licenseKey = $(this).val().trim(); |
| 345 | 346 | |
| 346 | 347 | /** |
| @@ -350,13 +351,13 @@ | ||
| 350 | 351 | enableActivateLicenseButton(); |
| 351 | 352 | } |
| 352 | 353 | }); |
| 353 | 354 | |
| 354 | - $modal.on( 'blur', 'input.license_key', function( evt ) { | |
| 355 | + $modal.on( 'blur', 'input.fs-license-key', function( evt ) { | |
| 355 | 356 | var |
| 356 | 357 | licenseKey = $(this).val().trim(), |
| 357 | 358 | $focusedElement = $( evt.relatedTarget ), |
| 358 | - hasSelectedAvailableLicense = ( hasLicenseTypes && $focusedElement.parents( '#available_license_key_container' ).length > 0 ); | |
| 359 | + hasSelectedAvailableLicense = ( hasLicenseTypes && $focusedElement.parents( '.fs-available-license-key-container' ).length > 0 ); | |
| 359 | 360 | |
| 360 | 361 | /** |
| 361 | 362 | * If license key is empty, disable the license activation button. |
| 362 | 363 | */ |
| @@ -521,9 +522,9 @@ | ||
| 521 | 522 | } else { |
| 522 | 523 | licenseKey = $otherLicenseKey.val(); |
| 523 | 524 | } |
| 524 | 525 | } else { |
| 525 | - licenseKey = $( 'input.license_key' ).val(); | |
| 526 | + licenseKey = $modal.find( 'input.fs-license-key' ).val(); | |
| 526 | 527 | } |
| 527 | 528 | |
| 528 | 529 | return ( licenseKey.trim().length > 0 ); |
| 529 | 530 | } |
| @@ -556,13 +557,13 @@ | ||
| 556 | 557 | licenseID = $availableLicenseKey.data('id'); |
| 557 | 558 | } |
| 558 | 559 | |
| 559 | 560 | // Cleanup previously auto-selected site. |
| 560 | - $('#sites_list_container input[type=checkbox]:disabled') | |
| 561 | + $modal.find( '.fs-sites-list-container input[type=checkbox]:disabled' ) | |
| 561 | 562 | .attr('disabled', false) |
| 562 | 563 | .attr('checked', false); |
| 563 | 564 | |
| 564 | - var $blogsWithActiveLicense = $('#sites_list_container tr[data-license-id=' + licenseID + '] input[type=checkbox]'); | |
| 565 | + var $blogsWithActiveLicense = $modal.find( '.fs-sites-list-container tr[data-license-id=' + licenseID + '] input[type=checkbox]' ); | |
| 565 | 566 | |
| 566 | 567 | if ($blogsWithActiveLicense.length > 0) { |
| 567 | 568 | $blogsWithActiveLicense.attr('checked', true) |
| 568 | 569 | .attr('disabled', true); |
| @@ -590,9 +591,9 @@ | ||
| 590 | 591 | activateLicenseCheckboxLabel = activateLicenseCheckboxLabel.replace( '%s', '<span data-left="' + activationsLeft + '" class="activations-left">' + activationsLeft + '</span>' ); |
| 591 | 592 | |
| 592 | 593 | // Update the label of the "Activate license on all sites" checkbox. |
| 593 | 594 | $applyOnAllSites.parent().find( 'span' ).html( activateLicenseCheckboxLabel ); |
| 594 | - $activationsLeft = $( '.activations-left' ); | |
| 595 | + $activationsLeft = $modal.find( '.activations-left' ); | |
| 595 | 596 | |
| 596 | 597 | if ( hasSelectedSite() ) { |
| 597 | 598 | enableActivateLicenseButton(); |
| 598 | 599 | enableDisableSitesSelection(); |