| @@ -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,17 +141,12 @@ | ||
| 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 | 147 | /** |
| 175 | 148 | * @param array $params |
| 176 | - * @return void | |
| 177 | 149 | */ |
| 178 | 150 | public function fill_with_defaults( $params = array() ) { |
| 179 | 151 | $settings = $this->default_options(); |
| 180 | 152 | $filter_html = ! FrmAppHelper::allow_unfiltered_html(); |
| @@ -179,9 +151,9 @@ | ||
| 179 | 151 | $settings = $this->default_options(); |
| 180 | 152 | $filter_html = ! FrmAppHelper::allow_unfiltered_html(); |
| 181 | 153 | |
| 182 | 154 | if ( $filter_html ) { |
| 183 | - $filter_keys = array( 'failed_msg', 'blank_msg', 'invalid_msg', 'admin_permission', 'unique_msg', 'success_msg', 'submit_value', 'login_msg', 'menu' ); | |
| 155 | + $filter_keys = array( 'failed_msg', 'blank_msg', 'invalid_msg', 'unique_msg', 'success_msg', 'submit_value', 'login_msg', 'menu' ); | |
| 184 | 156 | if ( ! empty( $params['additional_filter_keys'] ) ) { |
| 185 | 157 | $filter_keys = array_merge( $filter_keys, $params['additional_filter_keys'] ); |
| 186 | 158 | } |
| 187 | 159 | } else { |
| @@ -198,54 +170,20 @@ | ||
| 198 | 170 | if ( $setting === 'menu' && empty( $this->{$setting} ) ) { |
| 199 | 171 | $this->{$setting} = $default; |
| 200 | 172 | } |
| 201 | 173 | |
| 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; | |
| 174 | + if ( $filter_html && in_array( $setting, $filter_keys, true ) ) { | |
| 175 | + $this->{$setting} = FrmAppHelper::kses( $this->{$setting}, 'all' ); | |
| 222 | 176 | } |
| 223 | - return sanitize_textarea_field( $value ); | |
| 224 | - } | |
| 225 | 177 | |
| 226 | - if ( in_array( $key, $filter_keys, true ) ) { | |
| 227 | - return FrmAppHelper::kses( $value, 'all' ); | |
| 178 | + unset( $setting, $default ); | |
| 228 | 179 | } |
| 229 | - | |
| 230 | - return $value; | |
| 231 | 180 | } |
| 232 | 181 | |
| 233 | - /** | |
| 234 | - * @return void | |
| 235 | - */ | |
| 236 | - private function fill_captcha_settings() { | |
| 237 | - if ( ! isset( $this->active_captcha ) ) { | |
| 238 | - $this->active_captcha = 'recaptcha'; | |
| 239 | - } | |
| 182 | + private function fill_recaptcha_settings() { | |
| 183 | + $privkey = ''; | |
| 184 | + $re_lang = ''; | |
| 240 | 185 | |
| 241 | - $privkey = ''; | |
| 242 | - $re_lang = ''; | |
| 243 | - | |
| 244 | - if ( ! isset( $this->hcaptcha_privkey ) ) { | |
| 245 | - $this->hcaptcha_privkey = ''; | |
| 246 | - } | |
| 247 | - | |
| 248 | 186 | if ( ! isset( $this->pubkey ) ) { |
| 249 | 187 | // get the options from the database |
| 250 | 188 | $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' ); |
| 251 | 189 | $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : ''; |
| @@ -253,9 +191,9 @@ | ||
| 253 | 191 | $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang; |
| 254 | 192 | } |
| 255 | 193 | |
| 256 | 194 | if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) { |
| 257 | - $this->re_msg = __( 'The CAPTCHA was not entered correctly', 'formidable' ); | |
| 195 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); | |
| 258 | 196 | } |
| 259 | 197 | |
| 260 | 198 | if ( ! isset( $this->privkey ) ) { |
| 261 | 199 | $this->privkey = $privkey; |
| @@ -277,15 +215,12 @@ | ||
| 277 | 215 | /** |
| 278 | 216 | * Get values that may be shown on the front-end without an override in the form settings. |
| 279 | 217 | * |
| 280 | 218 | * @since 3.06.01 |
| 281 | - * | |
| 282 | - * @return string[] | |
| 283 | 219 | */ |
| 284 | 220 | public function translatable_strings() { |
| 285 | 221 | return array( |
| 286 | 222 | 'invalid_msg', |
| 287 | - 'admin_permission', | |
| 288 | 223 | 'failed_msg', |
| 289 | 224 | 'login_msg', |
| 290 | 225 | ); |
| 291 | 226 | } |
| @@ -293,10 +228,8 @@ | ||
| 293 | 228 | /** |
| 294 | 229 | * Allow strings to be filtered when a specific form may be displaying them. |
| 295 | 230 | * |
| 296 | 231 | * @since 3.06.01 |
| 297 | - * | |
| 298 | - * @return void | |
| 299 | 232 | */ |
| 300 | 233 | public function maybe_filter_for_form( $args ) { |
| 301 | 234 | if ( isset( $args['current_form'] ) && is_numeric( $args['current_form'] ) ) { |
| 302 | 235 | $this->current_form = $args['current_form']; |
| @@ -306,21 +239,12 @@ | ||
| 306 | 239 | } |
| 307 | 240 | } |
| 308 | 241 | } |
| 309 | 242 | |
| 310 | - /** | |
| 311 | - * @param array $params | |
| 312 | - * @param array $errors | |
| 313 | - */ | |
| 314 | 243 | public function validate( $params, $errors ) { |
| 315 | 244 | return apply_filters( 'frm_validate_settings', $errors, $params ); |
| 316 | 245 | } |
| 317 | 246 | |
| 318 | - /** | |
| 319 | - * @param array $params | |
| 320 | - * | |
| 321 | - * @return void | |
| 322 | - */ | |
| 323 | 247 | public function update( $params ) { |
| 324 | 248 | $this->fill_with_defaults( $params ); |
| 325 | 249 | $this->update_settings( $params ); |
| 326 | 250 | |
| @@ -334,39 +258,28 @@ | ||
| 334 | 258 | |
| 335 | 259 | do_action( 'frm_update_settings', $params ); |
| 336 | 260 | |
| 337 | 261 | if ( function_exists( 'get_filesystem_method' ) ) { |
| 338 | - // Save styling settings in case fallback setting changes. | |
| 262 | + // save styling settings in case fallback setting changes | |
| 339 | 263 | $frm_style = new FrmStyle(); |
| 340 | 264 | $frm_style->update( 'default' ); |
| 341 | 265 | } |
| 342 | 266 | } |
| 343 | 267 | |
| 344 | - /** | |
| 345 | - * @return void | |
| 346 | - */ | |
| 347 | 268 | 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']; | |
| 269 | + $this->pubkey = trim( $params['frm_pubkey'] ); | |
| 270 | + $this->privkey = $params['frm_privkey']; | |
| 271 | + $this->re_type = $params['frm_re_type']; | |
| 272 | + $this->re_lang = $params['frm_re_lang']; | |
| 273 | + $this->re_threshold = floatval( $params['frm_re_threshold'] ); | |
| 274 | + $this->load_style = $params['frm_load_style']; | |
| 359 | 275 | |
| 360 | - $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'custom_header_ip', 'tracking', 'admin_bar' ); | |
| 276 | + $checkboxes = array( 'mu_menu', 're_multi', 'use_html', 'jquery_css', 'accordion_js', 'fade_form', 'no_ips', 'tracking', 'admin_bar' ); | |
| 361 | 277 | foreach ( $checkboxes as $set ) { |
| 362 | - $this->$set = isset( $params[ 'frm_' . $set ] ) ? absint( $params[ 'frm_' . $set ] ) : 0; | |
| 278 | + $this->$set = isset( $params[ 'frm_' . $set ] ) ? $params[ 'frm_' . $set ] : 0; | |
| 363 | 279 | } |
| 364 | 280 | } |
| 365 | 281 | |
| 366 | - /** | |
| 367 | - * @return void | |
| 368 | - */ | |
| 369 | 282 | private function update_roles( $params ) { |
| 370 | 283 | global $wp_roles; |
| 371 | 284 | |
| 372 | 285 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| @@ -388,11 +301,8 @@ | ||
| 388 | 301 | } |
| 389 | 302 | } |
| 390 | 303 | } |
| 391 | 304 | |
| 392 | - /** | |
| 393 | - * @return void | |
| 394 | - */ | |
| 395 | 305 | public function store() { |
| 396 | 306 | // Save the posted value in the database |
| 397 | 307 | |
| 398 | 308 | update_option( 'frm_options', $this ); |