PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.10
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.10
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 +137 -58 6.36.10 View file →
@@ -28,11 +28,21 @@
28 28 public $load_style;
29 29 public $custom_style;
30 30
31 31 public $active_captcha;
32 - public $hcaptcha_pubkey;
33 - public $hcaptcha_privkey;
32 +
33 + /**
34 + * Settings for reCAPTCHA.
35 + */
36 +
37 + /**
38 + * @var string|null
39 + */
34 40 public $pubkey;
41 +
42 + /**
43 + * @var string|null
44 + */
35 45 public $privkey;
36 46 public $re_lang;
37 47 public $re_type;
38 48 public $re_msg;
@@ -37,17 +47,50 @@
37 47 public $re_type;
38 48 public $re_msg;
39 49 public $re_multi;
40 50
51 + /**
52 + * Settings for hCaptcha.
53 + */
54 +
55 + /**
56 + * @var string
57 + */
58 + public $hcaptcha_pubkey;
59 +
60 + /**
61 + * @var string|null
62 + */
63 + public $hcaptcha_privkey;
64 +
65 + /**
66 + * Settings for Turnstile.
67 + */
68 +
69 + /**
70 + * @var string
71 + */
72 + public $turnstile_pubkey;
73 +
74 + /**
75 + * @var string|null
76 + */
77 + public $turnstile_privkey;
78 +
41 79 public $no_ips;
42 80 public $custom_header_ip;
43 81 public $current_form = 0;
44 82 public $tracking;
83 + public $summary_emails;
84 + public $summary_emails_recipients;
45 85
86 + public $default_email;
87 + public $currency;
88 +
46 89 /**
47 90 * @since 6.0
48 91 *
49 - * @var string|false|null
92 + * @var false|string|null
50 93 */
51 94 public $custom_css;
52 95
53 96 public function __construct( $args = array() ) {
@@ -54,9 +97,9 @@
54 97 if ( ! defined( 'ABSPATH' ) ) {
55 98 die( 'You are not allowed to call this page directly.' );
56 99 }
57 100
58 - $settings = get_transient( $this->option_name );
101 + $settings = get_option( $this->option_name );
59 102
60 103 if ( ! is_object( $settings ) ) {
61 104 $settings = $this->translate_settings( $settings );
62 105 }
@@ -71,29 +114,18 @@
71 114 $this->maybe_filter_for_form( $args );
72 115 }
73 116
74 117 private function translate_settings( $settings ) {
75 - if ( $settings ) { //workaround for W3 total cache conflict
118 + if ( $settings ) {
119 + // Workaround for W3 total cache conflict.
76 120 return unserialize( serialize( $settings ) );
77 121 }
78 122
79 - $settings = get_option( $this->option_name );
80 - if ( is_object( $settings ) ) {
81 - set_transient( $this->option_name, $settings );
123 + // If unserializing didn't work.
124 + $settings = $this;
82 125
83 - return $settings;
84 - }
126 + update_option( $this->option_name, $settings, 'yes' );
85 127
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 128 return $settings;
97 129 }
98 130
99 131 /**
@@ -100,36 +132,43 @@
100 132 * @return array
101 133 */
102 134 public function default_options() {
103 135 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,
136 + 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ),
137 + 'mu_menu' => 0,
138 + 'use_html' => true,
139 + 'jquery_css' => false,
140 + 'accordion_js' => false,
141 + 'fade_form' => false,
142 + 'old_css' => false,
143 + 'admin_bar' => false,
112 144
113 - 're_multi' => 1,
145 + 're_multi' => 1,
114 146
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' ),
147 + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ),
148 + // translators: %s: [field_name] shortcode.
149 + 'blank_msg' => sprintf( __( '%s cannot be blank.', 'formidable' ), '[field_name]' ),
150 + // translators: %s: [field_name] shortcode.
151 + 'unique_msg' => sprintf( __( '%s must be unique.', 'formidable' ), '[field_name]' ),
152 + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ),
153 + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
154 + 'submit_value' => __( 'Submit', 'formidable' ),
155 + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
156 + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ),
157 + 'new_tab_msg' => __( 'The page has been opened in a new tab.', 'formidable' ),
123 158
124 - 'email_to' => '[admin_email]',
125 - 'no_ips' => 0,
126 - '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
127 - 'tracking' => FrmAppHelper::pro_is_installed(),
159 + 'email_to' => '[admin_email]',
160 + 'no_ips' => 0,
161 + // Use false by default. We show a warning when this is unset. Once global settings have been saved, this gets saved.
162 + 'custom_header_ip' => false,
163 + 'tracking' => FrmAppHelper::pro_is_installed(),
164 + // Only enable this by default for the main site.
165 + 'summary_emails' => get_current_blog_id() === get_main_site_id(),
166 + 'summary_emails_recipients' => '[admin_email]',
128 167
129 168 // Normally custom CSS is a string. A false value is used when nothing has been set.
130 169 // When it is false, we try to use the old custom_key value from the default style's post_content array.
131 - 'custom_css' => false,
170 + 'custom_css' => false,
132 171 );
133 172 }
134 173
135 174 /**
@@ -161,8 +200,16 @@
161 200 if ( ! isset( $this->$frm_role ) ) {
162 201 $this->$frm_role = 'administrator';
163 202 }
164 203 }
204 +
205 + if ( ! isset( $this->default_email ) ) {
206 + $this->default_email = get_option( 'admin_email' );
207 + }
208 +
209 + if ( ! isset( $this->currency ) ) {
210 + $this->currency = 'USD';
211 + }
165 212 }
166 213
167 214 /**
168 215 * @param array $params
@@ -230,17 +277,21 @@
230 277 if ( ! isset( $this->active_captcha ) ) {
231 278 $this->active_captcha = 'recaptcha';
232 279 }
233 280
234 - $privkey = '';
235 - $re_lang = '';
281 + $privkey = '';
282 + $re_lang = '';
236 283
237 284 if ( ! isset( $this->hcaptcha_privkey ) ) {
238 285 $this->hcaptcha_privkey = '';
239 286 }
240 287
288 + if ( ! isset( $this->turnstile_privkey ) ) {
289 + $this->turnstile_privkey = '';
290 + }
291 +
241 292 if ( ! isset( $this->pubkey ) ) {
242 - // get the options from the database
293 + // Get the options from the database.
243 294 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
244 295 $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
245 296 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
246 297 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
@@ -245,9 +296,9 @@
245 296 $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey;
246 297 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
247 298 }
248 299
249 - if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
300 + if ( empty( $this->re_msg ) ) {
250 301 $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
251 302 }
252 303
253 304 if ( ! isset( $this->privkey ) ) {
@@ -334,23 +385,28 @@
334 385 }
335 386 }
336 387
337 388 /**
389 + * @param array $params
338 390 * @return void
339 391 */
340 392 private function update_settings( $params ) {
341 - $this->active_captcha = $params['frm_active_captcha'];
342 - $this->hcaptcha_pubkey = trim( $params['frm_hcaptcha_pubkey'] );
343 - $this->hcaptcha_privkey = $params['frm_hcaptcha_privkey'];
344 - $this->pubkey = trim( $params['frm_pubkey'] );
345 - $this->privkey = $params['frm_privkey'];
346 - $this->re_type = $params['frm_re_type'];
347 - $this->re_lang = $params['frm_re_lang'];
348 - $this->re_threshold = floatval( $params['frm_re_threshold'] );
349 - $this->load_style = $params['frm_load_style'];
350 - $this->custom_css = $params['frm_custom_css'];
393 + $this->active_captcha = $params['frm_active_captcha'];
394 + $this->pubkey = trim( $params['frm_pubkey'] );
395 + $this->privkey = trim( $params['frm_privkey'] );
396 + $this->re_type = $params['frm_re_type'];
397 + $this->re_lang = $params['frm_re_lang'];
398 + $this->re_threshold = floatval( $params['frm_re_threshold'] );
399 + $this->hcaptcha_pubkey = trim( $params['frm_hcaptcha_pubkey'] );
400 + $this->hcaptcha_privkey = trim( $params['frm_hcaptcha_privkey'] );
401 + $this->turnstile_pubkey = trim( $params['frm_turnstile_pubkey'] );
402 + $this->turnstile_privkey = trim( $params['frm_turnstile_privkey'] );
403 + $this->load_style = $params['frm_load_style'];
404 + $this->custom_css = $params['frm_custom_css'];
405 + $this->default_email = $params['frm_default_email'];
406 + $this->currency = $params['frm_currency'];
351 407
352 - $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar' );
408 + $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar', 'summary_emails' );
353 409 foreach ( $checkboxes as $set ) {
354 410 $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
355 411 }
356 412 }
@@ -366,9 +422,9 @@
366 422 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
367 423 $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' );
368 424
369 425 // Make sure administrators always have permissions
370 - if ( ! in_array( 'administrator', $this->$frm_role ) ) {
426 + if ( ! in_array( 'administrator', $this->$frm_role, true ) ) {
371 427 array_push( $this->$frm_role, 'administrator' );
372 428 }
373 429
374 430 foreach ( $roles as $role => $details ) {
@@ -378,8 +434,31 @@
378 434 $wp_roles->remove_cap( $role, $frm_role );
379 435 }
380 436 }
381 437 }
438 + }
439 +
440 + /**
441 + * Updates a single setting with specified sanitization.
442 + *
443 + * @since 6.9
444 + *
445 + * @param string $key The setting key to update.
446 + * @param mixed $value The new value for the setting.
447 + * @param string $sanitize The name of the sanitization function to apply to the new value.
448 + * @return bool True on success, false on failure.
449 + */
450 + public function update_setting( $key, $value, $sanitize ) {
451 + if ( ! property_exists( $this, $key ) || ! is_callable( $sanitize ) ) {
452 + // Setting does not exist or sanitization function name is not callable.
453 + return false;
454 + }
455 +
456 + // Update the property value.
457 + FrmAppHelper::sanitize_value( $sanitize, $value );
458 + $this->{$key} = $value;
459 +
460 + return true;
382 461 }
383 462
384 463 /**
385 464 * @return void