PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.23
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.23
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 +166 -63 6.46.23 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,35 +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;
85 + public $currency;
86 +
46 87 /**
47 88 * @since 6.0
48 89 *
49 - * @var string|false|null
90 + * @var false|string|null
50 91 */
51 92 public $custom_css;
52 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 +
53 104 public function __construct( $args = array() ) {
54 105 if ( ! defined( 'ABSPATH' ) ) {
55 106 die( 'You are not allowed to call this page directly.' );
56 107 }
57 108
58 - $settings = get_transient( $this->option_name );
109 + $settings = get_option( $this->option_name );
59 110
60 111 if ( ! is_object( $settings ) ) {
61 112 $settings = $this->translate_settings( $settings );
62 113 }
@@ -71,29 +122,18 @@
71 122 $this->maybe_filter_for_form( $args );
72 123 }
73 124
74 125 private function translate_settings( $settings ) {
75 - if ( $settings ) { //workaround for W3 total cache conflict
126 + if ( $settings ) {
127 + // Workaround for W3 total cache conflict.
76 128 return unserialize( serialize( $settings ) );
77 129 }
78 130
79 - $settings = get_option( $this->option_name );
80 - if ( is_object( $settings ) ) {
81 - set_transient( $this->option_name, $settings );
131 + // If unserializing didn't work.
132 + $settings = $this;
82 133
83 - return $settings;
84 - }
134 + update_option( $this->option_name, $settings, 'yes' );
85 135
86 - // If unserializing didn't work
87 - if ( $settings ) { //workaround for W3 total cache conflict
88 - $settings = unserialize( serialize( $settings ) );
89 - } else {
90 - $settings = $this;
91 - }
92 -
93 - update_option( $this->option_name, $settings );
94 - set_transient( $this->option_name, $settings );
95 -
96 136 return $settings;
97 137 }
98 138
99 139 /**
@@ -100,37 +140,45 @@
100 140 * @return array
101 141 */
102 142 public function default_options() {
103 143 return array(
104 - 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ),
105 - 'mu_menu' => 0,
106 - 'use_html' => true,
107 - 'jquery_css' => false,
108 - 'accordion_js' => false,
109 - 'fade_form' => false,
110 - 'old_css' => false,
111 - 'admin_bar' => false,
144 + 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ),
145 + 'mu_menu' => 0,
146 + 'fade_form' => false,
147 + 'admin_bar' => false,
112 148
113 - 're_multi' => 1,
149 + 're_multi' => 1,
114 150
115 - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
116 - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ),
117 - 'unique_msg' => __( 'This value must be unique.', 'formidable' ),
118 - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
119 - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
120 - 'submit_value' => __( 'Submit', 'formidable' ),
121 - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
122 - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
123 - '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' ),
124 162
125 - 'email_to' => '[admin_email]',
126 - 'no_ips' => 0,
127 - '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
128 - '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]',
129 172
130 173 // Normally custom CSS is a string. A false value is used when nothing has been set.
131 174 // When it is false, we try to use the old custom_key value from the default style's post_content array.
132 - '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' => '',
133 181 );
134 182 }
135 183
136 184 /**
@@ -162,8 +210,16 @@
162 210 if ( ! isset( $this->$frm_role ) ) {
163 211 $this->$frm_role = 'administrator';
164 212 }
165 213 }
214 +
215 + if ( ! isset( $this->default_email ) ) {
216 + $this->default_email = get_option( 'admin_email' );
217 + }
218 +
219 + if ( ! isset( $this->currency ) ) {
220 + $this->currency = 'USD';
221 + }
166 222 }
167 223
168 224 /**
169 225 * @param array $params
@@ -231,17 +287,21 @@
231 287 if ( ! isset( $this->active_captcha ) ) {
232 288 $this->active_captcha = 'recaptcha';
233 289 }
234 290
235 - $privkey = '';
236 - $re_lang = '';
291 + $privkey = '';
292 + $re_lang = '';
237 293
238 294 if ( ! isset( $this->hcaptcha_privkey ) ) {
239 295 $this->hcaptcha_privkey = '';
240 296 }
241 297
298 + if ( ! isset( $this->turnstile_privkey ) ) {
299 + $this->turnstile_privkey = '';
300 + }
301 +
242 302 if ( ! isset( $this->pubkey ) ) {
243 - // get the options from the database
303 + // Get the options from the database.
244 304 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
245 305 $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
246 306 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
247 307 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
@@ -246,9 +306,9 @@
246 306 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
247 307 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
248 308 }
249 309
250 - if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
310 + if ( empty( $this->re_msg ) ) {
251 311 $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
252 312 }
253 313
254 314 if ( ! isset( $this->privkey ) ) {
@@ -335,23 +395,43 @@
335 395 }
336 396 }
337 397
338 398 /**
399 + * @param array $params
339 400 * @return void
340 401 */
341 402 private function update_settings( $params ) {
342 - $this->active_captcha = $params['frm_active_captcha'];
343 - $this->hcaptcha_pubkey = trim( $params['frm_hcaptcha_pubkey'] );
344 - $this->hcaptcha_privkey = trim( $params['frm_hcaptcha_privkey'] );
345 - $this->pubkey = trim( $params['frm_pubkey'] );
346 - $this->privkey = trim( $params['frm_privkey'] );
347 - $this->re_type = $params['frm_re_type'];
348 - $this->re_lang = $params['frm_re_lang'];
349 - $this->re_threshold = floatval( $params['frm_re_threshold'] );
350 - $this->load_style = $params['frm_load_style'];
351 - $this->custom_css = $params['frm_custom_css'];
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'];
352 418
353 - $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 + );
354 434 foreach ( $checkboxes as $set ) {
355 435 $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
356 436 }
357 437 }
@@ -367,9 +447,9 @@
367 447 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
368 448 $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
369 449
370 450 // Make sure administrators always have permissions
371 - if ( ! in_array( 'administrator', $this->$frm_role ) ) {
451 + if ( ! in_array( 'administrator', $this->$frm_role, true ) ) {
372 452 array_push( $this->$frm_role, 'administrator' );
373 453 }
374 454
375 455 foreach ( $roles as $role => $details ) {
@@ -379,8 +459,31 @@
379 459 $wp_roles->remove_cap( $role, $frm_role );
380 460 }
381 461 }
382 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;
383 486 }
384 487
385 488 /**
386 489 * @return void