| 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.8.3.1 Cleanup. |
| 9 |
* @version 1.8.3.7 Added support for cc_fields_format. |
| 10 |
* @version 1.8.8.6 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
$charitable_form = $view_args['form']; |
| 23 |
$charitable_field = $view_args['field']; |
| 24 |
$charitable_classes = $view_args['classes']; |
| 25 |
$charitable_gateways = $charitable_field['gateways']; |
| 26 |
$charitable_default = isset( $charitable_field['default'] ) && isset( $charitable_gateways[ $charitable_field['default'] ] ) ? $charitable_field['default'] : key( $charitable_gateways ); |
| 27 |
$charitable_cc_fields_format = ''; |
| 28 |
|
| 29 |
if ( charitable()->load_core_stripe() && class_exists( 'Charitable_Gateway_Stripe_AM' ) ) { |
| 30 |
$charitable_settings = get_option( 'charitable_settings' ); |
| 31 |
$charitable_cc_fields_format = ( ! empty( $charitable_settings['gateways_stripe']['cc_fields_format'] ) && '' !== $charitable_settings['gateways_stripe']['cc_fields_format'] ) ? $charitable_settings['gateways_stripe']['cc_fields_format'] : ''; |
| 32 |
} |
| 33 |
|
| 34 |
?> |
| 35 |
<fieldset id="charitable-gateway-fields" class="charitable-fieldset"> |
| 36 |
<?php do_action( 'charitable_gateway_fields_front', $charitable_form, $charitable_field, $charitable_gateways ); ?> |
| 37 |
<?php |
| 38 |
if ( isset( $charitable_field['legend'] ) ) : |
| 39 |
?> |
| 40 |
|
| 41 |
<div class="charitable-form-header"><?php echo esc_html( $charitable_field['legend'] ); ?></div> |
| 42 |
|
| 43 |
<?php |
| 44 |
endif; |
| 45 |
|
| 46 |
do_action( 'charitable_gateway_fields_after_legend', $charitable_form, $charitable_field, $charitable_gateways ); |
| 47 |
|
| 48 |
if ( count( $charitable_gateways ) > 1 ) : |
| 49 |
?> |
| 50 |
<fieldset class="charitable-fieldset-field-wrapper"> |
| 51 |
<div class="charitable-fieldset-field-header" id="charitable-gateway-selector-header"><?php esc_html_e( 'Choose Your Payment Method', 'charitable' ); ?></div> |
| 52 |
<ul id="charitable-gateway-selector" class="charitable-radio-list charitable-form-field"> |
| 53 |
<?php foreach ( $charitable_gateways as $charitable_gateway_id => $charitable_details ) : ?> |
| 54 |
<li><input type="radio" |
| 55 |
id="gateway-<?php echo esc_attr( $charitable_gateway_id ); ?>" |
| 56 |
name="gateway" |
| 57 |
value="<?php echo esc_attr( $charitable_gateway_id ); ?>" |
| 58 |
aria-describedby="charitable-gateway-selector-header" |
| 59 |
<?php checked( $charitable_default, $charitable_gateway_id ); ?> /> |
| 60 |
<label for="gateway-<?php echo esc_attr( $charitable_gateway_id ); ?>"><?php echo esc_html( $charitable_details['label'] ); ?></label> |
| 61 |
</li> |
| 62 |
<?php endforeach ?> |
| 63 |
</ul> |
| 64 |
</fieldset> |
| 65 |
<?php |
| 66 |
endif; |
| 67 |
|
| 68 |
foreach ( $charitable_gateways as $charitable_gateway_id => $charitable_details ) : |
| 69 |
|
| 70 |
if ( ! isset( $charitable_details['fields'] ) || empty( $charitable_details['fields'] ) ) : |
| 71 |
continue; |
| 72 |
endif; |
| 73 |
|
| 74 |
$charitable_gateway_fields_classes = 'charitable-gateway-fields charitable-form-fields cf'; |
| 75 |
$charitable_gateway_fields_classes .= ( 'stripe' === $charitable_gateway_id && ! empty( $charitable_cc_fields_format ) ) ? ' charitable-cc-fields-' . esc_attr( $charitable_cc_fields_format ) : 'standard'; |
| 76 |
|
| 77 |
?> |
| 78 |
<div id="charitable-gateway-fields-<?php echo esc_html( $charitable_gateway_id ); ?>" class="<?php echo esc_attr( $charitable_gateway_fields_classes ); ?>" data-gateway="<?php echo esc_html( $charitable_gateway_id ); ?>"> |
| 79 |
<?php $charitable_form->view()->render_fields( $charitable_details['fields'] ); ?> |
| 80 |
</div><!-- #charitable-gateway-fields-<?php echo esc_html( $charitable_gateway_id ); ?> --> |
| 81 |
<?php endforeach ?> |
| 82 |
|
| 83 |
<?php do_action( 'charitable_gateway_fields_end', $charitable_form, $charitable_field, $charitable_gateways ); ?> |
| 84 |
|
| 85 |
</fieldset><!-- .charitable-fieldset --> |
| 86 |
|