PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22.1
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 +160 -64 6.5.26.22.1 View file →
@@ -7,13 +7,9 @@
7 7 class FrmSettings {
8 8 public $option_name = 'frm_options';
9 9 public $menu;
10 10 public $mu_menu;
11 - public $use_html;
12 - public $jquery_css;
13 - public $accordion_js;
14 11 public $fade_form;
15 - public $old_css;
16 12 public $admin_bar;
17 13
18 14 public $success_msg;
19 15 public $blank_msg;
@@ -28,37 +24,90 @@
28 24 public $load_style;
29 25 public $custom_style;
30 26
31 27 public $active_captcha;
32 - public $hcaptcha_pubkey;
33 - public $hcaptcha_privkey;
28 +
29 + /**
30 + * Settings for reCAPTCHA.
31 + */
32 +
33 + /**
34 + * @var string|null
35 + */
34 36 public $pubkey;
37 +
38 + /**
39 + * @var string|null
40 + */
35 41 public $privkey;
36 42 public $re_lang;
37 43 public $re_type;
38 44 public $re_msg;
39 45 public $re_multi;
46 + public $re_threshold;
40 47
48 + /**
49 + * Settings for hCaptcha.
50 + */
51 +
52 + /**
53 + * @var string
54 + */
55 + public $hcaptcha_pubkey;
56 +
57 + /**
58 + * @var string|null
59 + */
60 + public $hcaptcha_privkey;
61 +
62 + /**
63 + * Settings for Turnstile.
64 + */
65 +
66 + /**
67 + * @var string
68 + */
69 + public $turnstile_pubkey;
70 +
71 + /**
72 + * @var string|null
73 + */
74 + public $turnstile_privkey;
75 +
41 76 public $no_ips;
42 77 public $custom_header_ip;
43 78 public $current_form = 0;
44 79 public $tracking;
80 + public $summary_emails;
81 + public $summary_emails_recipients;
45 82
83 + public $default_email;
84 + public $from_email;
46 85 public $currency;
47 86
48 87 /**
49 88 * @since 6.0
50 89 *
51 - * @var string|false|null
90 + * @var false|string|null
52 91 */
53 92 public $custom_css;
54 93
94 + public $honeypot;
95 +
96 + public $wp_spam_check;
97 +
98 + public $denylist_check;
99 +
100 + public $disallowed_words;
101 +
102 + public $allowed_words;
103 +
55 104 public function __construct( $args = array() ) {
56 105 if ( ! defined( 'ABSPATH' ) ) {
57 106 die( 'You are not allowed to call this page directly.' );
58 107 }
59 108
60 - $settings = get_transient( $this->option_name );
109 + $settings = get_option( $this->option_name );
61 110
62 111 if ( ! is_object( $settings ) ) {
63 112 $settings = $this->translate_settings( $settings );
64 113 }
@@ -73,29 +122,18 @@
73 122 $this->maybe_filter_for_form( $args );
74 123 }
75 124
76 125 private function translate_settings( $settings ) {
77 - if ( $settings ) { //workaround for W3 total cache conflict
126 + if ( $settings ) {
127 + // Workaround for W3 total cache conflict.
78 128 return unserialize( serialize( $settings ) );
79 129 }
80 130
81 - $settings = get_option( $this->option_name );
82 - if ( is_object( $settings ) ) {
83 - set_transient( $this->option_name, $settings );
131 + // If unserializing didn't work.
132 + $settings = $this;
84 133
85 - return $settings;
86 - }
134 + update_option( $this->option_name, $settings, 'yes' );
87 135
88 - // If unserializing didn't work
89 - if ( $settings ) { //workaround for W3 total cache conflict
90 - $settings = unserialize( serialize( $settings ) );
91 - } else {
92 - $settings = $this;
93 - }
94 -
95 - update_option( $this->option_name, $settings );
96 - set_transient( $this->option_name, $settings );
97 -
98 136 return $settings;
99 137 }
100 138
101 139 /**
@@ -102,37 +140,45 @@
102 140 * @return array
103 141 */
104 142 public function default_options() {
105 143 return array(
106 - 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ),
107 - 'mu_menu' => 0,
108 - 'use_html' => true,
109 - 'jquery_css' => false,
110 - 'accordion_js' => false,
111 - 'fade_form' => false,
112 - 'old_css' => false,
113 - 'admin_bar' => false,
144 + 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ),
145 + 'mu_menu' => 0,
146 + 'fade_form' => false,
147 + 'admin_bar' => false,
114 148
115 - 're_multi' => 1,
149 + 're_multi' => 1,
116 150
117 - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
118 - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
119 - 'unique_msg' => __( 'This value must be unique.', 'formidable' ),
120 - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
121 - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
122 - 'submit_value' => __( 'Submit', 'formidable' ),
123 - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
124 - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
125 - 'new_tab_msg' => __( 'The page has been opened in a new tab.', 'formidable' ),
151 + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
152 + // translators: %s: [field_name] shortcode.
153 + 'blank_msg' => sprintf( __( '%s cannot be blank.', 'formidable' ), '[field_name]' ),
154 + // translators: %s: [field_name] shortcode.
155 + 'unique_msg' => sprintf( __( '%s must be unique.', 'formidable' ), '[field_name]' ),
156 + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
157 + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
158 + 'submit_value' => __( 'Submit', 'formidable' ),
159 + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
160 + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
161 + 'new_tab_msg' => __( 'The page has been opened in a new tab.', 'formidable' ),
126 162
127 - 'email_to' => '[admin_email]',
128 - 'no_ips' => 0,
129 - 'custom_header_ip' => false, // Use false by default. We show a warning when this is unset. Once global settings have been saved, this gets saved
130 - 'tracking' => FrmAppHelper::pro_is_installed(),
163 + 'email_to' => '[admin_email]',
164 + 'enable_gdpr' => 0,
165 + 'no_gdpr_cookies' => 0,
166 + 'no_ips' => 0,
167 + 'custom_header_ip' => 0,
168 + 'tracking' => FrmAppHelper::pro_is_installed(),
169 + // Only enable this by default for the main site.
170 + 'summary_emails' => get_current_blog_id() === get_main_site_id(),
171 + 'summary_emails_recipients' => '[admin_email]',
131 172
132 173 // Normally custom CSS is a string. A false value is used when nothing has been set.
133 174 // When it is false, we try to use the old custom_key value from the default style's post_content array.
134 - 'custom_css' => false,
175 + 'custom_css' => false,
176 + 'honeypot' => 1,
177 + 'wp_spam_check' => 0,
178 + 'denylist_check' => 0,
179 + 'disallowed_words' => '',
180 + 'allowed_words' => '',
135 181 );
136 182 }
137 183
138 184 /**
@@ -165,8 +211,12 @@
165 211 $this->$frm_role = 'administrator';
166 212 }
167 213 }
168 214
215 + if ( ! isset( $this->default_email ) ) {
216 + $this->default_email = get_option( 'admin_email' );
217 + }
218 +
169 219 if ( ! isset( $this->currency ) ) {
170 220 $this->currency = 'USD';
171 221 }
172 222 }
@@ -237,17 +287,21 @@
237 287 if ( ! isset( $this->active_captcha ) ) {
238 288 $this->active_captcha = 'recaptcha';
239 289 }
240 290
241 - $privkey = '';
242 - $re_lang = '';
291 + $privkey = '';
292 + $re_lang = '';
243 293
244 294 if ( ! isset( $this->hcaptcha_privkey ) ) {
245 295 $this->hcaptcha_privkey = '';
246 296 }
247 297
298 + if ( ! isset( $this->turnstile_privkey ) ) {
299 + $this->turnstile_privkey = '';
300 + }
301 +
248 302 if ( ! isset( $this->pubkey ) ) {
249 - // get the options from the database
303 + // Get the options from the database.
250 304 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
251 305 $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
252 306 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
253 307 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
@@ -252,9 +306,9 @@
252 306 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
253 307 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
254 308 }
255 309
256 - if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
310 + if ( empty( $this->re_msg ) ) {
257 311 $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
258 312 }
259 313
260 314 if ( ! isset( $this->privkey ) ) {
@@ -341,24 +395,43 @@
341 395 }
342 396 }
343 397
344 398 /**
399 + * @param array $params
345 400 * @return void
346 401 */
347 402 private function update_settings( $params ) {
348 - $this->active_captcha = $params['frm_active_captcha'];
349 - $this->hcaptcha_pubkey = trim( $params['frm_hcaptcha_pubkey'] );
350 - $this->hcaptcha_privkey = trim( $params['frm_hcaptcha_privkey'] );
351 - $this->pubkey = trim( $params['frm_pubkey'] );
352 - $this->privkey = trim( $params['frm_privkey'] );
353 - $this->re_type = $params['frm_re_type'];
354 - $this->re_lang = $params['frm_re_lang'];
355 - $this->re_threshold = floatval( $params['frm_re_threshold'] );
356 - $this->load_style = $params['frm_load_style'];
357 - $this->custom_css = $params['frm_custom_css'];
358 - $this->currency = $params['frm_currency'];
403 + $this->active_captcha = $params['frm_active_captcha'];
404 + $this->pubkey = trim( $params['frm_pubkey'] );
405 + $this->privkey = trim( $params['frm_privkey'] );
406 + $this->re_type = $params['frm_re_type'];
407 + $this->re_lang = $params['frm_re_lang'];
408 + $this->re_threshold = floatval( $params['frm_re_threshold'] );
409 + $this->hcaptcha_pubkey = trim( $params['frm_hcaptcha_pubkey'] );
410 + $this->hcaptcha_privkey = trim( $params['frm_hcaptcha_privkey'] );
411 + $this->turnstile_pubkey = trim( $params['frm_turnstile_pubkey'] );
412 + $this->turnstile_privkey = trim( $params['frm_turnstile_privkey'] );
413 + $this->load_style = $params['frm_load_style'];
414 + $this->custom_css = $params['frm_custom_css'];
415 + $this->default_email = $params['frm_default_email'];
416 + $this->from_email = $params['frm_from_email'];
417 + $this->currency = $params['frm_currency'];
359 418
360 - $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar' );
419 + $checkboxes = array(
420 + 'mu_menu',
421 + 're_multi',
422 + 'fade_form',
423 + 'no_ips',
424 + 'no_gdpr_cookies',
425 + 'enable_gdpr',
426 + 'custom_header_ip',
427 + 'tracking',
428 + 'admin_bar',
429 + 'summary_emails',
430 + 'honeypot',
431 + 'wp_spam_check',
432 + 'denylist_check',
433 + );
361 434 foreach ( $checkboxes as $set ) {
362 435 $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
363 436 }
364 437 }
@@ -374,9 +447,9 @@
374 447 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
375 448 $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
376 449
377 450 // Make sure administrators always have permissions
378 - if ( ! in_array( 'administrator', $this->$frm_role ) ) {
451 + if ( ! in_array( 'administrator', $this->$frm_role, true ) ) {
379 452 array_push( $this->$frm_role, 'administrator' );
380 453 }
381 454
382 455 foreach ( $roles as $role => $details ) {
@@ -386,8 +459,31 @@
386 459 $wp_roles->remove_cap( $role, $frm_role );
387 460 }
388 461 }
389 462 }
463 + }
464 +
465 + /**
466 + * Updates a single setting with specified sanitization.
467 + *
468 + * @since 6.9
469 + *
470 + * @param string $key The setting key to update.
471 + * @param mixed $value The new value for the setting.
472 + * @param string $sanitize The name of the sanitization function to apply to the new value.
473 + * @return bool True on success, false on failure.
474 + */
475 + public function update_setting( $key, $value, $sanitize ) {
476 + if ( ! property_exists( $this, $key ) || ! is_callable( $sanitize ) ) {
477 + // Setting does not exist or sanitization function name is not callable.
478 + return false;
479 + }
480 +
481 + // Update the property value.
482 + FrmAppHelper::sanitize_value( $sanitize, $value );
483 + $this->{$key} = $value;
484 +
485 + return true;
390 486 }
391 487
392 488 /**
393 489 * @return void