PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5.4
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 +11 -79 6.45.5.4 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;
@@ -38,19 +37,11 @@
38 37 public $re_msg;
39 38 public $re_multi;
40 39
41 40 public $no_ips;
42 - public $custom_header_ip;
43 41 public $current_form = 0;
44 42 public $tracking;
45 43
46 - /**
47 - * @since 6.0
48 - *
49 - * @var string|false|null
50 - */
51 - public $custom_css;
52 -
53 44 public function __construct( $args = array() ) {
54 45 if ( ! defined( 'ABSPATH' ) ) {
55 46 die( 'You are not allowed to call this page directly.' );
56 47 }
@@ -119,24 +110,15 @@
119 110 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
120 111 'submit_value' => __( 'Submit', 'formidable' ),
121 112 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
122 113 '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' ),
124 114
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(),
129 -
130 - // Normally custom CSS is a string. A false value is used when nothing has been set.
131 - // 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,
115 + 'email_to' => '[admin_email]',
116 + 'no_ips' => 0,
117 + 'tracking' => FrmAppHelper::pro_is_installed(),
133 118 );
134 119 }
135 120
136 - /**
137 - * @return void
138 - */
139 121 private function set_default_options() {
140 122 $this->fill_captcha_settings();
141 123
142 124 if ( ! isset( $this->load_style ) ) {
@@ -166,9 +148,8 @@
166 148 }
167 149
168 150 /**
169 151 * @param array $params
170 - * @return void
171 152 */
172 153 public function fill_with_defaults( $params = array() ) {
173 154 $settings = $this->default_options();
174 155 $filter_html = ! FrmAppHelper::allow_unfiltered_html();
@@ -192,42 +173,16 @@
192 173 if ( $setting === 'menu' && empty( $this->{$setting} ) ) {
193 174 $this->{$setting} = $default;
194 175 }
195 176
196 - $this->{$setting} = $this->maybe_sanitize_global_setting( $this->{$setting}, $setting, $filter_keys );
197 - unset( $setting, $default );
198 - }
199 - }
200 -
201 - /**
202 - * Handle sanitizing for a target global setting key.
203 - *
204 - * @since 6.0
205 - *
206 - * @param mixed $value The unsanitized global setting value.
207 - * @param string $key The key of the global setting being saved.
208 - * @param array $filter_keys These keys that are filtered with kses.
209 - * @return mixed
210 - */
211 - private function maybe_sanitize_global_setting( $value, $key, $filter_keys ) {
212 - if ( 'custom_css' === $key ) {
213 - if ( false === $value ) {
214 - // Avoid changing the false default value to an empty string.
215 - return $value;
177 + if ( $filter_html && in_array( $setting, $filter_keys, true ) ) {
178 + $this->{$setting} = FrmAppHelper::kses( $this->{$setting}, 'all' );
216 179 }
217 - return sanitize_textarea_field( $value );
218 - }
219 180
220 - if ( in_array( $key, $filter_keys, true ) ) {
221 - return FrmAppHelper::kses( $value, 'all' );
181 + unset( $setting, $default );
222 182 }
223 -
224 - return $value;
225 183 }
226 184
227 - /**
228 - * @return void
229 - */
230 185 private function fill_captcha_settings() {
231 186 if ( ! isset( $this->active_captcha ) ) {
232 187 $this->active_captcha = 'recaptcha';
233 188 }
@@ -271,10 +226,8 @@
271 226 /**
272 227 * Get values that may be shown on the front-end without an override in the form settings.
273 228 *
274 229 * @since 3.06.01
275 - *
276 - * @return string[]
277 230 */
278 231 public function translatable_strings() {
279 232 return array(
280 233 'invalid_msg',
@@ -287,10 +240,8 @@
287 240 /**
288 241 * Allow strings to be filtered when a specific form may be displaying them.
289 242 *
290 243 * @since 3.06.01
291 - *
292 - * @return void
293 244 */
294 245 public function maybe_filter_for_form( $args ) {
295 246 if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) {
296 247 $this->current_form = $args['current_form'];
@@ -300,21 +251,12 @@
300 251 }
301 252 }
302 253 }
303 254
304 - /**
305 - * @param array $params
306 - * @param array $errors
307 - */
308 255 public function validate( $params, $errors ) {
309 256 return apply_filters( 'frm_validate_settings', $errors, $params );
310 257 }
311 258
312 - /**
313 - * @param array $params
314 - *
315 - * @return void
316 - */
317 259 public function update( $params ) {
318 260 $this->fill_with_defaults( $params );
319 261 $this->update_settings( $params );
320 262
@@ -328,38 +270,31 @@
328 270
329 271 do_action( 'frm_update_settings', $params );
330 272
331 273 if ( function_exists( 'get_filesystem_method' ) ) {
332 - // Save styling settings in case fallback setting changes.
274 + // save styling settings in case fallback setting changes
333 275 $frm_style = new FrmStyle();
334 276 $frm_style->update( 'default' );
335 277 }
336 278 }
337 279
338 - /**
339 - * @return void
340 - */
341 280 private function update_settings( $params ) {
342 281 $this->active_captcha = $params['frm_active_captcha'];
343 282 $this->hcaptcha_pubkey = trim( $params['frm_hcaptcha_pubkey'] );
344 - $this->hcaptcha_privkey = trim( $params['frm_hcaptcha_privkey'] );
283 + $this->hcaptcha_privkey = $params['frm_hcaptcha_privkey'];
345 284 $this->pubkey = trim( $params['frm_pubkey'] );
346 - $this->privkey = trim( $params['frm_privkey'] );
285 + $this->privkey = $params['frm_privkey'];
347 286 $this->re_type = $params['frm_re_type'];
348 287 $this->re_lang = $params['frm_re_lang'];
349 288 $this->re_threshold = floatval( $params['frm_re_threshold'] );
350 289 $this->load_style = $params['frm_load_style'];
351 - $this->custom_css = $params['frm_custom_css'];
352 290
353 - $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar' );
291 + $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'tracking', 'admin_bar' );
354 292 foreach ( $checkboxes as $set ) {
355 - $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
293 + $this->$set = isset( $params[ 'frm_' . $set ] ) ? $params[ 'frm_' . $set ] : 0;
356 294 }
357 295 }
358 296
359 - /**
360 - * @return void
361 - */
362 297 private function update_roles( $params ) {
363 298 global $wp_roles;
364 299
365 300 $frm_roles = FrmAppHelper::frm_capabilities();
@@ -381,11 +316,8 @@
381 316 }
382 317 }
383 318 }
384 319
385 - /**
386 - * @return void
387 - */
388 320 public function store() {
389 321 // Save the posted value in the database
390 322
391 323 update_option( 'frm_options', $this );