Skip to content

Commit 9a4535e

Browse files
authored
Upd. Integrations. Improve Divi newsletters flow to attach meta data to request. (#786)
2 parents e9f6f34 + 594489f commit 9a4535e

18 files changed

Lines changed: 170 additions & 67 deletions

inc/cleantalk-ajax.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,6 @@ function ct_ajax_hook($message_obj = null)
438438
}
439439
}
440440

441-
//divi subscription form needs to force alt cookies
442-
if ( Post::hasString('action', 'et_pb_submit_subscribe_form') ) {
443-
Cookie::$force_alt_cookies_global = true;
444-
}
445-
446441
// thriveleads modification to check gravity forms
447442
if ( Post::get('action') === 'tve_api_form_submit' ) {
448443
unset($_POST['ct_checkjs']);

js/apbct-public-bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/apbct-public-bundle_ext-protection.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/apbct-public-bundle_ext-protection_gathering.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/apbct-public-bundle_full-protection.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/apbct-public-bundle_full-protection_gathering.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/apbct-public-bundle_gathering.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/apbct-public-bundle_int-protection.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/apbct-public-bundle_int-protection_gathering.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/prebuild/apbct-public-bundle.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,11 +3075,9 @@ class ApbctHandler {
30753075
let smartFormsSign = document.querySelectorAll('script[id*="smart-forms"]').length > 0;
30763076
let jetpackCommentsForm = document.querySelectorAll('iframe[name="jetpack_remote_comment"]').length > 0;
30773077
let userRegistrationProForm = document.querySelectorAll('div[id^="user-registration-form"]').length > 0;
3078-
let etPbDiviSubscriptionForm = document.querySelectorAll('div[class^="et_pb_newsletter_form"]').length > 0;
30793078
ctPublic.force_alt_cookies = smartFormsSign ||
30803079
jetpackCommentsForm ||
3081-
userRegistrationProForm ||
3082-
etPbDiviSubscriptionForm;
3080+
userRegistrationProForm;
30833081

30843082
setTimeout(function() {
30853083
if (!ctPublic.force_alt_cookies) {
@@ -3102,6 +3100,7 @@ class ApbctHandler {
31023100
document.querySelector('div.wfu_container') !== null ||
31033101
document.querySelector('#newAppointmentForm') !== null ||
31043102
document.querySelector('.booked-calendar-shortcode-wrap') !== null ||
3103+
document.querySelector('.et_pb_newsletter_form') !== null ||
31053104
(
31063105
// Back In Stock Notifier for WooCommerce | WooCommerce Waitlist Pro
31073106
document.body.classList.contains('single-product') &&
@@ -3116,8 +3115,11 @@ class ApbctHandler {
31163115
(
31173116
body.indexOf('action=wfu_ajax_action_ask_server') !== -1 ||
31183117
body.indexOf('action=booked_add_appt') !== -1 ||
3119-
body.indexOf('action=cwginstock_product_subscribe') !== -1
3118+
body.indexOf('action=cwginstock_product_subscribe') !== -1 ||
3119+
body.indexOf('action=et_pb_submit_subscribe_form') !== -1
31203120
);
3121+
const isDiviNewsletterRequest = body && typeof body === 'string' &&
3122+
body.indexOf('action=et_pb_submit_subscribe_form') !== -1;
31213123

31223124
let isNeedToAddCleantalkDataCheckFormData = body && typeof body === 'object' &&
31233125
body instanceof FormData &&
@@ -3127,17 +3129,27 @@ class ApbctHandler {
31273129

31283130
if (isNeedToAddCleantalkDataCheckString) {
31293131
let addidionalCleantalkData = '';
3132+
const noCookieDataKey = isDiviNewsletterRequest ?
3133+
'ct_no_cookie_hidden_field' :
3134+
'data%5Bct_no_cookie_hidden_field%5D';
3135+
const eventTokenKey = isDiviNewsletterRequest ?
3136+
'ct_bot_detector_event_token' :
3137+
'data%5Bct_bot_detector_event_token%5D';
31303138

31313139
if (!(
31323140
+ctPublic.bot_detector_enabled &&
31333141
apbctLocalStorage.get('bot_detector_event_token')
31343142
)) {
31353143
let noCookieData = getNoCookieData();
3136-
addidionalCleantalkData += '&' + 'data%5Bct_no_cookie_hidden_field%5D=' + noCookieData;
3144+
if (body.indexOf('ct_no_cookie_hidden_field=') === -1) {
3145+
addidionalCleantalkData += '&' + noCookieDataKey + '=' + noCookieData;
3146+
}
31373147
} else {
31383148
const eventToken = new ApbctHandler().toolGetEventToken();
31393149
if (eventToken) {
3140-
addidionalCleantalkData += '&' + 'data%5Bct_bot_detector_event_token%5D=' + eventToken;
3150+
if (body.indexOf('ct_bot_detector_event_token=') === -1) {
3151+
addidionalCleantalkData += '&' + eventTokenKey + '=' + eventToken;
3152+
}
31413153
}
31423154
}
31433155

0 commit comments

Comments
 (0)