PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmSettings.php +15 -206 6.266.13 View file →
@@ -4,92 +4,31 @@
4 4 }
5 5
6 6 #[\AllowDynamicProperties]
7 7 class FrmSettings {
8 -
9 - /**
10 - * @var string
11 - */
12 8 public $option_name = 'frm_options';
13 -
14 - /**
15 - * @var int
16 - */
17 9 public $menu;
18 -
19 - /**
20 - * @var int
21 - */
22 10 public $mu_menu;
23 -
24 - /**
25 - * @var int
26 - */
11 + public $use_html;
12 + public $jquery_css;
13 + public $accordion_js;
27 14 public $fade_form;
28 -
29 - /**
30 - * @var bool
31 - */
15 + public $old_css;
32 16 public $admin_bar;
33 17
34 - /**
35 - * @var string
36 - */
37 18 public $success_msg;
38 -
39 - /**
40 - * @var string
41 - */
42 19 public $blank_msg;
43 -
44 - /**
45 - * @var string
46 - */
47 20 public $unique_msg;
48 -
49 - /**
50 - * @var string
51 - */
52 21 public $invalid_msg;
53 -
54 - /**
55 - * @var string
56 - */
57 22 public $failed_msg;
58 -
59 - /**
60 - * @var string
61 - */
62 23 public $submit_value;
63 -
64 - /**
65 - * @var string
66 - */
67 24 public $login_msg;
68 -
69 - /**
70 - * @var string
71 - */
72 25 public $admin_permission;
73 26
74 - /**
75 - * @var string
76 - */
77 27 public $email_to;
78 -
79 - /**
80 - * @var string|null
81 - */
82 28 public $load_style;
83 -
84 - /**
85 - * @var bool|int|null
86 - */
87 29 public $custom_style;
88 30
89 - /**
90 - * @var string|null
91 - */
92 31 public $active_captcha;
93 32
94 33 /**
95 34 * Settings for reCAPTCHA.
@@ -103,35 +42,14 @@
103 42 /**
104 43 * @var string|null
105 44 */
106 45 public $privkey;
107 -
108 - /**
109 - * @var string|null
110 - */
111 46 public $re_lang;
112 -
113 - /**
114 - * @var string|null
115 - */
116 47 public $re_type;
117 -
118 - /**
119 - * @var string
120 - */
121 48 public $re_msg;
122 -
123 - /**
124 - * @var bool
125 - */
126 49 public $re_multi;
127 50
128 51 /**
129 - * @var float|string|null
130 - */
131 - public $re_threshold;
132 -
133 - /**
134 52 * Settings for hCaptcha.
135 53 */
136 54
137 55 /**
@@ -157,51 +75,16 @@
157 75 * @var string|null
158 76 */
159 77 public $turnstile_privkey;
160 78
161 - /**
162 - * @var bool
163 - */
164 79 public $no_ips;
165 -
166 - /**
167 - * @var string
168 - */
169 80 public $custom_header_ip;
170 -
171 - /**
172 - * @var int
173 - */
174 81 public $current_form = 0;
175 -
176 - /**
177 - * @var bool
178 - */
179 82 public $tracking;
180 -
181 - /**
182 - * @var bool
183 - */
184 83 public $summary_emails;
185 -
186 - /**
187 - * @var string
188 - */
189 84 public $summary_emails_recipients;
190 85
191 - /**
192 - * @var string|null
193 - */
194 86 public $default_email;
195 -
196 - /**
197 - * @var string
198 - */
199 - public $from_email;
200 -
201 - /**
202 - * @var string|null
203 - */
204 87 public $currency;
205 88
206 89 /**
207 90 * @since 6.0
@@ -209,43 +92,8 @@
209 92 * @var false|string|null
210 93 */
211 94 public $custom_css;
212 95
213 - /**
214 - * @var string
215 - */
216 - public $honeypot;
217 -
218 - /**
219 - * @var bool
220 - */
221 - public $wp_spam_check;
222 -
223 - /**
224 - * @var bool
225 - */
226 - public $denylist_check;
227 -
228 - /**
229 - * @since 6.25.1
230 - *
231 - * @var int|null 1 if installed after welcome tour update, null otherwise.
232 - */
233 - public $installed_after_welcome_tour_update;
234 -
235 - /**
236 - * @var string
237 - */
238 - public $disallowed_words;
239 -
240 - /**
241 - * @var string
242 - */
243 - public $allowed_words;
244 -
245 - /**
246 - * @param array $args
247 - */
248 96 public function __construct( $args = array() ) {
249 97 if ( ! defined( 'ABSPATH' ) ) {
250 98 die( 'You are not allowed to call this page directly.' );
251 99 }
@@ -265,13 +113,8 @@
265 113
266 114 $this->maybe_filter_for_form( $args );
267 115 }
268 116
269 - /**
270 - * @param false|object $settings
271 - *
272 - * @return object
273 - */
274 117 private function translate_settings( $settings ) {
275 118 if ( $settings ) {
276 119 // Workaround for W3 total cache conflict.
277 120 return unserialize( serialize( $settings ) );
@@ -291,9 +134,13 @@
291 134 public function default_options() {
292 135 return array(
293 136 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ),
294 137 'mu_menu' => 0,
138 + 'use_html' => true,
139 + 'jquery_css' => false,
140 + 'accordion_js' => false,
295 141 'fade_form' => false,
142 + 'old_css' => false,
296 143 'admin_bar' => false,
297 144
298 145 're_multi' => 1,
299 146
@@ -309,12 +156,11 @@
309 156 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
310 157 'new_tab_msg' => __( 'The page has been opened in a new tab.', 'formidable' ),
311 158
312 159 'email_to' => '[admin_email]',
313 - 'enable_gdpr' => 0,
314 - 'no_gdpr_cookies' => 0,
315 160 'no_ips' => 0,
316 - 'custom_header_ip' => 0,
161 + // Use false by default. We show a warning when this is unset. Once global settings have been saved, this gets saved.
162 + 'custom_header_ip' => false,
317 163 'tracking' => FrmAppHelper::pro_is_installed(),
318 164 // Only enable this by default for the main site.
319 165 'summary_emails' => get_current_blog_id() === get_main_site_id(),
320 166 'summary_emails_recipients' => '[admin_email]',
@@ -321,14 +167,8 @@
321 167
322 168 // Normally custom CSS is a string. A false value is used when nothing has been set.
323 169 // When it is false, we try to use the old custom_key value from the default style's post_content array.
324 170 'custom_css' => false,
325 - 'honeypot' => 1,
326 - 'wp_spam_check' => 0,
327 - 'denylist_check' => 0,
328 - 'disallowed_words' => '',
329 - 'allowed_words' => '',
330 - 'email_style' => 'classic',
331 171 );
332 172 }
333 173
334 174 /**
@@ -348,9 +188,8 @@
348 188 $this->fill_with_defaults();
349 189
350 190 if ( is_multisite() && is_admin() ) {
351 191 $mu_menu = get_site_option( 'frm_admin_menu_name' );
352 -
353 192 if ( $mu_menu && ! empty( $mu_menu ) ) {
354 193 $this->menu = $mu_menu;
355 194 $this->mu_menu = 1;
356 195 }
@@ -356,9 +195,8 @@
356 195 }
357 196 }
358 197
359 198 $frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
360 -
361 199 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
362 200 if ( ! isset( $this->$frm_role ) ) {
363 201 $this->$frm_role = 'administrator';
364 202 }
@@ -374,9 +212,8 @@
374 212 }
375 213
376 214 /**
377 215 * @param array $params
378 - *
379 216 * @return void
380 217 */
381 218 public function fill_with_defaults( $params = array() ) {
382 219 $settings = $this->default_options();
@@ -383,9 +220,8 @@
383 220 $filter_html = ! FrmAppHelper::allow_unfiltered_html();
384 221
385 222 if ( $filter_html ) {
386 223 $filter_keys = array( 'failed_msg', 'blank_msg', 'invalid_msg', 'admin_permission', 'unique_msg', 'success_msg', 'submit_value', 'login_msg', 'menu' );
387 -
388 224 if ( ! empty( $params['additional_filter_keys'] ) ) {
389 225 $filter_keys = array_merge( $filter_keys, $params['additional_filter_keys'] );
390 226 }
391 227 } else {
@@ -415,9 +251,8 @@
415 251 *
416 252 * @param mixed $value The unsanitized global setting value.
417 253 * @param string $key The key of the global setting being saved.
418 254 * @param array $filter_keys These keys that are filtered with kses.
419 - *
420 255 * @return mixed
421 256 */
422 257 private function maybe_sanitize_global_setting( $value, $key, $filter_keys ) {
423 258 if ( 'custom_css' === $key ) {
@@ -456,11 +291,11 @@
456 291
457 292 if ( ! isset( $this->pubkey ) ) {
458 293 // Get the options from the database.
459 294 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
460 - $this->pubkey = $recaptcha_opt['pubkey'] ?? '';
461 - $privkey = $recaptcha_opt['privkey'] ?? $privkey;
462 - $re_lang = $recaptcha_opt['re_lang'] ?? $re_lang;
295 + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
296 + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
297 + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
463 298 }
464 299
465 300 if ( empty( $this->re_msg ) ) {
466 301 $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
@@ -503,16 +338,13 @@
503 338 * Allow strings to be filtered when a specific form may be displaying them.
504 339 *
505 340 * @since 3.06.01
506 341 *
507 - * @param array $args
508 - *
509 342 * @return void
510 343 */
511 344 public function maybe_filter_for_form( $args ) {
512 345 if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) {
513 346 $this->current_form = $args['current_form'];
514 -
515 347 foreach ( $this->translatable_strings() as $string ) {
516 348 $this->{$string} = apply_filters( 'frm_global_setting', $this->{$string}, $string, $this );
517 349 $this->{$string} = apply_filters( 'frm_global_' . $string, $this->{$string}, $this );
518 350 }
@@ -521,10 +353,8 @@
521 353
522 354 /**
523 355 * @param array $params
524 356 * @param array $errors
525 - *
526 - * @return array
527 357 */
528 358 public function validate( $params, $errors ) {
529 359 return apply_filters( 'frm_validate_settings', $errors, $params );
530 360 }
@@ -556,9 +386,8 @@
556 386 }
557 387
558 388 /**
559 389 * @param array $params
560 - *
561 390 * @return void
562 391 */
563 392 private function update_settings( $params ) {
564 393 $this->active_captcha = $params['frm_active_captcha'];
@@ -573,27 +402,11 @@
573 402 $this->turnstile_privkey = trim( $params['frm_turnstile_privkey'] );
574 403 $this->load_style = $params['frm_load_style'];
575 404 $this->custom_css = $params['frm_custom_css'];
576 405 $this->default_email = $params['frm_default_email'];
577 - $this->from_email = $params['frm_from_email'];
578 406 $this->currency = $params['frm_currency'];
579 407
580 - $checkboxes = array(
581 - 'mu_menu',
582 - 're_multi',
583 - 'fade_form',
584 - 'no_ips',
585 - 'no_gdpr_cookies',
586 - 'enable_gdpr',
587 - 'custom_header_ip',
588 - 'tracking',
589 - 'admin_bar',
590 - 'summary_emails',
591 - 'honeypot',
592 - 'wp_spam_check',
593 - 'denylist_check',
594 - );
595 -
408 + $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar', 'summary_emails' );
596 409 foreach ( $checkboxes as $set ) {
597 410 $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
598 411 }
599 412 }
@@ -598,10 +411,8 @@
598 411 }
599 412 }
600 413
601 414 /**
602 - * @param array $params
603 - *
604 415 * @return void
605 416 */
606 417 private function update_roles( $params ) {
607 418 global $wp_roles;
@@ -607,11 +418,10 @@
607 418 global $wp_roles;
608 419
609 420 $frm_roles = FrmAppHelper::frm_capabilities();
610 421 $roles = get_editable_roles();
611 -
612 422 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
613 - $this->$frm_role = (array) ( $params[ $frm_role ] ?? 'administrator' );
423 + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
614 424
615 425 // Make sure administrators always have permissions
616 426 if ( ! in_array( 'administrator', $this->$frm_role, true ) ) {
617 427 array_push( $this->$frm_role, 'administrator' );
@@ -634,9 +444,8 @@
634 444 *
635 445 * @param string $key The setting key to update.
636 446 * @param mixed $value The new value for the setting.
637 447 * @param string $sanitize The name of the sanitization function to apply to the new value.
638 - *
639 448 * @return bool True on success, false on failure.
640 449 */
641 450 public function update_setting( $key, $value, $sanitize ) {
642 451 if ( ! property_exists( $this, $key ) || ! is_callable( $sanitize ) ) {