| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template used to display the default form. |
| 4 |
* |
| 5 |
* Override this template by copying it to yourtheme/charitable/donation-form/form-donation.php |
| 6 |
* |
| 7 |
* @author WP Charitable LLC |
| 8 |
* @package Charitable/Templates/Donation Form |
| 9 |
* @since 1.0.0 |
| 10 |
* @version 1.6.57 |
| 11 |
* @version 1.8.3.5 Added $form_class to allow for charitable-minimal beta. |
| 12 |
* @version 1.8.4.2 Added charitable_donation_after_form_submit_button action. |
| 13 |
* @version 1.8.8.6 |
| 14 |
*/ |
| 15 |
|
| 16 |
// Exit if accessed directly. |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
$charitable_form = $view_args['form']; |
| 22 |
$charitable_user = wp_get_current_user(); |
| 23 |
$charitable_use_ajax = 'make_donation' == $charitable_form->get_form_action() && (int) Charitable_Gateways::get_instance()->gateways_support_ajax(); |
| 24 |
$charitable_form_id = isset( $view_args['form_id'] ) ? $view_args['form_id'] : charitable_get_donation_form_id(); |
| 25 |
$charitable_form_class = ! empty( $view_args['form_template'] ) ? apply_filters( 'charitable_donation_form_class', 'charitable-form charitable-donation-form charitable-template-' . esc_attr( $view_args['form_template'] ), $charitable_form ) : apply_filters( 'charitable_donation_form_class', 'charitable-form charitable-donation-form charitable-template-standard', $charitable_form ); // allows for charitable-minimal. |
| 26 |
|
| 27 |
if ( ! $charitable_form ) { |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
?> |
| 32 |
<form method="post" id="<?php echo esc_attr( $charitable_form_id ); ?>" class="<?php echo esc_attr( $charitable_form_class ); ?>" data-use-ajax="<?php echo esc_attr( $charitable_use_ajax ); ?>"> |
| 33 |
<?php |
| 34 |
/** |
| 35 |
* Do something before rendering the form fields. |
| 36 |
* |
| 37 |
* @since 1.0.0 |
| 38 |
* @since 1.6.0 Added $view_args parameter. |
| 39 |
* |
| 40 |
* @param Charitable_Form $form The form object. |
| 41 |
* @param array $view_args All args passed to template. |
| 42 |
*/ |
| 43 |
do_action( 'charitable_form_before_fields', $charitable_form, $view_args ); |
| 44 |
|
| 45 |
?> |
| 46 |
<div class="charitable-form-fields cf"> |
| 47 |
<?php $charitable_form->view()->render(); ?> |
| 48 |
</div><!-- .charitable-form-fields --> |
| 49 |
<?php |
| 50 |
/** |
| 51 |
* Do something after rendering the form fields. |
| 52 |
* |
| 53 |
* @since 1.0.0 |
| 54 |
* @since 1.6.0 Added $view_args parameter. |
| 55 |
* |
| 56 |
* @param Charitable_Form $form The form object. |
| 57 |
* @param array $view_args All args passed to template. |
| 58 |
*/ |
| 59 |
do_action( 'charitable_form_after_fields', $charitable_form, $view_args ); |
| 60 |
|
| 61 |
/** |
| 62 |
* Add filter to determine if the submit button should appear for the donation form. |
| 63 |
* 99.9% it should BUT there are cases - like spam busting - where we want to remove the ability for the donate form to be submitted. |
| 64 |
* |
| 65 |
* @since 1.7.0.9 |
| 66 |
*/ |
| 67 |
$charitable_show_donation_button = apply_filters( 'charitable_show_donation_form_button', true, $charitable_form, $view_args ); |
| 68 |
|
| 69 |
if ( $charitable_show_donation_button ) : |
| 70 |
?> |
| 71 |
<div class="charitable-form-field charitable-submit-field"> |
| 72 |
<button class="<?php echo esc_attr( charitable_get_button_class( 'donate' ) ); ?>" type="submit" name="donate"><?php esc_html_e( 'Donate', 'charitable' ); ?></button> |
| 73 |
<?php do_action( 'charitable_donation_after_form_submit_button', $charitable_form, $view_args ); ?> |
| 74 |
<div class="charitable-form-processing" style="display: none;"> |
| 75 |
<img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) ); ?>images/charitable-loading.gif" width="60" height="60" alt="<?php esc_attr_e( 'Loading…', 'charitable' ); ?>" /> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
<?php endif; ?> |
| 79 |
</form><!-- #<?php echo esc_html( $charitable_form_id ); ?>--> |
| 80 |
|