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 +162 -63 6.4.26.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,35 +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;
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 $disallowed_words;
99 +
100 + public $allowed_words;
101 +
53 102 public function __construct( $args = array() ) {
54 103 if ( ! defined( 'ABSPATH' ) ) {
55 104 die( 'You are not allowed to call this page directly.' );
56 105 }
57 106
58 - $settings = get_transient( $this->option_name );
107 + $settings = get_option( $this->option_name );
59 108
60 109 if ( ! is_object( $settings ) ) {
61 110 $settings = $this->translate_settings( $settings );
62 111 }
@@ -71,29 +120,18 @@
71 120 $this->maybe_filter_for_form( $args );
72 121 }
73 122
74 123 private function translate_settings( $settings ) {
75 - if ( $settings ) { //workaround for W3 total cache conflict
124 + if ( $settings ) {
125 + // Workaround for W3 total cache conflict.
76 126 return unserialize( serialize( $settings ) );
77 127 }
78 128
79 - $settings = get_option( $this->option_name );
80 - if ( is_object( $settings ) ) {
81 - set_transient( $this->option_name, $settings );
129 + // If unserializing didn't work.
130 + $settings = $this;
82 131
83 - return $settings;
84 - }
132 + update_option( $this->option_name, $settings, 'yes' );
85 133
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 134 return $settings;
97 135 }
98 136
99 137 /**
@@ -100,37 +138,44 @@
100 138 * @return array
101 139 */
102 140 public function default_options() {
103 141 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,
142 + 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ),
143 + 'mu_menu' => 0,
144 + 'fade_form' => false,
145 + 'admin_bar' => false,
112 146
113 - 're_multi' => 1,
147 + 're_multi' => 1,
114 148
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' ),
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' ),
124 160
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(),
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]',
129 170
130 171 // Normally custom CSS is a string. A false value is used when nothing has been set.
131 172 // 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,
173 + 'custom_css' => false,
174 + 'honeypot' => 1,
175 + 'wp_spam_check' => 0,
176 + 'disallowed_words' => '',
177 + 'allowed_words' => '',
133 178 );
134 179 }
135 180
136 181 /**
@@ -162,8 +207,16 @@
162 207 if ( ! isset( $this->$frm_role ) ) {
163 208 $this->$frm_role = 'administrator';
164 209 }
165 210 }
211 +
212 + if ( ! isset( $this->default_email ) ) {
213 + $this->default_email = get_option( 'admin_email' );
214 + }
215 +
216 + if ( ! isset( $this->currency ) ) {
217 + $this->currency = 'USD';
218 + }
166 219 }
167 220
168 221 /**
169 222 * @param array $params
@@ -231,17 +284,21 @@
231 284 if ( ! isset( $this->active_captcha ) ) {
232 285 $this->active_captcha = 'recaptcha';
233 286 }
234 287
235 - $privkey = '';
236 - $re_lang = '';
288 + $privkey = '';
289 + $re_lang = '';
237 290
238 291 if ( ! isset( $this->hcaptcha_privkey ) ) {
239 292 $this->hcaptcha_privkey = '';
240 293 }
241 294
295 + if ( ! isset( $this->turnstile_privkey ) ) {
296 + $this->turnstile_privkey = '';
297 + }
298 +
242 299 if ( ! isset( $this->pubkey ) ) {
243 - // get the options from the database
300 + // Get the options from the database.
244 301 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
245 302 $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
246 303 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
247 304 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
@@ -246,9 +303,9 @@
246 303 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
247 304 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
248 305 }
249 306
250 - if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
307 + if ( empty( $this->re_msg ) ) {
251 308 $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
252 309 }
253 310
254 311 if ( ! isset( $this->privkey ) ) {
@@ -335,23 +392,42 @@
335 392 }
336 393 }
337 394
338 395 /**
396 + * @param array $params
339 397 * @return void
340 398 */
341 399 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'];
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'];
352 415
353 - $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 + );
354 430 foreach ( $checkboxes as $set ) {
355 431 $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
356 432 }
357 433 }
@@ -367,9 +443,9 @@
367 443 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
368 444 $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
369 445
370 446 // Make sure administrators always have permissions
371 - if ( ! in_array( 'administrator', $this->$frm_role ) ) {
447 + if ( ! in_array( 'administrator', $this->$frm_role, true ) ) {
372 448 array_push( $this->$frm_role, 'administrator' );
373 449 }
374 450
375 451 foreach ( $roles as $role => $details ) {
@@ -379,8 +455,31 @@
379 455 $wp_roles->remove_cap( $role, $frm_role );
380 456 }
381 457 }
382 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;
383 482 }
384 483
385 484 /**
386 485 * @return void