PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.21
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.21
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Modules / Form / HoneyPot.php

HoneyPot.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 4.3.21, at app/Modules/Form/HoneyPot.php

61 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\Form;
4
5 use FluentForm\Framework\Foundation\Application;
6 use FluentForm\Framework\Helpers\ArrayHelper;
7
8 class HoneyPot
9 {
10 private $app;
11
12 public function __construct(Application $application)
13 {
14 $this->app = $application;
15 }
16
17 public function renderHoneyPot($form)
18 {
19 if (!$this->isEnabled($form->id)) {
20 return;
21 }
22 ?>
23 <span style="display: none !important;"><input type="checkbox"
24 name="<?php echo esc_attr($this->getFieldName($form->id)); ?>"
25 value="1" style="display:none !important;" tabindex="-1"></span>
26 <?php
27 }
28
29 public function verify($insertData, $requestData, $formId)
30 {
31 if (!$this->isEnabled($formId)) {
32 return;
33 }
34
35 // Now verify
36 if (ArrayHelper::get($requestData, $this->getFieldName($formId))) {
37 // It's a bot! Block him
38 wp_send_json(
39 [
40 'errors' => 'Sorry! You can not submit this form at this moment!',
41 ],
42 422
43 );
44 }
45
46 return;
47 }
48
49 public function isEnabled($formId = false)
50 {
51 $option = get_option('_fluentform_global_form_settings');
52 $status = 'yes' == ArrayHelper::get($option, 'misc.honeypotStatus');
53 return apply_filters('fluentform_honeypot_status', $status, $formId);
54 }
55
56 private function getFieldName($formId)
57 {
58 return apply_filters('fluentform_honeypot_name', 'item__' . $formId . '__fluent_checkme_', $formId);
59 }
60 }
61