Skip to content

Commit 324b561

Browse files
committed
Merge branch 'dev' into quform_codecov_2.ag
2 parents a91e13c + e7963fa commit 324b561

59 files changed

Lines changed: 1313 additions & 377 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.99-dev
7+
Version: 6.76.99-dev
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: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,6 @@ function apbct__bot_detector_get_fired_exclusions()
18591859
*/
18601860
function apbct__bot_detector_get_fd_log()
18611861
{
1862-
global $apbct;
18631862
$result = array(
18641863
'plugin_status' => 'OK',
18651864
'error_msg' => '',
@@ -1874,7 +1873,7 @@ function apbct__bot_detector_get_fd_log()
18741873
}
18751874

18761875
try {
1877-
if ( TT::toString($apbct->settings['data__bot_detector_enabled']) === '0') {
1876+
if ( ! apbct__is_bot_detector_enabled() ) {
18781877
throw new \Exception('bot detector library usage is disabled');
18791878
}
18801879
// Retrieve bot detector frontend data log from Alt Sessions
@@ -1931,3 +1930,24 @@ function apbct__bot_detector_get_custom_exclusion_from_settings()
19311930
}
19321931
return $exclusions;
19331932
}
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
@@ -135,7 +135,7 @@
135135
'ajax' => false
136136
),
137137
'EasyDigitalDownloads' => array(
138-
'hook' => array('edd_pre_process_register_form', 'edd_insert_user_args'),
138+
'hook' => array('edd_pre_process_register_form', 'edd_insert_user_args', 'edd_customer_pre_create'),
139139
'setting' => 'forms__registrations_test',
140140
'ajax' => false
141141
),

inc/cleantalk-public-integrations.php

Lines changed: 9 additions & 0 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'] = '';

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
) {
@@ -375,6 +375,36 @@ class_exists('Jetpack', false) &&
375375
}
376376
}
377377

378+
/**
379+
* SiteGround Speed Optimizer: register sgo_bypass_query_params filter.
380+
*/
381+
function apbct_sgo_optimizer__register_bypass_query_params()
382+
{
383+
if ( ! defined('SG_OPTIMIZER_VERSION') ) {
384+
return;
385+
}
386+
add_filter('sgo_bypass_query_params', 'apbct_sgo_bypass_query_params', 10, 1);
387+
}
388+
389+
/**
390+
* Adds apbct_no_cache to SG Optimizer bypass list.
391+
*
392+
* @param string[] $bypass_query_params
393+
*
394+
* @return string[]
395+
*/
396+
function apbct_sgo_bypass_query_params($bypass_query_params)
397+
{
398+
if ( ! is_array($bypass_query_params) ) {
399+
$bypass_query_params = array();
400+
}
401+
if ( ! in_array('apbct_no_cache', $bypass_query_params, true) ) {
402+
$bypass_query_params[] = 'apbct_no_cache';
403+
}
404+
405+
return $bypass_query_params;
406+
}
407+
378408
function apbct_buffer__start()
379409
{
380410
ob_start();
@@ -537,7 +567,7 @@ function apbct_hook__wp_footer()
537567
(
538568
$apbct->settings['data__pixel'] === '3' &&
539569
! apbct_is_cache_plugins_exists() &&
540-
$apbct->settings['data__bot_detector_enabled'] !== '1'
570+
! apbct__is_bot_detector_enabled()
541571
)
542572
) {
543573
echo '<img alt="Cleantalk Pixel" title="Cleantalk Pixel" id="apbct_pixel" style="display: none;" src="' . Escape::escUrl($apbct->pixel_url) . '">';
@@ -1242,7 +1272,7 @@ function apbct_enqueue_and_localize_public_scripts()
12421272
ApbctEnqueue::getInstance()->js($bundle_name, array(), $in_footer);
12431273

12441274
// Bot detector
1245-
if ( $apbct->settings['data__bot_detector_enabled'] && ! apbct_bot_detector_scripts_exclusion()) {
1275+
if ( apbct__is_bot_detector_enabled() && ! apbct_bot_detector_scripts_exclusion()) {
12461276
// Attention! Skip old enqueue way for external script.
12471277
wp_enqueue_script(
12481278
'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.

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.

0 commit comments

Comments
 (0)