| @@ -229,9 +229,9 @@ | ||
| 229 | 229 | * @since 3.0 |
| 230 | 230 | */ |
| 231 | 231 | private function replace_error_shortcode() { |
| 232 | 232 | $this->maybe_add_error_id(); |
| 233 | - $error = $this->pass_args['errors'][ 'field' . $this->field_id ] ?? false; | |
| 233 | + $error = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? $this->pass_args['errors'][ 'field' . $this->field_id ] : false; | |
| 234 | 234 | |
| 235 | 235 | if ( ! empty( $error ) && false === strpos( $this->html, 'role="alert"' ) && FrmAppHelper::should_include_alert_role_on_field_errors() ) { |
| 236 | 236 | $error_body = self::get_error_body( $this->html ); |
| 237 | 237 | if ( is_string( $error_body ) && false === strpos( $error_body, 'role=' ) ) { |
| @@ -386,9 +386,9 @@ | ||
| 386 | 386 | if ( isset( $shortcode_atts['opt'] ) ) { |
| 387 | 387 | --$shortcode_atts['opt']; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - $field_class = $shortcode_atts['class'] ?? ''; | |
| 390 | + $field_class = isset( $shortcode_atts['class'] ) ? $shortcode_atts['class'] : ''; | |
| 391 | 391 | $this->field_obj->set_field_column( 'input_class', $field_class ); |
| 392 | 392 | |
| 393 | 393 | if ( isset( $shortcode_atts['class'] ) ) { |
| 394 | 394 | unset( $shortcode_atts['class'] ); |
| @@ -393,9 +393,9 @@ | ||
| 393 | 393 | if ( isset( $shortcode_atts['class'] ) ) { |
| 394 | 394 | unset( $shortcode_atts['class'] ); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - $this->field_obj->set_aria_invalid_error( $shortcode_atts, $this->pass_args ); | |
| 397 | + $shortcode_atts['aria-invalid'] = isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ? 'true' : 'false'; | |
| 398 | 398 | |
| 399 | 399 | $this->field_obj->set_field_column( 'shortcodes', $shortcode_atts ); |
| 400 | 400 | |
| 401 | 401 | return $shortcode_atts; |
| @@ -429,15 +429,13 @@ | ||
| 429 | 429 | */ |
| 430 | 430 | private function add_field_div_classes() { |
| 431 | 431 | $classes = $this->get_field_div_classes(); |
| 432 | 432 | |
| 433 | - if ( in_array( $this->field_obj->get_field_column( 'type' ), array( 'html', 'summary' ), true ) && strpos( $this->html, '[error_class]' ) === false ) { | |
| 433 | + if ( $this->field_obj->get_field_column( 'type' ) === 'html' && strpos( $this->html, '[error_class]' ) === false ) { | |
| 434 | 434 | // there is no error_class shortcode for HTML fields |
| 435 | - $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . esc_attr( $classes ), $this->html ); | |
| 436 | - return; | |
| 435 | + $this->html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $classes, $this->html ); | |
| 437 | 436 | } |
| 438 | - | |
| 439 | - $this->html = str_replace( '[error_class]', esc_attr( $classes ), $this->html ); | |
| 437 | + $this->html = str_replace( '[error_class]', $classes, $this->html ); | |
| 440 | 438 | } |
| 441 | 439 | |
| 442 | 440 | /** |
| 443 | 441 | * Get the classes for a field div |
| @@ -473,14 +471,9 @@ | ||
| 473 | 471 | |
| 474 | 472 | $classes .= $this->field_obj->get_container_class(); |
| 475 | 473 | |
| 476 | 474 | // Get additional classes |
| 477 | - $classes = apply_filters( 'frm_field_div_classes', $classes, $this->field_obj->get_field(), array( 'field_id' => $this->field_id ) ); | |
| 478 | - | |
| 479 | - // Remove unexpected characters from class. | |
| 480 | - $classes = implode( ' ', array_map( 'FrmFormsHelper::sanitize_layout_class', explode( ' ', $classes ) ) ); | |
| 481 | - | |
| 482 | - return $classes; | |
| 475 | + return apply_filters( 'frm_field_div_classes', $classes, $this->field_obj->get_field(), array( 'field_id' => $this->field_id ) ); | |
| 483 | 476 | } |
| 484 | 477 | |
| 485 | 478 | /** |
| 486 | 479 | * This filters shortcodes in the field HTML |
| @@ -523,13 +516,8 @@ | ||
| 523 | 516 | |
| 524 | 517 | // Add 'aria-required' attribute to the field if required. |
| 525 | 518 | if ( $is_radio && '1' === $field['required'] ) { |
| 526 | 519 | $attributes['aria-required'] = 'true'; |
| 527 | - } | |
| 528 | - | |
| 529 | - // Add 'aria-invalid' attribute to the group if there are errors. | |
| 530 | - if ( isset( $this->pass_args['errors'][ 'field' . $this->field_id ] ) ) { | |
| 531 | - $attributes['aria-invalid'] = 'true'; | |
| 532 | 520 | } |
| 533 | 521 | |
| 534 | 522 | // Concatenate attributes into a string, and replace the role="group" in the HTML with the attributes string. |
| 535 | 523 | $html_attributes = FrmAppHelper::array_to_html_params( $attributes ); |