: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$modal.on( 'keyup paste delete cut', 'input.fs-license-key', function () {
clearTimeout(licenseTimeout);
licenseTimeout = setTimeout( function () {
var licenseKey = $licenseKeyInput.val().trim();
if ( licenseKey == previousLicenseKey ) {
afterLicenseUserDataLoaded();
if ( '' === licenseKey ) {
disableActivateLicenseButton();
$ownershipChangeOptionContainer.hide();
enableActivateLicenseButton();
if ( 32 <= licenseKey.length ) {
$ownershipChangeOptionContainer.hide();
previousLicenseKey = licenseKey;
$modal.on('input propertychange', 'input.fs-license-key', function () {
var licenseKey = $(this).val().trim();
* If license key is not empty, enable the license activation button.
if ( licenseKey.length > 0 && ( $modal.hasClass( 'is-single-site-activation' ) || ! isNetworkActivation || hasSelectedSite() ) ) {
enableActivateLicenseButton();
$modal.on( 'blur', 'input.fs-license-key', function( evt ) {
licenseKey = $(this).val().trim(),
$focusedElement = $( evt.relatedTarget ),
hasSelectedAvailableLicense = ( hasLicenseTypes && $focusedElement.parents( '.fs-available-license-key-container' ).length > 0 );
* If license key is empty, disable the license activation button.
if ( ( 0 === licenseKey.length && ( ! hasLicenseTypes || ! hasSelectedAvailableLicense ) ) ||
( isNetworkActivation && ! hasSelectedSite() )
disableActivateLicenseButton();
$modal.on('click', '.button-activate-license', function (evt) {
if ($(this).hasClass('disabled')) {
if ( isOtherLicenseKeySelected() ) {
licenseKey = $otherLicenseKey.val();
if ( ! hasLicensesDropdown ) {
licenseKey = $availableLicenseKey.data( 'license-key' );
licenseKey = $licensesDropdown.val();
licenseKey = $licenseKeyInput.val().trim();
disableActivateLicenseButton();
if (0 === licenseKey.length) {
action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>',
module_id : '<?php echo $fs->get_id() ?>'
if ( isNetworkActivation ) {
if ( null === singleBlogID ) {
applyOnAllSites = $applyOnAllSites.is( ':checked' );
$sitesListContainer.find( 'tr' ).each(function() {
includeSite = ( applyOnAllSites || $this.find( 'input' ).is( ':checked' ) );
uid : $this.find( '.uid' ).val(),
url : $this.find( '.url' ).val(),
title : $this.find( '.title' ).val(),
language: $this.find( '.language' ).val(),
blog_id : $this.find( '.blog-id' ).find( 'span' ).text()
data.blog_id = singleBlogID;
if ( $ownershipChangeOptionContainer.find( 'input:checked' ).length > 0 ) {
data.user_id = otherLicenseOwnerID;
url: <?php echo Freemius::ajax_url() ?>,
beforeSend: function () {
$activateLicenseButton.text( '<?php fs_esc_js_echo_inline( 'Activating license', 'activating-license', $slug ) ?>...' );
success: function( result ) {
var resultObj = $.parseJSON( result );
if ( resultObj.success ) {
// Redirect to the "Account" page and sync the license.
window.location.href = resultObj.next_page;
showError( resultObj.error.message ? resultObj.error.message : resultObj.error );
resetActivateLicenseButton();
// If the user has clicked outside the window, close the modal.
$modal.on('click', '.fs-close, .button-secondary', function () {
$body.trigger('licenseActivationLoaded');
* @author Leo Fajardo (@leorw)
function enableDisableSitesSelection() {
canApplyOnAllSites = $applyOnAllSites.is( ':enabled' ),
disableSitesSelection = null;
if ( ! canApplyOnAllSites ) {
selectedSites = $sitesListContainer.find( 'input[type="checkbox"]:checked' ).length,
activationsLeft = Math.max( 0, $activationsLeft.data( 'left' ) - selectedSites );
disableSitesSelection = ( 0 === activationsLeft );
$activationsLeft.text( activationsLeft );
disableSitesSelection = false;
.find( 'input[type="checkbox"]:not(:checked)' )
.attr( 'disabled', disableSitesSelection );
* @author Leo Fajardo (@leorw)
function isOtherLicenseKeySelected() {
return ( hasLicenseTypes && 'other' === $licenseTypes.filter( ':checked' ).val() );
* @author Leo Fajardo (@leorw)
function hasValidLicenseKey() {
if ( 'available' === $licenseTypes.filter( ':checked' ).val() ) {
licenseKey = $otherLicenseKey.val();
licenseKey = $modal.find( 'input.fs-license-key' ).val();
return ( licenseKey.trim().length > 0 );
* @author Leo Fajardo (@leorw)
function hasSelectedSite() {
return ( $applyOnAllSites.is( ':checked' ) ||
$sitesListContainer.find( 'input[type="checkbox"]:checked:not(:disabled)' ).length > 0 );
* @author Leo Fajardo (@leorw)
function toggleActivationOnAllSites() {
if (hasLicensesDropdown) {
var $selectedOption = $licensesDropdown.find( ':selected' );
activationsLeft = $selectedOption.data('left');
licenseID = $selectedOption.data('id');
activationsLeft = $availableLicenseKey.data('left');
licenseID = $availableLicenseKey.data('id');
// Cleanup previously auto-selected site.
$modal.find( '.fs-sites-list-container input[type=checkbox]:disabled' )
var $blogsWithActiveLicense = $modal.find( '.fs-sites-list-container tr[data-license-id=' + licenseID + '] input[type=checkbox]' );
if ($blogsWithActiveLicense.length > 0) {
$blogsWithActiveLicense.attr('checked', true)
activationsLeft += $blogsWithActiveLicense.length;
if ( activationsLeft >= totalSites ) {
$applyOnAllSites.attr( 'disabled', false );
enableDisableSitesSelection();
resetActivateLicenseCheckboxLabel();
$applyOnAllSites.attr( 'checked', false );
$applyOnAllSites.attr( 'disabled', true );
activateLicenseCheckboxLabel = '<?php fs_esc_js_echo_inline( 'Choose up to %s site(s) to activate the license on.', 'choose-up-to-n-sites-to-activate-the-license-on', $slug ) ?>';
activateLicenseCheckboxLabel = activateLicenseCheckboxLabel.replace( '%s', '<span data-left="' + activationsLeft + '" class="activations-left">' + activationsLeft + '</span>' );
// Update the label of the "Activate license on all sites" checkbox.
$applyOnAllSites.parent().find( 'span' ).html( activateLicenseCheckboxLabel );
$activationsLeft = $modal.find( '.activations-left' );
if ( hasSelectedSite() ) {
enableActivateLicenseButton();
enableDisableSitesSelection();
disableActivateLicenseButton();
* @author Leo Fajardo (@leorw)
function resetActivateLicenseCheckboxLabel() {
var activateLicenseCheckboxLabel = '<?php fs_esc_js_echo_inline( 'Activate license on all sites in the network.', 'activate-license-on-all-sites-in-the-network', $slug ) ?>';
$applyOnAllSites.parent().find( 'span' ).text( activateLicenseCheckboxLabel );
* @author Leo Fajardo (@leorw)
function showSites( show ) {
$sitesListContainer.toggle( show );
if ( show && null === maxSitesListHeight ) {
* Set the visible number of rows to 5 (5 * height of the first row).
* @author Leo Fajardo (@leorw)
maxSitesListHeight = ( 5 * $sitesListContainer.find( 'tr:first' ).height() );
$sitesListContainer.css( 'max-height', maxSitesListHeight );
function showModal( evt ) {
// Display the dialog box.
$modal.addClass('active');
$body.addClass('has-fs-modal');
$singleInstallDetails = $( evt.target ).parents( 'tr.fs-install-details' ),
isSingleSiteActivation = ( $singleInstallDetails.length > 0 );
$modal.toggleClass( 'is-single-site-activation', isSingleSiteActivation );
singleBlogID = isSingleSiteActivation ?
$singleInstallDetails.prev().data( 'blog-id' ) :
<?php if ( $fs->apply_filters( 'enable_per_site_activation', true ) ) : ?>
$multisiteOptionsContainer.toggle( isNetworkActivation && ! isSingleSiteActivation );
$licenseTypes.attr( 'checked', false );
if ( hasLicensesDropdown ) {
$licensesDropdown.find( 'option:first' ).attr( 'selected', true ).trigger( 'change' );
$licenseTypes.filter( '[value="available"]' ).click();
$otherLicenseKey.val( '' );
$licenseKeyInput.val( '' );
$licenseKeyInput.focus();
$modal.removeClass('active');
$body.removeClass('has-fs-modal');
function resetActivateLicenseButton() {
enableActivateLicenseButton();
$activateLicenseButton.text( <?php echo json_encode( $activate_button_text ) ?> );
resetActivateLicenseButton();
function enableActivateLicenseButton() {
$activateLicenseButton.removeClass( 'disabled' );
function disableActivateLicenseButton() {
$activateLicenseButton.addClass( 'disabled' );
$licenseActivationMessage.hide();
function showError( msg ) {
$licenseActivationMessage.find( ' > p' ).html( msg );
$licenseActivationMessage.show();
fs_require_once_template( 'api-connectivity-message-js.php' );