PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.13
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.13
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 / GlobalSettings / GlobalSettingsService.php

GlobalSettingsService.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.13, at app/Services/GlobalSettings/GlobalSettingsService.php

114 lines 3.3 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\GlobalSettings;
4
5 use FluentForm\Framework\Support\Arr;
6
7 class GlobalSettingsService
8 {
9 private function isAllowedOptionKey($key)
10 {
11 $allowedPrefixes = [
12 'fluentform_',
13 '_fluentform_',
14 'fluentform-',
15 '_fluentform-',
16 ];
17 foreach ($allowedPrefixes as $prefix) {
18 if (strpos($key, $prefix) === 0) {
19 return true;
20 }
21 }
22 return false;
23 }
24
25 public function get($attributes = [])
26 {
27 $values = [];
28 $key = Arr::get($attributes, 'key');
29
30 if (is_array($key)) {
31 foreach ($key as $key_item) {
32 $sanitizedKey = sanitize_text_field($key_item);
33 if (!$this->isAllowedOptionKey($sanitizedKey)) {
34 continue;
35 }
36 $values[$key_item] = get_option($sanitizedKey);
37 }
38 } else {
39 $sanitizedKey = sanitize_text_field($key);
40 if (!$this->isAllowedOptionKey($sanitizedKey)) {
41 return $values;
42 }
43 $values[$key] = get_option($sanitizedKey);
44 }
45
46 $values = apply_filters_deprecated(
47 'fluentform_get_global_settings_values',
48 [
49 $values,
50 $key
51 ],
52 FLUENTFORM_FRAMEWORK_UPGRADE,
53 'fluentform/get_global_settings_values',
54 'Use fluentform/get_global_settings_values instead of fluentform_get_global_settings_values.'
55 );
56
57 return apply_filters('fluentform/get_global_settings_values', $values, $key);
58 }
59
60 public function store($attributes = [])
61 {
62 $key = Arr::get($attributes, 'key');
63 if (is_array($key)) {
64 $key = array_map('sanitize_text_field', $key);
65 } else {
66 $key = sanitize_text_field($key);
67 }
68
69 $globalSettingsHelper = new GlobalSettingsHelper();
70
71 $allowedMethods = [
72 'storeReCaptcha',
73 'storeHCaptcha',
74 'storeTurnstile',
75 'storeCleantalk',
76 'storeSaveGlobalLayoutSettings',
77 'storeMailChimpSettings',
78 'storeEmailSummarySettings',
79 'storeAutosaveSettings',
80 'storeDefaultStyleTemplate',
81 ];
82
83 $method = '';
84 $container = [];
85 if (is_array($key)) {
86 foreach ($key as $item) {
87 $method = 'store' . ucwords($item);
88 if (in_array($method, $allowedMethods)) {
89 $container[] = $globalSettingsHelper->{$method}($attributes);
90 }
91 }
92 return $container;
93 } else {
94 $method = 'store' . ucwords($key);
95 }
96
97 do_action_deprecated(
98 'fluentform_saving_global_settings_with_key_method',
99 [
100 $attributes
101 ],
102 FLUENTFORM_FRAMEWORK_UPGRADE,
103 'fluentform/saving_global_settings_with_key_method',
104 'Use fluentform/saving_global_settings_with_key_method instead of fluentform_saving_global_settings_with_key_method.'
105 );
106
107 do_action('fluentform/saving_global_settings_with_key_method', $attributes);
108
109 if (in_array($method, $allowedMethods)) {
110 return $globalSettingsHelper->{$method}($attributes);
111 }
112 }
113 }
114