PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22
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 +6 -173 6.276.22 View file →
@@ -4,92 +4,27 @@
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 - */
27 11 public $fade_form;
28 -
29 - /**
30 - * @var bool
31 - */
32 12 public $admin_bar;
33 13
34 - /**
35 - * @var string
36 - */
37 14 public $success_msg;
38 -
39 - /**
40 - * @var string
41 - */
42 15 public $blank_msg;
43 -
44 - /**
45 - * @var string
46 - */
47 16 public $unique_msg;
48 -
49 - /**
50 - * @var string
51 - */
52 17 public $invalid_msg;
53 -
54 - /**
55 - * @var string
56 - */
57 18 public $failed_msg;
58 -
59 - /**
60 - * @var string
61 - */
62 19 public $submit_value;
63 -
64 - /**
65 - * @var string
66 - */
67 20 public $login_msg;
68 -
69 - /**
70 - * @var string
71 - */
72 21 public $admin_permission;
73 22
74 - /**
75 - * @var string
76 - */
77 23 public $email_to;
78 -
79 - /**
80 - * @var string|null
81 - */
82 24 public $load_style;
83 -
84 - /**
85 - * @var bool|int|null
86 - */
87 25 public $custom_style;
88 26
89 - /**
90 - * @var string|null
91 - */
92 27 public $active_captcha;
93 28
94 29 /**
95 30 * Settings for reCAPTCHA.
@@ -103,32 +38,12 @@
103 38 /**
104 39 * @var string|null
105 40 */
106 41 public $privkey;
107 -
108 - /**
109 - * @var string|null
110 - */
111 42 public $re_lang;
112 -
113 - /**
114 - * @var string|null
115 - */
116 43 public $re_type;
117 -
118 - /**
119 - * @var string
120 - */
121 44 public $re_msg;
122 -
123 - /**
124 - * @var bool
125 - */
126 45 public $re_multi;
127 -
128 - /**
129 - * @var float|string|null
130 - */
131 46 public $re_threshold;
132 47
133 48 /**
134 49 * Settings for hCaptcha.
@@ -157,51 +72,17 @@
157 72 * @var string|null
158 73 */
159 74 public $turnstile_privkey;
160 75
161 - /**
162 - * @var bool
163 - */
164 76 public $no_ips;
165 -
166 - /**
167 - * @var string
168 - */
169 77 public $custom_header_ip;
170 -
171 - /**
172 - * @var int
173 - */
174 78 public $current_form = 0;
175 -
176 - /**
177 - * @var bool
178 - */
179 79 public $tracking;
180 -
181 - /**
182 - * @var bool
183 - */
184 80 public $summary_emails;
185 -
186 - /**
187 - * @var string
188 - */
189 81 public $summary_emails_recipients;
190 82
191 - /**
192 - * @var string|null
193 - */
194 83 public $default_email;
195 -
196 - /**
197 - * @var string
198 - */
199 84 public $from_email;
200 -
201 - /**
202 - * @var string|null
203 - */
204 85 public $currency;
205 86
206 87 /**
207 88 * @since 6.0
@@ -209,43 +90,18 @@
209 90 * @var false|string|null
210 91 */
211 92 public $custom_css;
212 93
213 - /**
214 - * @var string
215 - */
216 94 public $honeypot;
217 95
218 - /**
219 - * @var bool
220 - */
221 96 public $wp_spam_check;
222 97
223 - /**
224 - * @var bool
225 - */
226 98 public $denylist_check;
227 99
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 100 public $disallowed_words;
239 101
240 - /**
241 - * @var string
242 - */
243 102 public $allowed_words;
244 103
245 - /**
246 - * @param array $args
247 - */
248 104 public function __construct( $args = array() ) {
249 105 if ( ! defined( 'ABSPATH' ) ) {
250 106 die( 'You are not allowed to call this page directly.' );
251 107 }
@@ -265,13 +121,8 @@
265 121
266 122 $this->maybe_filter_for_form( $args );
267 123 }
268 124
269 - /**
270 - * @param false|object $settings
271 - *
272 - * @return object
273 - */
274 125 private function translate_settings( $settings ) {
275 126 if ( $settings ) {
276 127 // Workaround for W3 total cache conflict.
277 128 return unserialize( serialize( $settings ) );
@@ -326,9 +177,8 @@
326 177 'wp_spam_check' => 0,
327 178 'denylist_check' => 0,
328 179 'disallowed_words' => '',
329 180 'allowed_words' => '',
330 - 'email_style' => 'classic',
331 181 );
332 182 }
333 183
334 184 /**
@@ -348,10 +198,9 @@
348 198 $this->fill_with_defaults();
349 199
350 200 if ( is_multisite() && is_admin() ) {
351 201 $mu_menu = get_site_option( 'frm_admin_menu_name' );
352 -
353 - if ( $mu_menu && $mu_menu ) {
202 + if ( $mu_menu && ! empty( $mu_menu ) ) {
354 203 $this->menu = $mu_menu;
355 204 $this->mu_menu = 1;
356 205 }
357 206 }
@@ -356,9 +205,8 @@
356 205 }
357 206 }
358 207
359 208 $frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
360 -
361 209 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
362 210 if ( ! isset( $this->$frm_role ) ) {
363 211 $this->$frm_role = 'administrator';
364 212 }
@@ -374,9 +222,8 @@
374 222 }
375 223
376 224 /**
377 225 * @param array $params
378 - *
379 226 * @return void
380 227 */
381 228 public function fill_with_defaults( $params = array() ) {
382 229 $settings = $this->default_options();
@@ -383,9 +230,8 @@
383 230 $filter_html = ! FrmAppHelper::allow_unfiltered_html();
384 231
385 232 if ( $filter_html ) {
386 233 $filter_keys = array( 'failed_msg', 'blank_msg', 'invalid_msg', 'admin_permission', 'unique_msg', 'success_msg', 'submit_value', 'login_msg', 'menu' );
387 -
388 234 if ( ! empty( $params['additional_filter_keys'] ) ) {
389 235 $filter_keys = array_merge( $filter_keys, $params['additional_filter_keys'] );
390 236 }
391 237 } else {
@@ -415,9 +261,8 @@
415 261 *
416 262 * @param mixed $value The unsanitized global setting value.
417 263 * @param string $key The key of the global setting being saved.
418 264 * @param array $filter_keys These keys that are filtered with kses.
419 - *
420 265 * @return mixed
421 266 */
422 267 private function maybe_sanitize_global_setting( $value, $key, $filter_keys ) {
423 268 if ( 'custom_css' === $key ) {
@@ -424,9 +269,8 @@
424 269 if ( false === $value ) {
425 270 // Avoid changing the false default value to an empty string.
426 271 return $value;
427 272 }
428 -
429 273 return sanitize_textarea_field( $value );
430 274 }
431 275
432 276 if ( in_array( $key, $filter_keys, true ) ) {
@@ -457,11 +301,11 @@
457 301
458 302 if ( ! isset( $this->pubkey ) ) {
459 303 // Get the options from the database.
460 304 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
461 - $this->pubkey = $recaptcha_opt['pubkey'] ?? '';
462 - $privkey = $recaptcha_opt['privkey'] ?? $privkey;
463 - $re_lang = $recaptcha_opt['re_lang'] ?? $re_lang;
305 + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
306 + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
307 + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
464 308 }
465 309
466 310 if ( empty( $this->re_msg ) ) {
467 311 $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
@@ -504,16 +348,13 @@
504 348 * Allow strings to be filtered when a specific form may be displaying them.
505 349 *
506 350 * @since 3.06.01
507 351 *
508 - * @param array $args
509 - *
510 352 * @return void
511 353 */
512 354 public function maybe_filter_for_form( $args ) {
513 355 if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) {
514 356 $this->current_form = $args['current_form'];
515 -
516 357 foreach ( $this->translatable_strings() as $string ) {
517 358 $this->{$string} = apply_filters( 'frm_global_setting', $this->{$string}, $string, $this );
518 359 $this->{$string} = apply_filters( 'frm_global_' . $string, $this->{$string}, $this );
519 360 }
@@ -522,10 +363,8 @@
522 363
523 364 /**
524 365 * @param array $params
525 366 * @param array $errors
526 - *
527 - * @return array
528 367 */
529 368 public function validate( $params, $errors ) {
530 369 return apply_filters( 'frm_validate_settings', $errors, $params );
531 370 }
@@ -557,9 +396,8 @@
557 396 }
558 397
559 398 /**
560 399 * @param array $params
561 - *
562 400 * @return void
563 401 */
564 402 private function update_settings( $params ) {
565 403 $this->active_captcha = $params['frm_active_captcha'];
@@ -592,9 +430,8 @@
592 430 'honeypot',
593 431 'wp_spam_check',
594 432 'denylist_check',
595 433 );
596 -
597 434 foreach ( $checkboxes as $set ) {
598 435 $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
599 436 }
600 437 }
@@ -599,10 +436,8 @@
599 436 }
600 437 }
601 438
602 439 /**
603 - * @param array $params
604 - *
605 440 * @return void
606 441 */
607 442 private function update_roles( $params ) {
608 443 global $wp_roles;
@@ -608,11 +443,10 @@
608 443 global $wp_roles;
609 444
610 445 $frm_roles = FrmAppHelper::frm_capabilities();
611 446 $roles = get_editable_roles();
612 -
613 447 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
614 - $this->$frm_role = (array) ( $params[ $frm_role ] ?? 'administrator' );
448 + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
615 449
616 450 // Make sure administrators always have permissions
617 451 if ( ! in_array( 'administrator', $this->$frm_role, true ) ) {
618 452 array_push( $this->$frm_role, 'administrator' );
@@ -618,9 +452,9 @@
618 452 array_push( $this->$frm_role, 'administrator' );
619 453 }
620 454
621 455 foreach ( $roles as $role => $details ) {
622 - if ( in_array( $role, $this->$frm_role, true ) ) {
456 + if ( in_array( $role, $this->$frm_role ) ) {
623 457 $wp_roles->add_cap( $role, $frm_role );
624 458 } else {
625 459 $wp_roles->remove_cap( $role, $frm_role );
626 460 }
@@ -635,9 +469,8 @@
635 469 *
636 470 * @param string $key The setting key to update.
637 471 * @param mixed $value The new value for the setting.
638 472 * @param string $sanitize The name of the sanitization function to apply to the new value.
639 - *
640 473 * @return bool True on success, false on failure.
641 474 */
642 475 public function update_setting( $key, $value, $sanitize ) {
643 476 if ( ! property_exists( $this, $key ) || ! is_callable( $sanitize ) ) {