| @@ -218,9 +218,9 @@ | ||
| 218 | 218 | |
| 219 | 219 | if ( is_string( $inner_html[2] ) ) { |
| 220 | 220 | $has_id = strpos( $inner_html[2], ' id=' ); |
| 221 | 221 | if ( ! $has_id ) { |
| 222 | - $id = 'frm_' . $id . '_' . $this->html_id; | |
| 222 | + $id = 'frm_' . $id . '_' . $this->html_id; | |
| 223 | 223 | $this->html = str_replace( 'class="frm_' . $param, 'id="' . esc_attr( $id ) . '" class="frm_' . esc_attr( $param ), $this->html ); |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | } |
| @@ -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=' ) ) { |
| @@ -246,9 +246,9 @@ | ||
| 246 | 246 | /** |
| 247 | 247 | * Pull the HTML between [if error] and [/if error] shortcodes. |
| 248 | 248 | * |
| 249 | 249 | * @param string $html |
| 250 | - * @return false|string | |
| 250 | + * @return string|false | |
| 251 | 251 | */ |
| 252 | 252 | private static function get_error_body( $html ) { |
| 253 | 253 | $start = strpos( $html, '[if error]' ); |
| 254 | 254 | if ( false === $start ) { |
| @@ -355,11 +355,11 @@ | ||
| 355 | 355 | $tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key ); |
| 356 | 356 | |
| 357 | 357 | $replace_with = ''; |
| 358 | 358 | |
| 359 | - if ( $tag === 'deletelink' && FrmAppHelper::pro_is_installed() ) { | |
| 359 | + if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { | |
| 360 | 360 | $replace_with = FrmProEntriesController::entry_delete_link( $shortcode_atts ); |
| 361 | - } elseif ( $tag === 'input' ) { | |
| 361 | + } elseif ( $tag == 'input' ) { | |
| 362 | 362 | $replace_with = $this->replace_input_shortcode( $shortcode_atts ); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | $this->html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $this->html ); |
| @@ -383,12 +383,12 @@ | ||
| 383 | 383 | * @return array |
| 384 | 384 | */ |
| 385 | 385 | private function prepare_input_shortcode_atts( $shortcode_atts ) { |
| 386 | 386 | if ( isset( $shortcode_atts['opt'] ) ) { |
| 387 | - --$shortcode_atts['opt']; | |
| 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 |
| @@ -453,9 +451,9 @@ | ||
| 453 | 451 | // Add label position class |
| 454 | 452 | $settings = $this->field_obj->display_field_settings(); |
| 455 | 453 | if ( isset( $settings['label_position'] ) && $settings['label_position'] ) { |
| 456 | 454 | $label_position = $this->field_obj->get_field_column( 'label' ); |
| 457 | - $classes .= ' frm_' . $label_position . '_container'; | |
| 455 | + $classes .= ' frm_' . $label_position . '_container'; | |
| 458 | 456 | |
| 459 | 457 | // Add class if field has value, to be used for floating label styling. |
| 460 | 458 | if ( 'inside' === $label_position && $this->field_obj->get_field_column( 'value' ) ) { |
| 461 | 459 | $classes .= ' frm_label_float_top'; |
| @@ -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 ); |