| 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 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
die( 'You are not allowed to call this page directly.' ); |
| 15 |
} |
| 16 |
|
| 17 |
if ( isset( $include_extra_container ) ) { ?> |
| 18 |
<div class="<?php echo esc_attr( $include_extra_container ); ?>" id="frm_form_<?php echo esc_attr( $form->id ); ?>_container"> |
| 19 |
<?php |
| 20 |
} |
| 21 |
|
| 22 |
// phpcs:ignore Universal.Operators.StrictComparisons |
| 23 |
if ( isset( $message ) && $message != '' ) { |
| 24 |
if ( FrmAppHelper::is_admin() ) { |
| 25 |
?> |
| 26 |
<div id="message" class="frm_updated_message" role="status"><?php echo wp_kses_post( $message ); ?></div> |
| 27 |
<?php |
| 28 |
} else { |
| 29 |
FrmFormsHelper::maybe_get_scroll_js( $form->id ); |
| 30 |
|
| 31 |
// We need to allow scripts here for javascript in the success message |
| 32 |
echo FrmAppHelper::maybe_kses( $message ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
if ( ! empty( $errors ) && is_array( $errors ) ) { |
| 37 |
if ( isset( $form ) && is_object( $form ) ) { |
| 38 |
FrmFormsHelper::get_scroll_js( $form->id ); |
| 39 |
} |
| 40 |
?> |
| 41 |
<div class="<?php echo esc_attr( FrmFormsHelper::form_error_class() ); ?>" role="alert"> |
| 42 |
<?php |
| 43 |
$img = ''; |
| 44 |
|
| 45 |
if ( ! FrmAppHelper::is_admin() ) { |
| 46 |
$img = apply_filters( 'frm_error_icon', $img ); |
| 47 |
|
| 48 |
if ( $img ) { |
| 49 |
echo '<img src="' . esc_url( $img ) . '" alt="" />'; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
FrmFormsHelper::show_errors( compact( 'img', 'errors', 'form' ) ); |
| 54 |
|
| 55 |
?> |
| 56 |
</div> |
| 57 |
<?php |
| 58 |
}//end if |
| 59 |
|
| 60 |
if ( isset( $include_extra_container ) ) { |
| 61 |
?> |
| 62 |
</div> |
| 63 |
<?php |
| 64 |
} |
| 65 |
|