| @@ -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 | } |
| @@ -120,24 +108,16 @@ | ||
| 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 | 111 | |
| 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(), | |
| 128 | - | |
| 129 | - // Normally custom CSS is a string. A false value is used when nothing has been set. | |
| 130 | - // 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, | |
| 112 | + 'email_to' => '[admin_email]', | |
| 113 | + 'no_ips' => 0, | |
| 114 | + 'tracking' => FrmAppHelper::pro_is_installed(), | |
| 132 | 115 | ); |
| 133 | 116 | } |
| 134 | 117 | |
| 135 | - /** | |
| 136 | - * @return void | |
| 137 | - */ | |
| 138 | 118 | private function set_default_options() { |
| 139 | - $this->fill_captcha_settings(); | |
| 119 | + $this->fill_recaptcha_settings(); | |
| 140 | 120 | |
| 141 | 121 | if ( ! isset( $this->load_style ) ) { |
| 142 | 122 | if ( ! isset( $this->custom_style ) ) { |
| 143 | 123 | $this->custom_style = true; |
| @@ -165,9 +145,8 @@ | ||
| 165 | 145 | } |
| 166 | 146 | |
| 167 | 147 | /** |
| 168 | 148 | * @param array $params |
| 169 | - * @return void | |
| 170 | 149 | */ |
| 171 | 150 | public function fill_with_defaults( $params = array() ) { |
| 172 | 151 | $settings = $this->default_options(); |
| 173 | 152 | $filter_html = ! FrmAppHelper::allow_unfiltered_html(); |
| @@ -191,54 +170,20 @@ | ||
| 191 | 170 | if ( $setting === 'menu' && empty( $this->{$setting} ) ) { |
| 192 | 171 | $this->{$setting} = $default; |
| 193 | 172 | } |
| 194 | 173 | |
| 195 | - $this->{$setting} = $this->maybe_sanitize_global_setting( $this->{$setting}, $setting, $filter_keys ); | |
| 196 | - unset( $setting, $default ); | |
| 197 | - } | |
| 198 | - } | |
| 199 | - | |
| 200 | - /** | |
| 201 | - * Handle sanitizing for a target global setting key. | |
| 202 | - * | |
| 203 | - * @since 6.0 | |
| 204 | - * | |
| 205 | - * @param mixed $value The unsanitized global setting value. | |
| 206 | - * @param string $key The key of the global setting being saved. | |
| 207 | - * @param array $filter_keys These keys that are filtered with kses. | |
| 208 | - * @return mixed | |
| 209 | - */ | |
| 210 | - private function maybe_sanitize_global_setting( $value, $key, $filter_keys ) { | |
| 211 | - if ( 'custom_css' === $key ) { | |
| 212 | - if ( false === $value ) { | |
| 213 | - // Avoid changing the false default value to an empty string. | |
| 214 | - return $value; | |
| 174 | + if ( $filter_html && in_array( $setting, $filter_keys, true ) ) { | |
| 175 | + $this->{$setting} = FrmAppHelper::kses( $this->{$setting}, 'all' ); | |
| 215 | 176 | } |
| 216 | - return sanitize_textarea_field( $value ); | |
| 217 | - } | |
| 218 | 177 | |
| 219 | - if ( in_array( $key, $filter_keys, true ) ) { | |
| 220 | - return FrmAppHelper::kses( $value, 'all' ); | |
| 178 | + unset( $setting, $default ); | |
| 221 | 179 | } |
| 222 | - | |
| 223 | - return $value; | |
| 224 | 180 | } |
| 225 | 181 | |
| 226 | - /** | |
| 227 | - * @return void | |
| 228 | - */ | |
| 229 | - private function fill_captcha_settings() { | |
| 230 | - if ( ! isset( $this->active_captcha ) ) { | |
| 231 | - $this->active_captcha = 'recaptcha'; | |
| 232 | - } | |
| 182 | + private function fill_recaptcha_settings() { | |
| 183 | + $privkey = ''; | |
| 184 | + $re_lang = ''; | |
| 233 | 185 | |
| 234 | - $privkey = ''; | |
| 235 | - $re_lang = ''; | |
| 236 | - | |
| 237 | - if ( ! isset( $this->hcaptcha_privkey ) ) { | |
| 238 | - $this->hcaptcha_privkey = ''; | |
| 239 | - } | |
| 240 | - | |
| 241 | 186 | if ( ! isset( $this->pubkey ) ) { |
| 242 | 187 | // get the options from the database |
| 243 | 188 | $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' ); |
| 244 | 189 | $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : ''; |
| @@ -246,9 +191,9 @@ | ||
| 246 | 191 | $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang; |
| 247 | 192 | } |
| 248 | 193 | |
| 249 | 194 | if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) { |
| 250 | - $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' ); | |
| 195 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); | |
| 251 | 196 | } |
| 252 | 197 | |
| 253 | 198 | if ( ! isset( $this->privkey ) ) { |
| 254 | 199 | $this->privkey = $privkey; |
| @@ -270,10 +215,8 @@ | ||
| 270 | 215 | /** |
| 271 | 216 | * Get values that may be shown on the front-end without an override in the form settings. |
| 272 | 217 | * |
| 273 | 218 | * @since 3.06.01 |
| 274 | - * | |
| 275 | - * @return string[] | |
| 276 | 219 | */ |
| 277 | 220 | public function translatable_strings() { |
| 278 | 221 | return array( |
| 279 | 222 | 'invalid_msg', |
| @@ -286,10 +229,8 @@ | ||
| 286 | 229 | /** |
| 287 | 230 | * Allow strings to be filtered when a specific form may be displaying them. |
| 288 | 231 | * |
| 289 | 232 | * @since 3.06.01 |
| 290 | - * | |
| 291 | - * @return void | |
| 292 | 233 | */ |
| 293 | 234 | public function maybe_filter_for_form( $args ) { |
| 294 | 235 | if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) { |
| 295 | 236 | $this->current_form = $args['current_form']; |
| @@ -299,21 +240,12 @@ | ||
| 299 | 240 | } |
| 300 | 241 | } |
| 301 | 242 | } |
| 302 | 243 | |
| 303 | - /** | |
| 304 | - * @param array $params | |
| 305 | - * @param array $errors | |
| 306 | - */ | |
| 307 | 244 | public function validate( $params, $errors ) { |
| 308 | 245 | return apply_filters( 'frm_validate_settings', $errors, $params ); |
| 309 | 246 | } |
| 310 | 247 | |
| 311 | - /** | |
| 312 | - * @param array $params | |
| 313 | - * | |
| 314 | - * @return void | |
| 315 | - */ | |
| 316 | 248 | public function update( $params ) { |
| 317 | 249 | $this->fill_with_defaults( $params ); |
| 318 | 250 | $this->update_settings( $params ); |
| 319 | 251 | |
| @@ -327,38 +259,28 @@ | ||
| 327 | 259 | |
| 328 | 260 | do_action( 'frm_update_settings', $params ); |
| 329 | 261 | |
| 330 | 262 | if ( function_exists( 'get_filesystem_method' ) ) { |
| 331 | - // Save styling settings in case fallback setting changes. | |
| 263 | + // save styling settings in case fallback setting changes | |
| 332 | 264 | $frm_style = new FrmStyle(); |
| 333 | 265 | $frm_style->update( 'default' ); |
| 334 | 266 | } |
| 335 | 267 | } |
| 336 | 268 | |
| 337 | - /** | |
| 338 | - * @return void | |
| 339 | - */ | |
| 340 | 269 | 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']; | |
| 270 | + $this->pubkey = trim( $params['frm_pubkey'] ); | |
| 271 | + $this->privkey = $params['frm_privkey']; | |
| 272 | + $this->re_type = $params['frm_re_type']; | |
| 273 | + $this->re_lang = $params['frm_re_lang']; | |
| 274 | + $this->re_threshold = floatval( $params['frm_re_threshold'] ); | |
| 275 | + $this->load_style = $params['frm_load_style']; | |
| 351 | 276 | |
| 352 | - $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar' ); | |
| 277 | + $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'tracking', 'admin_bar' ); | |
| 353 | 278 | foreach ( $checkboxes as $set ) { |
| 354 | - $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0; | |
| 279 | + $this->$set = isset( $params[ 'frm_' . $set ] ) ? $params[ 'frm_' . $set ] : 0; | |
| 355 | 280 | } |
| 356 | 281 | } |
| 357 | 282 | |
| 358 | - /** | |
| 359 | - * @return void | |
| 360 | - */ | |
| 361 | 283 | private function update_roles( $params ) { |
| 362 | 284 | global $wp_roles; |
| 363 | 285 | |
| 364 | 286 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| @@ -380,11 +302,8 @@ | ||
| 380 | 302 | } |
| 381 | 303 | } |
| 382 | 304 | } |
| 383 | 305 | |
| 384 | - /** | |
| 385 | - * @return void | |
| 386 | - */ | |
| 387 | 306 | public function store() { |
| 388 | 307 | // Save the posted value in the database |
| 389 | 308 | |
| 390 | 309 | update_option( 'frm_options', $this ); |