1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Give Form Template |
4
|
|
|
* |
5
|
|
|
* @package Give |
6
|
|
|
* @subpackage Forms |
7
|
|
|
* @copyright Copyright (c) 2016, WordImpress |
8
|
|
|
* @license https://opensource.org/licenses/gpl-license GNU Public License |
9
|
|
|
* @since 1.0 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
// Exit if accessed directly. |
13
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
14
|
|
|
exit; |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Get Donation Form. |
19
|
|
|
* |
20
|
|
|
* @param array $args An array of form arguments. |
21
|
|
|
* |
22
|
|
|
* @since 1.0 |
23
|
|
|
* |
24
|
|
|
* @return string Donation form. |
25
|
|
|
*/ |
26
|
|
|
function give_get_donation_form( $args = array() ) { |
27
|
|
|
|
28
|
1 |
|
global $post; |
29
|
|
|
static $count = 1; |
30
|
1 |
|
|
31
|
|
|
$form_id = is_object( $post ) ? $post->ID : 0; |
32
|
1 |
|
|
33
|
1 |
|
if ( isset( $args['id'] ) ) { |
34
|
1 |
|
$form_id = $args['id']; |
35
|
|
|
} |
36
|
1 |
|
|
37
|
|
|
$defaults = apply_filters( 'give_form_args_defaults', array( |
38
|
1 |
|
'form_id' => $form_id, |
39
|
|
|
) ); |
40
|
1 |
|
|
41
|
|
|
$args = wp_parse_args( $args, $defaults ); |
42
|
1 |
|
|
43
|
|
|
$form = new Give_Donate_Form( $args['form_id'] ); |
44
|
|
|
|
45
|
1 |
|
// Bail out, if no form ID. |
46
|
|
|
if ( empty( $form->ID ) ) { |
47
|
|
|
return false; |
48
|
|
|
} |
49
|
1 |
|
|
50
|
|
|
$args['id_prefix'] = "{$form_id}-{$count}"; |
51
|
1 |
|
$payment_mode = give_get_chosen_gateway( $form->ID ); |
52
|
1 |
|
|
53
|
1 |
|
$form_action = add_query_arg( |
54
|
1 |
|
apply_filters( 'give_form_action_args', array( |
55
|
1 |
|
'payment-mode' => $payment_mode, |
56
|
|
|
) |
57
|
|
|
), |
58
|
1 |
|
give_get_current_page_url() |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
// Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
62
|
1 |
|
if ( |
63
|
1 |
|
( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
64
|
1 |
|
|| ( 'trash' === $form->post_status ) |
65
|
|
|
) { |
66
|
1 |
|
return false; |
67
|
1 |
|
} |
68
|
1 |
|
|
69
|
|
|
// Get the form wrap CSS classes. |
70
|
|
|
$form_wrap_classes = $form->get_form_wrap_classes( $args ); |
71
|
1 |
|
|
72
|
1 |
|
// Get the <form> tag wrap CSS classes. |
73
|
|
|
$form_classes = $form->get_form_classes( $args ); |
74
|
1 |
|
|
75
|
1 |
|
ob_start(); |
76
|
|
|
|
77
|
|
|
/** |
78
|
1 |
|
* Fires while outputting donation form, before the form wrapper div. |
79
|
1 |
|
* |
80
|
1 |
|
* @since 1.0 |
81
|
|
|
* |
82
|
1 |
|
* @param int $form_id The form ID. |
83
|
1 |
|
* @param array $args An array of form arguments. |
84
|
|
|
*/ |
85
|
|
|
do_action( 'give_pre_form_output', $form->ID, $args, $form ); |
86
|
1 |
|
|
87
|
|
|
?> |
88
|
|
|
<div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
|
|
|
|
89
|
|
|
<?php |
90
|
|
|
if ( $form->is_close_donation_form() ) { |
91
|
|
|
|
92
|
|
|
$form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ) : ''; |
93
|
|
|
|
94
|
|
|
// Get Goal thank you message. |
95
|
|
|
$goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
96
|
|
|
$goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : ''; |
97
|
|
|
|
98
|
|
|
// Print thank you message. |
99
|
|
|
echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form ); |
|
|
|
|
100
|
|
|
|
101
|
|
|
} else { |
102
|
|
|
/** |
103
|
|
|
* Show form title: |
104
|
|
|
* 1. if show_title params set to true |
105
|
|
|
* 2. if admin set form display_style to button |
106
|
|
|
*/ |
107
|
|
|
$form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
108
|
|
|
if ( |
|
|
|
|
109
|
|
|
( |
110
|
|
|
( isset( $args['show_title'] ) && $args['show_title'] == true ) |
111
|
1 |
|
|| ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) ) |
112
|
|
|
) |
113
|
|
|
&& ! doing_action( 'give_single_form_summary' ) |
114
|
|
|
) { |
115
|
|
|
echo $form_title; |
|
|
|
|
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Fires while outputting donation form, before the form. |
120
|
|
|
* |
121
|
|
|
* @since 1.0 |
122
|
|
|
* |
123
|
|
|
* @param int $form_id The form ID. |
124
|
|
|
* @param array $args An array of form arguments. |
125
|
|
|
* @param Give_Donate_Form $form Form object. |
126
|
|
|
*/ |
127
|
|
|
do_action( 'give_pre_form', $form->ID, $args, $form ); |
128
|
|
|
|
129
|
|
|
// Set form html tags. |
130
|
|
|
$form_html_tags = array( |
131
|
|
|
'id' => "give-form-{$args['id_prefix']}", |
132
|
|
|
'class' => $form_classes, |
133
|
|
|
'action' => esc_url_raw( $form_action ), |
134
|
|
|
'data-id' => $args['id_prefix'], |
135
|
1 |
|
); |
136
|
|
|
|
137
|
1 |
|
/** |
138
|
1 |
|
* Filter the form html tags. |
139
|
|
|
* |
140
|
1 |
|
* @since 1.8.17 |
141
|
1 |
|
* |
142
|
1 |
|
* @param array $form_html_tags Array of form html tags. |
143
|
1 |
|
* @param Give_Donate_Form $form Form object. |
144
|
1 |
|
*/ |
145
|
|
|
$form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form ); |
146
|
|
|
?> |
147
|
|
|
<form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post"> |
|
|
|
|
148
|
|
|
<!-- The following field is for robots only, invisible to humans: --> |
149
|
1 |
|
<span class="give-hidden" style="display: none !important;"> |
150
|
|
|
<label for="give-form-honeypot-<?php echo $form_id; ?>"></label> |
|
|
|
|
151
|
1 |
|
<input id="give-form-honeypot-<?php echo $form_id; ?>" type="text" name="give-honeypot" |
|
|
|
|
152
|
|
|
class="give-honeypot give-hidden"/> |
153
|
1 |
|
</span> |
154
|
|
|
|
155
|
|
|
<?php |
156
|
|
|
/** |
157
|
|
|
* Fires while outputting donation form, before all other fields. |
158
|
|
|
* |
159
|
|
|
* @since 1.0 |
160
|
|
|
* |
161
|
|
|
* @param int $form_id The form ID. |
162
|
|
|
* @param array $args An array of form arguments. |
163
|
|
|
* @param Give_Donate_Form $form Form object. |
164
|
|
|
*/ |
165
|
|
|
do_action( 'give_donation_form_top', $form->ID, $args, $form ); |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Fires while outputting donation form, for payment gateway fields. |
169
|
|
|
* |
170
|
|
|
* @since 1.7 |
171
|
|
|
* |
172
|
|
|
* @param int $form_id The form ID. |
173
|
1 |
|
* @param array $args An array of form arguments. |
174
|
|
|
* @param Give_Donate_Form $form Form object. |
175
|
1 |
|
*/ |
176
|
|
|
do_action( 'give_payment_mode_select', $form->ID, $args, $form ); |
177
|
1 |
|
|
178
|
1 |
|
/** |
179
|
|
|
* Fires while outputting donation form, after all other fields. |
180
|
|
|
* |
181
|
|
|
* @since 1.0 |
182
|
|
|
* |
183
|
|
|
* @param int $form_id The form ID. |
184
|
|
|
* @param array $args An array of form arguments. |
185
|
|
|
* @param Give_Donate_Form $form Form object. |
186
|
|
|
*/ |
187
|
|
|
do_action( 'give_donation_form_bottom', $form->ID, $args, $form ); |
188
|
|
|
|
189
|
|
|
?> |
190
|
|
|
</form> |
191
|
|
|
|
192
|
|
|
<?php |
193
|
|
|
/** |
194
|
|
|
* Fires while outputting donation form, after the form. |
195
|
|
|
* |
196
|
|
|
* @since 1.0 |
197
|
|
|
* |
198
|
|
|
* @param int $form_id The form ID. |
199
|
1 |
|
* @param array $args An array of form arguments. |
200
|
|
|
* @param Give_Donate_Form $form Form object. |
201
|
1 |
|
*/ |
202
|
|
|
do_action( 'give_post_form', $form->ID, $args, $form ); |
203
|
|
|
|
204
|
|
|
} |
205
|
1 |
|
?> |
206
|
|
|
|
207
|
1 |
|
</div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
208
|
|
|
<?php |
209
|
1 |
|
|
210
|
|
|
/** |
211
|
1 |
|
* Fires while outputting donation form, after the form wrapper div. |
212
|
|
|
* |
213
|
1 |
|
* @since 1.0 |
214
|
|
|
* |
215
|
|
|
* @param int $form_id The form ID. |
216
|
1 |
|
* @param array $args An array of form arguments. |
217
|
1 |
|
*/ |
218
|
1 |
|
do_action( 'give_post_form_output', $form->ID, $args ); |
219
|
|
|
|
220
|
|
|
$final_output = ob_get_clean(); |
221
|
|
|
$count ++; |
222
|
1 |
|
|
223
|
|
|
echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
|
|
|
224
|
1 |
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Give Show Donation Form. |
228
|
|
|
* |
229
|
|
|
* Renders the Donation Form, hooks are provided to add to the checkout form. |
230
|
1 |
|
* The default Donation Form rendered displays a list of the enabled payment |
231
|
1 |
|
* gateways, a user registration form (if enable) and a credit card info form |
232
|
|
|
* if credit cards are enabled. |
233
|
|
|
* |
234
|
|
|
* @since 1.0 |
235
|
|
|
* |
236
|
|
|
* @param int $form_id The form ID. |
237
|
|
|
* |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
|
|
function give_show_purchase_form( $form_id, $args ) { |
241
|
|
|
|
242
|
|
|
$payment_mode = give_get_chosen_gateway( $form_id ); |
243
|
|
|
|
244
|
|
|
if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
245
|
|
|
$form_id = $_POST['give_form_id']; |
|
|
|
|
246
|
|
|
} |
247
|
1 |
|
|
248
|
|
|
/** |
249
|
|
|
* Fire before donation form render. |
250
|
|
|
* |
251
|
|
|
* @since 1.7 |
252
|
|
|
*/ |
253
|
|
|
do_action( 'give_payment_fields_top', $form_id ); |
254
|
|
|
|
255
|
|
|
if ( give_can_checkout() && isset( $form_id ) ) { |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* Fires while displaying donation form, before registration login. |
259
|
|
|
* |
260
|
|
|
* @since 1.7 |
261
|
|
|
*/ |
262
|
1 |
|
do_action( 'give_donation_form_before_register_login', $form_id, $args ); |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Fire when register/login form fields render. |
266
|
|
|
* |
267
|
|
|
* @since 1.7 |
268
|
|
|
*/ |
269
|
|
|
do_action( 'give_donation_form_register_login_fields', $form_id, $args ); |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Fire when credit card form fields render. |
273
|
|
|
* |
274
|
|
|
* @since 1.7 |
275
|
|
|
*/ |
276
|
|
|
do_action( 'give_donation_form_before_cc_form', $form_id, $args ); |
277
|
|
|
|
278
|
|
|
// Load the credit card form and allow gateways to load their own if they wish. |
279
|
|
|
if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
280
|
1 |
|
/** |
281
|
|
|
* Fires while displaying donation form, credit card form fields for a given gateway. |
282
|
1 |
|
* |
283
|
1 |
|
* @since 1.0 |
284
|
1 |
|
* |
285
|
1 |
|
* @param int $form_id The form ID. |
286
|
1 |
|
*/ |
287
|
1 |
|
do_action( "give_{$payment_mode}_cc_form", $form_id, $args ); |
288
|
1 |
|
} else { |
289
|
|
|
/** |
290
|
1 |
|
* Fires while displaying donation form, credit card form fields. |
291
|
|
|
* |
292
|
|
|
* @since 1.0 |
293
|
1 |
|
* |
294
|
|
|
* @param int $form_id The form ID. |
295
|
|
|
*/ |
296
|
|
|
do_action( 'give_cc_form', $form_id, $args ); |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* Fire after credit card form fields render. |
301
|
|
|
* |
302
|
|
|
* @since 1.7 |
303
|
|
|
*/ |
304
|
|
|
do_action( 'give_donation_form_after_cc_form', $form_id, $args ); |
305
|
|
|
|
306
|
|
|
} else { |
307
|
|
|
/** |
308
|
|
|
* Fire if user can not donate. |
309
|
|
|
* |
310
|
|
|
* @since 1.7 |
311
|
|
|
*/ |
312
|
|
|
do_action( 'give_donation_form_no_access', $form_id ); |
313
|
|
|
|
314
|
|
|
} |
315
|
1 |
|
|
316
|
|
|
/** |
317
|
|
|
* Fire after donation form rendered. |
318
|
|
|
* |
319
|
|
|
* @since 1.7 |
320
|
|
|
*/ |
321
|
|
|
do_action( 'give_payment_fields_bottom', $form_id, $args ); |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
add_action( 'give_donation_form', 'give_show_purchase_form', 10, 2 ); |
325
|
|
|
|
326
|
1 |
|
/** |
327
|
|
|
* Give Show Login/Register Form Fields. |
328
|
|
|
* |
329
|
|
|
* @since 1.4.1 |
330
|
|
|
* |
331
|
|
|
* @param int $form_id The form ID. |
332
|
|
|
* |
333
|
|
|
* @return void |
334
|
1 |
|
*/ |
335
|
1 |
|
function give_show_register_login_fields( $form_id ) { |
336
|
1 |
|
|
337
|
|
|
$show_register_form = give_show_login_register_option( $form_id ); |
338
|
1 |
|
|
339
|
1 |
|
if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
|
|
|
340
|
|
|
?> |
341
|
|
|
<div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
|
|
|
|
342
|
|
|
<?php |
343
|
|
|
/** |
344
|
|
|
* Fire if user registration form render. |
345
|
|
|
* |
346
|
|
|
* @since 1.7 |
347
|
|
|
*/ |
348
|
|
|
do_action( 'give_donation_form_register_fields', $form_id ); |
349
|
|
|
?> |
350
|
|
|
</div> |
351
|
|
|
<?php |
352
|
|
|
elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
|
|
|
353
|
|
|
?> |
354
|
|
|
<div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
|
|
|
|
355
|
|
|
<?php |
356
|
1 |
|
/** |
357
|
1 |
|
* Fire if user login form render. |
358
|
1 |
|
* |
359
|
1 |
|
* @since 1.7 |
360
|
1 |
|
*/ |
361
|
1 |
|
do_action( 'give_donation_form_login_fields', $form_id ); |
362
|
1 |
|
?> |
363
|
|
|
</div> |
364
|
1 |
|
<?php |
365
|
1 |
|
endif; |
366
|
|
|
|
367
|
|
|
if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
|
|
|
368
|
1 |
|
/** |
369
|
|
|
* Fire when user info render. |
370
|
1 |
|
* |
371
|
|
|
* @since 1.7 |
372
|
1 |
|
*/ |
373
|
1 |
|
do_action( 'give_donation_form_after_user_info', $form_id ); |
374
|
1 |
|
} |
375
|
1 |
|
} |
376
|
|
|
|
377
|
1 |
|
add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
378
|
1 |
|
|
379
|
1 |
|
/** |
380
|
1 |
|
* Donation Amount Field. |
381
|
1 |
|
* |
382
|
|
|
* Outputs the donation amount field that appears at the top of the donation forms. If the user has custom amount |
383
|
1 |
|
* enabled the field will output as a customizable input. |
384
|
|
|
* |
385
|
|
|
* @since 1.0 |
386
|
1 |
|
* |
387
|
|
|
* @param int $form_id The form ID. |
388
|
|
|
* @param array $args An array of form arguments. |
389
|
|
|
* |
390
|
|
|
* @return void |
391
|
|
|
*/ |
392
|
|
|
function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
393
|
|
|
|
394
|
1 |
|
$give_options = give_get_settings(); |
395
|
|
|
$variable_pricing = give_has_variable_prices( $form_id ); |
396
|
1 |
|
$allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
397
|
|
|
$currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
398
|
|
|
$symbol = give_currency_symbol( give_get_currency( $form_id, $args ) ); |
399
|
|
|
$currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
400
|
|
|
$default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false, 'currency' => give_get_currency( $form_id ) ) ); |
401
|
|
|
$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* Fires while displaying donation form, before donation level fields. |
405
|
|
|
* |
406
|
|
|
* @since 1.0 |
407
|
|
|
* |
408
|
|
|
* @param int $form_id The form ID. |
409
|
|
|
* @param array $args An array of form arguments. |
410
|
|
|
*/ |
411
|
|
|
do_action( 'give_before_donation_levels', $form_id, $args ); |
412
|
|
|
|
413
|
|
|
//Set Price, No Custom Amount Allowed means hidden price field |
414
|
|
|
if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
415
|
|
|
?> |
416
|
|
|
<label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
417
|
|
|
<input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
418
|
|
|
value="<?php echo $default_amount; ?>" required aria-required="true"/> |
|
|
|
|
419
|
|
|
<div class="set-price give-donation-amount form-row-wide"> |
420
|
|
|
<?php if ( $currency_position == 'before' ) { |
|
|
|
|
421
|
|
|
echo $currency_output; |
|
|
|
|
422
|
|
|
} ?> |
423
|
|
|
<span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
|
|
|
|
424
|
|
|
<?php if ( $currency_position == 'after' ) { |
|
|
|
|
425
|
|
|
echo $currency_output; |
|
|
|
|
426
|
|
|
} ?> |
427
|
|
|
</div> |
428
|
|
|
<?php |
429
|
|
|
} else { |
430
|
|
|
//Custom Amount Allowed. |
431
|
|
|
?> |
432
|
|
|
<div class="give-total-wrap"> |
433
|
|
|
<div class="give-donation-amount form-row-wide"> |
434
|
|
|
<?php if ( $currency_position == 'before' ) { |
|
|
|
|
435
|
|
|
echo $currency_output; |
|
|
|
|
436
|
|
|
} ?> |
437
|
|
|
<label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
438
|
|
|
<input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
439
|
|
|
placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
|
|
|
|
440
|
|
|
<?php if ( $currency_position == 'after' ) { |
|
|
|
|
441
|
|
|
echo $currency_output; |
|
|
|
|
442
|
|
|
} ?> |
443
|
|
|
</div> |
444
|
|
|
</div> |
445
|
|
|
<?php } |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Fires while displaying donation form, after donation amounf field(s). |
449
|
|
|
* |
450
|
|
|
* @since 1.0 |
451
|
|
|
* |
452
|
1 |
|
* @param int $form_id The form ID. |
453
|
1 |
|
* @param array $args An array of form arguments. |
454
|
|
|
*/ |
455
|
|
|
do_action( 'give_after_donation_amount', $form_id, $args ); |
456
|
|
|
|
457
|
|
|
//Custom Amount Text |
458
|
|
|
if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
459
|
|
|
<p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
|
|
|
|
460
|
|
|
<?php } |
461
|
|
|
|
462
|
|
|
//Output Variable Pricing Levels. |
463
|
|
|
if ( $variable_pricing ) { |
464
|
|
|
give_output_levels( $form_id ); |
465
|
|
|
} |
466
|
1 |
|
|
467
|
1 |
|
/** |
468
|
1 |
|
* Fires while displaying donation form, after donation level fields. |
469
|
|
|
* |
470
|
|
|
* @since 1.0 |
471
|
1 |
|
* |
472
|
|
|
* @param int $form_id The form ID. |
473
|
|
|
* @param array $args An array of form arguments. |
474
|
|
|
*/ |
475
|
1 |
|
do_action( 'give_after_donation_levels', $form_id, $args ); |
476
|
1 |
|
} |
477
|
|
|
|
478
|
1 |
|
add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
479
|
|
|
|
480
|
1 |
|
/** |
481
|
1 |
|
* Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
482
|
|
|
* |
483
|
|
|
* @since 1.0 |
484
|
|
|
* |
485
|
|
|
* @param int $form_id The form ID. |
486
|
|
|
* |
487
|
|
|
* @return string Donation levels. |
488
|
|
|
*/ |
489
|
|
|
function give_output_levels( $form_id ) { |
490
|
|
|
|
491
|
|
|
//Get variable pricing. |
492
|
|
|
$prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
493
|
|
|
$display_style = give_get_meta( $form_id, '_give_display_style', true ); |
494
|
|
|
$custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
495
|
|
|
$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
496
|
|
|
|
497
|
|
|
if ( empty( $custom_amount_text ) ) { |
498
|
|
|
$custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
$output = ''; |
502
|
|
|
|
503
|
|
|
switch ( $display_style ) { |
504
|
|
|
case 'buttons': |
505
|
|
|
|
506
|
|
|
$output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
507
|
|
|
|
508
|
|
|
foreach ( $prices as $price ) { |
509
|
|
|
$level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
510
|
|
|
$level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
511
|
|
|
|
512
|
|
|
$formatted_amount = give_format_amount( $price['_give_amount'], array( |
513
|
|
|
'sanitize' => false, |
514
|
|
|
'currency' => give_get_currency( $form_id ), |
515
|
|
|
) ); |
516
|
|
|
|
517
|
|
|
$output .= sprintf( |
518
|
|
|
'<li><button type="button" data-price-id="%1$s" class="%2$s" value="%3$s" data-default="%4$s">%5$s</button></li>', |
519
|
|
|
$price['_give_id']['level_id'], |
520
|
|
|
$level_classes, |
521
|
|
|
$formatted_amount, |
522
|
|
|
array_key_exists( '_give_default', $price ) ? 1 : 0, |
523
|
|
|
$level_text |
524
|
|
|
); |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
//Custom Amount. |
528
|
|
|
if ( |
529
|
|
|
give_is_setting_enabled( $custom_amount ) |
530
|
|
|
&& ! empty( $custom_amount_text ) |
531
|
|
|
) { |
532
|
|
|
|
533
|
|
|
$output .= sprintf( |
534
|
|
|
'<li><button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">%1$s</button></li>', |
535
|
|
|
$custom_amount_text |
536
|
|
|
); |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
$output .= '</ul>'; |
540
|
|
|
|
541
|
|
|
break; |
542
|
|
|
|
543
|
|
|
case 'radios': |
544
|
|
|
|
545
|
|
|
$output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
546
|
|
|
|
547
|
|
View Code Duplication |
foreach ( $prices as $price ) { |
|
|
|
|
548
|
|
|
$level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
549
|
|
|
$level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
550
|
|
|
|
551
|
|
|
$formatted_amount = give_format_amount( $price['_give_amount'], array( |
552
|
|
|
'sanitize' => false, |
553
|
|
|
'currency' => give_get_currency( $form_id ), |
554
|
|
|
) ); |
555
|
|
|
|
556
|
|
|
$output .= sprintf( |
557
|
|
|
'<li><input type="radio" data-price-id="%1$s" class="%2$s" value="%3$s" name="give-radio-donation-level" id="give-radio-level-%1$s" %4$s data-default="%5$s"><label for="give-radio-level-%1$s">%6$s</label></li>', |
558
|
|
|
$price['_give_id']['level_id'], |
559
|
|
|
$level_classes, |
560
|
|
|
$formatted_amount, |
561
|
|
|
( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ), |
562
|
|
|
array_key_exists( '_give_default', $price ) ? 1 : 0, |
563
|
|
|
$level_text |
564
|
|
|
); |
565
|
|
|
} |
566
|
|
|
|
567
|
|
|
//Custom Amount. |
568
|
|
|
if ( |
569
|
|
|
give_is_setting_enabled( $custom_amount ) |
570
|
|
|
&& ! empty( $custom_amount_text ) |
571
|
|
|
) { |
572
|
|
|
$output .= sprintf( |
573
|
|
|
'<li><input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom"><label for="give-radio-level-custom">%1$s</label></li>', |
574
|
|
|
$custom_amount_text |
575
|
|
|
); |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
$output .= '</ul>'; |
579
|
|
|
|
580
|
|
|
break; |
581
|
|
|
|
582
|
|
|
case 'dropdown': |
583
|
|
|
|
584
|
|
|
$output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
585
|
|
|
$output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
586
|
|
|
|
587
|
|
|
//first loop through prices. |
588
|
|
View Code Duplication |
foreach ( $prices as $price ) { |
|
|
|
|
589
|
|
|
$level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
590
|
|
|
$level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
591
|
|
|
|
592
|
|
|
$formatted_amount = give_format_amount( $price['_give_amount'], array( |
593
|
|
|
'sanitize' => false, |
594
|
|
|
'currency' => give_get_currency( $form_id ), |
595
|
|
|
) ); |
596
|
|
|
|
597
|
|
|
$output .= sprintf( |
598
|
|
|
'<option data-price-id="%1$s" class="%2$s" value="%3$s" %4$s data-default="%5$s">%6$s</option>', |
599
|
|
|
$price['_give_id']['level_id'], |
600
|
|
|
$level_classes, |
601
|
|
|
$formatted_amount, |
602
|
|
|
( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ), |
603
|
|
|
array_key_exists( '_give_default', $price ) ? 1 : 0, |
604
|
|
|
$level_text |
605
|
|
|
); |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
//Custom Amount. |
609
|
|
|
if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
610
|
|
|
$output .= sprintf( |
611
|
|
|
'<option data-price-id="custom" class="give-donation-level-custom" value="custom">%1$s</option>', |
612
|
|
|
$custom_amount_text |
613
|
|
|
); |
614
|
|
|
} |
615
|
|
|
|
616
|
|
|
$output .= '</select>'; |
617
|
|
|
|
618
|
|
|
break; |
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
|
|
|
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* Display Reveal & Lightbox Button. |
626
|
|
|
* |
627
|
|
|
* Outputs a button to reveal form fields. |
628
|
|
|
* |
629
|
|
|
* @since 1.0 |
630
|
|
|
* |
631
|
|
|
* @param int $form_id The form ID. |
632
|
|
|
* @param array $args An array of form arguments. |
633
|
|
|
* |
634
|
|
|
* @return string Checkout button. |
635
|
|
|
*/ |
636
|
|
|
function give_display_checkout_button( $form_id, $args ) { |
637
|
|
|
|
638
|
|
|
$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
639
|
|
|
? $args['display_style'] |
640
|
|
|
: give_get_meta( $form_id, '_give_payment_display', true ); |
641
|
|
|
|
642
|
|
|
if ( 'button' === $display_option ) { |
643
|
|
|
$display_option = 'modal'; |
644
|
|
|
} elseif ( $display_option === 'onpage' ) { |
|
|
|
|
645
|
|
|
return ''; |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
$display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
649
|
|
|
$display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
650
|
|
|
|
651
|
|
|
$output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
652
|
|
|
|
653
|
|
|
echo apply_filters( 'give_display_checkout_button', $output ); |
|
|
|
|
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
657
|
|
|
|
658
|
|
|
/** |
659
|
|
|
* Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
660
|
|
|
* |
661
|
|
|
* @since 1.0 |
662
|
|
|
* |
663
|
|
|
* @param int $form_id The form ID. |
664
|
|
|
* |
665
|
|
|
* @see For Pattern Attribute: https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation |
666
|
|
|
* |
667
|
|
|
* @return void |
668
|
|
|
*/ |
669
|
|
|
function give_user_info_fields( $form_id ) { |
670
|
|
|
// Get user info. |
671
|
|
|
$give_user_info = _give_get_prefill_form_field_values( $form_id ); |
672
|
|
|
|
673
|
|
|
/** |
674
|
|
|
* Fire before user personal information fields |
675
|
|
|
* |
676
|
|
|
* @since 1.7 |
677
|
|
|
*/ |
678
|
|
|
do_action( 'give_donation_form_before_personal_info', $form_id ); |
679
|
|
|
?> |
680
|
|
|
<fieldset id="give_checkout_user_info"> |
681
|
|
|
<legend><?php echo apply_filters( 'give_checkout_personal_info_text', __( 'Personal Info', 'give' ) ); ?></legend> |
|
|
|
|
682
|
|
|
<p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
683
|
|
|
<label class="give-label" for="give-first"> |
684
|
|
|
<?php _e( 'First Name', 'give' ); ?> |
685
|
|
|
<?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
686
|
|
|
<span class="give-required-indicator">*</span> |
687
|
|
|
<?php endif ?> |
688
|
|
|
<?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?> |
|
|
|
|
689
|
|
|
</label> |
690
|
|
|
<input |
691
|
|
|
class="give-input required" |
692
|
|
|
type="text" |
693
|
|
|
name="give_first" |
694
|
|
|
autocomplete="given-name" |
695
|
|
|
placeholder="<?php _e( 'First Name', 'give' ); ?>" |
696
|
|
|
id="give-first" |
697
|
|
|
value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
|
|
|
698
|
|
|
<?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
699
|
|
|
/> |
700
|
|
|
</p> |
701
|
|
|
|
702
|
|
|
<p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
703
|
|
|
<label class="give-label" for="give-last"> |
704
|
|
|
<?php _e( 'Last Name', 'give' ); ?> |
705
|
|
|
<?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
706
|
|
|
<span class="give-required-indicator">*</span> |
707
|
|
|
<?php endif ?> |
708
|
|
|
<?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?> |
|
|
|
|
709
|
|
|
</label> |
710
|
|
|
|
711
|
|
|
<input |
712
|
|
|
class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
|
|
|
713
|
|
|
type="text" |
714
|
|
|
name="give_last" |
715
|
|
|
autocomplete="family-name" |
716
|
|
|
id="give-last" |
717
|
|
|
placeholder="<?php _e( 'Last Name', 'give' ); ?>" |
718
|
|
|
value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
|
|
|
719
|
|
|
<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
720
|
|
|
/> |
721
|
|
|
</p> |
722
|
|
|
|
723
|
|
|
<?php if ( give_is_company_field_enabled( $form_id ) ) : ?> |
724
|
|
|
<?php $give_company = give_field_is_required( 'give_company_name', $form_id ); ?> |
725
|
|
|
<p id="give-company-wrap" class="form-row form-row-wide"> |
726
|
|
|
<label class="give-label" for="give-company"> |
727
|
|
|
<?php _e( 'Company Name', 'give' ); ?> |
728
|
|
|
<?php if ( $give_company ) : ?> |
729
|
|
|
<span class="give-required-indicator">*</span> |
730
|
|
|
<?php endif; ?> |
731
|
|
|
<?php echo Give()->tooltips->render_help( __( 'Donate on behalf of Company', 'give' ) ); ?> |
|
|
|
|
732
|
|
|
</label> |
733
|
|
|
|
734
|
|
|
<input |
735
|
|
|
class="give-input<?php echo( $give_company ? ' required' : '' ); ?>" |
|
|
|
|
736
|
|
|
type="text" |
737
|
|
|
name="give_company_name" |
738
|
|
|
placeholder="<?php _e( 'Company Name', 'give' ); ?>" |
739
|
|
|
id="give-company" |
740
|
|
|
value="<?php echo isset( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : ''; ?>" |
|
|
|
|
741
|
|
|
<?php echo( $give_company ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
742
|
|
|
/> |
743
|
|
|
|
744
|
|
|
</p> |
745
|
|
|
<?php endif ?> |
746
|
|
|
|
747
|
|
|
<?php |
748
|
|
|
/** |
749
|
|
|
* Fire before user email field |
750
|
|
|
* |
751
|
|
|
* @since 1.7 |
752
|
|
|
*/ |
753
|
|
|
do_action( 'give_donation_form_before_email', $form_id ); |
754
|
|
|
?> |
755
|
|
|
<p id="give-email-wrap" class="form-row form-row-wide"> |
756
|
|
|
<label class="give-label" for="give-email"> |
757
|
|
|
<?php _e( 'Email Address', 'give' ); ?> |
758
|
|
|
<?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
759
|
|
|
<span class="give-required-indicator">*</span> |
760
|
|
|
<?php } ?> |
761
|
|
|
<?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?> |
|
|
|
|
762
|
|
|
</label> |
763
|
|
|
|
764
|
|
|
<input |
765
|
|
|
class="give-input required" |
766
|
|
|
type="email" |
767
|
|
|
name="give_email" |
768
|
|
|
autocomplete="email" |
769
|
|
|
placeholder="<?php _e( 'Email Address', 'give' ); ?>" |
770
|
|
|
id="give-email" |
771
|
|
|
value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
|
|
|
772
|
|
|
<?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
773
|
|
|
/> |
774
|
|
|
|
775
|
|
|
</p> |
776
|
|
|
<?php |
777
|
|
|
/** |
778
|
|
|
* Fire after user email field |
779
|
|
|
* |
780
|
|
|
* @since 1.7 |
781
|
|
|
*/ |
782
|
|
|
do_action( 'give_donation_form_after_email', $form_id ); |
783
|
|
|
|
784
|
|
|
/** |
785
|
|
|
* Fire after personal email field |
786
|
|
|
* |
787
|
|
|
* @since 1.7 |
788
|
|
|
*/ |
789
|
|
|
do_action( 'give_donation_form_user_info', $form_id ); |
790
|
|
|
?> |
791
|
|
|
</fieldset> |
792
|
|
|
<?php |
793
|
|
|
/** |
794
|
|
|
* Fire after user personal information fields |
795
|
|
|
* |
796
|
|
|
* @since 1.7 |
797
|
|
|
*/ |
798
|
|
|
do_action( 'give_donation_form_after_personal_info', $form_id ); |
799
|
|
|
} |
800
|
|
|
|
801
|
|
|
add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
802
|
|
|
add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
803
|
|
|
|
804
|
|
|
/** |
805
|
|
|
* Renders the credit card info form. |
806
|
|
|
* |
807
|
|
|
* @since 1.0 |
808
|
|
|
* |
809
|
|
|
* @param int $form_id The form ID. |
810
|
|
|
* |
811
|
|
|
* @return void |
812
|
|
|
*/ |
813
|
|
|
function give_get_cc_form( $form_id ) { |
814
|
|
|
|
815
|
|
|
ob_start(); |
816
|
|
|
|
817
|
|
|
/** |
818
|
|
|
* Fires while rendering credit card info form, before the fields. |
819
|
|
|
* |
820
|
|
|
* @since 1.0 |
821
|
|
|
* |
822
|
|
|
* @param int $form_id The form ID. |
823
|
|
|
*/ |
824
|
|
|
do_action( 'give_before_cc_fields', $form_id ); |
825
|
|
|
?> |
826
|
|
|
<fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
|
|
|
|
827
|
|
|
<legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
|
|
|
828
|
|
|
<?php if ( is_ssl() ) : ?> |
829
|
|
|
<div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
|
|
|
|
830
|
|
|
<span class="give-icon padlock"></span> |
831
|
|
|
<span><?php _e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
832
|
|
|
</div> |
833
|
|
|
<?php endif; ?> |
834
|
|
|
<p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
|
|
|
|
835
|
|
|
<label for="card_number-<?php echo $form_id ?>" class="give-label"> |
|
|
|
|
836
|
|
|
<?php _e( 'Card Number', 'give' ); ?> |
837
|
|
|
<span class="give-required-indicator">*</span> |
838
|
|
|
<?php echo Give()->tooltips->render_help( __( 'The (typically) 16 digits on the front of your credit card.', 'give' ) ); ?> |
|
|
|
|
839
|
|
|
<span class="card-type"></span> |
840
|
|
|
</label> |
841
|
|
|
|
842
|
|
|
<input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
|
|
|
|
843
|
|
|
class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>" |
844
|
|
|
required aria-required="true"/> |
845
|
|
|
</p> |
846
|
|
|
|
847
|
|
|
<p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
|
|
|
|
848
|
|
|
<label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
|
|
|
|
849
|
|
|
<?php _e( 'CVC', 'give' ); ?> |
850
|
|
|
<span class="give-required-indicator">*</span> |
851
|
|
|
<?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?> |
|
|
|
|
852
|
|
|
</label> |
853
|
|
|
|
854
|
|
|
<input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
|
|
|
|
855
|
|
|
class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>" |
856
|
|
|
required aria-required="true"/> |
857
|
|
|
</p> |
858
|
|
|
|
859
|
|
|
<p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
|
|
|
|
860
|
|
|
<label for="card_name-<?php echo $form_id ?>" class="give-label"> |
|
|
|
|
861
|
|
|
<?php _e( 'Name on the Card', 'give' ); ?> |
862
|
|
|
<span class="give-required-indicator">*</span> |
863
|
|
|
<?php echo Give()->tooltips->render_help( __( 'The name printed on the front of your credit card.', 'give' ) ); ?> |
|
|
|
|
864
|
|
|
</label> |
865
|
|
|
|
866
|
|
|
<input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
|
|
|
|
867
|
|
|
class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
868
|
|
|
required aria-required="true"/> |
869
|
|
|
</p> |
870
|
|
|
<?php |
871
|
|
|
/** |
872
|
|
|
* Fires while rendering credit card info form, before expiration fields. |
873
|
|
|
* |
874
|
|
|
* @since 1.0 |
875
|
|
|
* |
876
|
|
|
* @param int $form_id The form ID. |
877
|
|
|
*/ |
878
|
|
|
do_action( 'give_before_cc_expiration' ); |
879
|
|
|
?> |
880
|
|
|
<p class="card-expiration form-row form-row-one-third form-row-responsive"> |
881
|
|
|
<label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
|
|
|
|
882
|
|
|
<?php _e( 'Expiration', 'give' ); ?> |
883
|
|
|
<span class="give-required-indicator">*</span> |
884
|
|
|
<?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?> |
|
|
|
|
885
|
|
|
</label> |
886
|
|
|
|
887
|
|
|
<input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
|
|
|
|
888
|
|
|
<input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
|
|
|
|
889
|
|
|
|
890
|
|
|
<input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true"/> |
|
|
|
|
891
|
|
|
</p> |
892
|
|
|
<?php |
893
|
|
|
/** |
894
|
|
|
* Fires while rendering credit card info form, after expiration fields. |
895
|
|
|
* |
896
|
|
|
* @since 1.0 |
897
|
|
|
* |
898
|
|
|
* @param int $form_id The form ID. |
899
|
|
|
*/ |
900
|
|
|
do_action( 'give_after_cc_expiration', $form_id ); |
901
|
|
|
?> |
902
|
|
|
</fieldset> |
903
|
|
|
<?php |
904
|
|
|
/** |
905
|
|
|
* Fires while rendering credit card info form, before the fields. |
906
|
|
|
* |
907
|
|
|
* @since 1.0 |
908
|
|
|
* |
909
|
|
|
* @param int $form_id The form ID. |
910
|
|
|
*/ |
911
|
|
|
do_action( 'give_after_cc_fields', $form_id ); |
912
|
|
|
|
913
|
|
|
echo ob_get_clean(); |
|
|
|
|
914
|
|
|
} |
915
|
|
|
|
916
|
|
|
add_action( 'give_cc_form', 'give_get_cc_form' ); |
917
|
|
|
|
918
|
|
|
/** |
919
|
|
|
* Outputs the default credit card address fields. |
920
|
|
|
* |
921
|
|
|
* @since 1.0 |
922
|
|
|
* |
923
|
|
|
* @param int $form_id The form ID. |
924
|
|
|
* |
925
|
|
|
* @return void |
926
|
|
|
*/ |
927
|
|
|
function give_default_cc_address_fields( $form_id ) { |
928
|
|
|
// Get user info. |
929
|
|
|
$give_user_info = _give_get_prefill_form_field_values( $form_id ); |
930
|
|
|
|
931
|
|
|
$logged_in = is_user_logged_in(); |
932
|
|
|
|
933
|
|
|
if ( $logged_in ) { |
934
|
|
|
$user_address = give_get_donor_address( get_current_user_id() ); |
|
|
|
|
935
|
|
|
} |
936
|
|
|
|
937
|
|
|
ob_start(); |
938
|
|
|
?> |
939
|
|
|
<fieldset id="give_cc_address" class="cc-address"> |
940
|
|
|
<legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
|
|
|
941
|
|
|
<?php |
942
|
|
|
/** |
943
|
|
|
* Fires while rendering credit card billing form, before address fields. |
944
|
|
|
* |
945
|
|
|
* @since 1.0 |
946
|
|
|
* |
947
|
|
|
* @param int $form_id The form ID. |
948
|
|
|
*/ |
949
|
|
|
do_action( 'give_cc_billing_top' ); |
950
|
|
|
|
951
|
|
|
// For Country. |
952
|
|
|
$selected_country = give_get_country(); |
953
|
|
View Code Duplication |
if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
|
|
|
954
|
|
|
$selected_country = $give_user_info['billing_country']; |
955
|
|
|
} |
956
|
|
|
$countries = give_get_country_list(); |
957
|
|
|
|
958
|
|
|
// For state |
959
|
|
|
$selected_state = ''; |
960
|
|
|
if ( $selected_country === give_get_country() ) { |
961
|
|
|
// Get defalut selected state by admin. |
962
|
|
|
$selected_state = give_get_state(); |
963
|
|
|
} |
964
|
|
|
// Get the last payment made by user states. |
965
|
|
|
if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
966
|
|
|
$selected_state = $give_user_info['card_state']; |
967
|
|
|
} |
968
|
|
|
// Get the country code |
969
|
|
View Code Duplication |
if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
|
|
|
970
|
|
|
$selected_country = $give_user_info['billing_country']; |
971
|
|
|
} |
972
|
|
|
$label = __( 'State', 'give' ); |
973
|
|
|
$states_label = give_get_states_label(); |
974
|
|
|
// Check if $country code exists in the array key for states label. |
975
|
|
|
if ( array_key_exists( $selected_country, $states_label ) ) { |
976
|
|
|
$label = $states_label[ $selected_country ]; |
977
|
|
|
} |
978
|
|
|
$states = give_get_states( $selected_country ); |
979
|
|
|
// Get the country list that do not have any states init. |
980
|
|
|
$no_states_country = give_no_states_country_list(); |
981
|
|
|
// Get the country list that does not require states. |
982
|
|
|
$states_not_required_country_list = give_states_not_required_country_list(); |
983
|
|
|
?> |
984
|
|
|
<p id="give-card-country-wrap" class="form-row form-row-wide"> |
985
|
|
|
<label for="billing_country" class="give-label"> |
986
|
|
|
<?php esc_html_e( 'Country', 'give' ); ?> |
987
|
|
|
<?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
988
|
|
|
<span class="give-required-indicator">*</span> |
989
|
|
|
<?php endif; ?> |
990
|
|
|
<span class="give-tooltip give-icon give-icon-question" |
991
|
|
|
data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
992
|
|
|
</label> |
993
|
|
|
|
994
|
|
|
<select |
995
|
1 |
|
name="billing_country" |
996
|
|
|
autocomplete="country-name" |
997
|
|
|
id="billing_country" |
998
|
|
|
class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
|
|
|
999
|
|
|
<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
1000
|
|
|
> |
1001
|
|
|
<?php |
1002
|
|
|
foreach ( $countries as $country_code => $country ) { |
1003
|
|
|
echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
|
|
|
1004
|
|
|
} |
1005
|
|
|
?> |
1006
|
|
|
</select> |
1007
|
|
|
</p> |
1008
|
|
|
|
1009
|
|
|
<p id="give-card-address-wrap" class="form-row form-row-wide"> |
1010
|
|
|
<label for="card_address" class="give-label"> |
1011
|
1 |
|
<?php _e( 'Address 1', 'give' ); ?> |
1012
|
1 |
|
<?php |
1013
|
1 |
|
if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
1014
|
1 |
|
<span class="give-required-indicator">*</span> |
1015
|
1 |
|
<?php endif; ?> |
1016
|
|
|
<?php echo Give()->tooltips->render_help( __( 'The primary billing address for your credit card.', 'give' ) ); ?> |
|
|
|
|
1017
|
|
|
</label> |
1018
|
|
|
|
1019
|
|
|
<input |
1020
|
|
|
type="text" |
1021
|
|
|
id="card_address" |
1022
|
|
|
name="card_address" |
1023
|
|
|
autocomplete="address-line1" |
1024
|
|
|
class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
|
|
|
1025
|
|
|
placeholder="<?php _e( 'Address line 1', 'give' ); ?>" |
1026
|
|
|
value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
|
|
|
1027
|
|
|
<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
1028
|
|
|
/> |
1029
|
|
|
</p> |
1030
|
|
|
|
1031
|
|
|
<p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
1032
|
|
|
<label for="card_address_2" class="give-label"> |
1033
|
1 |
|
<?php _e( 'Address 2', 'give' ); ?> |
1034
|
|
|
<?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
1035
|
|
|
<span class="give-required-indicator">*</span> |
1036
|
|
|
<?php endif; ?> |
1037
|
|
|
<?php echo Give()->tooltips->render_help( __( '(optional) The suite, apartment number, post office box (etc) associated with your billing address.', 'give' ) ); ?> |
|
|
|
|
1038
|
|
|
</label> |
1039
|
|
|
|
1040
|
|
|
<input |
1041
|
|
|
type="text" |
1042
|
|
|
id="card_address_2" |
1043
|
|
|
name="card_address_2" |
1044
|
|
|
autocomplete="address-line2" |
1045
|
|
|
class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
|
|
|
1046
|
|
|
placeholder="<?php _e( 'Address line 2', 'give' ); ?>" |
1047
|
|
|
value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
|
|
|
1048
|
|
|
<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
1049
|
|
|
/> |
1050
|
|
|
</p> |
1051
|
|
|
|
1052
|
1 |
|
<p id="give-card-city-wrap" class="form-row form-row-wide"> |
1053
|
1 |
|
<label for="card_city" class="give-label"> |
1054
|
1 |
|
<?php _e( 'City', 'give' ); ?> |
1055
|
|
|
<?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
1056
|
|
|
<span class="give-required-indicator">*</span> |
1057
|
|
|
<?php endif; ?> |
1058
|
|
|
<?php echo Give()->tooltips->render_help( __( 'The city for your billing address.', 'give' ) ); ?> |
|
|
|
|
1059
|
|
|
</label> |
1060
|
|
|
<input |
1061
|
|
|
type="text" |
1062
|
|
|
id="card_city" |
1063
|
|
|
name="card_city" |
1064
|
|
|
autocomplete="address-level3" |
1065
|
|
|
class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
|
|
|
1066
|
|
|
placeholder="<?php _e( 'City', 'give' ); ?>" |
1067
|
|
|
value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
|
|
|
1068
|
|
|
<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
1069
|
|
|
/> |
1070
|
|
|
</p> |
1071
|
|
|
|
1072
|
|
|
<p id="give-card-state-wrap" |
1073
|
|
|
class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
|
|
|
1074
|
|
|
<label for="card_state" class="give-label"> |
1075
|
|
|
<span class="state-label-text"><?php echo $label; ?></span> |
|
|
|
|
1076
|
|
|
<?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
1077
|
1 |
|
?> |
1078
|
|
|
<span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
|
|
|
1079
|
|
|
<?php endif; ?> |
1080
|
|
|
<span class="give-tooltip give-icon give-icon-question" |
1081
|
|
|
data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
1082
|
|
|
</label> |
1083
|
|
|
<?php |
1084
|
|
|
|
1085
|
|
|
if ( ! empty( $states ) ) : ?> |
1086
|
|
|
<select |
1087
|
|
|
name="card_state" |
1088
|
|
|
autocomplete="address-level4" |
1089
|
|
|
id="card_state" |
1090
|
|
|
class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
|
|
|
1091
|
|
|
<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
|
|
|
1092
|
|
|
<?php |
1093
|
1 |
|
foreach ( $states as $state_code => $state ) { |
1094
|
|
|
echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
|
|
|
1095
|
|
|
} |
1096
|
|
|
?> |
1097
|
1 |
|
</select> |
1098
|
|
|
<?php else : ?> |
1099
|
|
|
<input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
1100
|
1 |
|
placeholder="<?php echo $label; ?>" value="<?php echo $selected_state; ?>"/> |
|
|
|
|
1101
|
|
|
<?php endif; ?> |
1102
|
|
|
</p> |
1103
|
|
|
|
1104
|
|
|
<p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
1105
|
|
|
<label for="card_zip" class="give-label"> |
1106
|
|
|
<?php _e( 'Zip / Postal Code', 'give' ); ?> |
1107
|
|
|
<?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
1108
|
|
|
<span class="give-required-indicator">*</span> |
1109
|
1 |
|
<?php endif; ?> |
1110
|
|
|
<?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?> |
|
|
|
|
1111
|
|
|
</label> |
1112
|
|
|
|
1113
|
|
|
<input |
1114
|
|
|
type="text" |
1115
|
|
|
size="4" |
1116
|
|
|
id="card_zip" |
1117
|
|
|
name="card_zip" |
1118
|
|
|
autocomplete="postal-code" |
1119
|
|
|
class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
|
|
|
1120
|
|
|
placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" |
1121
|
|
|
value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
|
|
|
1122
|
|
|
<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
|
|
|
1123
|
|
|
/> |
1124
|
|
|
</p> |
1125
|
|
|
<?php |
1126
|
|
|
/** |
1127
|
|
|
* Fires while rendering credit card billing form, after address fields. |
1128
|
|
|
* |
1129
|
|
|
* @since 1.0 |
1130
|
|
|
* |
1131
|
|
|
* @param int $form_id The form ID. |
1132
|
|
|
*/ |
1133
|
|
|
do_action( 'give_cc_billing_bottom' ); |
1134
|
|
|
?> |
1135
|
|
|
</fieldset> |
1136
|
1 |
|
<?php |
1137
|
|
|
echo ob_get_clean(); |
|
|
|
|
1138
|
|
|
} |
1139
|
|
|
|
1140
|
|
|
add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
1141
|
|
|
|
1142
|
|
|
|
1143
|
|
|
/** |
1144
|
|
|
* Renders the user registration fields. If the user is logged in, a login form is displayed other a registration form |
1145
|
|
|
* is provided for the user to create an account. |
1146
|
|
|
* |
1147
|
|
|
* @since 1.0 |
1148
|
|
|
* |
1149
|
|
|
* @param int $form_id The form ID. |
1150
|
|
|
* |
1151
|
|
|
* @return string |
1152
|
|
|
*/ |
1153
|
1 |
|
function give_get_register_fields( $form_id ) { |
1154
|
1 |
|
|
1155
|
|
|
global $user_ID; |
1156
|
|
|
|
1157
|
|
|
if ( is_user_logged_in() ) { |
1158
|
|
|
$user_data = get_userdata( $user_ID ); |
|
|
|
|
1159
|
|
|
} |
1160
|
|
|
|
1161
|
1 |
|
$show_register_form = give_show_login_register_option( $form_id ); |
1162
|
|
|
|
1163
|
|
|
ob_start(); ?> |
1164
|
|
|
<fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
|
|
|
|
1165
|
|
|
|
1166
|
|
|
<?php |
1167
|
|
|
/** |
1168
|
|
|
* Fires while rendering user registration form, before registration fields. |
1169
|
|
|
* |
1170
|
|
|
* @since 1.0 |
1171
|
|
|
* |
1172
|
|
|
* @param int $form_id The form ID. |
1173
|
|
|
*/ |
1174
|
|
|
do_action( 'give_register_fields_before', $form_id ); |
1175
|
|
|
?> |
1176
|
1 |
|
|
1177
|
|
|
<fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
|
|
|
|
1178
|
1 |
|
<?php |
1179
|
|
|
/** |
1180
|
|
|
* Fires while rendering user registration form, before account fields. |
1181
|
|
|
* |
1182
|
|
|
* @since 1.0 |
1183
|
|
|
* |
1184
|
|
|
* @param int $form_id The form ID. |
1185
|
|
|
*/ |
1186
|
|
|
do_action( 'give_register_account_fields_before', $form_id ); |
1187
|
|
|
|
1188
|
|
|
$class = ( 'registration' === $show_register_form) ? 'form-row-wide' : 'form-row-first'; |
1189
|
|
|
?> |
1190
|
|
|
<div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row <?php echo esc_attr( $class ); ?> form-row-responsive"> |
|
|
|
|
1191
|
|
|
<label for="give-create-account-<?php echo $form_id; ?>"> |
|
|
|
|
1192
|
1 |
|
<?php |
1193
|
|
|
// Add attributes to checkbox, if Guest Checkout is disabled. |
1194
|
|
|
$is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true ); |
1195
|
|
|
$id = 'give-create-account-' . $form_id; |
1196
|
|
|
if ( ! give_is_setting_enabled( $is_guest_checkout ) ) { |
1197
|
|
|
echo Give()->tooltips->render( |
|
|
|
|
1198
|
|
|
array( |
1199
|
|
|
'tag_content' => sprintf( |
1200
|
|
|
'<input type="checkbox" name="give_create_account" value="on" id="%s" class="give-input give-disabled" checked />', |
1201
|
|
|
$id |
1202
|
|
|
), |
1203
|
|
|
'label' => __( 'Registration is required to donate.', 'give' ), |
1204
|
|
|
) ); |
|
|
|
|
1205
|
|
|
} else { |
1206
|
|
|
?> |
1207
|
|
|
<input type="checkbox" name="give_create_account" value="on" id="<?php echo $id; ?>" class="give-input" /> |
|
|
|
|
1208
|
|
|
<?php |
1209
|
1 |
|
} |
1210
|
1 |
|
?> |
1211
|
1 |
|
<?php _e( 'Create an account', 'give' ); ?> |
1212
|
1 |
|
<?php echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) ); ?> |
|
|
|
|
1213
|
1 |
|
<?php wp_nonce_field( 'give_form_create_user_nonce', 'give-form-user-register-hash', false, true );?> |
1214
|
1 |
|
</label> |
1215
|
1 |
|
</div> |
1216
|
1 |
|
|
1217
|
|
|
<?php if ( 'both' === $show_register_form ) { ?> |
1218
|
|
|
<div class="give-login-account-wrap form-row form-row-last form-row-responsive"> |
1219
|
1 |
|
<p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
1220
|
|
|
<a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
1221
|
|
|
data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
1222
|
|
|
</p> |
1223
|
|
|
<p class="give-loading-text"> |
1224
|
1 |
|
<span class="give-loading-animation"></span> |
1225
|
1 |
|
</p> |
1226
|
1 |
|
</div> |
1227
|
1 |
|
<?php } ?> |
1228
|
1 |
|
|
1229
|
|
|
<?php |
1230
|
1 |
|
/** |
1231
|
|
|
* Fires while rendering user registration form, after account fields. |
1232
|
|
|
* |
1233
|
|
|
* @since 1.0 |
1234
|
|
|
* |
1235
|
|
|
* @param int $form_id The form ID. |
1236
|
|
|
*/ |
1237
|
|
|
do_action( 'give_register_account_fields_after', $form_id ); |
1238
|
|
|
?> |
1239
|
|
|
</fieldset> |
1240
|
|
|
|
1241
|
|
|
<?php |
1242
|
|
|
/** |
1243
|
|
|
* Fires while rendering user registration form, after registration fields. |
1244
|
|
|
* |
1245
|
|
|
* @since 1.0 |
1246
|
|
|
* |
1247
|
|
|
* @param int $form_id The form ID. |
1248
|
|
|
*/ |
1249
|
|
|
do_action( 'give_register_fields_after', $form_id ); |
1250
|
|
|
?> |
1251
|
|
|
|
1252
|
|
|
<input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
1253
|
|
|
|
1254
|
|
|
<?php |
1255
|
|
|
/** |
1256
|
|
|
* Fire after register or login form render |
1257
|
|
|
* |
1258
|
|
|
* @since 1.7 |
1259
|
|
|
*/ |
1260
|
|
|
do_action( 'give_donation_form_user_info', $form_id ); |
1261
|
|
|
?> |
1262
|
|
|
|
1263
|
|
|
</fieldset> |
1264
|
|
|
<?php |
1265
|
|
|
echo ob_get_clean(); |
|
|
|
|
1266
|
|
|
} |
1267
|
|
|
|
1268
|
|
|
add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
1269
|
|
|
|
1270
|
|
|
/** |
1271
|
|
|
* Gets the login fields for the login form on the checkout. This function hooks |
1272
|
|
|
* on the give_donation_form_login_fields to display the login form if a user already |
1273
|
|
|
* had an account. |
1274
|
|
|
* |
1275
|
|
|
* @since 1.0 |
1276
|
|
|
* |
1277
|
|
|
* @param int $form_id The form ID. |
1278
|
|
|
* |
1279
|
|
|
* @return string |
1280
|
|
|
*/ |
1281
|
|
|
function give_get_login_fields( $form_id ) { |
1282
|
|
|
|
1283
|
|
|
$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
|
|
|
1284
|
|
|
$show_register_form = give_show_login_register_option( $form_id ); |
1285
|
|
|
|
1286
|
|
|
ob_start(); |
1287
|
|
|
?> |
1288
|
|
|
<fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
|
|
|
|
1289
|
|
|
<legend><?php echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) ); |
|
|
|
|
1290
|
|
|
if ( ! give_logged_in_only( $form_id ) ) { |
1291
|
|
|
echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>'; |
|
|
|
|
1292
|
|
|
} ?> |
1293
|
|
|
</legend> |
1294
|
|
|
<?php if ( $show_register_form == 'both' ) { ?> |
|
|
|
|
1295
|
|
|
<p class="give-new-account-link"> |
1296
|
|
|
<?php _e( 'Don\'t have an account?', 'give' ); ?> |
1297
|
|
|
<a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
|
|
|
1298
|
|
|
data-action="give_checkout_register"> |
1299
|
|
|
<?php if ( give_logged_in_only( $form_id ) ) { |
1300
|
|
|
_e( 'Register as a part of your donation »', 'give' ); |
1301
|
|
|
} else { |
1302
|
1 |
|
_e( 'Register or donate as a guest »', 'give' ); |
1303
|
1 |
|
} ?> |
1304
|
1 |
|
</a> |
1305
|
|
|
</p> |
1306
|
1 |
|
<p class="give-loading-text"> |
1307
|
|
|
<span class="give-loading-animation"></span> |
1308
|
1 |
|
</p> |
1309
|
1 |
|
<?php } ?> |
1310
|
1 |
|
<?php |
1311
|
|
|
/** |
1312
|
|
|
* Fires while rendering checkout login form, before the fields. |
1313
|
|
|
* |
1314
|
|
|
* @since 1.0 |
1315
|
|
|
* |
1316
|
|
|
* @param int $form_id The form ID. |
1317
|
|
|
*/ |
1318
|
|
|
do_action( 'give_checkout_login_fields_before', $form_id ); |
1319
|
|
|
?> |
1320
|
|
|
<div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
|
|
|
|
1321
|
|
|
<label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
|
|
|
|
1322
|
|
|
<?php _e( 'Username', 'give' ); ?> |
1323
|
|
|
<?php if ( give_logged_in_only( $form_id ) ) { ?> |
1324
|
|
|
<span class="give-required-indicator">*</span> |
1325
|
|
|
<?php } ?> |
1326
|
|
|
</label> |
1327
|
|
|
|
1328
|
|
|
<input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
|
|
|
1329
|
|
|
name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
|
|
|
|
1330
|
|
|
placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
|
|
|
1331
|
|
|
</div> |
1332
|
|
|
|
1333
|
|
|
<div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
|
|
|
|
1334
|
|
|
class="give_login_password form-row form-row-last form-row-responsive"> |
1335
|
|
|
<label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
|
|
|
|
1336
|
|
|
<?php _e( 'Password', 'give' ); ?> |
1337
|
|
|
<?php if ( give_logged_in_only( $form_id ) ) { ?> |
1338
|
|
|
<span class="give-required-indicator">*</span> |
1339
|
|
|
<?php } ?> |
1340
|
|
|
</label> |
1341
|
|
|
<input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
|
|
|
1342
|
|
|
type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
|
|
|
|
1343
|
|
|
placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
|
|
|
1344
|
|
|
<input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1345
|
|
|
</div> |
1346
|
|
|
|
1347
|
|
|
<div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
|
|
|
|
1348
|
|
|
<span class="give-forgot-password "> |
1349
|
|
|
<a href="<?php echo wp_lostpassword_url() ?>" |
|
|
|
|
1350
|
|
|
target="_blank"><?php _e( 'Reset Password', 'give' ) ?></a> |
1351
|
|
|
</span> |
1352
|
|
|
</div> |
1353
|
|
|
|
1354
|
|
|
<div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
|
|
|
|
1355
|
|
|
<input type="submit" class="give-submit give-btn button" name="give_login_submit" |
1356
|
1 |
|
value="<?php _e( 'Login', 'give' ); ?>"/> |
1357
|
|
|
<?php if ( $show_register_form !== 'login' ) { ?> |
|
|
|
|
1358
|
|
|
<input type="button" data-action="give_cancel_login" |
1359
|
|
|
class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
1360
|
|
|
value="<?php _e( 'Cancel', 'give' ); ?>"/> |
1361
|
|
|
<?php } ?> |
1362
|
|
|
<span class="give-loading-animation"></span> |
1363
|
1 |
|
</div> |
1364
|
|
|
<?php |
1365
|
1 |
|
/** |
1366
|
|
|
* Fires while rendering checkout login form, after the fields. |
1367
|
|
|
* |
1368
|
|
|
* @since 1.0 |
1369
|
|
|
* |
1370
|
|
|
* @param int $form_id The form ID. |
1371
|
|
|
*/ |
1372
|
|
|
do_action( 'give_checkout_login_fields_after', $form_id ); |
1373
|
|
|
?> |
1374
|
|
|
</fieldset><!--end #give-login-fields--> |
1375
|
|
|
<?php |
1376
|
|
|
echo ob_get_clean(); |
|
|
|
|
1377
|
|
|
} |
1378
|
|
|
|
1379
|
|
|
add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
1380
|
|
|
|
1381
|
|
|
/** |
1382
|
|
|
* Payment Mode Select. |
1383
|
|
|
* |
1384
|
|
|
* Renders the payment mode form by getting all the enabled payment gateways and |
1385
|
|
|
* outputting them as radio buttons for the user to choose the payment gateway. If |
1386
|
|
|
* a default payment gateway has been chosen from the Give Settings, it will be |
1387
|
|
|
* automatically selected. |
1388
|
|
|
* |
1389
|
|
|
* @since 1.0 |
1390
|
|
|
* |
1391
|
|
|
* @param int $form_id The form ID. |
1392
|
|
|
* |
1393
|
|
|
* @return void |
1394
|
|
|
*/ |
1395
|
|
|
function give_payment_mode_select( $form_id, $args ) { |
1396
|
|
|
|
1397
|
|
|
$gateways = give_get_enabled_payment_gateways( $form_id ); |
1398
|
|
|
$id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
1399
|
|
|
|
1400
|
|
|
/** |
1401
|
|
|
* Fires while selecting payment gateways, before the fields. |
1402
|
|
|
* |
1403
|
1 |
|
* @since 1.7 |
1404
|
|
|
* |
1405
|
1 |
|
* @param int $form_id The form ID. |
1406
|
|
|
*/ |
1407
|
|
|
do_action( 'give_payment_mode_top', $form_id ); |
1408
|
1 |
|
?> |
1409
|
|
|
|
1410
|
|
|
<fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
1411
|
|
|
echo 'style="display: none;"'; |
1412
|
|
|
} ?>> |
1413
|
|
|
<?php |
1414
|
|
|
/** |
1415
|
|
|
* Fires while selecting payment gateways, before the wrap div. |
1416
|
|
|
* |
1417
|
|
|
* @since 1.7 |
1418
|
|
|
* |
1419
|
|
|
* @param int $form_id The form ID. |
1420
|
|
|
*/ |
1421
|
|
|
do_action( 'give_payment_mode_before_gateways_wrap' ); |
1422
|
1 |
|
?> |
1423
|
|
|
<legend |
1424
|
|
|
class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
|
|
|
1425
|
1 |
|
<span class="give-loading-text"><span |
1426
|
|
|
class="give-loading-animation"></span> |
1427
|
|
|
</span> |
1428
|
|
|
</legend> |
1429
|
|
|
|
1430
|
1 |
|
<div id="give-payment-mode-wrap"> |
1431
|
|
|
<?php |
1432
|
|
|
/** |
1433
|
|
|
* Fires while selecting payment gateways, before the gateways list. |
1434
|
|
|
* |
1435
|
|
|
* @since 1.7 |
1436
|
|
|
*/ |
1437
|
|
|
do_action( 'give_payment_mode_before_gateways' ) |
1438
|
1 |
|
?> |
1439
|
|
|
<ul id="give-gateway-radio-list"> |
1440
|
|
|
<?php |
1441
|
|
|
/** |
1442
|
|
|
* Loop through the active payment gateways. |
1443
|
|
|
*/ |
1444
|
|
|
$selected_gateway = give_get_chosen_gateway( $form_id ); |
1445
|
|
|
$give_settings = give_get_settings(); |
1446
|
|
|
$gateways_label = array_key_exists( 'gateways_label', $give_settings ) ? |
1447
|
|
|
$give_settings['gateways_label'] : |
1448
|
|
|
array(); |
1449
|
|
|
|
1450
|
|
|
foreach ( $gateways as $gateway_id => $gateway ) : |
1451
|
|
|
//Determine the default gateway. |
1452
|
|
|
$checked = checked( $gateway_id, $selected_gateway, false ); |
1453
|
|
|
$checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
1454
|
|
|
<li<?php echo $checked_class ?>> |
|
|
|
|
1455
|
|
|
<input type="radio" name="payment-mode" class="give-gateway" |
1456
|
|
|
id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
|
|
|
|
1457
|
|
|
value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
|
|
|
1458
|
|
|
|
1459
|
|
|
<?php |
1460
|
|
|
$label = $gateway['checkout_label']; |
1461
|
|
|
if ( ! empty( $gateways_label[ $gateway_id ] ) ) { |
1462
|
|
|
$label = $gateways_label[ $gateway_id ]; |
1463
|
|
|
} |
1464
|
|
|
?> |
1465
|
|
|
<label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>" |
1466
|
|
|
class="give-gateway-option" |
1467
|
|
|
id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $label ); ?></label> |
1468
|
|
|
</li> |
1469
|
|
|
<?php |
1470
|
|
|
endforeach; |
1471
|
|
|
?> |
1472
|
|
|
</ul> |
1473
|
|
|
<?php |
1474
|
|
|
/** |
1475
|
|
|
* Fires while selecting payment gateways, before the gateways list. |
1476
|
|
|
* |
1477
|
|
|
* @since 1.7 |
1478
|
|
|
*/ |
1479
|
|
|
do_action( 'give_payment_mode_after_gateways' ); |
1480
|
|
|
?> |
1481
|
|
|
</div> |
1482
|
|
|
<?php |
1483
|
|
|
/** |
1484
|
|
|
* Fires while selecting payment gateways, after the wrap div. |
1485
|
|
|
* |
1486
|
|
|
* @since 1.7 |
1487
|
|
|
* |
1488
|
|
|
* @param int $form_id The form ID. |
1489
|
|
|
*/ |
1490
|
|
|
do_action( 'give_payment_mode_after_gateways_wrap' ); |
1491
|
|
|
?> |
1492
|
|
|
</fieldset> |
1493
|
|
|
|
1494
|
|
|
<?php |
1495
|
|
|
/** |
1496
|
|
|
* Fires while selecting payment gateways, after the fields. |
1497
|
|
|
* |
1498
|
|
|
* @since 1.7 |
1499
|
|
|
* |
1500
|
|
|
* @param int $form_id The form ID. |
1501
|
|
|
*/ |
1502
|
|
|
do_action( 'give_payment_mode_bottom', $form_id ); |
1503
|
|
|
?> |
1504
|
|
|
|
1505
|
|
|
<div id="give_purchase_form_wrap"> |
1506
|
|
|
|
1507
|
|
|
<?php |
1508
|
|
|
/** |
1509
|
|
|
* Fire after payment field render. |
1510
|
|
|
* |
1511
|
|
|
* @since 1.7 |
1512
|
|
|
*/ |
1513
|
|
|
do_action( 'give_donation_form', $form_id, $args ); |
1514
|
|
|
?> |
1515
|
|
|
|
1516
|
|
|
</div> |
1517
|
|
|
|
1518
|
|
|
<?php |
1519
|
|
|
/** |
1520
|
|
|
* Fire after donation form render. |
1521
|
|
|
* |
1522
|
|
|
* @since 1.7 |
1523
|
|
|
*/ |
1524
|
|
|
do_action( 'give_donation_form_wrap_bottom', $form_id ); |
1525
|
|
|
} |
1526
|
|
|
|
1527
|
|
|
add_action( 'give_payment_mode_select', 'give_payment_mode_select', 10, 2 ); |
1528
|
|
|
|
1529
|
|
|
/** |
1530
|
|
|
* Renders the Checkout Agree to Terms, this displays a checkbox for users to |
1531
|
|
|
* agree the T&Cs set in the Give Settings. This is only displayed if T&Cs are |
1532
|
|
|
* set in the Give Settings. |
1533
|
|
|
* |
1534
|
|
|
* @since 1.0 |
1535
|
|
|
* |
1536
|
|
|
* @param int $form_id The form ID. |
1537
|
|
|
* |
1538
|
|
|
* @return bool |
1539
|
|
|
*/ |
1540
|
|
|
function give_terms_agreement( $form_id ) { |
1541
|
|
|
$form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
1542
|
|
|
|
1543
|
|
|
// Bailout if per form and global term and conditions is not setup. |
1544
|
|
|
if ( |
1545
|
|
|
give_is_setting_enabled( $form_option, 'global' ) |
1546
|
|
|
&& give_is_setting_enabled( give_get_option( 'terms' ) ) |
1547
|
|
|
) { |
1548
|
|
|
$label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
1549
|
|
|
$terms = $terms = give_get_option( 'agreement_text', '' ); |
1550
|
|
|
$edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
1551
|
|
|
|
1552
|
|
|
} elseif ( give_is_setting_enabled( $form_option ) ) { |
1553
|
|
|
$label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
1554
|
|
|
$terms = give_get_meta( $form_id, '_give_agree_text', true ); |
1555
|
|
|
$edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
1556
|
|
|
|
1557
|
|
|
} else { |
1558
|
|
|
return false; |
1559
|
|
|
} |
1560
|
|
|
|
|
|
|
|
1561
|
|
|
|
1562
|
|
|
// Bailout: Check if term and conditions text is empty or not. |
1563
|
|
|
if ( empty( $terms ) ) { |
1564
|
|
|
if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
1565
|
|
|
echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
|
|
|
1566
|
|
|
} |
1567
|
|
|
|
1568
|
|
|
return false; |
1569
|
|
|
} |
1570
|
|
|
|
1571
|
|
|
/** |
1572
|
|
|
* Filter the form term content |
1573
|
|
|
* |
1574
|
|
|
* @since 2.1.5 |
1575
|
|
|
*/ |
1576
|
|
|
$terms = apply_filters( 'give_the_term_content', wpautop( do_shortcode( $terms ) ), $terms, $form_id ); |
1577
|
|
|
|
1578
|
|
|
?> |
1579
|
|
|
<fieldset id="give_terms_agreement"> |
1580
|
|
|
<legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
|
|
|
1581
|
|
|
<div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
|
|
|
|
1582
|
|
|
<?php |
1583
|
|
|
/** |
1584
|
|
|
* Fires while rendering terms of agreement, before the fields. |
1585
|
|
|
* |
1586
|
|
|
* @since 1.0 |
1587
|
|
|
*/ |
1588
|
|
|
do_action( 'give_before_terms' ); |
1589
|
|
|
|
1590
|
|
|
echo $terms; |
|
|
|
|
1591
|
|
|
/** |
1592
|
|
|
* Fires while rendering terms of agreement, after the fields. |
1593
|
|
|
* |
1594
|
|
|
* @since 1.0 |
1595
|
|
|
*/ |
1596
|
|
|
do_action( 'give_after_terms' ); |
1597
|
|
|
?> |
1598
|
|
|
</div> |
1599
|
|
|
<div id="give_show_terms"> |
1600
|
|
|
<a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
|
|
|
|
1601
|
|
|
aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
1602
|
|
|
<a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
|
|
|
|
1603
|
|
|
aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
1604
|
|
|
</div> |
1605
|
|
|
|
1606
|
|
|
<input name="give_agree_to_terms" class="required" type="checkbox" |
1607
|
|
|
id="give_agree_to_terms-<?php echo $form_id; ?>" value="1" required aria-required="true"/> |
|
|
|
|
1608
|
|
|
<label for="give_agree_to_terms-<?php echo $form_id; ?>"><?php echo $label; ?></label> |
|
|
|
|
1609
|
|
|
|
1610
|
|
|
</fieldset> |
1611
|
|
|
<?php |
1612
|
|
|
} |
1613
|
|
|
|
1614
|
|
|
add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
1615
|
|
|
|
1616
|
|
|
/** |
1617
|
|
|
* Checkout Final Total. |
1618
|
|
|
* |
1619
|
|
|
* Shows the final donation total at the bottom of the checkout page. |
1620
|
|
|
* |
1621
|
|
|
* @since 1.0 |
1622
|
|
|
* |
1623
|
|
|
* @param int $form_id The form ID. |
1624
|
|
|
* |
1625
|
|
|
* @return void |
1626
|
|
|
*/ |
1627
|
|
|
function give_checkout_final_total( $form_id ) { |
1628
|
|
|
|
1629
|
|
|
$total = isset( $_POST['give_total'] ) ? |
|
|
|
|
1630
|
|
|
apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
|
|
|
1631
|
|
|
give_get_default_form_amount( $form_id ); |
1632
|
|
|
|
|
|
|
|
1633
|
|
|
|
1634
|
|
|
// Only proceed if give_total available. |
1635
|
|
|
if ( empty( $total ) ) { |
1636
|
|
|
return; |
1637
|
|
|
} |
1638
|
|
|
?> |
1639
|
|
|
<p id="give-final-total-wrap" class="form-wrap "> |
1640
|
|
|
<?php |
1641
|
|
|
/** |
1642
|
|
|
* Fires before the donation total label |
1643
|
|
|
* |
1644
|
|
|
* @since 2.0.5 |
1645
|
|
|
*/ |
1646
|
|
|
do_action( 'give_donation_final_total_label_before', $form_id ); |
1647
|
|
|
?> |
1648
|
|
|
<span class="give-donation-total-label"> |
1649
|
|
|
<?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
|
|
|
1650
|
|
|
</span> |
1651
|
|
|
<span class="give-final-total-amount" |
1652
|
|
|
data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
|
|
|
1653
|
|
|
<?php |
1654
|
|
|
|
1655
|
|
|
echo give_currency_filter( give_format_amount( $total, array( |
|
|
|
|
1656
|
|
|
'sanitize' => false, |
1657
|
|
|
'currency' => give_get_currency( $form_id ), |
1658
|
|
|
) ), array( 'currency_code' => give_get_currency( $form_id ) ) ); ?> |
1659
|
|
|
</span> |
1660
|
|
|
<?php |
1661
|
|
|
/** |
1662
|
|
|
* Fires after the donation final total label |
1663
|
|
|
* |
1664
|
|
|
* @since 2.0.5 |
1665
|
|
|
*/ |
1666
|
|
|
do_action( 'give_donation_final_total_label_after', $form_id ); |
1667
|
|
|
?> |
1668
|
|
|
</p> |
1669
|
|
|
<?php |
1670
|
|
|
} |
1671
|
|
|
|
1672
|
|
|
add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
1673
|
|
|
|
1674
|
|
|
/** |
1675
|
|
|
* Renders the Checkout Submit section. |
1676
|
|
|
* |
1677
|
|
|
* @since 1.0 |
1678
|
|
|
* |
1679
|
|
|
* @param int $form_id The donation form ID. |
1680
|
|
|
* @param array $args List of arguments. |
1681
|
|
|
* |
1682
|
|
|
* @return void |
1683
|
|
|
*/ |
1684
|
|
|
function give_checkout_submit( $form_id, $args ) { |
1685
|
|
|
?> |
1686
|
|
|
<fieldset id="give_purchase_submit" class="give-donation-submit"> |
1687
|
|
|
<?php |
1688
|
|
|
/** |
1689
|
|
|
* Fire before donation form submit. |
1690
|
|
|
* |
1691
|
|
|
* @since 1.7 |
1692
|
|
|
*/ |
1693
|
|
|
do_action( 'give_donation_form_before_submit', $form_id, $args ); |
1694
|
|
|
|
1695
|
|
|
give_checkout_hidden_fields( $form_id ); |
1696
|
|
|
|
1697
|
|
|
echo give_get_donation_form_submit_button( $form_id ); |
|
|
|
|
1698
|
|
|
|
1699
|
|
|
/** |
1700
|
|
|
* Fire after donation form submit. |
1701
|
|
|
* |
1702
|
|
|
* @since 1.7 |
1703
|
|
|
*/ |
1704
|
|
|
do_action( 'give_donation_form_after_submit', $form_id, $args ); |
1705
|
|
|
?> |
1706
|
|
|
</fieldset> |
1707
|
|
|
<?php |
1708
|
|
|
} |
1709
|
|
|
|
1710
|
|
|
add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999, 2 ); |
1711
|
|
|
|
1712
|
|
|
/** |
1713
|
|
|
* Give Donation form submit button. |
1714
|
|
|
* |
1715
|
|
|
* @since 1.8.8 |
1716
|
|
|
* |
1717
|
|
|
* @param int $form_id The form ID. |
1718
|
|
|
* |
1719
|
|
|
* @return string |
1720
|
|
|
*/ |
1721
|
|
|
function give_get_donation_form_submit_button( $form_id ) { |
1722
|
|
|
|
1723
|
|
|
$display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
1724
|
|
|
$display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
1725
|
|
|
ob_start(); |
1726
|
|
|
?> |
1727
|
|
|
<div class="give-submit-button-wrap give-clearfix"> |
1728
|
|
|
<input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" |
1729
|
|
|
value="<?php echo $display_label; ?>" data-before-validation-label="<?php echo $display_label; ?>" /> |
|
|
|
|
1730
|
|
|
<span class="give-loading-animation"></span> |
1731
|
|
|
</div> |
1732
|
|
|
<?php |
1733
|
|
|
return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
1734
|
|
|
} |
1735
|
|
|
|
1736
|
|
|
/** |
1737
|
|
|
* Show Give Goals. |
1738
|
|
|
* |
1739
|
|
|
* @since 1.0 |
1740
|
|
|
* @since 1.6 Add template for Give Goals Shortcode. |
1741
|
|
|
* More info is on https://github.com/WordImpress/Give/issues/411 |
1742
|
|
|
* |
1743
|
|
|
* @param int $form_id The form ID. |
1744
|
|
|
* @param array $args An array of form arguments. |
1745
|
|
|
* |
1746
|
|
|
* @return mixed |
1747
|
|
|
*/ |
1748
|
|
|
function give_show_goal_progress( $form_id, $args = array() ) { |
1749
|
|
|
|
1750
|
|
|
ob_start(); |
1751
|
|
|
give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
1752
|
|
|
|
1753
|
|
|
/** |
1754
|
|
|
* Filter progress bar output |
1755
|
|
|
* |
1756
|
|
|
* @since 2.0 |
1757
|
|
|
*/ |
1758
|
|
|
echo apply_filters( 'give_goal_output', ob_get_clean(), $form_id, $args ); |
|
|
|
|
1759
|
|
|
|
1760
|
|
|
return true; |
1761
|
|
|
} |
1762
|
|
|
|
1763
|
|
|
add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
1764
|
|
|
|
1765
|
|
|
/** |
1766
|
|
|
* Show Give Totals Progress. |
1767
|
|
|
* |
1768
|
|
|
* @since 2.1 |
1769
|
|
|
* |
1770
|
|
|
* @param int $total Total amount based on shortcode parameter. |
1771
|
|
|
* @param int $total_goal Total Goal amount passed by Admin. |
1772
|
|
|
* |
1773
|
|
|
* @return mixed |
1774
|
|
|
*/ |
1775
|
|
|
function give_show_goal_totals_progress( $total, $total_goal ) { |
1776
|
|
|
|
1777
|
|
|
// Bail out if total goal is set as an array. |
1778
|
|
|
if ( isset( $total_goal ) && is_array( $total_goal ) ) { |
1779
|
|
|
return false; |
1780
|
|
|
} |
1781
|
|
|
|
1782
|
|
|
ob_start(); |
1783
|
|
|
give_get_template( 'shortcode-totals-progress', array( 'total' => $total, 'total_goal' => $total_goal ) ); |
1784
|
|
|
|
1785
|
|
|
echo apply_filters( 'give_total_progress_output', ob_get_clean() ); |
|
|
|
|
1786
|
|
|
|
1787
|
|
|
return true; |
1788
|
|
|
} |
1789
|
|
|
|
1790
|
|
|
add_action( 'give_pre_form', 'give_show_goal_totals_progress', 10, 2 ); |
1791
|
|
|
|
1792
|
|
|
/** |
1793
|
|
|
* Get form content position. |
1794
|
|
|
* |
1795
|
|
|
* @since 1.8 |
1796
|
|
|
* |
1797
|
|
|
* @param $form_id |
1798
|
|
|
* @param $args |
1799
|
|
|
* |
1800
|
|
|
* @return mixed|string |
1801
|
|
|
*/ |
1802
|
|
|
function give_get_form_content_placement( $form_id, $args ) { |
1803
|
|
|
$show_content = ''; |
1804
|
|
|
|
1805
|
|
|
if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
1806
|
|
|
// Content positions. |
1807
|
|
|
$content_placement = array( |
1808
|
|
|
'above' => 'give_pre_form', |
1809
|
|
|
'below' => 'give_post_form', |
1810
|
|
|
); |
1811
|
|
|
|
1812
|
|
|
// Check if content position already decoded. |
1813
|
|
|
if ( in_array( $args['show_content'], $content_placement ) ) { |
1814
|
|
|
return $args['show_content']; |
1815
|
|
|
} |
1816
|
|
|
|
1817
|
|
|
$show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
1818
|
|
|
|
1819
|
|
|
} elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
1820
|
|
|
$show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
1821
|
|
|
|
1822
|
|
|
} elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
1823
|
|
|
// Backward compatibility for _give_content_option for v18. |
1824
|
|
|
$show_content = give_get_meta( $form_id, '_give_content_option', true ); |
1825
|
|
|
} |
1826
|
|
|
|
1827
|
|
|
return $show_content; |
1828
|
|
|
} |
1829
|
|
|
|
1830
|
|
|
/** |
1831
|
|
|
* Adds Actions to Render Form Content. |
1832
|
|
|
* |
1833
|
|
|
* @since 1.0 |
1834
|
|
|
* |
1835
|
|
|
* @param int $form_id The form ID. |
1836
|
|
|
* @param array $args An array of form arguments. |
1837
|
|
|
* |
1838
|
|
|
* @return void|bool |
1839
|
|
|
*/ |
1840
|
|
|
function give_form_content( $form_id, $args ) { |
1841
|
|
|
|
1842
|
|
|
$show_content = give_get_form_content_placement( $form_id, $args ); |
1843
|
|
|
|
1844
|
|
|
// Bailout. |
1845
|
|
|
if ( empty( $show_content ) ) { |
1846
|
|
|
return false; |
1847
|
|
|
} |
1848
|
|
|
|
1849
|
|
|
// Add action according to value. |
1850
|
|
|
add_action( $show_content, 'give_form_display_content', 10, 2 ); |
1851
|
|
|
} |
1852
|
|
|
|
1853
|
|
|
add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
1854
|
|
|
|
1855
|
|
|
/** |
1856
|
|
|
* Renders Post Form Content. |
1857
|
|
|
* |
1858
|
|
|
* Displays content for Give forms; fired by action from give_form_content. |
1859
|
|
|
* |
1860
|
|
|
* @since 1.0 |
1861
|
|
|
* |
1862
|
|
|
* @param int $form_id The form ID. |
1863
|
|
|
* @param array $args An array of form arguments. |
1864
|
|
|
* |
1865
|
|
|
* @return void |
1866
|
|
|
*/ |
1867
|
|
|
function give_form_display_content( $form_id, $args ) { |
1868
|
|
|
$content = give_get_meta( $form_id, '_give_form_content', true ); |
1869
|
|
|
$show_content = give_get_form_content_placement( $form_id, $args ); |
1870
|
|
|
|
1871
|
|
|
if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
1872
|
|
|
$content = apply_filters( 'the_content', $content ); |
1873
|
|
|
} else{ |
|
|
|
|
1874
|
|
|
$content = wpautop( do_shortcode( $content ) ); |
1875
|
|
|
} |
1876
|
|
|
|
1877
|
|
|
$output = sprintf( |
1878
|
|
|
'<div id="give-form-content-%s" class="give-form-content-wrap %s-content">%s</div>', |
1879
|
|
|
$form_id, |
1880
|
|
|
$show_content, |
1881
|
|
|
$content |
1882
|
|
|
); |
1883
|
|
|
|
1884
|
|
|
/** |
1885
|
|
|
* Filter form content html |
1886
|
|
|
* |
1887
|
|
|
* @since 1.0 |
1888
|
|
|
* |
1889
|
|
|
* @param string $output |
1890
|
|
|
* @param int $form_id |
1891
|
|
|
* @param array $args |
1892
|
|
|
*/ |
1893
|
|
|
echo apply_filters( 'give_form_content_output', $output, $form_id, $args ); |
|
|
|
|
1894
|
|
|
|
1895
|
|
|
// remove action to prevent content output on addition forms on page. |
1896
|
|
|
// @see: https://github.com/WordImpress/Give/issues/634. |
1897
|
|
|
remove_action( $show_content, 'give_form_display_content' ); |
1898
|
|
|
} |
1899
|
|
|
|
1900
|
|
|
/** |
1901
|
|
|
* Renders the hidden Checkout fields. |
1902
|
|
|
* |
1903
|
|
|
* @since 1.0 |
1904
|
|
|
* |
1905
|
|
|
* @param int $form_id The form ID. |
1906
|
|
|
* |
1907
|
|
|
* @return void |
1908
|
|
|
*/ |
1909
|
|
|
function give_checkout_hidden_fields( $form_id ) { |
1910
|
|
|
|
1911
|
|
|
/** |
1912
|
|
|
* Fires while rendering hidden checkout fields, before the fields. |
1913
|
|
|
* |
1914
|
|
|
* @since 1.0 |
1915
|
|
|
* |
1916
|
|
|
* @param int $form_id The form ID. |
1917
|
|
|
*/ |
1918
|
|
|
do_action( 'give_hidden_fields_before', $form_id ); |
1919
|
|
|
|
1920
|
|
|
if ( is_user_logged_in() ) { ?> |
1921
|
|
|
<input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
|
|
|
|
1922
|
|
|
<?php } ?> |
1923
|
|
|
<input type="hidden" name="give_action" value="purchase"/> |
1924
|
|
|
<input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
|
|
|
1925
|
|
|
<?php |
1926
|
|
|
/** |
1927
|
|
|
* Fires while rendering hidden checkout fields, after the fields. |
1928
|
|
|
* |
1929
|
|
|
* @since 1.0 |
1930
|
|
|
* |
1931
|
|
|
* @param int $form_id The form ID. |
1932
|
|
|
*/ |
1933
|
|
|
do_action( 'give_hidden_fields_after', $form_id ); |
1934
|
|
|
|
1935
|
|
|
} |
1936
|
|
|
|
1937
|
|
|
/** |
1938
|
|
|
* Filter Success Page Content. |
1939
|
|
|
* |
1940
|
|
|
* Applies filters to the success page content. |
1941
|
|
|
* |
1942
|
|
|
* @since 1.0 |
1943
|
|
|
* |
1944
|
|
|
* @param string $content Content before filters. |
1945
|
|
|
* |
1946
|
|
|
* @return string $content Filtered content. |
1947
|
|
|
*/ |
1948
|
|
|
function give_filter_success_page_content( $content ) { |
1949
|
|
|
|
1950
|
|
|
$give_options = give_get_settings(); |
1951
|
|
|
|
1952
|
|
|
if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
1953
|
|
|
if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
1954
|
|
|
$content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
|
|
|
1955
|
|
|
} |
1956
|
|
|
} |
1957
|
|
|
|
1958
|
|
|
return $content; |
1959
|
|
|
} |
1960
|
|
|
|
1961
|
|
|
add_filter( 'the_content', 'give_filter_success_page_content' ); |
1962
|
|
|
|
1963
|
|
|
/** |
1964
|
|
|
* Test Mode Frontend Warning. |
1965
|
|
|
* |
1966
|
|
|
* Displays a notice on the frontend for donation forms. |
1967
|
|
|
* |
1968
|
|
|
* @since 1.1 |
1969
|
|
|
*/ |
1970
|
|
|
function give_test_mode_frontend_warning() { |
1971
|
|
|
|
1972
|
|
|
if ( give_is_test_mode() ) { |
1973
|
|
|
echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
1974
|
|
|
} |
1975
|
|
|
} |
1976
|
|
|
|
1977
|
|
|
add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
1978
|
|
|
|
1979
|
|
|
/** |
1980
|
|
|
* Members-only Form. |
1981
|
|
|
* |
1982
|
|
|
* If "Disable Guest Donations" and "Display Register / Login" is set to none. |
1983
|
|
|
* |
1984
|
|
|
* @since 1.4.1 |
1985
|
|
|
* |
1986
|
|
|
* @param string $final_output |
1987
|
|
|
* @param array $args |
1988
|
|
|
* |
1989
|
|
|
* @return string |
1990
|
|
|
*/ |
1991
|
|
|
function give_members_only_form( $final_output, $args ) { |
1992
|
|
|
|
1993
|
|
|
$form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
1994
|
|
|
|
1995
|
|
|
//Sanity Check: Must have form_id & not be logged in. |
1996
|
|
|
if ( empty( $form_id ) || is_user_logged_in() ) { |
1997
|
|
|
return $final_output; |
1998
|
|
|
} |
1999
|
|
|
|
2000
|
|
|
//Logged in only and Register / Login set to none. |
2001
|
|
|
if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
|
|
|
2002
|
|
|
|
2003
|
|
|
$final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
2004
|
|
|
|
2005
|
|
|
return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
2006
|
|
|
|
2007
|
|
|
} |
2008
|
|
|
|
2009
|
|
|
return $final_output; |
2010
|
|
|
|
2011
|
|
|
} |
2012
|
|
|
|
2013
|
|
|
add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
2014
|
|
|
|
2015
|
|
|
|
2016
|
|
|
/** |
2017
|
|
|
* Add donation form hidden fields. |
2018
|
|
|
* |
2019
|
|
|
* @since 1.8.17 |
2020
|
|
|
* |
2021
|
|
|
* @param int $form_id |
2022
|
|
|
* @param array $args |
2023
|
|
|
* @param Give_Donate_Form $form |
2024
|
|
|
*/ |
2025
|
|
|
function __give_form_add_donation_hidden_field( $form_id, $args, $form ) { |
2026
|
|
|
$id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : ''; |
2027
|
|
|
?> |
2028
|
|
|
<input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/> |
|
|
|
|
2029
|
|
|
<input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/> |
2030
|
|
|
<input type="hidden" name="give-form-title" value="<?php echo esc_html( $form->post_title ); ?>"/> |
2031
|
|
|
<input type="hidden" name="give-current-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
2032
|
|
|
<input type="hidden" name="give-form-url" value="<?php echo esc_url( give_get_current_page_url() ); ?>"/> |
2033
|
|
|
<?php |
2034
|
|
|
// Get the custom option amount. |
2035
|
|
|
$custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
2036
|
|
|
|
2037
|
|
|
// If custom amount enabled. |
2038
|
|
|
if ( give_is_setting_enabled( $custom_amount ) ) { |
2039
|
|
|
?> |
2040
|
|
|
<input type="hidden" name="give-form-minimum" |
2041
|
|
|
value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/> |
|
|
|
|
2042
|
|
|
<input type="hidden" name="give-form-maximum" |
2043
|
|
|
value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/> |
|
|
|
|
2044
|
|
|
<?php |
2045
|
|
|
} |
2046
|
|
|
|
2047
|
|
|
// WP nonce field. |
2048
|
|
|
echo str_replace( |
|
|
|
|
2049
|
|
|
'/>', |
2050
|
|
|
'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>', |
2051
|
|
|
give_get_nonce_field( "give_donation_form_nonce_{$form_id}", 'give-form-hash', false ) |
2052
|
|
|
); |
2053
|
|
|
|
2054
|
|
|
// Price ID hidden field for variable (multi-level) donation forms. |
2055
|
|
|
if ( give_has_variable_prices( $form_id ) ) { |
2056
|
|
|
|
2057
|
|
|
// Get default selected price ID. |
2058
|
|
|
$prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
2059
|
|
|
$price_id = 0; |
2060
|
|
|
|
2061
|
|
|
// Loop through prices. |
2062
|
|
|
foreach ( $prices as $price ) { |
2063
|
|
|
if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
|
|
|
2064
|
|
|
$price_id = $price['_give_id']['level_id']; |
2065
|
|
|
}; |
2066
|
|
|
} |
2067
|
|
|
|
|
|
|
|
2068
|
|
|
|
2069
|
|
|
echo sprintf( |
|
|
|
|
2070
|
|
|
'<input type="hidden" name="give-price-id" value="%s"/>', |
2071
|
|
|
$price_id |
2072
|
|
|
); |
2073
|
|
|
} |
2074
|
|
|
} |
2075
|
|
|
|
2076
|
|
|
add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 ); |
2077
|
|
|
|
2078
|
|
|
/** |
2079
|
|
|
* Add currency settings on donation form. |
2080
|
|
|
* |
2081
|
|
|
* @since 1.8.17 |
2082
|
|
|
* |
2083
|
|
|
* @param array $form_html_tags |
2084
|
|
|
* @param Give_Donate_Form $form |
2085
|
|
|
* |
2086
|
|
|
* @return array |
2087
|
|
|
*/ |
2088
|
|
|
function __give_form_add_currency_settings( $form_html_tags, $form ) { |
2089
|
|
|
$form_currency = give_get_currency( $form->ID ); |
2090
|
|
|
$currency_settings = give_get_currency_formatting_settings( $form_currency ); |
2091
|
|
|
|
2092
|
|
|
// Check if currency exist. |
2093
|
|
|
if ( empty( $currency_settings ) ) { |
2094
|
|
|
return $form_html_tags; |
2095
|
|
|
} |
2096
|
|
|
|
2097
|
|
|
$form_html_tags['data-currency_symbol'] = give_currency_symbol( $form_currency ); |
2098
|
|
|
$form_html_tags['data-currency_code'] = $form_currency; |
2099
|
|
|
|
2100
|
|
|
if ( ! empty( $currency_settings ) ) { |
2101
|
|
|
foreach ( $currency_settings as $key => $value ) { |
2102
|
|
|
$form_html_tags["data-{$key}"] = $value; |
|
|
|
|
2103
|
|
|
} |
2104
|
|
|
} |
2105
|
|
|
|
2106
|
|
|
return $form_html_tags; |
2107
|
|
|
} |
2108
|
|
|
|
2109
|
|
|
add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 ); |
2110
|
|
|
|
2111
|
|
|
/** |
2112
|
|
|
* Adds classes to progress bar container. |
2113
|
|
|
* |
2114
|
|
|
* @since 2.1 |
2115
|
|
|
* |
2116
|
|
|
* @param string $class_goal |
2117
|
|
|
* |
2118
|
|
|
* @return string |
2119
|
|
|
*/ |
2120
|
|
|
function add_give_goal_progress_class( $class_goal ) { |
|
|
|
|
2121
|
|
|
$class_goal = 'progress progress-striped active'; |
2122
|
|
|
|
2123
|
|
|
return $class_goal; |
2124
|
|
|
} |
2125
|
|
|
|
2126
|
|
|
/** |
2127
|
|
|
* Adds classes to progress bar span tag. |
2128
|
|
|
* |
2129
|
|
|
* @since 2.1 |
2130
|
|
|
* |
2131
|
|
|
* @param string $class_bar |
2132
|
|
|
* |
2133
|
|
|
* @return string |
2134
|
|
|
*/ |
2135
|
|
|
function add_give_goal_progress_bar_class( $class_bar ) { |
|
|
|
|
2136
|
|
|
$class_bar = 'bar'; |
2137
|
|
|
|
2138
|
|
|
return $class_bar; |
2139
|
|
|
} |
2140
|
|
|
|
2141
|
|
|
/** |
2142
|
|
|
* Add a class to the form wrap on the grid page. |
2143
|
|
|
* |
2144
|
|
|
* @param array $class Array of form wrapper classes. |
2145
|
|
|
* @param int $id ID of the form. |
2146
|
|
|
* @param array $args Additional args. |
2147
|
|
|
* |
2148
|
|
|
* @since 2.1 |
2149
|
|
|
* |
2150
|
|
|
* @return array |
2151
|
|
|
*/ |
2152
|
|
|
function add_class_for_form_grid( $class, $id, $args ) { |
|
|
|
|
2153
|
|
|
$class[] = 'give-form-grid-wrap'; |
2154
|
|
|
|
2155
|
|
|
foreach ( $class as $index => $item ) { |
2156
|
|
|
if( false !== strpos( $item, 'give-display-' ) ) { |
|
|
|
|
2157
|
|
|
unset( $class[$index] ); |
|
|
|
|
2158
|
|
|
} |
2159
|
|
|
} |
2160
|
|
|
|
2161
|
|
|
return $class; |
2162
|
|
|
} |
2163
|
|
|
|
2164
|
|
|
/** |
2165
|
|
|
* Add hidden field to Form Grid page |
2166
|
|
|
* |
2167
|
|
|
* @param int $form_id The form ID. |
|
|
|
|
2168
|
|
|
* @param array $args An array of form arguments. |
2169
|
|
|
* @param Give_Donate_Form $form Form object. |
2170
|
|
|
* |
2171
|
|
|
* @since 2.1 |
2172
|
|
|
*/ |
2173
|
|
|
function give_is_form_grid_page_hidden_field( $id, $args, $form ) { |
|
|
|
|
2174
|
|
|
echo '<input type="hidden" name="is-form-grid" value="true" />'; |
2175
|
|
|
} |
2176
|
|
|
|
2177
|
|
|
/** |
2178
|
|
|
* Redirect to the same paginated URL on the Form Grid page |
2179
|
|
|
* and adds query parameters to open the popup again after |
2180
|
|
|
* redirection. |
2181
|
|
|
* |
2182
|
|
|
* @param string $redirect URL for redirection. |
2183
|
|
|
* @param array $args Array of additional args. |
2184
|
|
|
* |
2185
|
|
|
* @since 2.1 |
2186
|
|
|
* @return string |
2187
|
|
|
*/ |
2188
|
|
|
function give_redirect_and_popup_form( $redirect, $args ) { |
2189
|
|
|
|
2190
|
|
|
// Check the page has Form Grid. |
2191
|
|
|
$is_form_grid = isset( $_POST['is-form-grid'] ) ? give_clean( $_POST['is-form-grid'] ) : ''; |
|
|
|
|
2192
|
|
|
|
2193
|
|
|
if ( 'true' === $is_form_grid ) { |
2194
|
|
|
|
2195
|
|
|
$payment_mode = give_clean( $_POST['payment-mode'] ); |
|
|
|
|
2196
|
|
|
$form_id = $args['form-id']; |
2197
|
|
|
|
2198
|
|
|
// Get the URL without Query parameters. |
2199
|
|
|
$redirect = strtok( $redirect, '?' ); |
2200
|
|
|
|
2201
|
|
|
// Add query parameters 'form-id' and 'payment-mode'. |
2202
|
|
|
$redirect = add_query_arg( array( |
2203
|
|
|
'form-id' => $form_id, |
2204
|
|
|
'payment-mode' => $payment_mode, |
2205
|
|
|
), $redirect ); |
2206
|
|
|
} |
2207
|
|
|
|
2208
|
|
|
// Return the modified URL. |
2209
|
|
|
return $redirect; |
2210
|
|
|
} |
2211
|
|
|
|
2212
|
|
|
add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 ); |
2213
|
|
|
|