| @@ -136,10 +136,8 @@ | ||
| 136 | 136 | $this->replace_entry_key(); |
| 137 | 137 | $this->replace_form_shortcodes(); |
| 138 | 138 | $this->process_wp_shortcodes(); |
| 139 | 139 | $this->maybe_replace_description_shortcode( true ); |
| 140 | - | |
| 141 | - $this->add_multiple_input_attributes(); | |
| 142 | 140 | } |
| 143 | 141 | |
| 144 | 142 | /** |
| 145 | 143 | * @since 3.0 |
| @@ -154,9 +152,9 @@ | ||
| 154 | 152 | //replace [key] |
| 155 | 153 | $this->html = str_replace( '[key]', $this->field_obj->get_field_column( 'field_key' ), $this->html ); |
| 156 | 154 | |
| 157 | 155 | //replace [field_name] |
| 158 | - $this->html = str_replace( '[field_name]', FrmAppHelper::maybe_kses( $this->field_obj->get_field_column( 'name' ) ), $this->html ); | |
| 156 | + $this->html = str_replace( '[field_name]', $this->field_obj->get_field_column( 'name' ), $this->html ); | |
| 159 | 157 | } |
| 160 | 158 | |
| 161 | 159 | /** |
| 162 | 160 | * @since 3.0 |
| @@ -184,9 +182,9 @@ | ||
| 184 | 182 | * @since 3.0 |
| 185 | 183 | */ |
| 186 | 184 | private function replace_description_shortcode() { |
| 187 | 185 | $this->maybe_add_description_id(); |
| 188 | - $description = FrmAppHelper::maybe_kses( $this->field_obj->get_field_column( 'description' ) ); | |
| 186 | + $description = $this->field_obj->get_field_column( 'description' ); | |
| 189 | 187 | FrmShortcodeHelper::remove_inline_conditions( ( $description && $description != '' ), 'description', $description, $this->html ); |
| 190 | 188 | } |
| 191 | 189 | |
| 192 | 190 | /** |
| @@ -231,42 +229,12 @@ | ||
| 231 | 229 | */ |
| 232 | 230 | private function replace_error_shortcode() { |
| 233 | 231 | $this->maybe_add_error_id(); |
| 234 | 232 | $error = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? $this->pass_args['errors'][ 'field' . $this->field_id ] : false; |
| 235 | - | |
| 236 | - if ( ! empty( $error ) && false === strpos( $this->html, 'role="alert"' ) && FrmAppHelper::should_include_alert_role_on_field_errors() ) { | |
| 237 | - $error_body = self::get_error_body( $this->html ); | |
| 238 | - if ( is_string( $error_body ) && false === strpos( $error_body, 'role=' ) ) { | |
| 239 | - $new_error_body = preg_replace( '/class="frm_error/', 'role="alert" class="frm_error', $error_body, 1 ); | |
| 240 | - $this->html = str_replace( '[if error]' . $error_body . '[/if error]', '[if error]' . $new_error_body . '[/if error]', $this->html ); | |
| 241 | - } | |
| 242 | - } | |
| 243 | - | |
| 244 | 233 | FrmShortcodeHelper::remove_inline_conditions( ! empty( $error ), 'error', $error, $this->html ); |
| 245 | 234 | } |
| 246 | 235 | |
| 247 | 236 | /** |
| 248 | - * Pull the HTML between [if error] and [/if error] shortcodes. | |
| 249 | - * | |
| 250 | - * @param string $html | |
| 251 | - * @return string|false | |
| 252 | - */ | |
| 253 | - private static function get_error_body( $html ) { | |
| 254 | - $start = strpos( $html, '[if error]' ); | |
| 255 | - if ( false === $start ) { | |
| 256 | - return false; | |
| 257 | - } | |
| 258 | - | |
| 259 | - $end = strpos( $html, '[/if error]', $start ); | |
| 260 | - if ( false === $end ) { | |
| 261 | - return false; | |
| 262 | - } | |
| 263 | - | |
| 264 | - $error_body = substr( $html, $start + 10, $end - $start - 10 ); | |
| 265 | - return $error_body; | |
| 266 | - } | |
| 267 | - | |
| 268 | - /** | |
| 269 | 237 | * Add an ID to the error message for aria-describedby. |
| 270 | 238 | * This ID was added to the HTML in v3.06.02. |
| 271 | 239 | * |
| 272 | 240 | * @since 3.06.02 |
| @@ -410,8 +378,11 @@ | ||
| 410 | 378 | */ |
| 411 | 379 | private function add_class_to_label() { |
| 412 | 380 | $label_class = $this->field_obj->get_label_class(); |
| 413 | 381 | $this->html = str_replace( '[label_position]', $label_class, $this->html ); |
| 382 | + if ( $this->field_obj->get_field_column( 'label' ) == 'inside' && $this->field_obj->get_field_column( 'value' ) != '' ) { | |
| 383 | + $this->html = str_replace( 'frm_primary_label', 'frm_primary_label frm_visible', $this->html ); | |
| 384 | + } | |
| 414 | 385 | } |
| 415 | 386 | |
| 416 | 387 | /** |
| 417 | 388 | * Replace [entry_key] |
| @@ -451,15 +422,9 @@ | ||
| 451 | 422 | |
| 452 | 423 | // Add label position class |
| 453 | 424 | $settings = $this->field_obj->display_field_settings(); |
| 454 | 425 | if ( isset( $settings['label_position'] ) && $settings['label_position'] ) { |
| 455 | - $label_position = $this->field_obj->get_field_column( 'label' ); | |
| 456 | - $classes .= ' frm_' . $label_position . '_container'; | |
| 457 | - | |
| 458 | - // Add class if field has value, to be used for floating label styling. | |
| 459 | - if ( 'inside' === $label_position && $this->field_obj->get_field_column( 'value' ) ) { | |
| 460 | - $classes .= ' frm_label_float_top'; | |
| 461 | - } | |
| 426 | + $classes .= ' frm_' . $this->field_obj->get_field_column( 'label' ) . '_container'; | |
| 462 | 427 | } |
| 463 | 428 | |
| 464 | 429 | // Add CSS layout classes |
| 465 | 430 | $extra_classes = $this->field_obj->get_field_column( 'classes' ); |
| @@ -484,57 +449,6 @@ | ||
| 484 | 449 | private function process_wp_shortcodes() { |
| 485 | 450 | if ( apply_filters( 'frm_do_html_shortcodes', true ) ) { |
| 486 | 451 | $this->html = do_shortcode( $this->html ); |
| 487 | 452 | } |
| 488 | - } | |
| 489 | - | |
| 490 | - /** | |
| 491 | - * Adds multiple input attributes. | |
| 492 | - * | |
| 493 | - * @since 6.4.1 | |
| 494 | - * @return void | |
| 495 | - */ | |
| 496 | - private function add_multiple_input_attributes() { | |
| 497 | - $field_type = $this->field_obj->get_field_column( 'type' ); | |
| 498 | - | |
| 499 | - // Check if the field type is one of the following. | |
| 500 | - if ( ! in_array( $field_type, array( 'radio', 'checkbox', 'data', 'product', 'scale' ), true ) ) { | |
| 501 | - return; | |
| 502 | - } | |
| 503 | - | |
| 504 | - $field = (array) $this->field_obj->get_field(); | |
| 505 | - $attributes = array(); | |
| 506 | - $is_radio = 'radio' === $field_type || 'scale' === $field_type; | |
| 507 | - $type_requires_aria_required = true; | |
| 508 | - | |
| 509 | - // Check if the field type is 'data' or 'product'. | |
| 510 | - if ( in_array( $field_type, array( 'data', 'product' ), true ) ) { | |
| 511 | - $data_type = FrmField::get_option( $field, 'data_type' ); | |
| 512 | - // Check if the data type isn't 'radio' or 'checkbox'. | |
| 513 | - if ( 'radio' !== $data_type && 'checkbox' !== $data_type ) { | |
| 514 | - // If data type aren't 'radio' or 'checkbox', doesn't need to add 'aria-required' to multiple input container. | |
| 515 | - $type_requires_aria_required = false; | |
| 516 | - } | |
| 517 | - // Check if data type is 'radio' | |
| 518 | - if ( 'radio' === $data_type ) { | |
| 519 | - $is_radio = true; | |
| 520 | - } | |
| 521 | - } | |
| 522 | - | |
| 523 | - // Add 'role' attribute to the field. | |
| 524 | - $attributes['role'] = $is_radio ? 'radiogroup' : 'group'; | |
| 525 | - | |
| 526 | - // Add 'aria-required' attribute to the field if required. | |
| 527 | - if ( $type_requires_aria_required && '1' === $field['required'] ) { | |
| 528 | - $attributes['aria-required'] = 'true'; | |
| 529 | - } | |
| 530 | - | |
| 531 | - // Add 'tabindex = "0"' attribute to the radio field. | |
| 532 | - if ( $is_radio ) { | |
| 533 | - $attributes['tabindex'] = 0; | |
| 534 | - } | |
| 535 | - | |
| 536 | - // Concatenate attributes into a string, and replace the role="group" in the HTML with the attributes string. | |
| 537 | - $html_attributes = FrmAppHelper::array_to_html_params( $attributes ); | |
| 538 | - $this->html = str_replace( ' role="group"', $html_attributes, $this->html ); | |
| 539 | 453 | } |
| 540 | 454 | } |