PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.14
3.1.14 3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 123 releases
firebox / Inc / Core / Form / Fields / Fields / HCaptcha.php

HCaptcha.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.14, at Inc/Core/Form/Fields/Fields/HCaptcha.php

110 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.14 Free
5 *
6 * @author FirePlugins <[email protected]>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Form\Fields\Fields;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 use FPFramework\Base\Filter;
20
21 class HCaptcha extends \FireBox\Core\Form\Fields\Field
22 {
23 protected $type = 'hcaptcha';
24
25 protected $siteKey = '';
26
27 protected $field_type = '';
28
29 public function __construct($options = [])
30 {
31 parent::__construct($options);
32
33 $this->siteKey = \FireBox\Core\Helpers\Captcha\HCaptcha::getSiteKey();
34
35 $this->field_type = $this->getOptionValue('field_type');
36 if ($this->field_type === 'invisible')
37 {
38 $this->options['css_class'][] = 'fb-hide';
39 }
40
41 // Empty the name in order to exclude this field from being stored in the database.
42 $this->setOptionValue('name', '');
43 }
44
45 /**
46 * Validate the field.
47 *
48 * @param mixed $value
49 *
50 * @return void
51 */
52 public function validate(&$value = '')
53 {
54 $integration = new \FPFramework\Base\Integrations\HCaptcha(
55 ['secret' => \FireBox\Core\Helpers\Captcha\HCaptcha::getSecretKey()]
56 );
57
58 $response = isset($this->data['h-captcha-response']) ? $this->data['h-captcha-response'] : null;
59
60 $integration->validate($response);
61
62 if (!$integration->success())
63 {
64 $this->validation_message = $integration->getLastError();
65 return false;
66 }
67
68 return true;
69 }
70
71 /**
72 * Returns the field input.
73 *
74 * @return void
75 */
76 public function getInput()
77 {
78 if (empty($this->siteKey) || empty(\FireBox\Core\Helpers\Captcha\HCaptcha::getSecretKey()))
79 {
80 ?>
81 <div class="form-error-message"><?php echo esc_html(firebox()->_('FB_ENTER_HCAPTCHA_KEYS')); ?>
82 <?php
83 return;
84 }
85
86 $locale = substr(get_locale(), 0, 2);
87
88 wp_enqueue_script(
89 'firebox-hcaptcha-lib',
90 'https://hcaptcha.com/1/api.js?onload=FireBoxInitHCaptcha&render=explicit&hl=' . $locale,
91 [],
92 FBOX_VERSION,
93 true
94 );
95 wp_enqueue_script('firebox-hcaptcha',
96 FBOX_MEDIA_PUBLIC_URL . 'js/hcaptcha.js',
97 [],
98 FBOX_VERSION,
99 true
100 );
101
102 ?>
103 <div
104 class="firebox-form-field-hcaptcha"
105 data-sitekey="<?php echo esc_attr($this->siteKey); ?>"
106 data-theme="<?php echo esc_attr($this->getOptionValue('theme')); ?>"
107 data-size="<?php echo esc_attr($this->field_type === 'invisible' ? $this->field_type : $this->getOptionValue('size')); ?>"></div>
108 <?php
109 }
110 }