PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.6
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.6
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 / Services / FormBuilder / Components / Hcaptcha.php

Hcaptcha.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.6, at app/Services/FormBuilder/Components/Hcaptcha.php

92 lines 2.9 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\Services\FormBuilder\Components;
4
5 class Hcaptcha extends BaseComponent
6 {
7 /**
8 * Compile and echo the html element
9 *
10 * @param array $data [element data]
11 * @param \stdClass $form [Form Object]
12 *
13 * @return void
14 */
15 public function compile($data, $form)
16 {
17 $elementName = $data['element'];
18 $data = apply_filters_deprecated(
19 'fluentform_rendering_field_data_' . $elementName,
20 [
21 $data,
22 $form
23 ],
24 FLUENTFORM_FRAMEWORK_UPGRADE,
25 'fluentform/rendering_field_data_' . $elementName,
26 'Use fluentform/rendering_field_data_' . $elementName . ' instead of fluentform_rendering_field_data_' . $elementName
27 );
28 $data = apply_filters('fluentform/rendering_field_data_' . $elementName, $data, $form);
29
30 $key = get_option('_fluentform_hCaptcha_details');
31 if ($key && isset($key['siteKey'])) {
32 $siteKey = $key['siteKey'];
33 } else {
34 $siteKey = '';
35 }
36
37 if (! $siteKey) {
38 return false;
39 }
40
41 if (!wp_script_is('hcaptcha')) {
42 $apiUrl = 'https://js.hcaptcha.com/1/api.js?render=explicit';
43
44 $locale = apply_filters('fluentform/hcaptcha_lang', '');
45 if ($locale) {
46 $apiUrl .= '&hl=' . $locale;
47 }
48
49 wp_enqueue_script(
50 'hcaptcha',
51 $apiUrl,
52 [],
53 FLUENTFORM_VERSION,
54 true
55 );
56 }
57
58 $hcaptchaBlock = "<div
59 data-sitekey='" . esc_attr($siteKey) . "'
60 id='fluentform-hcaptcha-{$form->id}-{$form->instance_index}'
61 class='ff-el-hcaptcha h-captcha'></div>";
62
63 $label = '';
64 if (! empty($data['settings']['label'])) {
65 $label = "<div class='ff-el-input--label'><label>" . $data['settings']['label'] . '</label></div>';
66 }
67
68 $containerClass = '';
69 if (! empty($data['settings']['label_placement'])) {
70 $containerClass = 'ff-el-form-' . $data['settings']['label_placement'];
71 }
72
73 $el = "<div class='ff-el-input--content'><div data-fluent_id='" . $form->id . "' name='h-captcha-response'>{$hcaptchaBlock}</div></div>";
74
75 $html = "<div class='ff-el-group " . esc_attr($containerClass) . "' >" . fluentform_sanitize_html($label) . "{$el}</div>";
76
77 $html = apply_filters_deprecated(
78 'fluentform_rendering_field_html_' . $elementName,
79 [
80 $html,
81 $data,
82 $form
83 ],
84 FLUENTFORM_FRAMEWORK_UPGRADE,
85 'fluentform/rendering_field_html_' . $elementName,
86 'Use fluentform/rendering_field_html_' . $elementName . ' instead of fluentform_rendering_field_html_' . $elementName
87 );
88
89 $this->printContent('fluentform/rendering_field_html_' . $elementName, $html, $data, $form);
90 }
91 }
92