diff --git a/inc/cleantalk-integrations-by-route.php b/inc/cleantalk-integrations-by-route.php index d1b0b334b..42e35a768 100644 --- a/inc/cleantalk-integrations-by-route.php +++ b/inc/cleantalk-integrations-by-route.php @@ -11,6 +11,11 @@ '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 4e23013f3..28b713ca5 100644 --- a/inc/cleantalk-pluggable.php +++ b/inc/cleantalk-pluggable.php @@ -1966,6 +1966,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(); + } +}