PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 +30 -130 6.55.0 View file →
@@ -2,9 +2,8 @@
2 2 if ( ! defined( 'ABSPATH' ) ) {
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 -#[\AllowDynamicProperties]
7 6 class FrmSettings {
8 7 public $option_name = 'frm_options';
9 8 public $menu;
10 9 public $mu_menu;
@@ -27,11 +26,8 @@
27 26 public $email_to;
28 27 public $load_style;
29 28 public $custom_style;
30 29
31 - public $active_captcha;
32 - public $hcaptcha_pubkey;
33 - public $hcaptcha_privkey;
34 30 public $pubkey;
35 31 public $privkey;
36 32 public $re_lang;
37 33 public $re_type;
@@ -38,21 +34,11 @@
38 34 public $re_msg;
39 35 public $re_multi;
40 36
41 37 public $no_ips;
42 - public $custom_header_ip;
43 38 public $current_form = 0;
44 39 public $tracking;
45 40
46 - public $currency;
47 -
48 - /**
49 - * @since 6.0
50 - *
51 - * @var string|false|null
52 - */
53 - public $custom_css;
54 -
55 41 public function __construct( $args = array() ) {
56 42 if ( ! defined( 'ABSPATH' ) ) {
57 43 die( 'You are not allowed to call this page directly.' );
58 44 }
@@ -121,26 +107,17 @@
121 107 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
122 108 'submit_value' => __( 'Submit', 'formidable' ),
123 109 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
124 110 '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' ),
126 111
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(),
131 -
132 - // Normally custom CSS is a string. A false value is used when nothing has been set.
133 - // 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,
112 + 'email_to' => '[admin_email]',
113 + 'no_ips' => 0,
114 + 'tracking' => FrmAppHelper::pro_is_installed(),
135 115 );
136 116 }
137 117
138 - /**
139 - * @return void
140 - */
141 118 private function set_default_options() {
142 - $this->fill_captcha_settings();
119 + $this->fill_recaptcha_settings();
143 120
144 121 if ( ! isset( $this->load_style ) ) {
145 122 if ( ! isset( $this->custom_style ) ) {
146 123 $this->custom_style = true;
@@ -164,31 +141,13 @@
164 141 if ( ! isset( $this->$frm_role ) ) {
165 142 $this->$frm_role = 'administrator';
166 143 }
167 144 }
168 -
169 - if ( ! isset( $this->currency ) ) {
170 - $this->currency = 'USD';
171 - }
172 145 }
173 146
174 - /**
175 - * @param array $params
176 - * @return void
177 - */
178 147 public function fill_with_defaults( $params = array() ) {
179 - $settings = $this->default_options();
180 - $filter_html = ! FrmAppHelper::allow_unfiltered_html();
148 + $settings = $this->default_options();
181 149
182 - if ( $filter_html ) {
183 - $filter_keys = array( 'failed_msg', 'blank_msg', 'invalid_msg', 'admin_permission', 'unique_msg', 'success_msg', 'submit_value', 'login_msg', 'menu' );
184 - if ( ! empty( $params['additional_filter_keys'] ) ) {
185 - $filter_keys = array_merge( $filter_keys, $params['additional_filter_keys'] );
186 - }
187 - } else {
188 - $filter_keys = array();
189 - }
190 -
191 150 foreach ( $settings as $setting => $default ) {
192 151 if ( isset( $params[ 'frm_' . $setting ] ) ) {
193 152 $this->{$setting} = $params[ 'frm_' . $setting ];
194 153 } elseif ( ! isset( $this->{$setting} ) ) {
@@ -194,58 +153,20 @@
194 153 } elseif ( ! isset( $this->{$setting} ) ) {
195 154 $this->{$setting} = $default;
196 155 }
197 156
198 - if ( $setting === 'menu' && empty( $this->{$setting} ) ) {
157 + if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
199 158 $this->{$setting} = $default;
200 159 }
201 160
202 - $this->{$setting} = $this->maybe_sanitize_global_setting( $this->{$setting}, $setting, $filter_keys );
203 161 unset( $setting, $default );
204 162 }
205 163 }
206 164
207 - /**
208 - * Handle sanitizing for a target global setting key.
209 - *
210 - * @since 6.0
211 - *
212 - * @param mixed $value The unsanitized global setting value.
213 - * @param string $key The key of the global setting being saved.
214 - * @param array $filter_keys These keys that are filtered with kses.
215 - * @return mixed
216 - */
217 - private function maybe_sanitize_global_setting( $value, $key, $filter_keys ) {
218 - if ( 'custom_css' === $key ) {
219 - if ( false === $value ) {
220 - // Avoid changing the false default value to an empty string.
221 - return $value;
222 - }
223 - return sanitize_textarea_field( $value );
224 - }
165 + private function fill_recaptcha_settings() {
166 + $privkey = '';
167 + $re_lang = '';
225 168
226 - if ( in_array( $key, $filter_keys, true ) ) {
227 - return FrmAppHelper::kses( $value, 'all' );
228 - }
229 -
230 - return $value;
231 - }
232 -
233 - /**
234 - * @return void
235 - */
236 - private function fill_captcha_settings() {
237 - if ( ! isset( $this->active_captcha ) ) {
238 - $this->active_captcha = 'recaptcha';
239 - }
240 -
241 - $privkey = '';
242 - $re_lang = '';
243 -
244 - if ( ! isset( $this->hcaptcha_privkey ) ) {
245 - $this->hcaptcha_privkey = '';
246 - }
247 -
248 169 if ( ! isset( $this->pubkey ) ) {
249 170 // get the options from the database
250 171 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
251 172 $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
@@ -253,9 +174,9 @@
253 174 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
254 175 }
255 176
256 177 if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
257 - $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
178 + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
258 179 }
259 180
260 181 if ( ! isset( $this->privkey ) ) {
261 182 $this->privkey = $privkey;
@@ -267,12 +188,8 @@
267 188
268 189 if ( ! isset( $this->re_type ) ) {
269 190 $this->re_type = '';
270 191 }
271 -
272 - if ( ! isset( $this->re_threshold ) ) {
273 - $this->re_threshold = .5;
274 - }
275 192 }
276 193
277 194 /**
278 195 * Get values that may be shown on the front-end without an override in the form settings.
@@ -277,15 +194,12 @@
277 194 /**
278 195 * Get values that may be shown on the front-end without an override in the form settings.
279 196 *
280 197 * @since 3.06.01
281 - *
282 - * @return string[]
283 198 */
284 199 public function translatable_strings() {
285 200 return array(
286 201 'invalid_msg',
287 - 'admin_permission',
288 202 'failed_msg',
289 203 'login_msg',
290 204 );
291 205 }
@@ -293,10 +207,8 @@
293 207 /**
294 208 * Allow strings to be filtered when a specific form may be displaying them.
295 209 *
296 210 * @since 3.06.01
297 - *
298 - * @return void
299 211 */
300 212 public function maybe_filter_for_form( $args ) {
301 213 if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) {
302 214 $this->current_form = $args['current_form'];
@@ -306,21 +218,12 @@
306 218 }
307 219 }
308 220 }
309 221
310 - /**
311 - * @param array $params
312 - * @param array $errors
313 - */
314 222 public function validate( $params, $errors ) {
315 223 return apply_filters( 'frm_validate_settings', $errors, $params );
316 224 }
317 225
318 - /**
319 - * @param array $params
320 - *
321 - * @return void
322 - */
323 226 public function update( $params ) {
324 227 $this->fill_with_defaults( $params );
325 228 $this->update_settings( $params );
326 229
@@ -334,39 +237,39 @@
334 237
335 238 do_action( 'frm_update_settings', $params );
336 239
337 240 if ( function_exists( 'get_filesystem_method' ) ) {
338 - // Save styling settings in case fallback setting changes.
241 + // save styling settings in case fallback setting changes
339 242 $frm_style = new FrmStyle();
340 243 $frm_style->update( 'default' );
341 244 }
342 245 }
343 246
344 - /**
345 - * @return void
346 - */
347 247 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'];
248 + $this->pubkey = trim( $params['frm_pubkey'] );
249 + $this->privkey = $params['frm_privkey'];
250 + $this->re_type = $params['frm_re_type'];
251 + $this->re_lang = $params['frm_re_lang'];
252 + $this->load_style = $params['frm_load_style'];
359 253
360 - $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar' );
254 + $previous_old_css_setting = $this->old_css;
255 +
256 + $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'old_css', 'no_ips', 'tracking', 'admin_bar' );
361 257 foreach ( $checkboxes as $set ) {
362 - $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
258 + $this->$set = isset( $params[ 'frm_' . $set ] ) ? $params[ 'frm_' . $set ] : 0;
363 259 }
260 +
261 + $this->maybe_remove_old_css_inbox_message( $previous_old_css_setting, $this->old_css );
364 262 }
365 263
366 - /**
367 - * @return void
368 - */
264 + private function maybe_remove_old_css_inbox_message( $previous_setting, $new_setting ) {
265 + $enabled_css_grid = $previous_setting && ! $new_setting;
266 + if ( $enabled_css_grid ) {
267 + $inbox = new FrmInbox();
268 + $inbox->remove( 'old_css' );
269 + }
270 + }
271 +
369 272 private function update_roles( $params ) {
370 273 global $wp_roles;
371 274
372 275 $frm_roles = FrmAppHelper::frm_capabilities();
@@ -388,11 +291,8 @@
388 291 }
389 292 }
390 293 }
391 294
392 - /**
393 - * @return void
394 - */
395 295 public function store() {
396 296 // Save the posted value in the database
397 297
398 298 update_option( 'frm_options', $this );