Skip to content

Commit e9f6f34

Browse files
committed
Merge branch 'dev' into quform_codecov.ag
2 parents bc8377f + 7eeb481 commit e9f6f34

72 files changed

Lines changed: 1980 additions & 501 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.77.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-admin.php

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -751,17 +751,10 @@ function apbct_admin__admin_bar__add_structure($wp_admin_bar)
751751
* Link to project manager
752752
*/
753753
$project_manager_title_node = apbct__admin_bar__get_title_for_project_manager();
754-
if ( $project_manager_title_node ) {
754+
$gf2db_title_node = apbct__admin_bar__add_gf2db_title();
755+
if ( $project_manager_title_node && $gf2db_title_node) {
755756
$wp_admin_bar->add_node($project_manager_title_node);
756-
$gf2db_title_node = apbct__admin_bar__add_gf2db_title();
757-
if ($gf2db_title_node) {
758-
$wp_admin_bar->add_node($gf2db_title_node);
759-
} else {
760-
$gf2db_invite_to_install_title = apbct__admin_bar__get_title_for_gf2db_invite_to_install();
761-
if ($gf2db_invite_to_install_title) {
762-
$wp_admin_bar->add_node($gf2db_invite_to_install_title);
763-
}
764-
}
757+
$wp_admin_bar->add_node($gf2db_title_node);
765758
}
766759

767760
/**
@@ -823,36 +816,6 @@ function apbct__admin_bar__add_gf2db_title()
823816
);
824817
}
825818

826-
/**
827-
* Gets the title for the "Gravity Forms to doBoard" Add-On invite to install admin bar node.
828-
*
829-
* This function constructs the title for the "Gravity Forms to doBoard" Add-On invite to install admin bar node based on various conditions.
830-
* The title includes a link to the "Gravity Forms to doBoard" Add-On invite to install.
831-
*
832-
* @return array|false The node data for the "Gravity Forms to doBoard" Add-On invite to install admin bar node, or false if the "Gravity Forms to doBoard" Add-On invite to install admin bar node is not enabled.
833-
*/
834-
function apbct__admin_bar__get_title_for_gf2db_invite_to_install()
835-
{
836-
if (is_plugin_active('cleantalk-doboard-add-on-for-gravity-forms/cleantalk-doboard-add-on-for-gravity-forms.php')) {
837-
return false;
838-
}
839-
840-
$title = sprintf(
841-
'<a href="%s" target="_blank" title="%s">%s</a>',
842-
admin_url('plugin-install.php?s=GF2DB&tab=search&type=term'),
843-
esc_html__(
844-
'Organize and track all messages from your site. Gravity Forms, upgraded with project management.',
845-
'cleantalk-spam-protect'
846-
),
847-
esc_html__('Install "Gravity Forms to doBoard" Add-On', 'cleantalk-spam-protect')
848-
);
849-
850-
return array(
851-
'parent' => 'project_manager__parent_node',
852-
'id' => 'gf2db_invite_to_install_title',
853-
'title' => $title,
854-
);
855-
}
856819

857820
/**
858821
* Gets the title for the APBCT admin bar node.

inc/cleantalk-common.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,14 @@ function apbct_get_sender_info()
591591
$page_hits = RequestParameters::get('apbct_page_hits', Cookie::$force_alt_cookies_global);
592592
$page_hits = !empty($page_hits) ? TT::toString($page_hits) : null;
593593

594+
$ct_options = json_encode(
595+
array_merge(
596+
(array) $apbct->settings,
597+
['data__bot_detector_enabled' => apbct__is_bot_detector_enabled() ? 1 : 0]
598+
),
599+
JSON_UNESCAPED_SLASHES
600+
);
601+
594602
//Let's keep $data_array for debugging
595603
$data_array = array(
596604
'plugin_request_id' => $apbct->plugin_request_id,
@@ -599,7 +607,7 @@ function apbct_get_sender_info()
599607
'USER_AGENT' => Server::get('HTTP_USER_AGENT'),
600608
'page_url' => apbct_sender_info___get_page_url(),
601609
'cms_lang' => substr(get_locale(), 0, 2),
602-
'ct_options' => json_encode($apbct->settings, JSON_UNESCAPED_SLASHES),
610+
'ct_options' => $ct_options,
603611
'fields_number' => sizeof($_POST),
604612
'direct_post' => $cookie_is_ok === null && apbct_is_post() ? 1 : 0,
605613
// Raw data to validated JavaScript test in the cloud
@@ -1843,7 +1851,6 @@ function apbct__bot_detector_get_fired_exclusions()
18431851
*/
18441852
function apbct__bot_detector_get_fd_log()
18451853
{
1846-
global $apbct;
18471854
$result = array(
18481855
'plugin_status' => 'OK',
18491856
'error_msg' => '',
@@ -1858,7 +1865,7 @@ function apbct__bot_detector_get_fd_log()
18581865
}
18591866

18601867
try {
1861-
if ( TT::toString($apbct->settings['data__bot_detector_enabled']) === '0') {
1868+
if ( ! apbct__is_bot_detector_enabled() ) {
18621869
throw new \Exception('bot detector library usage is disabled');
18631870
}
18641871
// Retrieve bot detector frontend data log from Alt Sessions
@@ -1915,3 +1922,24 @@ function apbct__bot_detector_get_custom_exclusion_from_settings()
19151922
}
19161923
return $exclusions;
19171924
}
1925+
1926+
/**
1927+
* Check if Bot-Detector is enabled/disabled
1928+
*
1929+
* @return bool
1930+
*/
1931+
function apbct__is_bot_detector_enabled()
1932+
{
1933+
global $apbct;
1934+
1935+
// Constant is preferred
1936+
if ( isset($apbct->service_constants->bot_detector_enabled) && $apbct->service_constants->bot_detector_enabled->isDefined() ) {
1937+
return (bool) $apbct->service_constants->bot_detector_enabled->getValue();
1938+
}
1939+
// Check by $apbct->data
1940+
if ( isset($apbct->data['bot_detector_enabled']) ) {
1941+
return (bool) $apbct->data['bot_detector_enabled'];
1942+
}
1943+
// By default - enabled
1944+
return true;
1945+
}

inc/cleantalk-integrations-by-hook.php

Lines changed: 8 additions & 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
),
@@ -291,6 +291,13 @@
291291
'setting' => 'forms__contact_forms_test',
292292
'ajax' => true
293293
),
294+
'BookingCalendar' => array(
295+
'hook' => [
296+
'WPBC_AJX_BOOKING__CREATE',
297+
],
298+
'setting' => 'forms__contact_forms_test',
299+
'ajax' => true
300+
),
294301
'JobstackThemeRegistration' => array(
295302
'hook' => 'wp_loaded',
296303
'setting' => 'forms__registrations_test',

inc/cleantalk-pluggable.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,13 @@ function apbct_is_skip_request($ajax = false, $ajax_message_obj = array())
14061406
return 'BookingPress service action';
14071407
}
14081408

1409+
if (
1410+
apbct_is_plugin_active('booking/wpdev-booking.php') &&
1411+
(Post::getString('action') === 'WPBC_AJX_BOOKING__CREATE')
1412+
) {
1413+
return 'WP BookingCalendar service action';
1414+
}
1415+
14091416
if (
14101417
(
14111418
apbct_is_plugin_active('pixelyoursite/pixelyoursite.php') ||
@@ -1812,6 +1819,11 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms')
18121819
apbct_is_in_uri('wc-ajax=iwd_opc_update_order_review') ) {
18131820
return 'cartflows_save_cart';
18141821
}
1822+
// WC addon - Metorik Helper plugin service requests
1823+
if ( apbct_is_plugin_active('metorik-helper/metorik-helper.php') &&
1824+
apbct_is_in_uri('wc-ajax=metorik_capture_customer_data') ) {
1825+
return 'metorik-helper skip';
1826+
}
18151827
// Vault Press (JetPack) plugin service requests
18161828
if (
18171829
Post::get('do_backups') !== '' &&

inc/cleantalk-public-integrations.php

Lines changed: 31 additions & 14 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'] = '';
@@ -1451,6 +1460,11 @@ function apbct_form__contactForm7__testSpam($spam, $_submission = null)
14511460
*/
14521461
$input_array = apply_filters('apbct__filter_post', $_POST);
14531462

1463+
$honeypot_params = array();
1464+
if ( isset($input_array['apbct__email_id__wp_contact_form_7']) ) {
1465+
$honeypot_params['honeypot_field'] = ($input_array['apbct__email_id__wp_contact_form_7'] === '') ? 1 : 0;
1466+
}
1467+
14541468
$ct_temp_msg_data = ct_get_fields_any($input_array);
14551469

14561470
$sender_email = isset($ct_temp_msg_data['email']) ? $ct_temp_msg_data['email'] : '';
@@ -1463,21 +1477,24 @@ function apbct_form__contactForm7__testSpam($spam, $_submission = null)
14631477
}
14641478

14651479
$base_call_result = apbct_base_call(
1466-
array(
1467-
'message' => $message,
1468-
'sender_email' => $sender_email,
1469-
'sender_nickname' => $sender_nickname,
1470-
'js_on' => $checkjs,
1471-
'post_info' => array('comment_type' => 'contact_form_wordpress_cf7'),
1472-
'sender_info' => array(
1473-
'form_validation' => ! isset($apbct->validation_error)
1474-
? null
1475-
: json_encode(array(
1476-
'validation_notice' => $apbct->validation_error,
1477-
'page_url' => TT::toString(Server::get('HTTP_HOST')) . TT::toString(Server::get('REQUEST_URI')),
1478-
)),
1479-
'sender_emails_array' => $sender_emails_array,
1480+
array_merge(
1481+
array(
1482+
'message' => $message,
1483+
'sender_email' => $sender_email,
1484+
'sender_nickname' => $sender_nickname,
1485+
'js_on' => $checkjs,
1486+
'post_info' => array('comment_type' => 'contact_form_wordpress_cf7'),
1487+
'sender_info' => array(
1488+
'form_validation' => ! isset($apbct->validation_error)
1489+
? null
1490+
: json_encode(array(
1491+
'validation_notice' => $apbct->validation_error,
1492+
'page_url' => TT::toString(Server::get('HTTP_HOST')) . TT::toString(Server::get('REQUEST_URI')),
1493+
)),
1494+
'sender_emails_array' => $sender_emails_array,
1495+
),
14801496
),
1497+
$honeypot_params
14811498
)
14821499
);
14831500

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',

0 commit comments

Comments
 (0)