| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?> |
| 7 |
<div class="frm_forms <?php echo esc_attr( FrmFormsHelper::get_form_style_class( $form ) ); ?>" id="frm_form_<?php echo esc_attr( $form->id ); ?>_container"> |
| 8 |
<div class="frm_error_style"> |
| 9 |
<strong><?php esc_html_e( 'Oops!', 'formidable' ); ?></strong> |
| 10 |
<?php |
| 11 |
printf( |
| 12 |
/* translators: %1$s: HTML open link, %2$s: HTML close link */ |
| 13 |
esc_html__( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), |
| 14 |
'<a href="' . esc_url( FrmForm::get_edit_link( $form->id ) ) . '">', |
| 15 |
'</a>' |
| 16 |
); |
| 17 |
?> |
| 18 |
</div> |
| 19 |
</div> |
| 20 |
<?php |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
global $frm_vars; |
| 25 |
FrmFormsController::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
| 26 |
|
| 27 |
// Get conditionally hidden fields |
| 28 |
$frm_hide_fields = FrmAppHelper::get_post_param( 'frm_hide_fields_' . $form->id, '', 'sanitize_text_field' ); |
| 29 |
|
| 30 |
?> |
| 31 |
<div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>"> |
| 32 |
<fieldset> |
| 33 |
<?php |
| 34 |
/** |
| 35 |
* @since 5.5.1 |
| 36 |
*/ |
| 37 |
do_action( 'frm_before_title', compact( 'form' ) ); |
| 38 |
echo FrmAppHelper::maybe_kses( FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 39 |
?> |
| 40 |
<div <?php echo wp_strip_all_tags( apply_filters( 'frm_fields_container_class', 'class="frm_fields_container"' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> |
| 41 |
<?php do_action( 'frm_after_title', compact( 'form' ) ); ?> |
| 42 |
<input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ); ?>" /> |
| 43 |
<input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ); ?>" /> |
| 44 |
<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ); ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ); ?>" value="<?php echo esc_attr( $frm_hide_fields ); ?>" /> |
| 45 |
<input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ); ?>" /> |
| 46 |
<input type="hidden" name="item_meta[0]" value="" /> |
| 47 |
<?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?> |
| 48 |
<?php if ( isset( $id ) ) { ?> |
| 49 |
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> |
| 50 |
<?php } ?> |
| 51 |
<?php |
| 52 |
if ( $values['fields'] ) { |
| 53 |
/** |
| 54 |
* Allows modifying the list of fields in the frontend form. |
| 55 |
* |
| 56 |
* @since 5.0.04 |
| 57 |
* |
| 58 |
* @param array $fields Array of fields. |
| 59 |
* @param array $args The arguments. Contains `form`. |
| 60 |
*/ |
| 61 |
$fields_to_show = apply_filters( 'frm_fields_in_form', $values['fields'], compact( 'form' ) ); |
| 62 |
FrmFieldsHelper::show_fields( $fields_to_show, $errors, $form, $form_action ); |
| 63 |
} |
| 64 |
|
| 65 |
$frm_settings = FrmAppHelper::get_settings(); |
| 66 |
if ( FrmAppHelper::is_admin() ) { |
| 67 |
?> |
| 68 |
<div class="frm_form_field form-field"> |
| 69 |
<label class="frm_primary_label"><?php esc_html_e( 'Entry Key', 'formidable' ); ?></label> |
| 70 |
<input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" /> |
| 71 |
</div> |
| 72 |
<?php |
| 73 |
} else { |
| 74 |
?> |
| 75 |
<input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" /> |
| 76 |
<?php |
| 77 |
FrmHoneypot::maybe_render_field( $form->id ); |
| 78 |
FrmFormState::maybe_render_state_field( $form ); |
| 79 |
} |
| 80 |
|
| 81 |
do_action( 'frm_entry_form', $form, $form_action, $errors ); |
| 82 |
|
| 83 |
global $frm_vars; |
| 84 |
// close open section div |
| 85 |
if ( isset( $frm_vars['div'] ) && $frm_vars['div'] ) { |
| 86 |
echo "</div>\n"; |
| 87 |
unset( $frm_vars['div'] ); |
| 88 |
} |
| 89 |
|
| 90 |
// close open collapsible toggle div |
| 91 |
if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) { |
| 92 |
echo "</div>\n"; |
| 93 |
unset( $frm_vars['collapse_div'] ); |
| 94 |
} |
| 95 |
|
| 96 |
echo FrmAppHelper::maybe_kses( FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 97 |
|
| 98 |
if ( FrmForm::show_submit( $form ) ) { |
| 99 |
/** |
| 100 |
* @since 5.5.1 |
| 101 |
*/ |
| 102 |
do_action( 'frm_before_submit_btn', compact( 'form' ) ); |
| 103 |
|
| 104 |
$copy_values = $values; |
| 105 |
unset( $copy_values['fields'] ); |
| 106 |
|
| 107 |
if ( isset( $form->options['form_class'] ) && strpos( $form->options['form_class'], 'frm_inline_success' ) !== false ) { |
| 108 |
ob_start(); |
| 109 |
ob_implicit_flush( false ); |
| 110 |
FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values ); |
| 111 |
$clip = ob_get_clean(); |
| 112 |
|
| 113 |
ob_start(); |
| 114 |
ob_implicit_flush( false ); |
| 115 |
include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php'; |
| 116 |
$message = ob_get_clean(); |
| 117 |
|
| 118 |
echo preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $message . '</div>', $clip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 119 |
} else { |
| 120 |
FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values ); |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* @since 5.5.1 |
| 125 |
*/ |
| 126 |
do_action( 'frm_after_submit_btn', compact( 'form' ) ); |
| 127 |
} |
| 128 |
?> |
| 129 |
</div> |
| 130 |
</fieldset> |
| 131 |
</div> |
| 132 |
<?php if ( has_action( 'frm_entries_footer_scripts' ) ) { ?> |
| 133 |
<script type="text/javascript"><?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?></script> |
| 134 |
<?php } ?> |
| 135 |
|