| @@ -1,5 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Form errors and success message wrapper. | |
| 4 | + * | |
| 5 | + * @package Formidable | |
| 6 | + * | |
| 7 | + * @var stdClass|null $form Form object when available. | |
| 8 | + * @var string|null $message Success message HTML. | |
| 9 | + * @var array|null $errors Field errors keyed by field id. | |
| 10 | + * @var string|null $include_extra_container Optional CSS class for a wrapping container. | |
| 11 | + */ | |
| 12 | + | |
| 2 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | 14 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 15 | } |
| 5 | 16 | |
| @@ -6,8 +17,10 @@ | ||
| 6 | 17 | if ( isset( $include_extra_container ) ) { ?> |
| 7 | 18 | <div class="<?php echo esc_attr( $include_extra_container ); ?>" id="frm_form_<?php echo esc_attr( $form->id ); ?>_container"> |
| 8 | 19 | <?php |
| 9 | 20 | } |
| 21 | + | |
| 22 | +// phpcs:ignore Universal.Operators.StrictComparisons | |
| 10 | 23 | if ( isset( $message ) && $message != '' ) { |
| 11 | 24 | if ( FrmAppHelper::is_admin() ) { |
| 12 | 25 | ?> |
| 13 | 26 | <div id="message" class="frm_updated_message" role="status"><?php echo wp_kses_post( $message ); ?></div> |
| @@ -14,15 +27,14 @@ | ||
| 14 | 27 | <?php |
| 15 | 28 | } else { |
| 16 | 29 | FrmFormsHelper::maybe_get_scroll_js( $form->id ); |
| 17 | 30 | |
| 18 | - // we need to allow scripts here for javascript in the success message | |
| 31 | + // We need to allow scripts here for javascript in the success message | |
| 19 | 32 | echo FrmAppHelper::maybe_kses( $message ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 20 | 33 | } |
| 21 | 34 | } |
| 22 | 35 | |
| 23 | -if ( isset( $errors ) && is_array( $errors ) && ! empty( $errors ) ) { | |
| 24 | - | |
| 36 | +if ( ! empty( $errors ) && is_array( $errors ) ) { | |
| 25 | 37 | if ( isset( $form ) && is_object( $form ) ) { |
| 26 | 38 | FrmFormsHelper::get_scroll_js( $form->id ); |
| 27 | 39 | } |
| 28 | 40 | ?> |
| @@ -28,11 +40,13 @@ | ||
| 28 | 40 | ?> |
| 29 | 41 | <div class="<?php echo esc_attr( FrmFormsHelper::form_error_class() ); ?>" role="alert"> |
| 30 | 42 | <?php |
| 31 | 43 | $img = ''; |
| 44 | + | |
| 32 | 45 | if ( ! FrmAppHelper::is_admin() ) { |
| 33 | 46 | $img = apply_filters( 'frm_error_icon', $img ); |
| 34 | - if ( $img && ! empty( $img ) ) { | |
| 47 | + | |
| 48 | + if ( $img ) { | |
| 35 | 49 | echo '<img src="' . esc_url( $img ) . '" alt="" />'; |
| 36 | 50 | } |
| 37 | 51 | } |
| 38 | 52 | |
| @@ -40,9 +54,9 @@ | ||
| 40 | 54 | |
| 41 | 55 | ?> |
| 42 | 56 | </div> |
| 43 | 57 | <?php |
| 44 | -} | |
| 58 | +}//end if | |
| 45 | 59 | |
| 46 | 60 | if ( isset( $include_extra_container ) ) { |
| 47 | 61 | ?> |
| 48 | 62 | </div> |