| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template used to display the gateway fields. |
| 4 |
* |
| 5 |
* @author WP Charitable LLC |
| 6 |
* @package Charitable/Templates/Donation Form |
| 7 |
* @since 1.0.0 |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
// Exit if accessed directly. |
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
$form = $view_args['form']; |
| 21 |
$field = $view_args['field']; |
| 22 |
$classes = $view_args['classes']; |
| 23 |
$gateways = $field['gateways']; |
| 24 |
$default = isset( $field['default'] ) && isset( $gateways[ $field['default'] ] ) ? $field['default'] : key( $gateways ); |
| 25 |
|
| 26 |
?> |
| 27 |
<fieldset id="charitable-gateway-fields" class="charitable-fieldset"> |
| 28 |
<?php |
| 29 |
if ( isset( $field['legend'] ) ) : ?> |
| 30 |
|
| 31 |
<div class="charitable-form-header"><?php echo $field['legend'] ?></div> |
| 32 |
|
| 33 |
<?php |
| 34 |
endif; |
| 35 |
|
| 36 |
if ( count( $gateways ) > 1 ) : |
| 37 |
?> |
| 38 |
<fieldset class="charitable-fieldset-field-wrapper"> |
| 39 |
<div class="charitable-fieldset-field-header" id="charitable-gateway-selector-header"><?php _e( 'Choose Your Payment Method', 'charitable' ) ?></div> |
| 40 |
<ul id="charitable-gateway-selector" class="charitable-radio-list charitable-form-field"> |
| 41 |
<?php foreach ( $gateways as $gateway_id => $details ) : ?> |
| 42 |
<li><input type="radio" |
| 43 |
id="gateway-<?php echo esc_attr( $gateway_id ) ?>" |
| 44 |
name="gateway" |
| 45 |
value="<?php echo esc_attr( $gateway_id ) ?>" |
| 46 |
aria-describedby="charitable-gateway-selector-header" |
| 47 |
<?php checked( $default, $gateway_id ) ?> /> |
| 48 |
<label for="gateway-<?php echo esc_attr( $gateway_id ) ?>"><?php echo $details['label'] ?></label> |
| 49 |
</li> |
| 50 |
<?php endforeach ?> |
| 51 |
</ul> |
| 52 |
</fieldset> |
| 53 |
<?php |
| 54 |
endif; |
| 55 |
|
| 56 |
foreach ( $gateways as $gateway_id => $details ) : |
| 57 |
|
| 58 |
if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) : |
| 59 |
continue; |
| 60 |
endif; |
| 61 |
|
| 62 |
?> |
| 63 |
<div id="charitable-gateway-fields-<?php echo $gateway_id ?>" class="charitable-gateway-fields charitable-form-fields cf" data-gateway="<?php echo $gateway_id ?>"> |
| 64 |
<?php $form->view()->render_fields( $details['fields'] ) ?> |
| 65 |
</div><!-- #charitable-gateway-fields-<?php echo $gateway_id ?> --> |
| 66 |
<?php endforeach ?> |
| 67 |
</fieldset><!-- .charitable-fieldset --> |
| 68 |
|