From f65d15cda077cf86e685e119f602517ba0564802 Mon Sep 17 00:00:00 2001 From: Glomberg Date: Wed, 18 Feb 2026 20:36:23 +0300 Subject: [PATCH] Upd. Integration. HivePress forms protection improved. --- inc/cleantalk-integrations-by-route.php | 7 ++- inc/cleantalk-pluggable.php | 5 +++ inc/cleantalk-public-validate.php | 18 -------- .../Antispam/Integrations/HivePress.php | 44 +++++++++++++++++++ 4 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 lib/Cleantalk/Antispam/Integrations/HivePress.php diff --git a/inc/cleantalk-integrations-by-route.php b/inc/cleantalk-integrations-by-route.php index 9bc3bdb92..42e35a768 100644 --- a/inc/cleantalk-integrations-by-route.php +++ b/inc/cleantalk-integrations-by-route.php @@ -10,7 +10,12 @@ 'rest_route' => '/wp-recipe-maker/v1/user-rating/', 'setting' => 'forms__contact_forms_test', 'rest' => true, - ) + ), + 'HivePress' => array( + 'rest_route' => '/hivepress/v1/listings/', + 'setting' => 'forms__contact_forms_test', + 'rest' => true, + ), ); add_filter('rest_pre_dispatch', function ($result, $_, $request) use ($apbct_active_rest_integrations) { diff --git a/inc/cleantalk-pluggable.php b/inc/cleantalk-pluggable.php index 24fcab4e7..015c387a6 100644 --- a/inc/cleantalk-pluggable.php +++ b/inc/cleantalk-pluggable.php @@ -1926,6 +1926,11 @@ class_exists('Cleantalk\Antispam\Integrations\CleantalkInternalForms') ) { return 'AsgarosForum'; } + + // Plugin Name: HivePress + if ( apbct_is_plugin_active('hivepress/hivepress.php') && apbct_is_in_uri('/hivepress/v1/listings/')) { + return 'Plugin Name: HivePress skip REST route checking'; + } } // WP Fusion Abandoned Cart Addon diff --git a/inc/cleantalk-public-validate.php b/inc/cleantalk-public-validate.php index a7d4348af..1ba477999 100644 --- a/inc/cleantalk-public-validate.php +++ b/inc/cleantalk-public-validate.php @@ -211,24 +211,6 @@ function ct_contact_form_validate() return false; } - //hivepress theme listing integration - if ( empty($sender_email) && - function_exists('hivepress') && - is_callable('hivepress') && - apbct_is_user_logged_in() && - $apbct->settings['data__protect_logged_in'] - ) { - if (! isset($_POST['_model'])) { - $current_user = wp_get_current_user(); - if ( ! empty($current_user->data->user_email) ) { - $sender_email = $current_user->data->user_email; - } - } else { - do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '(hivepress theme listing integration):' . __LINE__, $_POST); - return false; - } - } - //tellallfriend integration #1 if ( isset($_POST['TellAFriend_Link']) ) { $tmp = Sanitize::cleanTextField(Post::get('TellAFriend_Link')); diff --git a/lib/Cleantalk/Antispam/Integrations/HivePress.php b/lib/Cleantalk/Antispam/Integrations/HivePress.php new file mode 100644 index 000000000..50a1eda3c --- /dev/null +++ b/lib/Cleantalk/Antispam/Integrations/HivePress.php @@ -0,0 +1,44 @@ +settings['data__protect_logged_in'] + ) { + do_action('apbct_skipped_request', __FILE__ . ' -> ' . __FUNCTION__ . '(hivepress theme listing integration):' . __LINE__, $_POST); + return null; + } + + $sender_email = ''; + $current_user = wp_get_current_user(); + if ( ! empty($current_user->data->user_email) ) { + $sender_email = $current_user->data->user_email; + } + + $data = ct_gfa_dto(apply_filters('apbct__filter_post', $argument), $sender_email)->getArray(); + return $data; + } + + public function allow() + { + return null; + } + + public function doBlock($message) + { + wp_send_json( + [ + 'error' => ['message' => $message], + ] + ); + die(); + } +}