Skip to content

Commit 13ebd6b

Browse files
committed
[api] Minor refactoring/cleanup (orphan license check).
1 parent c58aa41 commit 13ebd6b

File tree

5 files changed

+19
-64
lines changed

5 files changed

+19
-64
lines changed

assets/scss/admin/_gdpr-consent.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#fs_marketing_optin
1+
#fs_marketing_optin, #fs_orphan_license_message
22
{
33
display: none;
44
margin-top: 10px;

assets/scss/admin/_privacy_license_owner.scss

Lines changed: 0 additions & 16 deletions
This file was deleted.

assets/scss/admin/connect.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ $box_border_radius: 3px;
370370

371371
@import "multisite-options";
372372
@import "gdpr-consent";
373-
@import "privacy_license_owner";
374373

375374
.rtl
376375
{

start.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @var string
1717
*/
18-
$this_sdk_version = '2.11.0.5';
18+
$this_sdk_version = '2.11.0.6';
1919

2020
#region SDK Selection Logic --------------------------------------------------------------------
2121

templates/connect.php

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ class="wrap<?php if ( ! fs_is_network_admin() && ( ! $fs->is_enable_anonymous()
336336
</label>
337337
</div>
338338
</div>
339-
<div id="fs_privacy_license_owner">
340-
<span class="fs-message"><?php fs_echo_inline( "A user has not yet been associated with the license, which is necessary to prevent unauthorized activation. To assign the license to your user, you agree to share your WP user's full name and email address." ) ?></span>
339+
<div id="fs_orphan_license_message">
340+
<span class="fs-message"><?php fs_echo_inline( "A user has not yet been associated with the license, which is necessary to prevent unauthorized activation. To assign the license to your user, you agree to share your WordPress user's full name and email address." ) ?></span>
341341
</div>
342342
<?php endif ?>
343343
<?php if ( $is_network_level_activation ) : ?>
@@ -918,16 +918,14 @@ function updatePrimaryCtaText( actionType ) {
918918

919919
if ('' === key) {
920920
$primaryCta.attr('disabled', 'disabled');
921-
$marketingOptin.hide();
922-
toggleSensitiveDataFields(false);
921+
hideOptinAndLicenseMessage();
923922
} else {
924923
$primaryCta.prop('disabled', false);
925924

926925
if (32 <= key.length){
927926
fetchIsMarketingAllowedFlagAndToggleOptin();
928927
} else {
929-
$marketingOptin.hide();
930-
toggleSensitiveDataFields(false);
928+
hideOptinAndLicenseMessage();
931929
}
932930
}
933931

@@ -963,34 +961,10 @@ function updatePrimaryCtaText( actionType ) {
963961
//region GDPR
964962
//--------------------------------------------------------------------------------
965963
var isMarketingAllowedByLicense = {},
966-
licenseOwnerIdByLicense = {},
967-
$marketingOptin = $('#fs_marketing_optin'),
968-
$privacyLicenseOwner = $('#fs_privacy_license_owner'),
969-
$fieldFirstName = document.querySelector("input[name='user_firstname']"),
970-
$fieldLastName = document.querySelector("input[name='user_lastname']"),
971-
$fieldEmail = document.querySelector("input[name='user_email']"),
972-
$form = $fieldFirstName.parentNode,
973-
previousLicenseKey = null;
974-
975-
// A function to enable/disable sensitive data fields
976-
var toggleSensitiveDataFields = function (shouldSendSensitiveData) {
977-
if (shouldSendSensitiveData) {
978-
$privacyLicenseOwner.show();
979-
// Add fields to the form if they are not already there.
980-
$form.appendChild($fieldFirstName);
981-
$form.appendChild($fieldLastName);
982-
$form.appendChild($fieldEmail);
983-
} else {
984-
$privacyLicenseOwner.hide();
985-
// Remove fields from the form if they are there.
986-
if ($fieldFirstName.parentNode === $form)
987-
$form.removeChild($fieldFirstName);
988-
if ($fieldLastName.parentNode === $form)
989-
$form.removeChild($fieldLastName);
990-
if ($fieldEmail.parentNode === $form)
991-
$form.removeChild($fieldEmail);
992-
}
993-
};
964+
licenseOwnerIDByLicense = {},
965+
$marketingOptin = $('#fs_marketing_optin'),
966+
$orphanLicenseMessage = $('#fs_orphan_license_message'),
967+
previousLicenseKey = null;
994968

995969
if (requireLicenseKey) {
996970

@@ -1013,11 +987,7 @@ function updatePrimaryCtaText( actionType ) {
1013987
$primaryCta.focus();
1014988
}
1015989

1016-
if (null == licenseOwnerIdByLicense[licenseKey]){
1017-
toggleSensitiveDataFields(true);
1018-
} else {
1019-
toggleSensitiveDataFields(false);
1020-
}
990+
$orphanLicenseMessage.toggle( false === licenseOwnerIDByLicense[ licenseKey ] );
1021991
},
1022992
/**
1023993
* @author Leo Fajardo (@leorw)
@@ -1027,8 +997,8 @@ function updatePrimaryCtaText( actionType ) {
1027997
var licenseKey = $licenseKeyInput.val();
1028998

1029999
if (licenseKey.length < 32) {
1030-
$marketingOptin.hide();
1031-
toggleSensitiveDataFields(false);
1000+
hideOptinAndLicenseMessage();
1001+
10321002
return;
10331003
}
10341004

@@ -1037,9 +1007,7 @@ function updatePrimaryCtaText( actionType ) {
10371007
return;
10381008
}
10391009

1040-
$marketingOptin.hide();
1041-
toggleSensitiveDataFields(false);
1042-
1010+
hideOptinAndLicenseMessage();
10431011
setLoadingMode();
10441012

10451013
$primaryCta.addClass('fs-loading');
@@ -1063,12 +1031,16 @@ function updatePrimaryCtaText( actionType ) {
10631031

10641032
// Cache result.
10651033
isMarketingAllowedByLicense[licenseKey] = result.is_marketing_allowed;
1066-
licenseOwnerIdByLicense[licenseKey] = result.license_owner_id;
1034+
licenseOwnerIDByLicense[licenseKey] = result.license_owner_id;
10671035
}
10681036

10691037
afterMarketingFlagLoaded();
10701038
}
10711039
});
1040+
},
1041+
hideOptinAndLicenseMessage = function() {
1042+
$marketingOptin.hide();
1043+
$orphanLicenseMessage.hide();
10721044
};
10731045

10741046
$marketingOptin.find( 'input' ).click(function() {

0 commit comments

Comments
 (0)