| 1 |
<?php |
| 2 |
$available_actions = $this->get_available_form_actions(); |
| 3 |
?> |
| 4 |
|
| 5 |
<div> |
| 6 |
<h2><?php echo __( 'Form Actions', 'html-forms' ); ?></h2> |
| 7 |
|
| 8 |
<div id="hf-form-actions"> |
| 9 |
<?php |
| 10 |
if( ! empty( $form->settings['actions'] ) ) { |
| 11 |
$index = 0; |
| 12 |
foreach ($form->settings['actions'] as $action_settings ) { |
| 13 |
?> |
| 14 |
<div class="hf-action-settings" data-title="<?php echo esc_attr( $available_actions[ $action_settings['type'] ] ); ?>"> |
| 15 |
<?php |
| 16 |
|
| 17 |
/** |
| 18 |
* Output setting fields for a registered action |
| 19 |
* |
| 20 |
* @param array $action_settings |
| 21 |
* @param int $index |
| 22 |
*/ |
| 23 |
do_action( 'hf_output_form_action_' . $action_settings['type'] . '_settings', $action_settings, $index++ ); |
| 24 |
|
| 25 |
/** |
| 26 |
* Deprecated action hook. Use the above action (hf_output_form_action_...) instead. |
| 27 |
*/ |
| 28 |
do_action( 'hf_render_form_action_' . $action_settings['type'] . '_settings', $action_settings, $index++ ); ?> |
| 29 |
</div> |
| 30 |
<?php |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
echo '<p id="hf-form-actions-empty">' . __( 'No form actions configured for this form.', 'html-forms' ) . '</p>'; |
| 35 |
?> |
| 36 |
</div> |
| 37 |
</div> |
| 38 |
|
| 39 |
<div class="hf-medium-margin"> |
| 40 |
<h3><?php echo __( 'Add form action', 'html-forms' ); ?></h3> |
| 41 |
<p><?php _e( 'Use the below button(s) to configure and perform an action whenever this form is successfully submitted.', 'html-forms' ); ?></p> |
| 42 |
<p id="hf-available-form-actions"> |
| 43 |
<?php |
| 44 |
foreach( $available_actions as $type => $label ) { |
| 45 |
echo sprintf( '<input type="button" value="%s" data-action-type="%s" class="button" />', esc_html( $label ), esc_attr( $type ) ) . ' '; |
| 46 |
}; |
| 47 |
?> |
| 48 |
</p> |
| 49 |
</div> |
| 50 |
|
| 51 |
<div> |
| 52 |
<?php submit_button(); ?> |
| 53 |
</div> |
| 54 |
|
| 55 |
<div style="display: none;" id="hf-form-action-templates"> |
| 56 |
<?php |
| 57 |
foreach( $available_actions as $type => $label ) { |
| 58 |
echo sprintf( '<script type="text/x-template" id="hf-action-type-%s-template">', $type ); |
| 59 |
do_action( 'hf_output_form_action_' . $type . '_settings', array(), '$index' ); |
| 60 |
echo '</script>'; |
| 61 |
} |
| 62 |
?> |
| 63 |
</div> |
| 64 |
|