Skip to content

Commit 05c1b43

Browse files
Merge pull request #601 from CleanTalk/chaty_integration.ag
Chaty plugin integration
2 parents 867f9cf + 11377ca commit 05c1b43

10 files changed

Lines changed: 92 additions & 11 deletions

inc/cleantalk-integrations-by-hook.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@
404404
'setting' => 'forms__contact_forms_test',
405405
'ajax' => false
406406
),
407+
'ChatyContactForm' => array(
408+
'hook' => 'chaty_front_form_save_data',
409+
'setting' => 'forms__contact_forms_test',
410+
'ajax' => true
411+
),
407412
);
408413

409414
add_action('plugins_loaded', function () use ($apbct_active_integrations) {

inc/cleantalk-pluggable.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ function apbct_is_skip_request($ajax = false, $ajax_message_obj = array())
695695
'wcf_woocommerce_login', //WooCommerce CartFlows login
696696
'nasa_process_login', //Nasa login
697697
'leaky_paywall_validate_registration', //Leaky Paywall validation request
698+
'cleantalk_force_ajax_check', //Force ajax check has direct integration
698699
);
699700

700701
// Skip test if
@@ -1522,13 +1523,21 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms')
15221523
return 'fusion_form/avada_theme skip';
15231524
}
15241525

1525-
// skip Newsletter - have direct integration
1526+
// skip Newsletter - has direct integration
15261527
if (
15271528
apbct_is_plugin_active('newsletter/plugin.php') &&
15281529
Request::getString('action') === 'tnp'
15291530
) {
15301531
return 'Newsletter';
15311532
}
1533+
1534+
// skip ChatyContactForm - has direct integration
1535+
if (
1536+
apbct_is_plugin_active('chaty/cht-icons.php') &&
1537+
Request::getString('action') === 'chaty_front_form_save_data'
1538+
) {
1539+
return 'ChatyContactForm';
1540+
}
15321541
} else {
15331542
/*****************************************/
15341543
/* Here is non-ajax requests skipping */

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.min.js.map

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.min.js.map

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/src/apbct-public--5--external-forms.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ function ctCheckAjax(elem) {
636636
function isIntegratedForm(formObj) {
637637
const formAction = typeof(formObj.action) == 'string' ? formObj.action : '';
638638
const formId = formObj.getAttribute('id') !== null ? formObj.getAttribute('id') : '';
639+
const formClassName = typeof(formObj.className) == 'string' ? formObj.className : '';
639640

640641
if (
641642
(
@@ -673,8 +674,14 @@ function isIntegratedForm(formObj) {
673674
formAction.indexOf('wufoo.com') !== -1 || // Wufoo form
674675
formAction.indexOf('activehosted.com') !== -1 || // Activehosted form
675676
formAction.indexOf('publisher.copernica.com') !== -1 || // publisher.copernica
676-
( formObj.classList !== undefined &&
677-
formObj.classList.contains('sp-element-container') ) || // Sendpulse form
677+
(
678+
formAction.indexOf('whatsapp.com') !== -1 &&
679+
formClassName.indexOf('chaty') !== -1
680+
) || // chaty plugin whatsapp form
681+
(
682+
formObj.classList !== undefined &&
683+
formObj.classList.contains('sp-element-container')
684+
) || // Sendpulse form
678685
apbctIsFormInDiv(formObj, 'b24-form') // Bitrix24 CRM external forms
679686
) {
680687
return true;

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4889,6 +4889,7 @@ function ctCheckAjax(elem) {
48894889
function isIntegratedForm(formObj) {
48904890
const formAction = typeof(formObj.action) == 'string' ? formObj.action : '';
48914891
const formId = formObj.getAttribute('id') !== null ? formObj.getAttribute('id') : '';
4892+
const formClassName = typeof(formObj.className) == 'string' ? formObj.className : '';
48924893

48934894
if (
48944895
(
@@ -4926,8 +4927,14 @@ function isIntegratedForm(formObj) {
49264927
formAction.indexOf('wufoo.com') !== -1 || // Wufoo form
49274928
formAction.indexOf('activehosted.com') !== -1 || // Activehosted form
49284929
formAction.indexOf('publisher.copernica.com') !== -1 || // publisher.copernica
4929-
( formObj.classList !== undefined &&
4930-
formObj.classList.contains('sp-element-container') ) || // Sendpulse form
4930+
(
4931+
formAction.indexOf('whatsapp.com') !== -1 &&
4932+
formClassName.indexOf('chaty') !== -1
4933+
) || // chaty plugin whatsapp form
4934+
(
4935+
formObj.classList !== undefined &&
4936+
formObj.classList.contains('sp-element-container')
4937+
) || // Sendpulse form
49314938
apbctIsFormInDiv(formObj, 'b24-form') // Bitrix24 CRM external forms
49324939
) {
49334940
return true;

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5330,6 +5330,7 @@ function ctCheckAjax(elem) {
53305330
function isIntegratedForm(formObj) {
53315331
const formAction = typeof(formObj.action) == 'string' ? formObj.action : '';
53325332
const formId = formObj.getAttribute('id') !== null ? formObj.getAttribute('id') : '';
5333+
const formClassName = typeof(formObj.className) == 'string' ? formObj.className : '';
53335334

53345335
if (
53355336
(
@@ -5367,8 +5368,14 @@ function isIntegratedForm(formObj) {
53675368
formAction.indexOf('wufoo.com') !== -1 || // Wufoo form
53685369
formAction.indexOf('activehosted.com') !== -1 || // Activehosted form
53695370
formAction.indexOf('publisher.copernica.com') !== -1 || // publisher.copernica
5370-
( formObj.classList !== undefined &&
5371-
formObj.classList.contains('sp-element-container') ) || // Sendpulse form
5371+
(
5372+
formAction.indexOf('whatsapp.com') !== -1 &&
5373+
formClassName.indexOf('chaty') !== -1
5374+
) || // chaty plugin whatsapp form
5375+
(
5376+
formObj.classList !== undefined &&
5377+
formObj.classList.contains('sp-element-container')
5378+
) || // Sendpulse form
53725379
apbctIsFormInDiv(formObj, 'b24-form') // Bitrix24 CRM external forms
53735380
) {
53745381
return true;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Cleantalk\Antispam\Integrations;
4+
5+
use Cleantalk\ApbctWP\Variables\Request;
6+
use Cleantalk\ApbctWP\Variables\Post;
7+
8+
class ChatyContactForm extends IntegrationBase
9+
{
10+
public function getDataForChecking($argument)
11+
{
12+
if ( Request::get('nonce') ) {
13+
$event_token = Post::getString('ct_bot_detector_event_token');
14+
/**
15+
* Filter for POST
16+
*/
17+
$input_array = apply_filters('apbct__filter_post', $_POST);
18+
19+
unset($input_array['apbct_visible_fields']);
20+
21+
$base_call_data = ct_gfa_dto($input_array)->getArray();
22+
23+
$base_call_data['event_token'] = $event_token;
24+
25+
if (isset($base_call_data['message']['message'])) {
26+
$base_call_data['message'] = $base_call_data['message']['message'];
27+
}
28+
29+
return $base_call_data;
30+
}
31+
32+
return null;
33+
}
34+
35+
public function doBlock($message)
36+
{
37+
$response = [
38+
'status' => 0,
39+
'error' => '',
40+
'errors' => [],
41+
'message' => $message,
42+
];
43+
wp_send_json($response);
44+
exit;
45+
}
46+
}

0 commit comments

Comments
 (0)