| @@ -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,21 +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 | - public $currency; | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * @since 6.0 | |
| 50 | - * | |
| 51 | - * @var string|false|null | |
| 52 | - */ | |
| 53 | - public $custom_css; | |
| 54 | - | |
| 55 | 44 | public function __construct( $args = array() ) { |
| 56 | 45 | if ( ! defined( 'ABSPATH' ) ) { |
| 57 | 46 | die( 'You are not allowed to call this page directly.' ); |
| 58 | 47 | } |
| @@ -121,24 +110,15 @@ | ||
| 121 | 110 | 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
| 122 | 111 | 'submit_value' => __( 'Submit', 'formidable' ), |
| 123 | 112 | 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
| 124 | 113 | '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 | 114 | |
| 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, | |
| 115 | + 'email_to' => '[admin_email]', | |
| 116 | + 'no_ips' => 0, | |
| 117 | + 'tracking' => FrmAppHelper::pro_is_installed(), | |
| 135 | 118 | ); |
| 136 | 119 | } |
| 137 | 120 | |
| 138 | - /** | |
| 139 | - * @return void | |
| 140 | - */ | |
| 141 | 121 | private function set_default_options() { |
| 142 | 122 | $this->fill_captcha_settings(); |
| 143 | 123 | |
| 144 | 124 | if ( ! isset( $this->load_style ) ) { |
| @@ -164,17 +144,12 @@ | ||
| 164 | 144 | if ( ! isset( $this->$frm_role ) ) { |
| 165 | 145 | $this->$frm_role = 'administrator'; |
| 166 | 146 | } |
| 167 | 147 | } |
| 168 | - | |
| 169 | - if ( ! isset( $this->currency ) ) { | |
| 170 | - $this->currency = 'USD'; | |
| 171 | - } | |
| 172 | 148 | } |
| 173 | 149 | |
| 174 | 150 | /** |
| 175 | 151 | * @param array $params |
| 176 | - * @return void | |
| 177 | 152 | */ |
| 178 | 153 | public function fill_with_defaults( $params = array() ) { |
| 179 | 154 | $settings = $this->default_options(); |
| 180 | 155 | $filter_html = ! FrmAppHelper::allow_unfiltered_html(); |
| @@ -198,42 +173,16 @@ | ||
| 198 | 173 | if ( $setting === 'menu' && empty( $this->{$setting} ) ) { |
| 199 | 174 | $this->{$setting} = $default; |
| 200 | 175 | } |
| 201 | 176 | |
| 202 | - $this->{$setting} = $this->maybe_sanitize_global_setting( $this->{$setting}, $setting, $filter_keys ); | |
| 203 | - unset( $setting, $default ); | |
| 204 | - } | |
| 205 | - } | |
| 206 | - | |
| 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; | |
| 177 | + if ( $filter_html && in_array( $setting, $filter_keys, true ) ) { | |
| 178 | + $this->{$setting} = FrmAppHelper::kses( $this->{$setting}, 'all' ); | |
| 222 | 179 | } |
| 223 | - return sanitize_textarea_field( $value ); | |
| 224 | - } | |
| 225 | 180 | |
| 226 | - if ( in_array( $key, $filter_keys, true ) ) { | |
| 227 | - return FrmAppHelper::kses( $value, 'all' ); | |
| 181 | + unset( $setting, $default ); | |
| 228 | 182 | } |
| 229 | - | |
| 230 | - return $value; | |
| 231 | 183 | } |
| 232 | 184 | |
| 233 | - /** | |
| 234 | - * @return void | |
| 235 | - */ | |
| 236 | 185 | private function fill_captcha_settings() { |
| 237 | 186 | if ( ! isset( $this->active_captcha ) ) { |
| 238 | 187 | $this->active_captcha = 'recaptcha'; |
| 239 | 188 | } |
| @@ -277,10 +226,8 @@ | ||
| 277 | 226 | /** |
| 278 | 227 | * Get values that may be shown on the front-end without an override in the form settings. |
| 279 | 228 | * |
| 280 | 229 | * @since 3.06.01 |
| 281 | - * | |
| 282 | - * @return string[] | |
| 283 | 230 | */ |
| 284 | 231 | public function translatable_strings() { |
| 285 | 232 | return array( |
| 286 | 233 | 'invalid_msg', |
| @@ -293,10 +240,8 @@ | ||
| 293 | 240 | /** |
| 294 | 241 | * Allow strings to be filtered when a specific form may be displaying them. |
| 295 | 242 | * |
| 296 | 243 | * @since 3.06.01 |
| 297 | - * | |
| 298 | - * @return void | |
| 299 | 244 | */ |
| 300 | 245 | public function maybe_filter_for_form( $args ) { |
| 301 | 246 | if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) { |
| 302 | 247 | $this->current_form = $args['current_form']; |
| @@ -306,21 +251,12 @@ | ||
| 306 | 251 | } |
| 307 | 252 | } |
| 308 | 253 | } |
| 309 | 254 | |
| 310 | - /** | |
| 311 | - * @param array $params | |
| 312 | - * @param array $errors | |
| 313 | - */ | |
| 314 | 255 | public function validate( $params, $errors ) { |
| 315 | 256 | return apply_filters( 'frm_validate_settings', $errors, $params ); |
| 316 | 257 | } |
| 317 | 258 | |
| 318 | - /** | |
| 319 | - * @param array $params | |
| 320 | - * | |
| 321 | - * @return void | |
| 322 | - */ | |
| 323 | 259 | public function update( $params ) { |
| 324 | 260 | $this->fill_with_defaults( $params ); |
| 325 | 261 | $this->update_settings( $params ); |
| 326 | 262 | |
| @@ -334,39 +270,31 @@ | ||
| 334 | 270 | |
| 335 | 271 | do_action( 'frm_update_settings', $params ); |
| 336 | 272 | |
| 337 | 273 | if ( function_exists( 'get_filesystem_method' ) ) { |
| 338 | - // Save styling settings in case fallback setting changes. | |
| 274 | + // save styling settings in case fallback setting changes | |
| 339 | 275 | $frm_style = new FrmStyle(); |
| 340 | 276 | $frm_style->update( 'default' ); |
| 341 | 277 | } |
| 342 | 278 | } |
| 343 | 279 | |
| 344 | - /** | |
| 345 | - * @return void | |
| 346 | - */ | |
| 347 | 280 | private function update_settings( $params ) { |
| 348 | 281 | $this->active_captcha = $params['frm_active_captcha']; |
| 349 | 282 | $this->hcaptcha_pubkey = trim( $params['frm_hcaptcha_pubkey'] ); |
| 350 | - $this->hcaptcha_privkey = trim( $params['frm_hcaptcha_privkey'] ); | |
| 283 | + $this->hcaptcha_privkey = $params['frm_hcaptcha_privkey']; | |
| 351 | 284 | $this->pubkey = trim( $params['frm_pubkey'] ); |
| 352 | - $this->privkey = trim( $params['frm_privkey'] ); | |
| 285 | + $this->privkey = $params['frm_privkey']; | |
| 353 | 286 | $this->re_type = $params['frm_re_type']; |
| 354 | 287 | $this->re_lang = $params['frm_re_lang']; |
| 355 | 288 | $this->re_threshold = floatval( $params['frm_re_threshold'] ); |
| 356 | 289 | $this->load_style = $params['frm_load_style']; |
| 357 | - $this->custom_css = $params['frm_custom_css']; | |
| 358 | - $this->currency = $params['frm_currency']; | |
| 359 | 290 | |
| 360 | - $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' ); | |
| 361 | 292 | foreach ( $checkboxes as $set ) { |
| 362 | - $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0; | |
| 293 | + $this->$set = isset( $params[ 'frm_' . $set ] ) ? $params[ 'frm_' . $set ] : 0; | |
| 363 | 294 | } |
| 364 | 295 | } |
| 365 | 296 | |
| 366 | - /** | |
| 367 | - * @return void | |
| 368 | - */ | |
| 369 | 297 | private function update_roles( $params ) { |
| 370 | 298 | global $wp_roles; |
| 371 | 299 | |
| 372 | 300 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| @@ -388,11 +316,8 @@ | ||
| 388 | 316 | } |
| 389 | 317 | } |
| 390 | 318 | } |
| 391 | 319 | |
| 392 | - /** | |
| 393 | - * @return void | |
| 394 | - */ | |
| 395 | 320 | public function store() { |
| 396 | 321 | // Save the posted value in the database |
| 397 | 322 | |
| 398 | 323 | update_option( 'frm_options', $this ); |