PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.13
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.13
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 3.6.66 All 195 releases
fluentform / app / Hooks / Frontend.php

Frontend.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 4.3.13, at app/Hooks/Frontend.php

79 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Declare frontend actions/filters/shortcodes
5 */
6
7 //if ($app->getEnv() == 'dev') {
8 // add_filter('init', function() use ($app) {
9 // if ($header = $app->request->header('X-HOOK')) {
10 // error_log($header);
11 // }
12 // });
13 //}
14
15
16 /*
17 * Exclude For WP Rocket Settings
18 */
19 if(defined('WP_ROCKET_VERSION')) {
20 add_filter('rocket_excluded_inline_js_content', function ($lines) {
21 $lines[] = 'fluent_form_ff_form_instance';
22 $lines[] = 'fluentFormVars';
23 $lines[] = 'fluentform_payment';
24 return $lines;
25 });
26 }
27 /*
28 * Push captcha in all forms when enabled from global settings
29 */
30 add_filter('fluentform_rendering_form', function ($form) {
31 $option = get_option('_fluentform_global_form_settings');
32 $enabled = \FluentForm\Framework\Helpers\ArrayHelper::get($option, 'misc.autoload_captcha');
33 if (!$enabled) {
34 return $form;
35 }
36 $type = \FluentForm\Framework\Helpers\ArrayHelper::get($option, 'misc.captcha_type');
37 $reCaptcha = [
38 "element" => "recaptcha",
39 "attributes" => [
40 "name" => "recaptcha",
41 ],
42 ];
43 $hCaptcha = [
44 "element" => "hcaptcha",
45 "attributes" => [
46 "name" => "hcaptcha",
47 ],
48 ];
49 $turnstile = [
50 "element" => "turnstile",
51 "attributes" => [
52 "name" => "turnstile",
53 ],
54 ];
55
56 if ($type == 'recaptcha') {
57 $captcha = $reCaptcha;
58 } elseif ($type == 'hcaptcha') {
59 $captcha = $hCaptcha;
60 } elseif ($type == 'turnstile') {
61 $captcha = $turnstile;
62 }
63
64 // place recaptcha below custom submit button
65 $hasCustomSubmit = false;
66 foreach ($form->fields['fields'] as $index => $field) {
67 if ($field['element'] == 'custom_submit_button') {
68 $hasCustomSubmit = true;
69 array_splice($form->fields['fields'], $index, 0, [$captcha]);
70 break;
71 }
72 }
73 if (!$hasCustomSubmit) {
74 $form->fields['fields'][] = $captcha;
75 }
76
77 return $form;
78 }, 10, 1);
79