PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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 +5 -200 6.266.19 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,8 @@
209 90 * @var false|string|null
210 91 */
211 92 public $custom_css;
212 93
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 94 public function __construct( $args = array() ) {
249 95 if ( ! defined( 'ABSPATH' ) ) {
250 96 die( 'You are not allowed to call this page directly.' );
251 97 }
@@ -265,13 +111,8 @@
265 111
266 112 $this->maybe_filter_for_form( $args );
267 113 }
268 114
269 - /**
270 - * @param false|object $settings
271 - *
272 - * @return object
273 - */
274 115 private function translate_settings( $settings ) {
275 116 if ( $settings ) {
276 117 // Workaround for W3 total cache conflict.
277 118 return unserialize( serialize( $settings ) );
@@ -321,14 +162,8 @@
321 162
322 163 // Normally custom CSS is a string. A false value is used when nothing has been set.
323 164 // When it is false, we try to use the old custom_key value from the default style's post_content array.
324 165 '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 166 );
332 167 }
333 168
334 169 /**
@@ -348,9 +183,8 @@
348 183 $this->fill_with_defaults();
349 184
350 185 if ( is_multisite() && is_admin() ) {
351 186 $mu_menu = get_site_option( 'frm_admin_menu_name' );
352 -
353 187 if ( $mu_menu && ! empty( $mu_menu ) ) {
354 188 $this->menu = $mu_menu;
355 189 $this->mu_menu = 1;
356 190 }
@@ -356,9 +190,8 @@
356 190 }
357 191 }
358 192
359 193 $frm_roles = FrmAppHelper::frm_capabilities( 'pro' );
360 -
361 194 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
362 195 if ( ! isset( $this->$frm_role ) ) {
363 196 $this->$frm_role = 'administrator';
364 197 }
@@ -374,9 +207,8 @@
374 207 }
375 208
376 209 /**
377 210 * @param array $params
378 - *
379 211 * @return void
380 212 */
381 213 public function fill_with_defaults( $params = array() ) {
382 214 $settings = $this->default_options();
@@ -383,9 +215,8 @@
383 215 $filter_html = ! FrmAppHelper::allow_unfiltered_html();
384 216
385 217 if ( $filter_html ) {
386 218 $filter_keys = array( 'failed_msg', 'blank_msg', 'invalid_msg', 'admin_permission', 'unique_msg', 'success_msg', 'submit_value', 'login_msg', 'menu' );
387 -
388 219 if ( ! empty( $params['additional_filter_keys'] ) ) {
389 220 $filter_keys = array_merge( $filter_keys, $params['additional_filter_keys'] );
390 221 }
391 222 } else {
@@ -415,9 +246,8 @@
415 246 *
416 247 * @param mixed $value The unsanitized global setting value.
417 248 * @param string $key The key of the global setting being saved.
418 249 * @param array $filter_keys These keys that are filtered with kses.
419 - *
420 250 * @return mixed
421 251 */
422 252 private function maybe_sanitize_global_setting( $value, $key, $filter_keys ) {
423 253 if ( 'custom_css' === $key ) {
@@ -456,11 +286,11 @@
456 286
457 287 if ( ! isset( $this->pubkey ) ) {
458 288 // Get the options from the database.
459 289 $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;
290 + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
291 + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
292 + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
463 293 }
464 294
465 295 if ( empty( $this->re_msg ) ) {
466 296 $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
@@ -503,16 +333,13 @@
503 333 * Allow strings to be filtered when a specific form may be displaying them.
504 334 *
505 335 * @since 3.06.01
506 336 *
507 - * @param array $args
508 - *
509 337 * @return void
510 338 */
511 339 public function maybe_filter_for_form( $args ) {
512 340 if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) {
513 341 $this->current_form = $args['current_form'];
514 -
515 342 foreach ( $this->translatable_strings() as $string ) {
516 343 $this->{$string} = apply_filters( 'frm_global_setting', $this->{$string}, $string, $this );
517 344 $this->{$string} = apply_filters( 'frm_global_' . $string, $this->{$string}, $this );
518 345 }
@@ -521,10 +348,8 @@
521 348
522 349 /**
523 350 * @param array $params
524 351 * @param array $errors
525 - *
526 - * @return array
527 352 */
528 353 public function validate( $params, $errors ) {
529 354 return apply_filters( 'frm_validate_settings', $errors, $params );
530 355 }
@@ -556,9 +381,8 @@
556 381 }
557 382
558 383 /**
559 384 * @param array $params
560 - *
561 385 * @return void
562 386 */
563 387 private function update_settings( $params ) {
564 388 $this->active_captcha = $params['frm_active_captcha'];
@@ -576,24 +400,9 @@
576 400 $this->default_email = $params['frm_default_email'];
577 401 $this->from_email = $params['frm_from_email'];
578 402 $this->currency = $params['frm_currency'];
579 403
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 -
404 + $checkboxes = array( 'mu_menu', 're_multi', 'fade_form', 'no_ips', 'no_gdpr_cookies', 'enable_gdpr', 'custom_header_ip', 'tracking', 'admin_bar', 'summary_emails' );
596 405 foreach ( $checkboxes as $set ) {
597 406 $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
598 407 }
599 408 }
@@ -598,10 +407,8 @@
598 407 }
599 408 }
600 409
601 410 /**
602 - * @param array $params
603 - *
604 411 * @return void
605 412 */
606 413 private function update_roles( $params ) {
607 414 global $wp_roles;
@@ -607,11 +414,10 @@
607 414 global $wp_roles;
608 415
609 416 $frm_roles = FrmAppHelper::frm_capabilities();
610 417 $roles = get_editable_roles();
611 -
612 418 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
613 - $this->$frm_role = (array) ( $params[ $frm_role ] ?? 'administrator' );
419 + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
614 420
615 421 // Make sure administrators always have permissions
616 422 if ( ! in_array( 'administrator', $this->$frm_role, true ) ) {
617 423 array_push( $this->$frm_role, 'administrator' );
@@ -634,9 +440,8 @@
634 440 *
635 441 * @param string $key The setting key to update.
636 442 * @param mixed $value The new value for the setting.
637 443 * @param string $sanitize The name of the sanitization function to apply to the new value.
638 - *
639 444 * @return bool True on success, false on failure.
640 445 */
641 446 public function update_setting( $key, $value, $sanitize ) {
642 447 if ( ! property_exists( $this, $key ) || ! is_callable( $sanitize ) ) {