Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions inc/cleantalk-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ function ct_ajax_hook($message_obj = null)

$base_call_result = apbct_base_call($base_call_params, $reg_flag);

// Remove service fields from POST before any early return.
apbct_clear_post_service_data_after_base_call();

if (!isset($base_call_result['ct_result'])) {
return null;
}
Expand Down
5 changes: 5 additions & 0 deletions inc/cleantalk-integrations-by-hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
'setting' => 'forms__contact_forms_test',
'ajax' => true
),
'Pagelayer' => array(
'hook' => 'pagelayer_contact_submit_start',
'setting' => 'forms__contact_forms_test',
'ajax' => false
),
'EstimationForm' => array('hook' => 'send_email', 'setting' => 'forms__contact_forms_test', 'ajax' => true),
'LandingPageBuilder' => array(
'hook' => 'ulpb_formBuilderEmail_ajax',
Expand Down
9 changes: 9 additions & 0 deletions inc/cleantalk-pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,15 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms')
return 'Nex Forms';
}

// Pagelayer contact form has the direct integration.
// The form posts to admin-ajax.php?action=..., so the action arrives via GET.
if (
apbct_is_plugin_active('pagelayer/pagelayer.php') &&
Request::getString('action') === 'pagelayer_contact_submit'
) {
return 'Pagelayer contact form - has the direct integration';
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion js/apbct-public-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_ext-protection_gathering.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_full-protection_gathering.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_gathering.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/apbct-public-bundle_int-protection_gathering.min.js

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle_ext-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle_ext-protection_gathering.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle_full-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle_full-protection_gathering.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle_gathering.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle_int-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/prebuild/apbct-public-bundle_int-protection_gathering.js
Original file line number Diff line number Diff line change
Expand Up @@ -3207,6 +3207,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -3232,6 +3247,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
18 changes: 18 additions & 0 deletions js/src/public-1-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,21 @@ class ApbctHandler {
return false;
}

/**
* Forms with an inline onsubmit whose returned value controls the submit.
* A deferred call loses that value and lets the form submit natively.
* @param {object} form
* @return {boolean}
*/
prevCallSyncRequired(form) {
if (form.classList === undefined) {
return false;
}

// Pagelayer contact form: onsubmit="return pagelayer_contact_submit(this, event)"
return form.classList.contains('pagelayer-contact-form');
}

/**
* Catch main
* @param {object} form
Expand All @@ -477,6 +492,9 @@ class ApbctHandler {
if (event.target.classList !== undefined && event.target.classList.contains('brave_form_form')) {
event.preventDefault();
}
if (handler.prevCallSyncRequired(event.target)) {
return event.target.onsubmit_prev.call(event.target, event);
}
setTimeout(function() {
event.target.onsubmit_prev.call(event.target, event);
}, 0);
Expand Down
64 changes: 64 additions & 0 deletions lib/Cleantalk/Antispam/Integrations/Pagelayer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Cleantalk\Antispam\Integrations;

use Cleantalk\ApbctWP\Variables\Post;

class Pagelayer extends IntegrationBase
{
public function getDataForChecking($argument)
{
$event_token = Post::getString('ct_bot_detector_event_token');

/**
* Filter for POST
*/
$input_array = apply_filters('apbct__filter_post', $_POST);

$service_fields = array(
'apbct_visible_fields',
'ct_bot_detector_event_token',
'ct_no_cookie_hidden_field',
'action',
'pagelayer_nonce',
'pagelayer-contact-submit',
'cfa-pagelayer-id',
'cfa-post-id',
'cfa-custom-template',
'cfa-redirect',
);

foreach ( $service_fields as $service_field ) {
unset($input_array[$service_field]);
}

$base_call_data = ct_gfa_dto($input_array)->getArray();

$base_call_data['event_token'] = $event_token;

return $base_call_data;
}

public function doBlock($message)
{
// Pagelayer frontend renders the 'failed' key as the form error message
echo json_encode(array('failed' => $message));
wp_die();
}

public function allow()
{
return 1;
}

/**
* Pagelayer copies $_POST into its own $formdata right after this filter returns,
* so service fields have to be dropped here to keep them out of the email body.
*/
public function doFinalActions($argument)
{
apbct_clear_post_service_data_after_base_call();
Comment thread
AntonV1211 marked this conversation as resolved.

return $argument;
}
}
Loading
Loading