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 -123 6.45.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,19 +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 - /**
47 - * @since 6.0
48 - *
49 - * @var string|false|null
50 - */
51 - public $custom_css;
52 -
53 41 public function __construct( $args = array() ) {
54 42 if ( ! defined( 'ABSPATH' ) ) {
55 43 die( 'You are not allowed to call this page directly.' );
56 44 }
@@ -119,26 +107,17 @@
119 107 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ),
120 108 'submit_value' => __( 'Submit', 'formidable' ),
121 109 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ),
122 110 '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 111
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,
112 + 'email_to' => '[admin_email]',
113 + 'no_ips' => 0,
114 + 'tracking' => FrmAppHelper::pro_is_installed(),
133 115 );
134 116 }
135 117
136 - /**
137 - * @return void
138 - */
139 118 private function set_default_options() {
140 - $this->fill_captcha_settings();
119 + $this->fill_recaptcha_settings();
141 120
142 121 if ( ! isset( $this->load_style ) ) {
143 122 if ( ! isset( $this->custom_style ) ) {
144 123 $this->custom_style = true;
@@ -164,25 +143,11 @@
164 143 }
165 144 }
166 145 }
167 146
168 - /**
169 - * @param array $params
170 - * @return void
171 - */
172 147 public function fill_with_defaults( $params = array() ) {
173 - $settings = $this->default_options();
174 - $filter_html = ! FrmAppHelper::allow_unfiltered_html();
148 + $settings = $this->default_options();
175 149
176 - if ( $filter_html ) {
177 - $filter_keys = array( 'failed_msg', 'blank_msg', 'invalid_msg', 'admin_permission', 'unique_msg', 'success_msg', 'submit_value', 'login_msg', 'menu' );
178 - if ( ! empty( $params['additional_filter_keys'] ) ) {
179 - $filter_keys = array_merge( $filter_keys, $params['additional_filter_keys'] );
180 - }
181 - } else {
182 - $filter_keys = array();
183 - }
184 -
185 150 foreach ( $settings as $setting => $default ) {
186 151 if ( isset( $params[ 'frm_' . $setting ] ) ) {
187 152 $this->{$setting} = $params[ 'frm_' . $setting ];
188 153 } elseif ( ! isset( $this->{$setting} ) ) {
@@ -188,58 +153,20 @@
188 153 } elseif ( ! isset( $this->{$setting} ) ) {
189 154 $this->{$setting} = $default;
190 155 }
191 156
192 - if ( $setting === 'menu' && empty( $this->{$setting} ) ) {
157 + if ( $setting == 'menu' && empty( $this->{$setting} ) ) {
193 158 $this->{$setting} = $default;
194 159 }
195 160
196 - $this->{$setting} = $this->maybe_sanitize_global_setting( $this->{$setting}, $setting, $filter_keys );
197 161 unset( $setting, $default );
198 162 }
199 163 }
200 164
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;
216 - }
217 - return sanitize_textarea_field( $value );
218 - }
165 + private function fill_recaptcha_settings() {
166 + $privkey = '';
167 + $re_lang = '';
219 168
220 - if ( in_array( $key, $filter_keys, true ) ) {
221 - return FrmAppHelper::kses( $value, 'all' );
222 - }
223 -
224 - return $value;
225 - }
226 -
227 - /**
228 - * @return void
229 - */
230 - private function fill_captcha_settings() {
231 - if ( ! isset( $this->active_captcha ) ) {
232 - $this->active_captcha = 'recaptcha';
233 - }
234 -
235 - $privkey = '';
236 - $re_lang = '';
237 -
238 - if ( ! isset( $this->hcaptcha_privkey ) ) {
239 - $this->hcaptcha_privkey = '';
240 - }
241 -
242 169 if ( ! isset( $this->pubkey ) ) {
243 170 // get the options from the database
244 171 $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' );
245 172 $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : '';
@@ -247,9 +174,9 @@
247 174 $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang;
248 175 }
249 176
250 177 if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) {
251 - $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' );
178 + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' );
252 179 }
253 180
254 181 if ( ! isset( $this->privkey ) ) {
255 182 $this->privkey = $privkey;
@@ -261,12 +188,8 @@
261 188
262 189 if ( ! isset( $this->re_type ) ) {
263 190 $this->re_type = '';
264 191 }
265 -
266 - if ( ! isset( $this->re_threshold ) ) {
267 - $this->re_threshold = .5;
268 - }
269 192 }
270 193
271 194 /**
272 195 * Get values that may be shown on the front-end without an override in the form settings.
@@ -271,15 +194,12 @@
271 194 /**
272 195 * Get values that may be shown on the front-end without an override in the form settings.
273 196 *
274 197 * @since 3.06.01
275 - *
276 - * @return string[]
277 198 */
278 199 public function translatable_strings() {
279 200 return array(
280 201 'invalid_msg',
281 - 'admin_permission',
282 202 'failed_msg',
283 203 'login_msg',
284 204 );
285 205 }
@@ -287,10 +207,8 @@
287 207 /**
288 208 * Allow strings to be filtered when a specific form may be displaying them.
289 209 *
290 210 * @since 3.06.01
291 - *
292 - * @return void
293 211 */
294 212 public function maybe_filter_for_form( $args ) {
295 213 if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) {
296 214 $this->current_form = $args['current_form'];
@@ -300,21 +218,12 @@
300 218 }
301 219 }
302 220 }
303 221
304 - /**
305 - * @param array $params
306 - * @param array $errors
307 - */
308 222 public function validate( $params, $errors ) {
309 223 return apply_filters( 'frm_validate_settings', $errors, $params );
310 224 }
311 225
312 - /**
313 - * @param array $params
314 - *
315 - * @return void
316 - */
317 226 public function update( $params ) {
318 227 $this->fill_with_defaults( $params );
319 228 $this->update_settings( $params );
320 229
@@ -328,38 +237,39 @@
328 237
329 238 do_action( 'frm_update_settings', $params );
330 239
331 240 if ( function_exists( 'get_filesystem_method' ) ) {
332 - // Save styling settings in case fallback setting changes.
241 + // save styling settings in case fallback setting changes
333 242 $frm_style = new FrmStyle();
334 243 $frm_style->update( 'default' );
335 244 }
336 245 }
337 246
338 - /**
339 - * @return void
340 - */
341 247 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'];
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'];
352 253
353 - $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' );
354 257 foreach ( $checkboxes as $set ) {
355 - $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0;
258 + $this->$set = isset( $params[ 'frm_' . $set ] ) ? $params[ 'frm_' . $set ] : 0;
356 259 }
260 +
261 + $this->maybe_remove_old_css_inbox_message( $previous_old_css_setting, $this->old_css );
357 262 }
358 263
359 - /**
360 - * @return void
361 - */
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 +
362 272 private function update_roles( $params ) {
363 273 global $wp_roles;
364 274
365 275 $frm_roles = FrmAppHelper::frm_capabilities();
@@ -381,11 +291,8 @@
381 291 }
382 292 }
383 293 }
384 294
385 - /**
386 - * @return void
387 - */
388 295 public function store() {
389 296 // Save the posted value in the database
390 297
391 298 update_option( 'frm_options', $this );