| 1 |
<?php |
| 2 |
/** |
| 3 |
* On Submit form action settings |
| 4 |
* |
| 5 |
* @package Formidable |
| 6 |
* @since 6.0 |
| 7 |
* |
| 8 |
* @var object $instance Form action post object. |
| 9 |
* @var array $args Contains `form`, `action_key`, `values`. |
| 10 |
* @var FrmFormAction $this FrmFormAction instance. |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
die( 'You are not allowed to call this page directly.' ); |
| 15 |
} |
| 16 |
|
| 17 |
$success_action = $instance->post_content['success_action']; |
| 18 |
|
| 19 |
$types = array( |
| 20 |
'message' => array( |
| 21 |
'label' => __( 'Show Message', 'formidable' ), |
| 22 |
'icon' => 'frm_icon_font frm_chat_forms_icon frm_svg20', |
| 23 |
'sub_settings' => array( 'FrmOnSubmitHelper', 'show_message_settings' ), |
| 24 |
), |
| 25 |
'redirect' => array( |
| 26 |
'label' => __( 'Redirect to URL', 'formidable' ), |
| 27 |
'icon' => 'frm_icon_font frm_globe_icon frm_svg20', |
| 28 |
'sub_settings' => array( 'FrmOnSubmitHelper', 'show_redirect_settings' ), |
| 29 |
), |
| 30 |
'page' => array( |
| 31 |
'label' => __( 'Show Page Content', 'formidable' ), |
| 32 |
'icon' => 'frm_icon_font frm_file_text_icon frm_svg20', |
| 33 |
'sub_settings' => array( 'FrmOnSubmitHelper', 'show_page_settings' ), |
| 34 |
), |
| 35 |
); |
| 36 |
|
| 37 |
$col_count = count( $types ); |
| 38 |
if ( $col_count <= 4 ) { |
| 39 |
$col_class = 'frm' . ( 12 / $col_count ); |
| 40 |
} else { |
| 41 |
$col_count = 'frm2'; |
| 42 |
} |
| 43 |
?> |
| 44 |
<div class="frm_on_submit_type_setting"> |
| 45 |
<div class="frm_grid_container"> |
| 46 |
<?php |
| 47 |
foreach ( $types as $type => $type_data ) : |
| 48 |
$input_id = $this->get_field_id( 'success_action_' . $type ); |
| 49 |
?> |
| 50 |
<div class="frm_on_submit_type frm_form_field <?php echo esc_attr( $col_class ); ?>"> |
| 51 |
<input |
| 52 |
type="radio" |
| 53 |
id="<?php echo esc_attr( $input_id ); ?>" |
| 54 |
name="<?php echo esc_attr( $this->get_field_name( 'success_action' ) ); ?>" |
| 55 |
value="<?php echo esc_attr( $type ); ?>" |
| 56 |
<?php checked( $type, $success_action ); ?> |
| 57 |
/> |
| 58 |
<label for="<?php echo esc_attr( $input_id ); ?>"> |
| 59 |
<?php FrmAppHelper::icon_by_class( $type_data['icon'], array( 'echo' => true ) ); ?> |
| 60 |
<?php echo esc_html( $type_data['label'] ); ?> |
| 61 |
</label> |
| 62 |
</div> |
| 63 |
<?php endforeach; ?> |
| 64 |
</div> |
| 65 |
</div><!-- End .frm_on_submit_type_setting --> |
| 66 |
|
| 67 |
<?php |
| 68 |
$type_args = $args; |
| 69 |
$type_args['form_action'] = $instance; |
| 70 |
$type_args['action_control'] = $this; |
| 71 |
foreach ( $types as $type_name => $type ) { |
| 72 |
$css_class = 'frm_on_submit_' . esc_attr( $type_name ) . '_settings frm_on_submit_dependent_setting'; |
| 73 |
if ( $success_action !== $type_name ) { |
| 74 |
$css_class .= ' frm_hidden'; |
| 75 |
} |
| 76 |
?> |
| 77 |
<div class="<?php echo esc_attr( $css_class ); ?>" data-show-if-<?php echo esc_attr( $type_name ); ?>> |
| 78 |
<?php |
| 79 |
if ( is_callable( $type['sub_settings'] ) ) { |
| 80 |
call_user_func( $type['sub_settings'], $type_args ); |
| 81 |
} |
| 82 |
?> |
| 83 |
</div><!-- End .frm_on_submit_<?php echo esc_attr( $type_name ); ?>_settings --> |
| 84 |
<?php |
| 85 |
} |
| 86 |
|
| 87 |
unset( $css_class, $type_args, $type_name, $type, $success_action ); |
| 88 |
|