PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.21
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.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 / Services / FormBuilder / Components / Recaptcha.php

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

52 lines 1.5 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 Recaptcha extends BaseComponent
6 {
7 /**
8 * Compile and echo the html element
9 * @param array $data [element data]
10 * @param stdClass $form [Form Object]
11 * @return viod
12 */
13 public function compile($data, $form)
14 {
15 $elementName = $data['element'];
16 $data = apply_filters('fluenform_rendering_field_data_'.$elementName, $data, $form);
17
18 wp_enqueue_script(
19 'google-recaptcha',
20 'https://www.google.com/recaptcha/api.js',
21 array(),
22 FLUENTFORM_VERSION,
23 true
24 );
25
26 $key = get_option('_fluentform_reCaptcha_details');
27 if($key && isset($key['siteKey'])) {
28 $siteKey = $key['siteKey'];
29 } else {
30 $siteKey = '';
31 }
32
33 $recaptchaBlock = "<div
34 data-sitekey='{$siteKey}'
35 id='fluentform-recaptcha-{$form->id}'
36 class='ff-el-recaptcha g-recaptcha'
37 data-callback='fluentFormrecaptchaSuccessCallback'></div>";
38
39 $label = '';
40 if (!empty($data['settings']['label'])) {
41 $label = "<div class='ff-el-input--label'><label>{$data['settings']['label']}</label></div>";
42 }
43
44 $el = "<div class='ff-el-input--content'><div data-fluent_id='".$form->id."' name='g-recaptcha-response'>{$recaptchaBlock}</div></div>";
45 $atts = $this->buildAttributes(
46 \FluentForm\Framework\Helpers\ArrayHelper::except($data['attributes'], 'name')
47 );
48 $html = "<div class='ff-el-group' {$atts}>{$label}{$el}</div>";
49 echo apply_filters('fluenform_rendering_field_html_'.$elementName, $html, $data, $form);
50 }
51 }
52