Skip to content

Commit e04368d

Browse files
authored
Merge pull request #719 from CleanTalk/beta
Beta
2 parents 04a5a8e + 4554df5 commit e04368d

63 files changed

Lines changed: 1122 additions & 221 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.

.github/workflows/dev-fix-zip.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919

20-
- name: Install p7zip
21-
run: sudo apt-get update && sudo apt-get install -y p7zip-full
20+
- name: Install dependencies
21+
run: sudo apt-get update && sudo apt-get install -y p7zip-full rsync
2222

2323
- name: Set plugin name
2424
run: echo "PLUGIN_NAME=cleantalk-spam-protect" >> $GITHUB_ENV
@@ -55,8 +55,15 @@ jobs:
5555
.*
5656
EOF
5757
58-
- name: Create ZIP archive with 7z
59-
run: 7z a -tzip "${PLUGIN_NAME}.zip" . -xr@.7zignore
58+
- name: Prepare plugin directory
59+
run: |
60+
mkdir "${PLUGIN_NAME}"
61+
rsync -a ./ "${PLUGIN_NAME}/" \
62+
--exclude-from=.7zignore \
63+
--exclude="${PLUGIN_NAME}"
64+
65+
- name: Create ZIP archive
66+
run: 7z a -tzip "${PLUGIN_NAME}.zip" "${PLUGIN_NAME}"
6067

6168
- name: Create / update GitHub Release and upload asset
6269
uses: softprops/action-gh-release@v2
@@ -74,7 +81,8 @@ jobs:
7481

7582
- name: Clean up
7683
run: |
84+
rm -rf "${PLUGIN_NAME}"
7785
rm -f "${PLUGIN_NAME}.zip"
7886
if [ "${{ steps.check_ignore.outputs.ignore_exists }}" = "false" ]; then
7987
rm -f .7zignore
80-
fi
88+
fi

cleantalk.php

Lines changed: 41 additions & 7 deletions
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.70.1
7+
Version: 6.71
88
Author: CleanTalk - Anti-Spam Protection <welcome@cleantalk.org>
99
Author URI: https://cleantalk.org
1010
Text Domain: cleantalk-spam-protect
@@ -29,6 +29,7 @@
2929
use Cleantalk\ApbctWP\Firewall\SFW;
3030
use Cleantalk\ApbctWP\Firewall\SFWUpdateHelper;
3131
use Cleantalk\ApbctWP\Helper;
32+
use Cleantalk\ApbctWP\Promotions\GF2DBPromotion;
3233
use Cleantalk\ApbctWP\RemoteCalls;
3334
use Cleantalk\ApbctWP\RequestParameters\RequestParameters;
3435
use Cleantalk\ApbctWP\RequestParameters\SubmitTimeHandler;
@@ -272,6 +273,10 @@ function apbct_register_my_rest_routes()
272273
add_action('init', function () {
273274
global $apbct;
274275

276+
//promotions
277+
$promotion_gf2db = new GF2DBPromotion();
278+
$promotion_gf2db->init();
279+
275280
// Self cron
276281
$ct_cron = Cron::getInstance();
277282
$tasks_to_run = $ct_cron->checkTasks(); // Check for current tasks. Drop tasks inner counters.
@@ -1122,13 +1127,10 @@ function apbct_sfw_update__init($delay = 0)
11221127
return false;
11231128
}
11241129

1125-
// The Access key is empty
1126-
if ( ! $apbct->api_key && ! $apbct->ip_license ) {
1127-
return array('error' => 'SFW UPDATE INIT: KEY_IS_EMPTY');
1128-
}
1130+
$requirements_check = apply_filters('apbct_sfw_update__check_requirements', apbct_sfw_update__check_requirements());
11291131

1130-
if ( ! $apbct->data['key_is_ok'] ) {
1131-
return array('error' => 'SFW UPDATE INIT: KEY_IS_NOT_VALID');
1132+
if (true !== $requirements_check) {
1133+
return array('error' => $requirements_check);
11321134
}
11331135

11341136
// Get update period for server
@@ -1213,6 +1215,38 @@ function apbct_sfw_update__init($delay = 0)
12131215
);
12141216
}
12151217

1218+
/**
1219+
* Precheck server requirements before SFW update started.
1220+
* @return string|true True if check passed, first error string otherwise.
1221+
*/
1222+
function apbct_sfw_update__check_requirements()
1223+
{
1224+
global $apbct;
1225+
$result = true;
1226+
try {
1227+
// The Access key is empty
1228+
if ( ! $apbct->api_key && ! $apbct->ip_license ) {
1229+
throw new \Exception('KEY_IS_EMPTY');
1230+
}
1231+
1232+
if ( ! $apbct->data['key_is_ok'] ) {
1233+
throw new \Exception('KEY_IS_NOT_VALID');
1234+
}
1235+
1236+
$requirements_checker = new Cleantalk\ApbctWP\ServerRequirementsChecker\ServerRequirementsChecker();
1237+
1238+
$curl_multi_ok = $requirements_checker->getRequiredParameterValue('curl_multi_funcs_array');
1239+
1240+
if (!$curl_multi_ok) {
1241+
throw new \Exception('CURL MULTI FUNCTIONS NOT AVAILABLE');
1242+
}
1243+
} catch (\Exception $e) {
1244+
$result = 'SFW UPDATE INIT: ' . $e->getMessage();
1245+
}
1246+
1247+
return $result;
1248+
}
1249+
12161250
/**
12171251
* Decide need to force direct update
12181252
*

inc/cleantalk-admin.php

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ function apbct_admin__init()
353353

354354
add_filter('cleantalk_admin_bar__parent_node__before', 'apbct_admin__admin_bar__prepare_counters');
355355
add_filter('cleantalk_admin_bar__add_icon_to_parent_node', 'apbct_admin__admin_bar__prepare_counters');
356-
// Temporary disable the icon
357-
//add_filter( 'cleantalk_admin_bar__parent_node__before', 'apbct_admin__admin_bar__add_parent_icon', 10, 1 );
358356
add_filter('cleantalk_admin_bar__parent_node__after', 'apbct_admin__admin_bar__add_counter', 10, 1);
359357

360358
add_action('admin_bar_menu', 'apbct_admin__admin_bar__add_child_nodes', 1000);
@@ -677,6 +675,9 @@ function apbct_admin__badge__get_premium($placement = null)
677675
'top_info' => array(
678676
'prefix' => __('Make it right!', 'cleantalk-spam-protect') . ' ',
679677
'utm_set' => 'renew_top_info'),
678+
'cleantalk-bbpress-spam-scanner' => array(
679+
'prefix' => __('Make it right!', 'cleantalk-spam-protect') . ' ',
680+
'utm_set' => 'cleantalk-bbpress-spam-scanner'),
680681
'plugins_listing' => array(
681682
'prefix' => '',
682683
'utm_set' => 'renew_plugins_listing'),
@@ -746,6 +747,23 @@ function apbct_admin__admin_bar__add_structure($wp_admin_bar)
746747
$wp_admin_bar->add_node($spbc_title_node);
747748
}
748749

750+
/**
751+
* Link to project manager
752+
*/
753+
$project_manager_title_node = apbct__admin_bar__get_title_for_project_manager();
754+
if ( $project_manager_title_node ) {
755+
$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+
}
765+
}
766+
749767
/**
750768
* Adding FAQ node
751769
*/
@@ -756,6 +774,86 @@ function apbct_admin__admin_bar__add_structure($wp_admin_bar)
756774
}
757775
}
758776

777+
/**
778+
* Gets the title for the project manager admin bar node.
779+
*
780+
* This function constructs the title for the project manager admin bar node based on various conditions.
781+
* The title includes a link to the project manager.
782+
*
783+
* @return array|false The node data for the project manager admin bar node, or false if the project manager admin bar is not enabled.
784+
*/
785+
function apbct__admin_bar__get_title_for_project_manager()
786+
{
787+
if (!is_plugin_active('gravityforms/gravityforms.php')) {
788+
return false;
789+
}
790+
791+
$title = '<span><a>' . __('Project management', 'cleantalk-spam-protect') . '</a></span>';
792+
793+
return array(
794+
'parent' => 'cleantalk_admin_bar__parent_node',
795+
'id' => 'project_manager__parent_node',
796+
'title' => $title,
797+
);
798+
}
799+
800+
/**
801+
* Adds the title for the Gravity Forms to doBoard / Settings admin bar node.
802+
*
803+
* This function constructs the title for the Gravity Forms to doBoard / Settings admin bar node based on various conditions.
804+
* The title includes a link to the Gravity Forms to doBoard / Settings.
805+
*
806+
*/
807+
function apbct__admin_bar__add_gf2db_title()
808+
{
809+
if (!is_plugin_active('cleantalk-doboard-add-on-for-gravity-forms/cleantalk-doboard-add-on-for-gravity-forms.php')) {
810+
return false;
811+
}
812+
813+
$title = sprintf(
814+
'<a href="%s" target="_blank">%s</a>',
815+
admin_url('admin.php?page=gf_settings&subview=cleantalk-doboard-add-on-for-gravity-forms'),
816+
esc_html__('Gravity Forms to doBoard / Settings', 'cleantalk-spam-protect')
817+
);
818+
819+
return array(
820+
'parent' => 'project_manager__parent_node',
821+
'id' => 'gf2db_title',
822+
'title' => $title,
823+
);
824+
}
825+
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+
}
856+
759857
/**
760858
* Gets the title for the APBCT admin bar node.
761859
*

inc/cleantalk-common.php

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -427,39 +427,54 @@ function apbct_exclusions_check__url()
427427
$exclusions = explode(',', $apbct->settings['exclusions__urls']);
428428
}
429429

430+
//default haystack is request_uri
431+
$url_haystack = Server::getString('REQUEST_URI');
432+
433+
/**
434+
* Fix for AJAX and WP REST API forms
435+
*/
436+
// case for admin-ajax routes, may contain get params(!)
437+
$is_admin_ajax_like = stripos(Server::getString('REQUEST_URI'), '/wp-admin/admin-ajax.php') === 0;
438+
// case for wp-json paths
439+
$is_wp_json_like = stripos(Server::getString('REQUEST_URI'), '/wp-json/') === 0;
440+
// case for rest paths
430441
$rest_url_only_path = apbct_get_rest_url_only_path();
431-
// Fix for AJAX and WP REST API forms
432-
$haystack =
442+
$is_rest_only_path = $rest_url_only_path !== 'index.php' && stripos(Server::getString('REQUEST_URI'), $rest_url_only_path) === 0;
443+
444+
// if need to use http referrer as haystack
445+
$do_use_http_referrer = (
446+
Server::getString('HTTP_REFERER') &&
433447
(
434-
Server::get('REQUEST_URI') === '/wp-admin/admin-ajax.php' ||
435-
stripos(TT::toString(Server::getString('REQUEST_URI')), '/wp-json/') === 0 ||
436-
(
437-
$rest_url_only_path !== 'index.php' &&
438-
stripos(TT::toString(Server::getString('REQUEST_URI')), $rest_url_only_path) === 0
439-
)
440-
) &&
441-
TT::toString(Server::get('HTTP_REFERER'))
442-
? str_ireplace(
448+
$is_admin_ajax_like ||
449+
$is_wp_json_like ||
450+
$is_rest_only_path
451+
)
452+
);
453+
454+
// do combine actions from referrer if so
455+
if ($do_use_http_referrer) {
456+
$url_haystack = str_ireplace(
443457
array('http://', 'https://', strval(TT::toString(Server::get('HTTP_HOST')))),
444458
'',
445-
TT::toString(Server::get('HTTP_REFERER'))
446-
)
447-
: TT::toString(Server::get('REQUEST_URI'));
459+
Server::getString('HTTP_REFERER')
460+
);
461+
}
448462

463+
// if exclusions is full-url like, modify haystack to being full-url also
449464
if ( $apbct->data['check_exclusion_as_url'] ) {
450465
$protocol = ! in_array(Server::get('HTTPS'), ['off', '']) || Server::get('SERVER_PORT') == 443 ? 'https://' : 'http://';
451-
$haystack = $protocol . TT::toString(Server::get('SERVER_NAME')) . TT::toString($haystack);
466+
$url_haystack = $protocol . TT::toString(Server::get('SERVER_NAME')) . TT::toString($url_haystack);
452467
}
453468

454-
$haystack = TT::toString($haystack);
469+
$url_haystack = TT::toString($url_haystack);
455470

456471
foreach ( $exclusions as $exclusion ) {
457472
if (
458473
(
459474
$apbct->settings['exclusions__urls__use_regexp'] &&
460-
preg_match('@' . $exclusion . '@', $haystack) === 1
475+
preg_match('@' . $exclusion . '@', $url_haystack) === 1
461476
) ||
462-
stripos($haystack, $exclusion) !== false
477+
stripos($url_haystack, $exclusion) !== false
463478
) {
464479
return true;
465480
}

inc/cleantalk-integrations-by-hook.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@
478478
'setting' => 'forms__contact_forms_test',
479479
'ajax' => true
480480
),
481+
'BitForm' => array(
482+
'hook' => 'bitform_filter_form_validation',
483+
'setting' => 'forms__contact_forms_test',
484+
'ajax' => false
485+
),
481486
);
482487

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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ function skip_for_ct_contact_form_validate()
112112
'12' => apbct_is_in_referer('/wp-admin/'),
113113
// task 9405 - prevent Forminator forms direct attacks
114114
'13' => apbct_is_in_uri('/login/') && Post::get('action') !== 'forminator_submit_form_custom-forms',
115-
'14' => apbct_is_in_uri('/my-account/edit-account/'),
115+
'14' => (apbct_is_in_uri('/my-account/edit-account/') && (int)$apbct->settings['data__protect_logged_in'] === 1),
116116
// WooCommerce edit account page
117-
'15' => apbct_is_in_uri('/my-account/edit-address/'),
117+
'15' => (apbct_is_in_uri('/my-account/edit-address/') && (int)$apbct->settings['data__protect_logged_in'] === 1),
118118
// WooCommerce edit account page
119-
'16' => (isset($_POST['action']) && $_POST['action'] === 'save_account_details'),
119+
'16' => (isset($_POST['action']) && $_POST['action'] === 'save_account_details' && (int)$apbct->settings['data__protect_logged_in'] === 1),
120120
// WooCommerce edit account action
121121
'17' => apbct_is_in_uri('/peepsoajax/profilefieldsajax.validate_register'),
122122
'18' => (isset($_GET['ptype']) && $_GET['ptype'] === 'login'),

0 commit comments

Comments
 (0)