PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
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 / Settings / Customizer.php

Customizer.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.14, at app/Services/Settings/Customizer.php

57 lines 1.7 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\Settings;
4
5 use Exception;
6 use FluentForm\App\Models\FormMeta;
7 use FluentForm\App\Helpers\Helper;
8 use FluentForm\Framework\Support\Arr;
9
10 class Customizer
11 {
12 public function get($formId, $metaKeys = ['_custom_form_css', '_custom_form_js'])
13 {
14 $result = [];
15
16 foreach ($metaKeys as $metaKey) {
17 $value = Helper::getFormMeta($formId, $metaKey, '');
18
19 // If the meta doesn't exist or is empty, skip it
20 if ($value === '' || $value === null) {
21 continue;
22 }
23
24 if ($metaKey === '_custom_form_css') {
25 $result['css'] = $value;
26 } elseif ($metaKey === '_ff_selected_style') {
27 $result['styler_theme'] = $value;
28 } elseif ($metaKey === '_ff_form_styles') {
29 $result['styler_styles'] = $value;
30 } elseif ($metaKey === '_custom_form_js') {
31 $result['js'] = $value;
32 } else {
33 $result[$metaKey] = $value;
34 }
35 }
36
37 return $result;
38 }
39
40 public function store($attributes = [])
41 {
42 if (!fluentformCanUnfilteredHTML()) {
43 throw new Exception(
44 esc_html__('You need unfiltered_html permission to save Custom CSS & JS', 'fluentform')
45 );
46 }
47
48 $formId = absint(Arr::get($attributes, 'form_id'));
49
50 $css = fluentformSanitizeCSS(Arr::get($attributes, 'css'));
51 $js = fluentform_kses_js(Arr::get($attributes, 'js'));
52
53 FormMeta::persist($formId, '_custom_form_css', $css);
54 FormMeta::persist($formId, '_custom_form_js', $js);
55 }
56 }
57