| 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 |
<?php if ( ! defined( 'HF_PREMIUM_VERSION' ) ) : ?> |
| 9 |
<p class="hf-premium"> |
| 10 |
<?php echo sprintf( __('Notify other services whenever a form is submitted using the Webhooks form action in <a href="%s">HTML Forms Premium</a>', 'html-forms' ), 'https://htmlformsplugin.com/premium/#utm_source=wp-plugin&utm_medium=html-forms&utm_campaign=actions-tab' ); ?>. |
| 11 |
</p> |
| 12 |
<?php endif; ?> |
| 13 |
|
| 14 |
<div id="hf-form-actions"> |
| 15 |
<?php |
| 16 |
if( ! empty( $form->settings['actions'] ) ) { |
| 17 |
$index = 0; |
| 18 |
foreach ($form->settings['actions'] as $action_settings ) { |
| 19 |
// skip invalid options (eg from deleted actions) |
| 20 |
if( empty( $available_actions[ $action_settings['type'] ] ) ) { |
| 21 |
continue; |
| 22 |
} |
| 23 |
|
| 24 |
?> |
| 25 |
<div class="hf-action-settings" data-title="<?php echo esc_attr( $available_actions[ $action_settings['type'] ] ); ?>"> |
| 26 |
<?php |
| 27 |
|
| 28 |
/** |
| 29 |
* Output setting fields for a registered action |
| 30 |
* |
| 31 |
* @param array $action_settings |
| 32 |
* @param int $index |
| 33 |
*/ |
| 34 |
do_action( 'hf_output_form_action_' . $action_settings['type'] . '_settings', $action_settings, $index++ ); |
| 35 |
|
| 36 |
/** |
| 37 |
* Deprecated action hook. Use the above action (hf_output_form_action_...) instead. |
| 38 |
*/ |
| 39 |
do_action( 'hf_render_form_action_' . $action_settings['type'] . '_settings', $action_settings, $index++ ); ?> |
| 40 |
</div> |
| 41 |
<?php |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
echo '<p id="hf-form-actions-empty">' . __( 'No form actions configured for this form.', 'html-forms' ) . '</p>'; |
| 46 |
?> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
|
| 50 |
<div class="hf-medium-margin"> |
| 51 |
<h3><?php echo __( 'Add Form Action', 'html-forms' ); ?></h3> |
| 52 |
<p><?php _e( 'Use the below button(s) to configure and perform an action whenever this form is successfully submitted.', 'html-forms' ); ?></p> |
| 53 |
<p id="hf-available-form-actions"> |
| 54 |
<?php |
| 55 |
foreach( $available_actions as $type => $label ) { |
| 56 |
echo sprintf( '<input type="button" value="%s" data-action-type="%s" class="button" />', esc_html( $label ), esc_attr( $type ) ) . ' '; |
| 57 |
}; |
| 58 |
?> |
| 59 |
</p> |
| 60 |
</div> |
| 61 |
|
| 62 |
<div> |
| 63 |
<?php submit_button(); ?> |
| 64 |
</div> |
| 65 |
|
| 66 |
<div style="display: none;" id="hf-form-action-templates"> |
| 67 |
<?php |
| 68 |
foreach( $available_actions as $type => $label ) { |
| 69 |
echo sprintf( '<script type="text/x-template" id="hf-action-type-%s-template">', $type ); |
| 70 |
do_action( 'hf_output_form_action_' . $type . '_settings', array(), '$index' ); |
| 71 |
echo '</script>'; |
| 72 |
} |
| 73 |
?> |
| 74 |
</div> |
| 75 |
|