Skip to content

Commit c1de423

Browse files
authored
Merge pull request #771 from CleanTalk/beta (Version: 6.76.)
Version: 6.76.
2 parents 55e785f + 80f33e6 commit c1de423

61 files changed

Lines changed: 2554 additions & 653 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cleantalk.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Plugin Name: Anti-Spam by CleanTalk
55
Plugin URI: https://cleantalk.org
66
Description: Max power, all-in-one, no Captcha, premium anti-spam plugin. No comment spam, no registration spam, no contact spam, protects any WordPress forms.
7-
Version: 6.75
7+
Version: 6.76
88
Author: CleanTalk - Anti-Spam Protection <welcome@cleantalk.org>
99
Author URI: https://cleantalk.org
1010
Text Domain: cleantalk-spam-protect
@@ -694,6 +694,9 @@ function apbct_wpms__delete_blog(WP_Site $old_site)
694694
// After plugin loaded - to load locale as described in manual
695695
add_action('init', 'apbct_plugin_loaded');
696696

697+
// SiteGround Speed Optimizer: skip cache for URLs with apbct_no_cache.
698+
add_action('plugins_loaded', 'apbct_sgo_optimizer__register_bypass_query_params', 1);
699+
697700
if ( ! empty($apbct->settings['data__use_ajax']) &&
698701
! apbct_is_in_uri('.xml') &&
699702
! apbct_is_in_uri('.xsl')

inc/cleantalk-common.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ function apbct_base_call($params = array(), $reg_flag = false)
193193

194194
// Misc
195195
'auth_key' => $apbct->api_key,
196-
'js_on' => apbct_js_test(Sanitize::cleanTextField(Cookie::get('ct_checkjs')), true) ? 1 : apbct_js_test(TT::toString(Post::get('ct_checkjs'))),
196+
'js_on' => apbct_js_test(Sanitize::cleanTextField(Cookie::getString('ct_checkjs')), true)
197+
? 1
198+
: apbct_js_test(Post::getString('ct_checkjs')),
197199

198200
'agent' => APBCT_AGENT,
199201
'sender_info' => $sender_info,
@@ -1857,7 +1859,6 @@ function apbct__bot_detector_get_fired_exclusions()
18571859
*/
18581860
function apbct__bot_detector_get_fd_log()
18591861
{
1860-
global $apbct;
18611862
$result = array(
18621863
'plugin_status' => 'OK',
18631864
'error_msg' => '',
@@ -1872,7 +1873,7 @@ function apbct__bot_detector_get_fd_log()
18721873
}
18731874

18741875
try {
1875-
if ( TT::toString($apbct->settings['data__bot_detector_enabled']) === '0') {
1876+
if ( ! apbct__is_bot_detector_enabled() ) {
18761877
throw new \Exception('bot detector library usage is disabled');
18771878
}
18781879
// Retrieve bot detector frontend data log from Alt Sessions
@@ -1929,3 +1930,24 @@ function apbct__bot_detector_get_custom_exclusion_from_settings()
19291930
}
19301931
return $exclusions;
19311932
}
1933+
1934+
/**
1935+
* Check if Bot-Detector is enabled/disabled
1936+
*
1937+
* @return bool
1938+
*/
1939+
function apbct__is_bot_detector_enabled()
1940+
{
1941+
global $apbct;
1942+
1943+
// Constant is preferred
1944+
if ( isset($apbct->service_constants->bot_detector_enabled) && $apbct->service_constants->bot_detector_enabled->isDefined() ) {
1945+
return (bool) $apbct->service_constants->bot_detector_enabled->getValue();
1946+
}
1947+
// Check by $apbct->data
1948+
if ( isset($apbct->data['bot_detector_enabled']) ) {
1949+
return (bool) $apbct->data['bot_detector_enabled'];
1950+
}
1951+
// By default - enabled
1952+
return true;
1953+
}

inc/cleantalk-integrations-by-hook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@
226226
'ajax' => true
227227
),
228228
'PiotnetAddonsForElementorPro' => array(
229-
'hook' => array('pafe_ajax_form_builder'),
229+
'hook' => 'pafe_ajax_form_builder',
230230
'setting' => 'forms__contact_forms_test',
231231
'ajax' => true
232232
),

inc/cleantalk-pluggable.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ function apbct_is_skip_request($ajax = false, $ajax_message_obj = array())
723723
'fl_builder_subscribe_form_submit', // FLBuilderForms has direct integration
724724
'tutor_pro_social_authentication', // Tutor Pro social authentication, we trust a third-party service
725725
'drplus_login', // Doctor Plus theme login
726+
'fluent_cal_schedule_meeting', // Fluent Booking has direct integration
726727
);
727728

728729
// Skip test if
@@ -1429,7 +1430,11 @@ function apbct_is_skip_request($ajax = false, $ajax_message_obj = array())
14291430
apbct_is_plugin_active('piotnet-addons-for-elementor-pro/piotnet-addons-for-elementor-pro.php') ||
14301431
apbct_is_plugin_active('piotnet-addons-for-elementor/piotnet-addons-for-elementor.php')
14311432
) &&
1432-
Post::get('action') === 'pafe_ajax_form_builder_preview_submission' ) {
1433+
(
1434+
Post::get('action') === 'pafe_ajax_form_builder_preview_submission' ||
1435+
Post::get('action') === 'pafe_ajax_form_builder'
1436+
)
1437+
) {
14331438
return 'PAFE';
14341439
}
14351440

inc/cleantalk-public-integrations.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,11 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
938938
$checkjs = $checkjs_cookie ?: $checkjs_post;
939939
}
940940

941+
// BuddyBoss Platform use rest api for registration from phone app
942+
if ( apbct_is_plugin_active('buddyboss-app/buddyboss-app.php') && apbct_is_in_uri('/wp-json/buddyboss-app/v1/signup') ) {
943+
$checkjs = Post::getString('checkjs') === 'true' ? 1 : 0;
944+
}
945+
941946
$sender_info = array(
942947
'post_checkjs_passed' => $checkjs_post,
943948
'cookie_checkjs_passed' => $checkjs_cookie,
@@ -1049,6 +1054,10 @@ function ct_registration_errors($errors, $sanitized_user_login = null, $user_ema
10491054
$bp->signup->errors['signup_username'] = $ct_result->comment;
10501055
}
10511056

1057+
if (apbct_is_plugin_active('buddyboss-app/buddyboss-app.php') && apbct_is_in_uri('/wp-json/buddyboss-app/v1/signup')) {
1058+
wp_send_json_error(['success' => false, 'message' => $ct_result->comment]);
1059+
}
1060+
10521061
if ( $facebook ) {
10531062
/** @psalm-suppress InvalidArrayOffset */
10541063
$_POST['FB_userdata']['email'] = '';
@@ -1870,19 +1879,16 @@ function ct_quform_post_validate($result, $form)
18701879
* Filter for POST
18711880
*/
18721881
$input_array = apply_filters('apbct__filter_post', $form->getValues());
1873-
18741882
$ct_temp_msg_data = ct_get_fields_any($input_array);
18751883
$sender_email = isset($ct_temp_msg_data['email']) ? $ct_temp_msg_data['email'] : '';
18761884
$sender_emails_array = isset($ct_temp_msg_data['emails_array']) ? $ct_temp_msg_data['emails_array'] : '';
18771885

1878-
$checkjs = apbct_js_test(Sanitize::cleanTextField(Cookie::get('ct_checkjs')), true);
18791886
$base_call_result = apbct_base_call(
18801887
array(
18811888
'message' => $form->getValues(),
18821889
'sender_email' => $sender_email,
18831890
'post_info' => array('comment_type' => $comment_type),
18841891
'sender_info' => array('sender_emails_array' => $sender_emails_array),
1885-
'js_on' => $checkjs,
18861892
)
18871893
);
18881894

inc/cleantalk-public-validate-skip-functions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ function skip_for_ct_contact_form_validate()
287287
Get::equal('wc-ajax', 'wc_stripe_frontend_request') &&
288288
! empty(Post::getString('stripe_applepay_token_key'))
289289
),
290+
// BuddyBoss REST API has a direct integration
291+
'101' => (
292+
apbct_is_plugin_active('buddyboss-platform/buddyboss-platform.php') &&
293+
apbct_is_in_uri('/wp-json/buddyboss/v1/signup')
294+
),
290295
);
291296

292297
foreach ( $exclusions as $exclusion_key => $state ) {

inc/cleantalk-public.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function apbct_init()
3232
$apbct->settings['data__pixel'] &&
3333
empty($apbct->pixel_url) &&
3434
!(
35-
$apbct->settings['data__bot_detector_enabled'] === '1' &&
35+
apbct__is_bot_detector_enabled() &&
3636
$apbct->settings['data__pixel'] === '3'
3737
)
3838
) {
@@ -378,6 +378,36 @@ class_exists('Jetpack', false) &&
378378
}
379379
}
380380

381+
/**
382+
* SiteGround Speed Optimizer: register sgo_bypass_query_params filter.
383+
*/
384+
function apbct_sgo_optimizer__register_bypass_query_params()
385+
{
386+
if ( ! defined('SG_OPTIMIZER_VERSION') ) {
387+
return;
388+
}
389+
add_filter('sgo_bypass_query_params', 'apbct_sgo_bypass_query_params', 10, 1);
390+
}
391+
392+
/**
393+
* Adds apbct_no_cache to SG Optimizer bypass list.
394+
*
395+
* @param string[] $bypass_query_params
396+
*
397+
* @return string[]
398+
*/
399+
function apbct_sgo_bypass_query_params($bypass_query_params)
400+
{
401+
if ( ! is_array($bypass_query_params) ) {
402+
$bypass_query_params = array();
403+
}
404+
if ( ! in_array('apbct_no_cache', $bypass_query_params, true) ) {
405+
$bypass_query_params[] = 'apbct_no_cache';
406+
}
407+
408+
return $bypass_query_params;
409+
}
410+
381411
function apbct_buffer__start()
382412
{
383413
ob_start();
@@ -540,7 +570,7 @@ function apbct_hook__wp_footer()
540570
(
541571
$apbct->settings['data__pixel'] === '3' &&
542572
! apbct_is_cache_plugins_exists() &&
543-
$apbct->settings['data__bot_detector_enabled'] !== '1'
573+
! apbct__is_bot_detector_enabled()
544574
)
545575
) {
546576
echo '<img alt="Cleantalk Pixel" title="Cleantalk Pixel" id="apbct_pixel" style="display: none;" src="' . Escape::escUrl($apbct->pixel_url) . '">';
@@ -1245,7 +1275,7 @@ function apbct_enqueue_and_localize_public_scripts()
12451275
ApbctEnqueue::getInstance()->js($bundle_name, array(), $in_footer);
12461276

12471277
// Bot detector
1248-
if ( $apbct->settings['data__bot_detector_enabled'] && ! apbct_bot_detector_scripts_exclusion()) {
1278+
if ( apbct__is_bot_detector_enabled() && ! apbct_bot_detector_scripts_exclusion()) {
12491279
// Attention! Skip old enqueue way for external script.
12501280
wp_enqueue_script(
12511281
'ct_bot_detector',

inc/cleantalk-settings.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -564,14 +564,17 @@ function apbct_settings__set_fields()
564564
'callback' => 'apbct_settings__check_alt_cookies_types'
565565
),
566566
//bot detector
567-
'data__bot_detector_enabled' => array(
568-
'title' => __('Use ', 'cleantalk-spam-protect')
569-
. $apbct->data['wl_brandname']
570-
. __(' JavaScript library', 'cleantalk-spam-protect'),
571-
'description' => __('This option includes external ', 'cleantalk-spam-protect')
572-
. $apbct->data['wl_brandname']
573-
. __(' JavaScript library to getting visitors info data', 'cleantalk-spam-protect'),
574-
'childrens' => array('exclusions__bot_detector')
567+
'bot_detector_state' => array(
568+
'callback' => function () {
569+
printf(
570+
esc_html__('JavaScript library (Bot Detector) is %s', 'cleantalk-spam-protect'),
571+
apbct__is_bot_detector_enabled()
572+
? esc_html__('enabled', 'cleantalk-spam-protect')
573+
: esc_html__('disabled', 'cleantalk-spam-protect')
574+
);
575+
},
576+
'long_description' => true,
577+
'display' => apbct__is_bot_detector_enabled(),
575578
),
576579
'exclusions__bot_detector' => array(
577580
'title' => __('JavaScript Library Exclusions', 'cleantalk-spam-protect'),
@@ -584,28 +587,31 @@ function apbct_settings__set_fields()
584587
'Regular expression. Use to skip a HTML form from special service field attach.',
585588
'cleantalk-spam-protect'
586589
),
587-
'parent' => 'data__bot_detector_enabled',
590+
'display' => apbct__is_bot_detector_enabled(),
588591
),
589592
'exclusions__bot_detector__form_attributes' => array(
590593
'type' => 'text',
591594
'title' => __('Exclude any forms that has attribute matches.', 'cleantalk-spam-protect'),
592595
'parent' => 'exclusions__bot_detector',
593596
'class' => 'apbct_settings-field_wrapper--sub',
594597
'long_description' => true,
598+
'display' => apbct__is_bot_detector_enabled(),
595599
),
596600
'exclusions__bot_detector__form_children_attributes' => array(
597601
'type' => 'text',
598602
'title' => __('Exclude any forms that includes a child element with attribute matches.', 'cleantalk-spam-protect'),
599603
'parent' => 'exclusions__bot_detector',
600604
'class' => 'apbct_settings-field_wrapper--sub',
601605
'long_description' => true,
606+
'display' => apbct__is_bot_detector_enabled(),
602607
),
603608
'exclusions__bot_detector__form_parent_attributes' => array(
604609
'type' => 'text',
605610
'title' => __('Exclude any forms that includes a parent element with attribute matches.', 'cleantalk-spam-protect'),
606611
'parent' => 'exclusions__bot_detector',
607612
'class' => 'apbct_settings-field_wrapper--sub',
608613
'long_description' => true,
614+
'display' => apbct__is_bot_detector_enabled(),
609615
),
610616
'wp__use_builtin_http_api' => array(
611617
'title' => __("Use WordPress HTTP API", 'cleantalk-spam-protect'),
@@ -3150,6 +3156,14 @@ function apbct_settings__get__long_description()
31503156
'title' => __('Contact data encoding', 'cleantalk-spam-protect'),
31513157
'desc' => ContactsEncoder::getEmailEncoderCommonLongDescription(),
31523158
),
3159+
'bot_detector_state' => array(
3160+
'title' => esc_html__('JavaScript library (Bot Detector)', 'cleantalk-spam-protect'),
3161+
'desc' => esc_html__("The Bot Detector is a JavaScript library that runs in the visitor's browser and collects behavioral signals to distinguish real users from bots.", 'cleantalk-spam-protect')
3162+
. '<br><br>' . esc_html__("This data is sent to the CleanTalk cloud along with each spam check request, significantly improving detection accuracy for spam on any website forms.", 'cleantalk-spam-protect')
3163+
. '<br><br>' . esc_html__("Disabling the Bot Detector will reduce anti-spam effectiveness.", 'cleantalk-spam-protect')
3164+
. '<br>' . esc_html__("It can only be disabled by adding the following constant to your wp-config.php: define('APBCT_SERVICE__BOT_DETECTOR_ENABLED', false);", 'cleantalk-spam-protect')
3165+
. '<br>' . esc_html__("We do not recommend disabling this functionality.", 'cleantalk-spam-protect')
3166+
),
31533167
);
31543168

31553169
if (!empty($setting_id) && isset($descriptions[$setting_id])) {

inc/cleantalk-updater.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,3 +1377,14 @@ function apbct_update_to_6_60_0()
13771377
}
13781378
}
13791379
}
1380+
1381+
function apbct_update_to_6_76_0()
1382+
{
1383+
global $apbct;
1384+
1385+
if ( isset($apbct->settings['data__bot_detector_enabled']) ) {
1386+
$bot_detector_state = $apbct->settings['data__bot_detector_enabled'];
1387+
$apbct->data['bot_detector_enabled'] = $bot_detector_state;
1388+
$apbct->saveData();
1389+
}
1390+
}

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.

0 commit comments

Comments
 (0)