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