PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | includes/forms/template.php +680 -521 2.3.24.16.9 View file →
@@ -18,32 +18,44 @@
18 18 * Get Donation Form.
19 19 *
20 20 * @param array $args An array of form arguments.
21 21 *
22 + * @return string Donation form.
22 23 * @since 1.0
23 - *
24 - * @return string Donation form.
25 24 */
26 -function give_get_donation_form( $args = array() ) {
25 +function give_get_donation_form( $args = [] ) {
27 26
28 27 global $post;
29 28 static $count = 1;
30 29
31 - $form_id = is_object( $post ) ? $post->ID : 0;
30 + /**
31 + * @since 3.11.0 sanitize $args
32 + */
33 + $args = give_clean($args);
32 34
33 - if ( isset( $args['id'] ) ) {
34 - $form_id = $args['id'];
35 + $args = wp_parse_args( $args, give_get_default_form_shortcode_args() );
36 +
37 + // Backward compatibility for `form_id` function param.
38 + // If are calling this function directly with `form_id` the use `id` instead.
39 + $args['id'] = ! empty( $args['form_id'] ) ? absint( $args['form_id'] ) : $args['id'];
40 +
41 + // If `id` is not set then maybe we are single donation form page, so lets render form.
42 + if ( empty( $args['id'] ) && is_object( $post ) && $post->ID ) {
43 + $args['id'] = $post->ID;
35 44 }
36 45
37 - $defaults = apply_filters(
38 - 'give_form_args_defaults', array(
39 - 'form_id' => $form_id,
40 - )
41 - );
46 + // set `form_id` for backward compatibility because many legacy filters and functions are using it.
47 + $args['form_id'] = $args['id'];
42 48
43 - $args = wp_parse_args( $args, $defaults );
49 + /**
50 + * Fire the filter
51 + * Note: we will deprecate this filter soon. Use give_get_default_form_shortcode_args instead
52 + *
53 + * @deprecated 2.4.1
54 + */
55 + $args = apply_filters( 'give_form_args_defaults', $args );
44 56
45 - $form = new Give_Donate_Form( $args['form_id'] );
57 + $form = new Give_Donate_Form( $args['id'] );
46 58
47 59 // Bail out, if no form ID.
48 60 if ( empty( $form->ID ) ) {
49 61 return false;
@@ -48,16 +60,18 @@
48 60 if ( empty( $form->ID ) ) {
49 61 return false;
50 62 }
51 63
52 - $args['id_prefix'] = "{$form_id}-{$count}";
64 + $args['id_prefix'] = "{$form->ID}-{$count}";
53 65 $payment_mode = give_get_chosen_gateway( $form->ID );
54 66
55 67 $form_action = add_query_arg(
56 68 apply_filters(
57 - 'give_form_action_args', array(
69 + 'give_form_action_args',
70 + [
58 71 'payment-mode' => $payment_mode,
59 - )
72 + 'form-id' => $form->ID,
73 + ]
60 74 ),
61 75 give_get_current_page_url()
62 76 );
63 77
@@ -79,12 +93,12 @@
79 93
80 94 /**
81 95 * Fires while outputting donation form, before the form wrapper div.
82 96 *
97 + * @param int Give_Donate_Form::ID The form ID.
98 + * @param array $args An array of form arguments.
99 + *
83 100 * @since 1.0
84 - *
85 - * @param int $form_id The form ID.
86 - * @param array $args An array of form arguments.
87 101 */
88 102 do_action( 'give_pre_form_output', $form->ID, $args, $form );
89 103
90 104 ?>
@@ -91,12 +105,12 @@
91 105 <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>">
92 106 <?php
93 107 if ( $form->is_close_donation_form() ) {
94 108
95 - $form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ) : '';
109 + $form_title = ! is_singular( 'give_forms' ) ? apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form->ID ) . '</h2>' ) : '';
96 110
97 111 // Get Goal thank you message.
98 - $goal_achieved_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true );
112 + $goal_achieved_message = give_get_meta( $form->ID, '_give_form_goal_achieved_message', true );
99 113 $goal_achieved_message = ! empty( $goal_achieved_message ) ? $form_title . apply_filters( 'the_content', $goal_achieved_message ) : '';
100 114
101 115 // Print thank you message.
102 116 echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID, $form );
@@ -103,19 +117,13 @@
103 117
104 118 } else {
105 119 /**
106 120 * Show form title:
107 - * 1. if show_title params set to true
108 - * 2. if admin set form display_style to button
121 + * 1. if admin set form display_style to button or modal
109 122 */
110 - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' );
111 - if (
112 - (
113 - ( isset( $args['show_title'] ) && $args['show_title'] == true )
114 - || ( 'button' === get_post_meta( $form_id, '_give_payment_display', true ) )
115 - )
116 - && ! doing_action( 'give_single_form_summary' )
117 - ) {
123 + $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form->ID ) . '</h2>' );
124 +
125 + if ( ! doing_action( 'give_single_form_summary' ) && true === $args['show_title'] ) {
118 126 echo $form_title;
119 127 }
120 128
121 129 /**
@@ -120,31 +128,31 @@
120 128
121 129 /**
122 130 * Fires while outputting donation form, before the form.
123 131 *
132 + * @param int Give_Donate_Form::ID The form ID.
133 + * @param array $args An array of form arguments.
134 + * @param Give_Donate_Form $form Form object.
135 + *
124 136 * @since 1.0
125 - *
126 - * @param int $form_id The form ID.
127 - * @param array $args An array of form arguments.
128 - * @param Give_Donate_Form $form Form object.
129 137 */
130 138 do_action( 'give_pre_form', $form->ID, $args, $form );
131 139
132 140 // Set form html tags.
133 - $form_html_tags = array(
141 + $form_html_tags = [
134 142 'id' => "give-form-{$args['id_prefix']}",
135 143 'class' => $form_classes,
136 144 'action' => esc_url_raw( $form_action ),
137 - 'data-id' => $args['id_prefix'],
138 - );
145 + 'data-id' => $args['id_prefix']
146 + ];
139 147
140 148 /**
141 149 * Filter the form html tags.
142 150 *
143 - * @since 1.8.17
144 - *
145 151 * @param array $form_html_tags Array of form html tags.
146 152 * @param Give_Donate_Form $form Form object.
153 + *
154 + * @since 1.8.17
147 155 */
148 156 $form_html_tags = apply_filters( 'give_form_html_tags', (array) $form_html_tags, $form );
149 157 ?>
150 158 <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post">
@@ -149,11 +157,11 @@
149 157 ?>
150 158 <form <?php echo give_get_attribute_str( $form_html_tags ); ?> method="post">
151 159 <!-- The following field is for robots only, invisible to humans: -->
152 160 <span class="give-hidden" style="display: none !important;">
153 - <label for="give-form-honeypot-<?php echo $form_id; ?>"></label>
154 - <input id="give-form-honeypot-<?php echo $form_id; ?>" type="text" name="give-honeypot"
155 - class="give-honeypot give-hidden"/>
161 + <label for="give-form-honeypot-<?php echo $form->ID; ?>"></label>
162 + <input id="give-form-honeypot-<?php echo $form->ID; ?>" type="text" name="give-honeypot"
163 + class="give-honeypot give-hidden"/>
156 164 </span>
157 165
158 166 <?php
159 167 /**
@@ -158,13 +166,13 @@
158 166 <?php
159 167 /**
160 168 * Fires while outputting donation form, before all other fields.
161 169 *
170 + * @param int Give_Donate_Form::ID The form ID.
171 + * @param array $args An array of form arguments.
172 + * @param Give_Donate_Form $form Form object.
173 + *
162 174 * @since 1.0
163 - *
164 - * @param int $form_id The form ID.
165 - * @param array $args An array of form arguments.
166 - * @param Give_Donate_Form $form Form object.
167 175 */
168 176 do_action( 'give_donation_form_top', $form->ID, $args, $form );
169 177
170 178 /**
@@ -169,13 +177,13 @@
169 177
170 178 /**
171 179 * Fires while outputting donation form, for payment gateway fields.
172 180 *
181 + * @param int Give_Donate_Form::ID The form ID.
182 + * @param array $args An array of form arguments.
183 + * @param Give_Donate_Form $form Form object.
184 + *
173 185 * @since 1.7
174 - *
175 - * @param int $form_id The form ID.
176 - * @param array $args An array of form arguments.
177 - * @param Give_Donate_Form $form Form object.
178 186 */
179 187 do_action( 'give_payment_mode_select', $form->ID, $args, $form );
180 188
181 189 /**
@@ -180,13 +188,13 @@
180 188
181 189 /**
182 190 * Fires while outputting donation form, after all other fields.
183 191 *
192 + * @param int Give_Donate_Form::ID The form ID.
193 + * @param array $args An array of form arguments.
194 + * @param Give_Donate_Form $form Form object.
195 + *
184 196 * @since 1.0
185 - *
186 - * @param int $form_id The form ID.
187 - * @param array $args An array of form arguments.
188 - * @param Give_Donate_Form $form Form object.
189 197 */
190 198 do_action( 'give_donation_form_bottom', $form->ID, $args, $form );
191 199
192 200 ?>
@@ -195,13 +203,13 @@
195 203 <?php
196 204 /**
197 205 * Fires while outputting donation form, after the form.
198 206 *
207 + * @param int Give_Donate_Form::ID The form ID.
208 + * @param array $args An array of form arguments.
209 + * @param Give_Donate_Form $form Form object.
210 + *
199 211 * @since 1.0
200 - *
201 - * @param int $form_id The form ID.
202 - * @param array $args An array of form arguments.
203 - * @param Give_Donate_Form $form Form object.
204 212 */
205 213 do_action( 'give_post_form', $form->ID, $args, $form );
206 214
207 215 }
@@ -212,12 +220,12 @@
212 220
213 221 /**
214 222 * Fires while outputting donation form, after the form wrapper div.
215 223 *
224 + * @param int Give_Donate_Form::ID The form ID.
225 + * @param array $args An array of form arguments.
226 + *
216 227 * @since 1.0
217 - *
218 - * @param int $form_id The form ID.
219 - * @param array $args An array of form arguments.
220 228 */
221 229 do_action( 'give_post_form_output', $form->ID, $args );
222 230
223 231 $final_output = ob_get_clean();
@@ -233,13 +241,12 @@
233 241 * The default Donation Form rendered displays a list of the enabled payment
234 242 * gateways, a user registration form (if enable) and a credit card info form
235 243 * if credit cards are enabled.
236 244 *
237 - * @since 1.0
245 + * @param int $form_id The form ID.
238 246 *
239 - * @param int $form_id The form ID.
240 - *
241 247 * @return string
248 + * @since 1.0
242 249 */
243 250 function give_show_purchase_form( $form_id, $args ) {
244 251
245 252 $payment_mode = give_get_chosen_gateway( $form_id );
@@ -282,11 +289,11 @@
282 289 if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) {
283 290 /**
284 291 * Fires while displaying donation form, credit card form fields for a given gateway.
285 292 *
293 + * @param int $form_id The form ID.
294 + *
286 295 * @since 1.0
287 - *
288 - * @param int $form_id The form ID.
289 296 */
290 297 do_action( "give_{$payment_mode}_cc_form", $form_id, $args );
291 298 } else {
292 299 /**
@@ -291,11 +298,11 @@
291 298 } else {
292 299 /**
293 300 * Fires while displaying donation form, credit card form fields.
294 301 *
302 + * @param int $form_id The form ID.
303 + *
295 304 * @since 1.0
296 - *
297 - * @param int $form_id The form ID.
298 305 */
299 306 do_action( 'give_cc_form', $form_id, $args );
300 307 }
301 308
@@ -328,13 +335,12 @@
328 335
329 336 /**
330 337 * Give Show Login/Register Form Fields.
331 338 *
332 - * @since 1.4.1
339 + * @param int $form_id The form ID.
333 340 *
334 - * @param int $form_id The form ID.
335 - *
336 341 * @return void
342 + * @since 1.4.1
337 343 */
338 344 function give_show_register_login_fields( $form_id ) {
339 345
340 346 $show_register_form = give_show_login_register_option( $form_id );
@@ -350,9 +356,9 @@
350 356 */
351 357 do_action( 'give_donation_form_register_fields', $form_id );
352 358 ?>
353 359 </div>
354 - <?php
360 + <?php
355 361 elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) :
356 362 ?>
357 363 <div id="give-checkout-login-register-<?php echo $form_id; ?>">
358 364 <?php
@@ -363,9 +369,9 @@
363 369 */
364 370 do_action( 'give_donation_form_login_fields', $form_id );
365 371 ?>
366 372 </div>
367 - <?php
373 + <?php
368 374 endif;
369 375
370 376 if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) {
371 377 /**
@@ -384,16 +390,15 @@
384 390 *
385 391 * Outputs the donation amount field that appears at the top of the donation forms. If the user has custom amount
386 392 * enabled the field will output as a customizable input.
387 393 *
388 - * @since 1.0
394 + * @param int $form_id The form ID.
395 + * @param array $args An array of form arguments.
389 396 *
390 - * @param int $form_id The form ID.
391 - * @param array $args An array of form arguments.
392 - *
393 397 * @return void
398 + * @since 1.0
394 399 */
395 -function give_output_donation_amount_top( $form_id = 0, $args = array() ) {
400 +function give_output_donation_amount_top( $form_id = 0, $args = [] ) {
396 401
397 402 $give_options = give_get_settings();
398 403 $variable_pricing = give_has_variable_prices( $form_id );
399 404 $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true );
@@ -398,14 +403,15 @@
398 403 $variable_pricing = give_has_variable_prices( $form_id );
399 404 $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true );
400 405 $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before';
401 406 $symbol = give_currency_symbol( give_get_currency( $form_id, $args ) );
402 - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>';
407 + $currency_output = '<span class="give-currency-symbol give-currency-position-' . esc_attr($currency_position) . '">' . esc_html($symbol) . '</span>';
403 408 $default_amount = give_format_amount(
404 - give_get_default_form_amount( $form_id ), array(
409 + give_get_default_form_amount( $form_id ),
410 + [
405 411 'sanitize' => false,
406 412 'currency' => give_get_currency( $form_id ),
407 - )
413 + ]
408 414 );
409 415 $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
410 416
411 417 /**
@@ -410,12 +416,12 @@
410 416
411 417 /**
412 418 * Fires while displaying donation form, before donation level fields.
413 419 *
414 - * @since 1.0
415 - *
416 420 * @param int $form_id The form ID.
417 421 * @param array $args An array of form arguments.
422 + *
423 + * @since 1.0
418 424 */
419 425 do_action( 'give_before_donation_levels', $form_id, $args );
420 426
421 427 // Set Price, No Custom Amount Allowed means hidden price field.
@@ -420,11 +426,11 @@
420 426
421 427 // Set Price, No Custom Amount Allowed means hidden price field.
422 428 if ( ! give_is_setting_enabled( $allow_custom_amount ) ) {
423 429 ?>
424 - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label>
430 + <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label>
425 431 <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount"
426 - value="<?php echo $default_amount; ?>" required aria-required="true"/>
432 + value="<?php echo esc_attr($default_amount); ?>" required aria-required="true"/>
427 433 <div class="set-price give-donation-amount form-row-wide">
428 434 <?php
429 435 if ( 'before' === $currency_position ) {
430 436 echo $currency_output;
@@ -448,10 +454,10 @@
448 454 echo $currency_output;
449 455 }
450 456 ?>
451 457 <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label>
452 - <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel"
453 - placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off">
458 + <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="text" inputmode="decimal"
459 + placeholder="" value="<?php echo esc_attr($default_amount); ?>" autocomplete="off">
454 460 <?php
455 461 if ( 'after' === $currency_position ) {
456 462 echo $currency_output;
457 463 }
@@ -461,14 +467,14 @@
461 467 <?php
462 468 }
463 469
464 470 /**
465 - * Fires while displaying donation form, after donation amounf field(s).
471 + * Fires while displaying donation form, after donation amount field(s).
466 472 *
467 - * @since 1.0
468 - *
469 473 * @param int $form_id The form ID.
470 474 * @param array $args An array of form arguments.
475 + *
476 + * @since 1.0
471 477 */
472 478 do_action( 'give_after_donation_amount', $form_id, $args );
473 479
474 480 // Custom Amount Text
@@ -473,9 +479,9 @@
473 479
474 480 // Custom Amount Text
475 481 if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) {
476 482 ?>
477 - <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p>
483 + <p class="give-custom-amount-text"><?php echo esc_html($custom_amount_text); ?></p>
478 484 <?php
479 485 }
480 486
481 487 // Output Variable Pricing Levels.
@@ -485,12 +491,12 @@
485 491
486 492 /**
487 493 * Fires while displaying donation form, after donation level fields.
488 494 *
489 - * @since 1.0
490 - *
491 495 * @param int $form_id The form ID.
492 496 * @param array $args An array of form arguments.
497 + *
498 + * @since 1.0
493 499 */
494 500 do_action( 'give_after_donation_levels', $form_id, $args );
495 501 }
496 502
@@ -500,10 +506,9 @@
500 506 * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons.
501 507 *
502 508 * @since 1.0
503 509 *
504 - * @param int $form_id The form ID.
505 - *
510 + * @param int $form_id The form ID.
506 511 * @return string Donation levels.
507 512 */
508 513 function give_output_levels( $form_id ) {
509 514
@@ -509,14 +514,14 @@
509 514
510 515 /**
511 516 * Filter the variable pricing
512 517 *
513 - * @since 1.0
514 - * @deprecated 2.2 Use give_get_donation_levels filter instead of give_form_variable_prices.
515 - * Check Give_Donate_Form::get_prices().
516 - *
517 518 * @param array $prices Array of variable prices.
518 519 * @param int $form Form ID.
520 + *
521 + * @since 1.0
522 + * @deprecated 2.2 Use give_get_donation_levels filter instead of give_form_variable_prices.
523 + * Check Give_Donate_Form::get_prices().
519 524 */
520 525 $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
521 526
522 527 $display_style = give_get_meta( $form_id, '_give_display_style', true );
@@ -523,9 +528,9 @@
523 528 $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true );
524 529 $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
525 530
526 531 if ( empty( $custom_amount_text ) ) {
527 - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' );
532 + $custom_amount_text = esc_html__( 'Custom Amount', 'give' );
528 533 }
529 534
530 535 $output = '';
531 536
@@ -533,25 +538,26 @@
533 538 case 'buttons':
534 539 $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">';
535 540
536 541 foreach ( $prices as $price ) {
537 - $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 ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ), $form_id, $price );
542 + $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], [ 'sanitize' => false ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ), $form_id, $price );
538 543 $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( give_is_default_level_id( $price ) ? 'give-default-level' : '' ), $form_id, $price );
539 544
540 545 $formatted_amount = give_format_amount(
541 - $price['_give_amount'], array(
546 + $price['_give_amount'],
547 + [
542 548 'sanitize' => false,
543 549 'currency' => give_get_currency( $form_id ),
544 - )
550 + ]
545 551 );
546 552
547 553 $output .= sprintf(
548 554 '<li><button type="button" data-price-id="%1$s" class="%2$s" value="%3$s" data-default="%4$s">%5$s</button></li>',
549 - $price['_give_id']['level_id'],
550 - $level_classes,
551 - $formatted_amount,
555 + esc_attr($price['_give_id']['level_id']),
556 + esc_attr($level_classes),
557 + esc_attr($formatted_amount),
552 558 array_key_exists( '_give_default', $price ) ? 1 : 0,
553 - $level_text
559 + esc_html($level_text)
554 560 );
555 561 }
556 562
557 563 // Custom Amount.
@@ -561,9 +567,9 @@
561 567 ) {
562 568
563 569 $output .= sprintf(
564 570 '<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>',
565 - $custom_amount_text
571 + esc_html( $custom_amount_text )
566 572 );
567 573 }
568 574
569 575 $output .= '</ul>';
@@ -573,26 +579,27 @@
573 579 case 'radios':
574 580 $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">';
575 581
576 582 foreach ( $prices as $price ) {
577 - $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 ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ), $form_id, $price );
583 + $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], [ 'sanitize' => false ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ), $form_id, $price );
578 584 $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( give_is_default_level_id( $price ) ? ' give-default-level' : '' ), $form_id, $price );
579 585
580 586 $formatted_amount = give_format_amount(
581 - $price['_give_amount'], array(
587 + $price['_give_amount'],
588 + [
582 589 'sanitize' => false,
583 590 'currency' => give_get_currency( $form_id ),
584 - )
591 + ]
585 592 );
586 593
587 594 $output .= sprintf(
588 595 '<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>',
589 - $price['_give_id']['level_id'],
590 - $level_classes,
591 - $formatted_amount,
596 + esc_attr($price['_give_id']['level_id']),
597 + esc_attr($level_classes),
598 + esc_attr($formatted_amount),
592 599 ( give_is_default_level_id( $price ) ? 'checked="checked"' : '' ),
593 600 array_key_exists( '_give_default', $price ) ? 1 : 0,
594 - $level_text
601 + esc_html($level_text)
595 602 );
596 603 }
597 604
598 605 // Custom Amount.
@@ -601,9 +608,9 @@
601 608 && ! empty( $custom_amount_text )
602 609 ) {
603 610 $output .= sprintf(
604 611 '<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>',
605 - $custom_amount_text
612 + esc_html( $custom_amount_text )
606 613 );
607 614 }
608 615
609 616 $output .= '</ul>';
@@ -615,29 +622,32 @@
615 622 $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">';
616 623
617 624 // first loop through prices.
618 625 foreach ( $prices as $price ) {
619 - $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 ) ), array( 'currency_code' => give_get_currency( $form_id ) ) ), $form_id, $price );
626 + $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], [ 'sanitize' => false ] ), [ 'currency_code' => give_get_currency( $form_id ) ] ), $form_id, $price );
620 627 $level_classes = apply_filters(
621 - 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( give_is_default_level_id( $price ) ? ' give-default-level' : '' ), $form_id,
628 + 'give_form_level_classes',
629 + 'give-donation-level-' . $price['_give_id']['level_id'] . ( give_is_default_level_id( $price ) ? ' give-default-level' : '' ),
630 + $form_id,
622 631 $price
623 632 );
624 633
625 634 $formatted_amount = give_format_amount(
626 - $price['_give_amount'], array(
635 + $price['_give_amount'],
636 + [
627 637 'sanitize' => false,
628 638 'currency' => give_get_currency( $form_id ),
629 - )
639 + ]
630 640 );
631 641
632 642 $output .= sprintf(
633 643 '<option data-price-id="%1$s" class="%2$s" value="%3$s" %4$s data-default="%5$s">%6$s</option>',
634 - $price['_give_id']['level_id'],
635 - $level_classes,
636 - $formatted_amount,
644 + esc_attr($price['_give_id']['level_id']),
645 + esc_attr($level_classes),
646 + esc_attr($formatted_amount),
637 647 ( give_is_default_level_id( $price ) ? 'selected="selected"' : '' ),
638 648 array_key_exists( '_give_default', $price ) ? 1 : 0,
639 - $level_text
649 + esc_html($level_text)
640 650 );
641 651 }
642 652
643 653 // Custom Amount.
@@ -643,9 +653,9 @@
643 653 // Custom Amount.
644 654 if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) {
645 655 $output .= sprintf(
646 656 '<option data-price-id="custom" class="give-donation-level-custom" value="custom">%1$s</option>',
647 - $custom_amount_text
657 + esc_html( $custom_amount_text )
648 658 );
649 659 }
650 660
651 661 $output .= '</select>';
@@ -660,52 +670,97 @@
660 670 * Display Reveal & Lightbox Button.
661 671 *
662 672 * Outputs a button to reveal form fields.
663 673 *
664 - * @since 1.0
674 + * @param int $form_id The form ID.
675 + * @param array $args An array of form arguments.
665 676 *
666 - * @param int $form_id The form ID.
667 - * @param array $args An array of form arguments.
668 - *
669 677 * @return string Checkout button.
678 + * @since 1.0
670 679 */
671 680 function give_display_checkout_button( $form_id, $args ) {
672 -
673 681 $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
674 682 ? $args['display_style']
675 683 : give_get_meta( $form_id, '_give_payment_display', true );
676 684
677 685 if ( 'button' === $display_option ) {
678 - $display_option = 'modal';
679 - } elseif ( $display_option === 'onpage' ) {
686 + add_action( 'give_post_form', 'give_add_button_open_form', 10, 2 );
680 687 return '';
681 688 }
682 689
690 + if ( $display_option === 'onpage' ) {
691 + return '';
692 + }
693 +
683 694 $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true );
684 695 $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) );
685 696
686 - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>';
697 + $output = '<button type="button" class="give-btn give-btn-' . esc_attr($display_option) . '">' . esc_html($display_label) . '</button>';
687 698
688 - echo apply_filters( 'give_display_checkout_button', $output );
699 + /**
700 + * filter the button html
701 + *
702 + * @param string $output Button HTML.
703 + * @param int $form_id Form ID.
704 + * @param array $args Shortcode argument
705 + */
706 + echo apply_filters( 'give_display_checkout_button', $output, $form_id, $args );
689 707 }
690 708
691 709 add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 );
692 710
693 711 /**
712 + * Display MagnificPopup Button.
713 + *
714 + * @since 2.5.11
715 + *
716 + * @param $form_id
717 + * @param $args
718 + *
719 + * @return string
720 + */
721 +function give_add_button_open_form( $form_id, $args ) {
722 + $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true );
723 + $display_label = ! empty( $args['continue_button_title'] )
724 + ? $args['continue_button_title']
725 + : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) );
726 +
727 + $output = sprintf(
728 + '<button type="button" class="give-btn give-btn-modal">%1$s</button>',
729 + esc_html($display_label)
730 + );
731 +
732 + /**
733 + * filter the button html
734 + *
735 + * @param string $output Button HTML.
736 + * @param int $form_id Form ID.
737 + * @param array $args Shortcode argument
738 + */
739 + echo apply_filters( 'give_display_checkout_button', $output, $form_id, $args );
740 +
741 + // Remove action otherwise button will be added to coming form.
742 + // @see https://github.com/impress-org/givewp/issues/4395
743 + remove_action( 'give_post_form', 'give_add_button_open_form', 10 );
744 +}
745 +
746 +/**
694 747 * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided.
695 748 *
696 - * @since 1.0
749 + * @since 3.1.0 Add the give_user_info_fields_user_info filter
750 + * @since 2.25.0 add radio group to conditionally enable/disable company name field
751 + * @since 1.0
697 752 *
698 - * @param int $form_id The form ID.
753 + * @param int $form_id The form ID.
699 754 *
700 - * @see For Pattern Attribute: https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation
701 - *
702 755 * @return void
756 + * @see For Pattern Attribute: https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Form_validation
703 757 */
704 758 function give_user_info_fields( $form_id ) {
705 759
706 760 // Get user info.
707 - $give_user_info = _give_get_prefill_form_field_values( $form_id );
761 + $give_user_info = apply_filters('give_user_info_fields_user_info', _give_get_prefill_form_field_values( $form_id ), $form_id );
762 +
708 763 $title = ! empty( $give_user_info['give_title'] ) ? $give_user_info['give_title'] : '';
709 764 $first_name = ! empty( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : '';
710 765 $last_name = ! empty( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : '';
711 766 $company_name = ! empty( $give_user_info['company_name'] ) ? $give_user_info['company_name'] : '';
@@ -735,135 +790,245 @@
735 790 <?php esc_attr_e( 'Title', 'give' ); ?>
736 791 <?php if ( give_field_is_required( 'give_title', $form_id ) ) : ?>
737 792 <span class="give-required-indicator">*</span>
738 793 <?php endif ?>
739 - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?>
794 + <?php echo Give()->tooltips->render_help( __( 'Title is used to personalize your donation record..', 'give' ) ); ?>
740 795 </label>
741 796 <select
742 - class="give-input required"
797 + class="give-input"
743 798 type="text"
744 799 name="give_title"
745 800 id="give-title"
746 - <?php echo( give_field_is_required( 'give_title', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
747 - >
748 - <?php foreach ( $title_prefixes as $key => $value ) { ?>
749 - <option
750 - value="<?php echo esc_html( $value ); ?>" <?php selected( $value, $title, true ); ?>><?php echo esc_html( $value ); ?></option>
751 - <?php } ?>
752 - </select>
753 - </p>
754 - <?php } ?>
801 + <?php
802 + echo(give_field_is_required('give_title', $form_id) ? ' required aria-required="true" ' : ''); ?>
803 + >
804 + <?php
805 + foreach ($title_prefixes as $key => $value) { ?>
806 + <option
807 + value="<?php
808 + echo esc_html($value); ?>" <?php
809 + selected($value, $title, true); ?>><?php
810 + echo esc_html($value); ?></option>
811 + <?php
812 + } ?>
813 + </select>
814 + </p>
815 + <?php
816 + } ?>
755 817
756 - <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive">
757 - <label class="give-label" for="give-first">
758 - <?php esc_attr_e( 'First Name', 'give' ); ?>
759 - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?>
760 - <span class="give-required-indicator">*</span>
761 - <?php endif ?>
762 - <?php echo Give()->tooltips->render_help( __( 'We will use this to personalize your account experience.', 'give' ) ); ?>
763 - </label>
764 - <input
765 - class="give-input required"
766 - type="text"
767 - name="give_first"
768 - autocomplete="given-name"
769 - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>"
770 - id="give-first"
771 - value="<?php echo esc_html( $first_name ); ?>"
772 - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
773 - />
774 - </p>
818 + <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive">
819 + <label class="give-label" for="give-first">
820 + <?php
821 + esc_attr_e('First Name', 'give'); ?>
822 + <?php
823 + if (give_field_is_required('give_first', $form_id)) : ?>
824 + <span class="give-required-indicator">*</span>
825 + <?php
826 + endif ?>
827 + <?php
828 + echo Give()->tooltips->render_help(__('First Name is used to personalize your donation record.',
829 + 'give')); ?>
830 + </label>
831 + <input
832 + class="give-input required"
833 + type="text"
834 + name="give_first"
835 + autocomplete="given-name"
836 + placeholder="<?php
837 + esc_attr_e('First Name', 'give'); ?>"
838 + id="give-first"
839 + value="<?php
840 + echo esc_html($first_name); ?>"
841 + <?php
842 + echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?>
843 + />
844 + </p>
775 845
776 - <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive">
777 - <label class="give-label" for="give-last">
778 - <?php esc_attr_e( 'Last Name', 'give' ); ?>
779 - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?>
780 - <span class="give-required-indicator">*</span>
781 - <?php endif ?>
782 - <?php echo Give()->tooltips->render_help( __( 'We will use this as well to personalize your account experience.', 'give' ) ); ?>
783 - </label>
846 + <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive">
847 + <label class="give-label" for="give-last">
848 + <?php
849 + esc_attr_e('Last Name', 'give'); ?>
850 + <?php
851 + if (give_field_is_required('give_last', $form_id)) : ?>
852 + <span class="give-required-indicator">*</span>
853 + <?php
854 + endif ?>
855 + <?php
856 + echo Give()->tooltips->render_help(__('Last Name is used to personalize your donation record.',
857 + 'give')); ?>
858 + </label>
784 859
785 - <input
786 - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>"
787 - type="text"
788 - name="give_last"
789 - autocomplete="family-name"
790 - id="give-last"
791 - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>"
792 - value="<?php echo esc_html( $last_name ); ?>"
793 - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
794 - />
795 - </p>
860 + <input
861 + class="give-input<?php
862 + echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>"
863 + type="text"
864 + name="give_last"
865 + autocomplete="family-name"
866 + id="give-last"
867 + placeholder="<?php
868 + esc_attr_e('Last Name', 'give'); ?>"
869 + value="<?php
870 + echo esc_html($last_name); ?>"
871 + <?php
872 + echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?>
873 + />
874 + </p>
796 875
797 - <?php if ( give_is_company_field_enabled( $form_id ) ) : ?>
798 - <?php $give_company = give_field_is_required( 'give_company_name', $form_id ); ?>
799 - <p id="give-company-wrap" class="form-row form-row-wide">
800 - <label class="give-label" for="give-company">
801 - <?php esc_attr_e( 'Company Name', 'give' ); ?>
802 - <?php if ( $give_company ) : ?>
803 - <span class="give-required-indicator">*</span>
804 - <?php endif; ?>
805 - <?php echo Give()->tooltips->render_help( __( 'Donate on behalf of Company', 'give' ) ); ?>
806 - </label>
807 - <input
808 - class="give-input<?php echo( $give_company ? ' required' : '' ); ?>"
809 - type="text"
810 - name="give_company_name"
811 - placeholder="<?php esc_attr_e( 'Company Name', 'give' ); ?>"
812 - id="give-company"
813 - value="<?php echo esc_html( $company_name ); ?>"
814 - <?php echo( $give_company ? ' required aria-required="true" ' : '' ); ?>
815 - />
816 - </p>
817 - <?php endif ?>
876 + <?php
877 + if (give_is_company_field_enabled($form_id)) :
878 + $give_company = give_field_is_required('give_company_name', $form_id);
818 879
819 - <?php
820 - /**
821 - * Fire before user email field
822 - *
823 - * @since 1.7
824 - */
825 - do_action( 'give_donation_form_before_email', $form_id );
826 - ?>
827 - <p id="give-email-wrap" class="form-row form-row-wide">
828 - <label class="give-label" for="give-email">
829 - <?php esc_attr_e( 'Email Address', 'give' ); ?>
830 - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?>
831 - <span class="give-required-indicator">*</span>
832 - <?php } ?>
833 - <?php echo Give()->tooltips->render_help( __( 'We will send the donation receipt to this address.', 'give' ) ); ?>
834 - </label>
835 - <input
836 - class="give-input required"
837 - type="email"
838 - name="give_email"
839 - autocomplete="email"
840 - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>"
841 - id="give-email"
842 - value="<?php echo esc_html( $email ); ?>"
843 - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
844 - />
880 + if ( ! $give_company) :
881 + ?>
882 + <div id="give-company-radio-list-wrap" class="form-row form-row-wide">
883 + <label><?php
884 + esc_html_e('Is this donation on behalf of a company?', 'give'); ?></label>
885 + <ul id="<?php
886 + echo esc_attr('give-company-name-radio-list'); ?>" class="give-company-radio-list">
887 + <li>
888 + <input
889 + checked
890 + type="radio"
891 + id="<?php
892 + echo esc_attr('give-no-company'); ?>"
893 + class="give_company_option"
894 + name="give_company_option"
895 + value="no"
896 + />
897 + <label for="<?php
898 + echo esc_attr('give-no-company'); ?>" class="give-company-option"
899 + id="<?php
900 + echo esc_attr('give-no-company'); ?>">
901 + <?php
902 + esc_html_e('No', 'give'); ?>
903 + </label>
904 + </li>
905 + <li>
906 + <input
907 + type="radio"
908 + id="<?php
909 + echo esc_attr('give-has-company'); ?>"
910 + class="give_company_option"
911 + name="give_company_option"
912 + value="yes"
913 + />
914 + <label for="<?php
915 + echo esc_attr('give-has-company'); ?>" class="give-company-option"
916 + id="<?php
917 + echo esc_attr('give-has-company'); ?>">
918 + <?php
919 + esc_html_e('Yes', 'give'); ?>
920 + </label>
921 + </li>
922 + </ul>
923 + </div>
924 + <?php
925 + endif; ?>
926 + <p id="give-company-wrap" class="form-row form-row-wide">
927 + <label class="give-label" for="give-company">
928 + <?php
929 + esc_attr_e('Company Name', 'give'); ?>
930 + <?php
931 + if ($give_company) : ?>
932 + <span class="give-required-indicator">*</span>
933 + <?php
934 + endif; ?>
935 + <?php
936 + echo Give()->tooltips->render_help(__('Donate on behalf of Company', 'give')); ?>
937 + </label>
938 + <input
939 + class="give-input<?php
940 + echo($give_company ? ' required' : ''); ?>"
941 + type="text"
942 + name="give_company_name"
943 + placeholder="<?php
944 + esc_attr_e('Company Name', 'give'); ?>"
945 + id="give-company"
946 + value="<?php
947 + echo esc_html($company_name); ?>"
948 + <?php
949 + echo($give_company ? ' required aria-required="true" ' : ''); ?>
950 + />
951 + </p>
952 + <?php
953 + endif ?>
845 954
846 - </p>
955 + <?php
956 + /**
957 + * Fire before user email field
958 + *
959 + * @since 1.7
960 + */
961 + do_action('give_donation_form_before_email', $form_id);
962 + ?>
963 + <p id="give-email-wrap" class="form-row form-row-wide">
964 + <label class="give-label" for="give-email">
965 + <?php
966 + esc_attr_e('Email Address', 'give'); ?>
967 + <?php
968 + if (give_field_is_required('give_email', $form_id)) { ?>
969 + <span class="give-required-indicator">*</span>
970 + <?php
971 + } ?>
972 + <?php
973 + echo Give()->tooltips->render_help(__('We will send the donation receipt to this address.', 'give')); ?>
974 + </label>
975 + <input
976 + class="give-input required"
977 + type="email"
978 + name="give_email"
979 + autocomplete="email"
980 + placeholder="<?php
981 + esc_attr_e('Email Address', 'give'); ?>"
982 + id="give-email"
983 + value="<?php
984 + echo esc_html($email); ?>"
985 + <?php
986 + echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?>
987 + />
847 988
848 - <?php if ( give_is_anonymous_donation_field_enabled( $form_id ) ) : ?>
849 - <?php $is_anonymous_donation = isset( $_POST['give_anonymous_donation'] ) ? absint( $_POST['give_anonymous_donation'] ) : 0; ?>
850 - <p id="give-anonymous-donation-wrap" class="form-row form-row-wide">
851 - <label class="give-label" for="give-anonymous-donation">
852 - <input
853 - type="checkbox"
854 - class="give-input<?php echo( give_field_is_required( 'give_anonymous_donation', $form_id ) ? ' required' : '' ); ?>"
855 - name="give_anonymous_donation"
856 - id="give-anonymous-donation"
857 - value="1"
858 - <?php echo( give_field_is_required( 'give_anonymous_donation', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
859 - <?php checked( 1, $is_anonymous_donation ); ?>
860 - >
861 - <?php _e( 'Make this an anonymous donation', 'give' ); ?>
862 - <?php if ( give_field_is_required( 'give_comment', $form_id ) ) { ?>
989 + </p>
990 +
991 + <?php
992 + if (give_is_anonymous_donation_field_enabled($form_id)) : ?>
993 + <?php
994 + $is_anonymous_donation = isset($_POST['give_anonymous_donation']) ? absint($_POST['give_anonymous_donation']) : 0; ?>
995 + <p id="give-anonymous-donation-wrap" class="form-row form-row-wide">
996 + <label class="give-label" for="give-anonymous-donation">
997 + <input
998 + type="checkbox"
999 + class="give-input<?php
1000 + echo(give_field_is_required('give_anonymous_donation', $form_id) ? ' required' : ''); ?>"
1001 + name="give_anonymous_donation"
1002 + id="give-anonymous-donation"
1003 + value="1"
1004 + <?php
1005 + echo(give_field_is_required('give_anonymous_donation',
1006 + $form_id) ? ' required aria-required="true" ' : ''); ?>
1007 + <?php
1008 + checked(1, $is_anonymous_donation); ?>
1009 + >
1010 + <?php
1011 + /**
1012 + * Filters the checkbox label.
1013 + *
1014 + * @since 2.4.1
1015 + */
1016 + echo apply_filters('give_anonymous_donation_checkbox_label',
1017 + __('Make this an anonymous donation.', 'give'), $form_id);
1018 +
1019 + if ( give_field_is_required( 'give_comment', $form_id ) ) {
1020 + ?>
863 1021 <span class="give-required-indicator">*</span>
864 1022 <?php } ?>
865 - <?php echo Give()->tooltips->render_help( esc_html__( 'Would you like to prevent this donation from being displayed publicly?', 'give' ) ); ?>
1023 + <?php
1024 + // Conditional tooltip text when comments enabled:
1025 + // https://github.com/impress-org/give/issues/3911
1026 + $anonymous_donation_tooltip = give_is_donor_comment_field_enabled( $form_id ) ? esc_html__( 'Would you like to prevent your name, image, and comment from being displayed publicly?', 'give' ) : esc_html__( 'Would you like to prevent your name and image from being displayed publicly?', 'give' );
1027 +
1028 + echo Give()->tooltips->render_help( $anonymous_donation_tooltip );
1029 + ?>
1030 +
866 1031 </label>
867 1032 </p>
868 1033 <?php endif; ?>
869 1034
@@ -917,13 +1082,12 @@
917 1082
918 1083 /**
919 1084 * Renders the credit card info form.
920 1085 *
921 - * @since 1.0
1086 + * @param int $form_id The form ID.
922 1087 *
923 - * @param int $form_id The form ID.
924 - *
925 1088 * @return void
1089 + * @since 1.0
926 1090 */
927 1091 function give_get_cc_form( $form_id ) {
928 1092
929 1093 ob_start();
@@ -930,11 +1094,11 @@
930 1094
931 1095 /**
932 1096 * Fires while rendering credit card info form, before the fields.
933 1097 *
1098 + * @param int $form_id The form ID.
1099 + *
934 1100 * @since 1.0
935 - *
936 - * @param int $form_id The form ID.
937 1101 */
938 1102 do_action( 'give_before_cc_fields', $form_id );
939 1103 ?>
940 1104 <fieldset id="give_cc_fields-<?php echo $form_id; ?>" class="give-do-validate">
@@ -953,10 +1117,10 @@
953 1117 <span class="card-type"></span>
954 1118 </label>
955 1119
956 1120 <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id; ?>"
957 - class="card-number give-input required" placeholder="<?php _e( 'Card number', 'give' ); ?>"
958 - required aria-required="true"/>
1121 + class="card-number give-input required" placeholder="<?php _e( 'Card Number', 'give' ); ?>"
1122 + required aria-required="true"/>
959 1123 </p>
960 1124
961 1125 <p id="give-card-cvc-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-responsive">
962 1126 <label for="card_cvc-<?php echo $form_id; ?>" class="give-label">
@@ -965,10 +1129,10 @@
965 1129 <?php echo Give()->tooltips->render_help( __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ) ); ?>
966 1130 </label>
967 1131
968 1132 <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id; ?>"
969 - class="card-cvc give-input required" placeholder="<?php _e( 'Security code', 'give' ); ?>"
970 - required aria-required="true"/>
1133 + class="card-cvc give-input required" placeholder="<?php _e( 'CVC', 'give' ); ?>"
1134 + required aria-required="true"/>
971 1135 </p>
972 1136
973 1137 <p id="give-card-name-wrap-<?php echo $form_id; ?>" class="form-row form-row-two-thirds form-row-responsive">
974 1138 <label for="card_name-<?php echo $form_id; ?>" class="give-label">
@@ -977,18 +1141,18 @@
977 1141 <?php echo Give()->tooltips->render_help( __( 'The name of the credit card account holder.', 'give' ) ); ?>
978 1142 </label>
979 1143
980 1144 <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id; ?>"
981 - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Cardholder Name', 'give' ); ?>"
982 - required aria-required="true"/>
1145 + class="card-name give-input required" placeholder="<?php esc_attr_e( 'Cardholder Name', 'give' ); ?>"
1146 + required aria-required="true"/>
983 1147 </p>
984 1148 <?php
985 1149 /**
986 1150 * Fires while rendering credit card info form, before expiration fields.
987 1151 *
1152 + * @param int $form_id The form ID.
1153 + *
988 1154 * @since 1.0
989 - *
990 - * @param int $form_id The form ID.
991 1155 */
992 1156 do_action( 'give_before_cc_expiration' );
993 1157 ?>
994 1158 <p class="card-expiration form-row form-row-one-third form-row-responsive">
@@ -998,23 +1162,23 @@
998 1162 <?php echo Give()->tooltips->render_help( __( 'The date your credit card expires, typically on the front of the card.', 'give' ) ); ?>
999 1163 </label>
1000 1164
1001 1165 <input type="hidden" id="card_exp_month-<?php echo $form_id; ?>" name="card_exp_month"
1002 - class="card-expiry-month"/>
1166 + class="card-expiry-month"/>
1003 1167 <input type="hidden" id="card_exp_year-<?php echo $form_id; ?>" name="card_exp_year"
1004 - class="card-expiry-year"/>
1168 + class="card-expiry-year"/>
1005 1169
1006 1170 <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id; ?>"
1007 - class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>"
1008 - required aria-required="true"/>
1171 + class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>"
1172 + required aria-required="true"/>
1009 1173 </p>
1010 1174 <?php
1011 1175 /**
1012 1176 * Fires while rendering credit card info form, after expiration fields.
1013 1177 *
1178 + * @param int $form_id The form ID.
1179 + *
1014 1180 * @since 1.0
1015 - *
1016 - * @param int $form_id The form ID.
1017 1181 */
1018 1182 do_action( 'give_after_cc_expiration', $form_id );
1019 1183 ?>
1020 1184 </fieldset>
@@ -1021,11 +1185,11 @@
1021 1185 <?php
1022 1186 /**
1023 1187 * Fires while rendering credit card info form, before the fields.
1024 1188 *
1189 + * @param int $form_id The form ID.
1190 + *
1025 1191 * @since 1.0
1026 - *
1027 - * @param int $form_id The form ID.
1028 1192 */
1029 1193 do_action( 'give_after_cc_fields', $form_id );
1030 1194
1031 1195 echo ob_get_clean();
@@ -1035,24 +1199,21 @@
1035 1199
1036 1200 /**
1037 1201 * Outputs the default credit card address fields.
1038 1202 *
1203 + * @since 3.1.0 Add the give_default_cc_address_fields_user_info filter
1039 1204 * @since 1.0
1040 1205 *
1041 - * @param int $form_id The form ID.
1206 + * @param int $form_id The form ID.
1207 + * @param bool $return Whether to return the output or echo it. *
1042 1208 *
1043 - * @return void
1209 + * @return void|string
1044 1210 */
1045 -function give_default_cc_address_fields( $form_id ) {
1211 +function give_default_cc_address_fields($form_id, $return = false)
1212 +{
1046 1213 // Get user info.
1047 - $give_user_info = _give_get_prefill_form_field_values( $form_id );
1214 + $give_user_info = apply_filters('give_default_cc_address_fields_user_info', _give_get_prefill_form_field_values( $form_id ), $form_id);
1048 1215
1049 - $logged_in = is_user_logged_in();
1050 -
1051 - if ( $logged_in ) {
1052 - $user_address = give_get_donor_address( get_current_user_id() );
1053 - }
1054 -
1055 1216 ob_start();
1056 1217 ?>
1057 1218 <fieldset id="give_cc_address" class="cc-address">
1058 1219 <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend>
@@ -1059,11 +1220,11 @@
1059 1220 <?php
1060 1221 /**
1061 1222 * Fires while rendering credit card billing form, before address fields.
1062 1223 *
1224 + * @param int $form_id The form ID.
1225 + *
1063 1226 * @since 1.0
1064 - *
1065 - * @param int $form_id The form ID.
1066 1227 */
1067 1228 do_action( 'give_cc_billing_top' );
1068 1229
1069 1230 // For Country.
@@ -1086,19 +1247,8 @@
1086 1247 // Get the country code.
1087 1248 if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) {
1088 1249 $selected_country = $give_user_info['billing_country'];
1089 1250 }
1090 - $label = __( 'State', 'give' );
1091 - $states_label = give_get_states_label();
1092 - // Check if $country code exists in the array key for states label.
1093 - if ( array_key_exists( $selected_country, $states_label ) ) {
1094 - $label = $states_label[ $selected_country ];
1095 - }
1096 - $states = give_get_states( $selected_country );
1097 - // Get the country list that do not have any states init.
1098 - $no_states_country = give_no_states_country_list();
1099 - // Get the country list that does not require states.
1100 - $states_not_required_country_list = give_states_not_required_country_list();
1101 1251
1102 1252 // Get the country list that does not require city.
1103 1253 $city_required = ! array_key_exists( $selected_country, give_city_not_required_country_list() );
1104 1254
@@ -1109,14 +1259,14 @@
1109 1259 <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?>
1110 1260 <span class="give-required-indicator">*</span>
1111 1261 <?php endif; ?>
1112 1262 <span class="give-tooltip give-icon give-icon-question"
1113 - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span>
1263 + data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span>
1114 1264 </label>
1115 1265
1116 1266 <select
1117 1267 name="billing_country"
1118 - autocomplete="country-name"
1268 + autocomplete="country"
1119 1269 id="billing_country"
1120 1270 class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>"
1121 1271 <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
1122 1272 >
@@ -1183,9 +1333,9 @@
1183 1333 <input
1184 1334 type="text"
1185 1335 id="card_city"
1186 1336 name="card_city"
1187 - autocomplete="address-level3"
1337 + autocomplete="address-level2"
1188 1338 class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>"
1189 1339 placeholder="<?php _e( 'City', 'give' ); ?>"
1190 1340 value="<?php echo( isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : '' ); ?>"
1191 1341 <?php echo( give_field_is_required( 'card_city', $form_id ) && $city_required ? ' required aria-required="true" ' : '' ); ?>
@@ -1191,17 +1341,40 @@
1191 1341 <?php echo( give_field_is_required( 'card_city', $form_id ) && $city_required ? ' required aria-required="true" ' : '' ); ?>
1192 1342 />
1193 1343 </p>
1194 1344
1345 + <?php
1346 + /**
1347 + * State field logic.
1348 + */
1349 + $state_label = __( 'State', 'give' );
1350 + $states_label = give_get_states_label();
1351 + // Check if $country code exists in the array key for states label.
1352 + if ( array_key_exists( $selected_country, $states_label ) ) {
1353 + $state_label = $states_label[ $selected_country ];
1354 + }
1355 + $states = give_get_states( $selected_country );
1356 + // Get the country list that do not have any states.
1357 + $no_states_country = give_no_states_country_list();
1358 + // Get the country list that does not require states.
1359 + $states_not_required_country_list = give_states_not_required_country_list();
1360 + // Used to determine if state is required.
1361 + $require_state = ! array_key_exists( $selected_country, $no_states_country ) && give_field_is_required( 'card_state', $form_id );
1362 + // Used to determine is state input should be marked as required.
1363 + $validate_state = ! array_key_exists( $selected_country, $states_not_required_country_list ) && give_field_is_required( 'card_state', $form_id );
1364 + // Check if post code is required
1365 + $postcode_required = $selected_country
1366 + ? ! array_key_exists( $selected_country, give_get_country_list_without_postcodes() ) && give_field_is_required( 'card_zip', $form_id )
1367 + : give_field_is_required( 'card_zip', $form_id );
1368 + ?>
1195 1369 <p id="give-card-state-wrap"
1196 - class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> ">
1370 + class="form-row form-row-first form-row-responsive <?php echo ( ! empty( $selected_country ) && ! $require_state ) ? 'give-hidden' : ''; ?> ">
1197 1371 <label for="card_state" class="give-label">
1198 - <span class="state-label-text"><?php echo $label; ?></span>
1199 - <?php
1200 - if ( give_field_is_required( 'card_state', $form_id ) ) : ?>
1201 - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ); ?> ">*</span>
1202 - <?php endif; ?>
1203 - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span>
1372 + <span class="state-label-text"><?php echo $state_label; ?></span>
1373 + <span
1374 + class="give-required-indicator <?php echo $validate_state ? '' : 'give-hidden'; ?> ">*</span>
1375 + <span class="give-tooltip give-icon give-icon-question"
1376 + data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span>
1204 1377 </label>
1205 1378 <?php
1206 1379
1207 1380 if ( ! empty( $states ) ) :
@@ -1207,12 +1380,12 @@
1207 1380 if ( ! empty( $states ) ) :
1208 1381 ?>
1209 1382 <select
1210 1383 name="card_state"
1211 - autocomplete="address-level4"
1384 + autocomplete="address-level1"
1212 1385 id="card_state"
1213 - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>"
1214 - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>>
1386 + class="card_state give-select<?php echo $validate_state ? ' required' : ''; ?>"
1387 + <?php echo $validate_state ? ' required aria-required="true" ' : ''; ?>>
1215 1388 <?php
1216 1389 foreach ( $states as $state_code => $state ) {
1217 1390 echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
1218 1391 }
@@ -1219,19 +1392,19 @@
1219 1392 ?>
1220 1393 </select>
1221 1394 <?php else : ?>
1222 1395 <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input"
1223 - placeholder="<?php echo $label; ?>" value="<?php echo $selected_state; ?>"/>
1396 + placeholder="<?php echo $state_label; ?>" value="<?php echo $selected_state; ?>"
1397 + <?php echo $validate_state ? ' required aria-required="true" ' : ''; ?>
1398 + />
1224 1399 <?php endif; ?>
1225 1400 </p>
1226 1401
1227 - <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive">
1402 + <p id="give-card-zip-wrap" class="form-row <?php echo $require_state ? 'form-row-last' : ''; ?> form-row-responsive">
1228 1403 <label for="card_zip" class="give-label">
1229 1404 <?php _e( 'Zip / Postal Code', 'give' ); ?>
1230 - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?>
1231 - <span class="give-required-indicator">*</span>
1232 - <?php endif; ?>
1233 - <?php echo Give()->tooltips->render_help( __( 'The ZIP Code or postal code for your billing address.', 'give' ) ); ?>
1405 + <span class="give-required-indicator<?php echo ( $postcode_required ? '' : ' give-hidden' ); ?>">*</span>
1406 + <?php echo Give()->tooltips->render_help( __( 'The zip or postal code for your billing address.', 'give' ) ); ?>
1234 1407 </label>
1235 1408
1236 1409 <input
1237 1410 type="text"
@@ -1238,12 +1411,12 @@
1238 1411 size="4"
1239 1412 id="card_zip"
1240 1413 name="card_zip"
1241 1414 autocomplete="postal-code"
1242 - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>"
1415 + class="card-zip give-input<?php echo( $postcode_required ? ' required' : '' ); ?>"
1243 1416 placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>"
1244 1417 value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>"
1245 - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?>
1418 + <?php echo( $postcode_required ? ' required aria-required="true" ' : '' ); ?>
1246 1419 />
1247 1420 </p>
1248 1421 <?php
1249 1422 /**
@@ -1248,16 +1421,21 @@
1248 1421 <?php
1249 1422 /**
1250 1423 * Fires while rendering credit card billing form, after address fields.
1251 1424 *
1425 + * @param int $form_id The form ID.
1426 + *
1252 1427 * @since 1.0
1253 - *
1254 - * @param int $form_id The form ID.
1255 1428 */
1256 1429 do_action( 'give_cc_billing_bottom' );
1257 1430 ?>
1258 1431 </fieldset>
1259 1432 <?php
1433 +
1434 + if ($return) {
1435 + return ob_get_clean();
1436 + }
1437 +
1260 1438 echo ob_get_clean();
1261 1439 }
1262 1440
1263 1441 add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' );
@@ -1266,13 +1444,12 @@
1266 1444 /**
1267 1445 * Renders the user registration fields. If the user is logged in, a login form is displayed other a registration form
1268 1446 * is provided for the user to create an account.
1269 1447 *
1270 - * @since 1.0
1448 + * @param int $form_id The form ID.
1271 1449 *
1272 - * @param int $form_id The form ID.
1273 - *
1274 1450 * @return string
1451 + * @since 1.0
1275 1452 */
1276 1453 function give_get_register_fields( $form_id ) {
1277 1454
1278 1455 global $user_ID;
@@ -1290,11 +1467,11 @@
1290 1467 <?php
1291 1468 /**
1292 1469 * Fires while rendering user registration form, before registration fields.
1293 1470 *
1471 + * @param int $form_id The form ID.
1472 + *
1294 1473 * @since 1.0
1295 - *
1296 - * @param int $form_id The form ID.
1297 1474 */
1298 1475 do_action( 'give_register_fields_before', $form_id );
1299 1476 ?>
1300 1477
@@ -1302,49 +1479,49 @@
1302 1479 <?php
1303 1480 /**
1304 1481 * Fires while rendering user registration form, before account fields.
1305 1482 *
1483 + * @param int $form_id The form ID.
1484 + *
1306 1485 * @since 1.0
1307 - *
1308 - * @param int $form_id The form ID.
1309 1486 */
1310 1487 do_action( 'give_register_account_fields_before', $form_id );
1311 1488
1312 1489 $class = ( 'registration' === $show_register_form ) ? 'form-row-wide' : 'form-row-first';
1490 + // Add attributes to checkbox, if Guest Checkout is disabled.
1491 + $is_guest_checkout = give_is_setting_enabled( give_get_meta( $form_id, '_give_logged_in_only', true ) );
1313 1492 ?>
1314 - <div id="give-create-account-wrap-<?php echo $form_id; ?>"
1315 - class="form-row <?php echo esc_attr( $class ); ?> form-row-responsive">
1493 +
1494 + <?php
1495 + /**
1496 + * If Guest Checkout is enabled, display label and checkbox - unchecked.
1497 + * If Guest Checkout it disabled, display hidden checkbox - checked.
1498 + * @since 2.9.6
1499 + * @since 2.9.7 Create account checkbox is hidden when guest registration is disabled.
1500 + */
1501 + ?>
1502 + <div id="give-create-account-wrap-<?php echo $form_id; ?>" class="form-row <?php echo esc_attr( $class ); ?> form-row-responsive">
1503 + <?php
1504 + $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true );
1505 + if ( give_is_setting_enabled( $is_guest_checkout ) ) {
1506 + ?>
1316 1507 <label for="give-create-account-<?php echo $form_id; ?>">
1508 + <input type="checkbox" id="give-create-account-<?php echo $form_id; ?>" name="give_create_account" class="give-input" value="on" />
1317 1509 <?php
1318 - // Add attributes to checkbox, if Guest Checkout is disabled.
1319 - $is_guest_checkout = give_get_meta( $form_id, '_give_logged_in_only', true );
1320 - $id = 'give-create-account-' . $form_id;
1321 - if ( ! give_is_setting_enabled( $is_guest_checkout ) ) {
1322 - echo Give()->tooltips->render(
1323 - array(
1324 - 'tag_content' => sprintf(
1325 - '<input type="checkbox" name="give_create_account" value="on" id="%s" class="give-input give-disabled" checked />',
1326 - $id
1327 - ),
1328 - 'label' => __( 'Registration is required to donate.', 'give' ),
1329 - )
1330 - );
1331 - } else {
1332 - ?>
1333 - <input type="checkbox" name="give_create_account" value="on" id="<?php echo $id; ?>"
1334 - class="give-input"/>
1335 - <?php
1336 - }
1337 -
1338 1510 _e( 'Create an account', 'give' );
1339 1511 echo Give()->tooltips->render_help( __( 'Create an account on the site to see and manage donation history.', 'give' ) );
1512 + ?>
1513 + </label>
1514 + <?php } else { ?>
1515 + <input type="hidden" id="give-create-account-<?php echo $form_id; ?>" name="give_create_account" class="give-input" value="on" checked />
1516 + <?php } ?>
1517 + <?php
1340 1518 echo str_replace(
1341 1519 '/>',
1342 1520 'data-time="' . time() . '" data-nonce-life="' . give_get_nonce_life() . '"/>',
1343 1521 give_get_nonce_field( "give_form_create_user_nonce_{$form_id}", 'give-form-user-register-hash', false )
1344 1522 );
1345 - ?>
1346 - </label>
1523 + ?>
1347 1524 </div>
1348 1525
1349 1526 <?php if ( 'both' === $show_register_form ) { ?>
1350 1527 <div class="give-login-account-wrap form-row form-row-last form-row-responsive">
@@ -1361,11 +1538,11 @@
1361 1538 <?php
1362 1539 /**
1363 1540 * Fires while rendering user registration form, after account fields.
1364 1541 *
1542 + * @param int $form_id The form ID.
1543 + *
1365 1544 * @since 1.0
1366 - *
1367 - * @param int $form_id The form ID.
1368 1545 */
1369 1546 do_action( 'give_register_account_fields_after', $form_id );
1370 1547 ?>
1371 1548 </fieldset>
@@ -1373,11 +1550,11 @@
1373 1550 <?php
1374 1551 /**
1375 1552 * Fires while rendering user registration form, after registration fields.
1376 1553 *
1554 + * @param int $form_id The form ID.
1555 + *
1377 1556 * @since 1.0
1378 - *
1379 - * @param int $form_id The form ID.
1380 1557 */
1381 1558 do_action( 'give_register_fields_after', $form_id );
1382 1559 ?>
1383 1560
@@ -1403,34 +1580,33 @@
1403 1580 * Gets the login fields for the login form on the checkout. This function hooks
1404 1581 * on the give_donation_form_login_fields to display the login form if a user already
1405 1582 * had an account.
1406 1583 *
1407 - * @since 1.0
1584 + * @param int $form_id The form ID.
1408 1585 *
1409 - * @param int $form_id The form ID.
1410 - *
1411 1586 * @return string
1587 + * @since 1.0
1412 1588 */
1413 1589 function give_get_login_fields( $form_id ) {
1414 1590
1415 - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id;
1591 + $form_id = isset( $_POST['form_id'] ) ? give_clean( $_POST['form_id'] ) : $form_id;
1416 1592 $show_register_form = give_show_login_register_option( $form_id );
1417 1593
1418 1594 ob_start();
1419 1595 ?>
1420 - <fieldset id="give-login-fields-<?php echo $form_id; ?>">
1596 + <fieldset id="give-login-fields-<?php echo esc_attr( $form_id ); ?>">
1421 1597 <legend>
1422 1598 <?php
1423 - echo apply_filters( 'give_account_login_fieldset_heading', __( 'Login to Your Account', 'give' ) );
1599 + echo apply_filters( 'give_account_login_fieldset_heading', __( 'Log In to Your Account', 'give' ) );
1424 1600 if ( ! give_logged_in_only( $form_id ) ) {
1425 1601 echo ' <span class="sub-text">' . __( '(optional)', 'give' ) . '</span>';
1426 1602 }
1427 1603 ?>
1428 1604 </legend>
1429 - <?php if ( $show_register_form == 'both' ) { ?>
1605 + <?php if ( $show_register_form === 'both' ) { ?>
1430 1606 <p class="give-new-account-link">
1431 1607 <?php _e( 'Don\'t have an account?', 'give' ); ?>&nbsp;
1432 - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel"
1608 + <a href="<?php echo esc_url( remove_query_arg( 'login' ) ); ?>" class="give-checkout-register-cancel"
1433 1609 data-action="give_checkout_register">
1434 1610 <?php
1435 1611 if ( give_logged_in_only( $form_id ) ) {
1436 1612 _e( 'Register as a part of your donation &raquo;', 'give' );
@@ -1447,18 +1623,18 @@
1447 1623 <?php
1448 1624 /**
1449 1625 * Fires while rendering checkout login form, before the fields.
1450 1626 *
1627 + * @param int $form_id The form ID.
1628 + *
1451 1629 * @since 1.0
1452 - *
1453 - * @param int $form_id The form ID.
1454 1630 */
1455 1631 do_action( 'give_donation_form_login_fields_before', $form_id );
1456 1632 ?>
1457 1633 <div class="give-user-login-fields-container">
1458 - <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive">
1459 - <label class="give-label" for="give-user-login-<?php echo $form_id; ?>">
1460 - <?php _e( 'Username', 'give' ); ?>
1634 + <div id="give-user-login-wrap-<?php echo esc_attr( $form_id ); ?>" class="form-row form-row-first form-row-responsive">
1635 + <label class="give-label" for="give-user-login-<?php echo esc_attr( $form_id ); ?>">
1636 + <?php _e( 'Username or Email Address', 'give' ); ?>
1461 1637 <?php if ( give_logged_in_only( $form_id ) ) { ?>
1462 1638 <span class="give-required-indicator">*</span>
1463 1639 <?php } ?>
1464 1640 </label>
@@ -1463,16 +1639,16 @@
1463 1639 <?php } ?>
1464 1640 </label>
1465 1641
1466 1642 <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>"
1467 - type="text"
1468 - name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value=""
1469 - placeholder="<?php _e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/>
1643 + type="text"
1644 + name="give_user_login" id="give-user-login-<?php echo esc_attr( $form_id ); ?>" value=""
1645 + placeholder="<?php _e( 'Your username or email', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/>
1470 1646 </div>
1471 1647
1472 - <div id="give-user-pass-wrap-<?php echo $form_id; ?>"
1473 - class="give_login_password form-row form-row-last form-row-responsive">
1474 - <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>">
1648 + <div id="give-user-pass-wrap-<?php echo esc_attr( $form_id ); ?>"
1649 + class="give_login_password form-row form-row-last form-row-responsive">
1650 + <label class="give-label" for="give-user-pass-<?php echo esc_attr( $form_id ); ?>">
1475 1651 <?php _e( 'Password', 'give' ); ?>
1476 1652 <?php if ( give_logged_in_only( $form_id ) ) { ?>
1477 1653 <span class="give-required-indicator">*</span>
1478 1654 <?php } ?>
@@ -1477,39 +1653,40 @@
1477 1653 <span class="give-required-indicator">*</span>
1478 1654 <?php } ?>
1479 1655 </label>
1480 1656 <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>"
1481 - type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>"
1482 - placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/>
1483 - <input type="hidden" name="give-purchase-var" value="needs-to-login"/>
1657 + type="password" name="give_user_pass" id="give-user-pass-<?php echo esc_attr( $form_id ); ?>"
1658 + placeholder="<?php _e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/>
1659 + <?php if ( give_logged_in_only( $form_id ) ) : ?>
1660 + <input type="hidden" name="give-purchase-var" value="needs-to-login"/>
1661 + <?php endif; ?>
1484 1662 </div>
1485 -
1486 - <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password">
1487 - <span class="give-forgot-password ">
1488 - <a href="<?php echo wp_lostpassword_url(); ?>"
1489 - target="_blank"><?php _e( 'Reset Password', 'give' ); ?></a>
1490 - </span>
1491 - </div>
1492 1663 </div>
1493 1664
1494 -
1495 - <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix">
1665 + <div id="give-user-login-submit-<?php echo esc_attr( $form_id ); ?>" class="give-clearfix">
1496 1666 <input type="submit" class="give-submit give-btn button" name="give_login_submit"
1497 - value="<?php _e( 'Login', 'give' ); ?>"/>
1667 + value="<?php _e( 'Login', 'give' ); ?>"/>
1498 1668 <?php if ( $show_register_form !== 'login' ) { ?>
1499 1669 <input type="button" data-action="give_cancel_login"
1500 - class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel"
1501 - value="<?php _e( 'Cancel', 'give' ); ?>"/>
1670 + class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel"
1671 + value="<?php _e( 'Cancel', 'give' ); ?>"/>
1502 1672 <?php } ?>
1503 1673 <span class="give-loading-animation"></span>
1674 + <div id="give-forgot-password-wrap-<?php echo esc_attr( $form_id ); ?>" class="give_login_forgot_password">
1675 + <span class="give-forgot-password ">
1676 + <a href="<?php echo wp_lostpassword_url(); ?>" target="_blank"><?php _e( 'Reset Password', 'give' ); ?></a>
1677 + </span>
1678 + </div>
1504 1679 </div>
1680 + <input type="hidden" name="give_login_nonce"
1681 + value="<?php echo wp_create_nonce( 'give-login-nonce' ); ?>"/>
1505 1682 <?php
1506 1683 /**
1507 1684 * Fires while rendering checkout login form, after the fields.
1508 1685 *
1686 + * @param int $form_id The form ID.
1687 + *
1509 1688 * @since 1.0
1510 - *
1511 - * @param int $form_id The form ID.
1512 1689 */
1513 1690 do_action( 'give_donation_form_login_fields_after', $form_id );
1514 1691 ?>
1515 1692 </fieldset><!--end #give-login-fields-->
@@ -1526,17 +1703,15 @@
1526 1703 * outputting them as radio buttons for the user to choose the payment gateway. If
1527 1704 * a default payment gateway has been chosen from the Give Settings, it will be
1528 1705 * automatically selected.
1529 1706 *
1530 - * @since 1.0
1707 + * @param int $form_id The form ID.
1531 1708 *
1532 - * @param int $form_id The form ID.
1533 - *
1534 1709 * @return void
1710 + * @since 1.0
1535 1711 */
1536 1712 function give_payment_mode_select( $form_id, $args ) {
1537 -
1538 - $gateways = give_get_enabled_payment_gateways( $form_id );
1713 + $gateways = give_get_enabled_payment_gateways($form_id, 2);
1539 1714 $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : '';
1540 1715
1541 1716 /**
1542 1717 * Fires while selecting payment gateways, before the fields.
@@ -1543,20 +1718,15 @@
1543 1718 *
1544 1719 * @since 1.7
1545 1720 *
1546 1721 * @param int $form_id The form ID.
1722 + *
1547 1723 */
1548 1724 do_action( 'give_payment_mode_top', $form_id );
1549 1725 ?>
1550 1726
1551 - <fieldset id="give-payment-mode-select"
1727 + <fieldset id="give-payment-mode-select"<?php echo count( $gateways ) <= 1 ? ' style="display: none;"' : ''; ?>>
1552 1728 <?php
1553 - if ( count( $gateways ) <= 1 ) {
1554 - echo 'style="display: none;"';
1555 - }
1556 - ?>
1557 - >
1558 - <?php
1559 1729 /**
1560 1730 * Fires while selecting payment gateways, before the wrap div.
1561 1731 *
1562 1732 * @since 1.7
@@ -1561,8 +1731,9 @@
1561 1731 *
1562 1732 * @since 1.7
1563 1733 *
1564 1734 * @param int $form_id The form ID.
1735 + *
1565 1736 */
1566 1737 do_action( 'give_payment_mode_before_gateways_wrap' );
1567 1738 ?>
1568 1739 <legend
@@ -1585,35 +1756,28 @@
1585 1756 <?php
1586 1757 /**
1587 1758 * Loop through the active payment gateways.
1588 1759 */
1589 - $selected_gateway = give_get_chosen_gateway( $form_id );
1590 - $give_settings = give_get_settings();
1591 - $gateways_label = array_key_exists( 'gateways_label', $give_settings ) ?
1592 - $give_settings['gateways_label'] :
1593 - array();
1760 + $selected_gateway = give_get_chosen_gateway( $form_id );
1594 1761
1595 1762 foreach ( $gateways as $gateway_id => $gateway ) :
1596 1763 // Determine the default gateway.
1597 - $checked = checked( $gateway_id, $selected_gateway, false );
1598 - $checked_class = $checked ? ' class="give-gateway-option-selected"' : '';
1599 - ?>
1600 - <li<?php echo $checked_class; ?>>
1601 - <input type="radio" name="payment-mode" class="give-gateway"
1602 - id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>"
1603 - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>>
1764 + $checked = checked( $gateway_id, $selected_gateway, false );
1765 + $checked_class = $checked ? ' class="give-gateway-option-selected"' : '';
1766 + $is_payment_method_visible = isset( $gateway['is_visible'] ) ? $gateway['is_visible'] : true;
1604 1767
1768 + if ( true === $is_payment_method_visible ) {
1769 + ?>
1770 + <li<?php echo $checked_class; ?>>
1771 + <input type="radio" name="payment-mode" class="give-gateway"
1772 + id="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>"
1773 + value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>>
1774 + <label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>"
1775 + class="give-gateway-option"
1776 + id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label>
1777 + </li>
1605 1778 <?php
1606 - $label = $gateway['checkout_label'];
1607 - if ( ! empty( $gateways_label[ $gateway_id ] ) ) {
1608 - $label = $gateways_label[ $gateway_id ];
1609 - }
1610 - ?>
1611 - <label for="give-gateway-<?php echo esc_attr( $gateway_id . '-' . $id_prefix ); ?>"
1612 - class="give-gateway-option"
1613 - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $label ); ?></label>
1614 - </li>
1615 - <?php
1779 + }
1616 1780 endforeach;
1617 1781 ?>
1618 1782 </ul>
1619 1783 <?php
@@ -1628,11 +1792,11 @@
1628 1792 <?php
1629 1793 /**
1630 1794 * Fires while selecting payment gateways, after the wrap div.
1631 1795 *
1796 + * @param int $form_id The form ID.
1797 + *
1632 1798 * @since 1.7
1633 - *
1634 - * @param int $form_id The form ID.
1635 1799 */
1636 1800 do_action( 'give_payment_mode_after_gateways_wrap' );
1637 1801 ?>
1638 1802 </fieldset>
@@ -1640,11 +1804,11 @@
1640 1804 <?php
1641 1805 /**
1642 1806 * Fires while selecting payment gateways, after the fields.
1643 1807 *
1808 + * @param int $form_id The form ID.
1809 + *
1644 1810 * @since 1.7
1645 - *
1646 - * @param int $form_id The form ID.
1647 1811 */
1648 1812 do_action( 'give_payment_mode_bottom', $form_id );
1649 1813 ?>
1650 1814
@@ -1676,13 +1840,12 @@
1676 1840 * Renders the Checkout Agree to Terms, this displays a checkbox for users to
1677 1841 * agree the T&Cs set in the Give Settings. This is only displayed if T&Cs are
1678 1842 * set in the Give Settings.
1679 1843 *
1680 - * @since 1.0
1844 + * @param int $form_id The form ID.
1681 1845 *
1682 - * @param int $form_id The form ID.
1683 - *
1684 1846 * @return bool
1847 + * @since 1.0
1685 1848 */
1686 1849 function give_terms_agreement( $form_id ) {
1687 1850 $form_option = give_get_meta( $form_id, '_give_terms_option', true );
1688 1851
@@ -1748,9 +1911,9 @@
1748 1911 aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a>
1749 1912 </div>
1750 1913
1751 1914 <input name="give_agree_to_terms" class="required" type="checkbox"
1752 - id="give_agree_to_terms-<?php echo $form_id; ?>" value="1" required aria-required="true"/>
1915 + id="give_agree_to_terms-<?php echo $form_id; ?>" value="1" required aria-required="true"/>
1753 1916 <label for="give_agree_to_terms-<?php echo $form_id; ?>"><?php echo $label; ?></label>
1754 1917
1755 1918 </fieldset>
1756 1919 <?php
@@ -1762,18 +1925,17 @@
1762 1925 * Checkout Final Total.
1763 1926 *
1764 1927 * Shows the final donation total at the bottom of the checkout page.
1765 1928 *
1766 - * @since 1.0
1929 + * @param int $form_id The form ID.
1767 1930 *
1768 - * @param int $form_id The form ID.
1769 - *
1770 1931 * @return void
1932 + * @since 1.0
1771 1933 */
1772 1934 function give_checkout_final_total( $form_id ) {
1773 1935
1774 1936 $total = isset( $_POST['give_total'] ) ?
1775 - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) :
1937 + apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'], [ 'currency' => give_get_currency( $form_id ) ] ) ) :
1776 1938 give_get_default_form_amount( $form_id );
1777 1939
1778 1940 // Only proceed if give_total available.
1779 1941 if ( empty( $total ) ) {
@@ -1792,17 +1954,19 @@
1792 1954 <span class="give-donation-total-label">
1793 1955 <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?>
1794 1956 </span>
1795 1957 <span class="give-final-total-amount"
1796 - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>">
1958 + data-total="<?php echo give_format_amount( $total, [ 'sanitize' => false ] ); ?>">
1797 1959 <?php
1798 1960 echo give_currency_filter(
1799 1961 give_format_amount(
1800 - $total, array(
1962 + $total,
1963 + [
1801 1964 'sanitize' => false,
1802 1965 'currency' => give_get_currency( $form_id ),
1803 - )
1804 - ), array( 'currency_code' => give_get_currency( $form_id ) )
1966 + ]
1967 + ),
1968 + [ 'currency_code' => give_get_currency( $form_id ) ]
1805 1969 );
1806 1970 ?>
1807 1971 </span>
1808 1972 <?php
@@ -1821,14 +1985,13 @@
1821 1985
1822 1986 /**
1823 1987 * Renders the Checkout Submit section.
1824 1988 *
1825 - * @since 1.0
1826 - *
1827 1989 * @param int $form_id The donation form ID.
1828 1990 * @param array $args List of arguments.
1829 1991 *
1830 1992 * @return void
1993 + * @since 1.0
1831 1994 */
1832 1995 function give_checkout_submit( $form_id, $args ) {
1833 1996 ?>
1834 1997 <fieldset id="give_purchase_submit" class="give-donation-submit">
@@ -1839,11 +2002,11 @@
1839 2002 * @since 1.7
1840 2003 */
1841 2004 do_action( 'give_donation_form_before_submit', $form_id, $args );
1842 2005
1843 - give_checkout_hidden_fields( $form_id );
2006 + give_checkout_hidden_fields( $form_id, $args );
1844 2007
1845 - echo give_get_donation_form_submit_button( $form_id );
2008 + echo give_get_donation_form_submit_button( $form_id, $args );
1846 2009
1847 2010 /**
1848 2011 * Fire after donation form submit.
1849 2012 *
@@ -1859,49 +2022,53 @@
1859 2022
1860 2023 /**
1861 2024 * Give Donation form submit button.
1862 2025 *
2026 + * @since 4.16.2 Escape submit button label in form markup.
1863 2027 * @since 1.8.8
1864 2028 *
1865 - * @param int $form_id The form ID.
2029 + * @param int $form_id The form ID.
2030 + * @param array $args
1866 2031 *
1867 2032 * @return string
1868 2033 */
1869 -function give_get_donation_form_submit_button( $form_id ) {
2034 +function give_get_donation_form_submit_button( $form_id, $args = [] ) {
1870 2035
1871 2036 $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true );
2037 + $display_label_field = apply_filters( 'give_donation_form_submit_button_text', $display_label_field, $form_id, $args );
1872 2038 $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) );
1873 2039 ob_start();
1874 2040 ?>
1875 2041 <div class="give-submit-button-wrap give-clearfix">
1876 2042 <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase"
1877 - value="<?php echo $display_label; ?>" data-before-validation-label="<?php echo $display_label; ?>"/>
2043 + value="<?php echo esc_attr( $display_label ); ?>" data-before-validation-label="<?php echo esc_attr( $display_label ); ?>"/>
1878 2044 <span class="give-loading-animation"></span>
1879 2045 </div>
1880 2046 <?php
1881 - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id );
2047 + return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id, $args );
1882 2048 }
1883 2049
1884 2050 /**
1885 2051 * Show Give Goals.
1886 2052 *
1887 - * @since 1.0
1888 - * @since 1.6 Add template for Give Goals Shortcode.
2053 + * @param int $form_id The form ID.
2054 + * @param array $args An array of form arguments.
2055 + *
2056 + * @return mixed
2057 + * @since 1.6 Add template for Give Goals Shortcode.
1889 2058 * More info is on https://github.com/impress-org/give/issues/411
1890 2059 *
1891 - * @param int $form_id The form ID.
1892 - * @param array $args An array of form arguments.
1893 - *
1894 - * @return mixed
2060 + * @since 1.0
1895 2061 */
1896 -function give_show_goal_progress( $form_id, $args = array() ) {
2062 +function give_show_goal_progress( $form_id, $args = [] ) {
1897 2063
1898 2064 ob_start();
1899 2065 give_get_template(
1900 - 'shortcode-goal', array(
2066 + 'shortcode-goal',
2067 + [
1901 2068 'form_id' => $form_id,
1902 2069 'args' => $args,
1903 - )
2070 + ]
1904 2071 );
1905 2072
1906 2073 /**
1907 2074 * Filter progress bar output
@@ -1917,14 +2084,13 @@
1917 2084
1918 2085 /**
1919 2086 * Show Give Totals Progress.
1920 2087 *
1921 - * @since 2.1
2088 + * @param int $total Total amount based on shortcode parameter.
2089 + * @param int $total_goal Total Goal amount passed by Admin.
1922 2090 *
1923 - * @param int $total Total amount based on shortcode parameter.
1924 - * @param int $total_goal Total Goal amount passed by Admin.
1925 - *
1926 2091 * @return mixed
2092 + * @since 2.1
1927 2093 */
1928 2094 function give_show_goal_totals_progress( $total, $total_goal ) {
1929 2095
1930 2096 // Bail out if total goal is set as an array.
@@ -1933,12 +2099,13 @@
1933 2099 }
1934 2100
1935 2101 ob_start();
1936 2102 give_get_template(
1937 - 'shortcode-totals-progress', array(
2103 + 'shortcode-totals-progress',
2104 + [
1938 2105 'total' => $total,
1939 2106 'total_goal' => $total_goal,
1940 - )
2107 + ]
1941 2108 );
1942 2109
1943 2110 echo apply_filters( 'give_total_progress_output', ob_get_clean() );
1944 2111
@@ -1949,14 +2116,13 @@
1949 2116
1950 2117 /**
1951 2118 * Get form content position.
1952 2119 *
1953 - * @since 1.8
1954 - *
1955 2120 * @param $form_id
1956 2121 * @param $args
1957 2122 *
1958 2123 * @return mixed|string
2124 + * @since 1.8
1959 2125 */
1960 2126 function give_get_form_content_placement( $form_id, $args ) {
1961 2127 $show_content = '';
1962 2128
@@ -1961,12 +2127,12 @@
1961 2127 $show_content = '';
1962 2128
1963 2129 if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) {
1964 2130 // Content positions.
1965 - $content_placement = array(
2131 + $content_placement = [
1966 2132 'above' => 'give_pre_form',
1967 2133 'below' => 'give_post_form',
1968 - );
2134 + ];
1969 2135
1970 2136 // Check if content position already decoded.
1971 2137 if ( in_array( $args['show_content'], $content_placement ) ) {
1972 2138 return $args['show_content'];
@@ -1976,11 +2142,8 @@
1976 2142
1977 2143 } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) {
1978 2144 $show_content = give_get_meta( $form_id, '_give_content_placement', true );
1979 2145
1980 - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) {
1981 - // Backward compatibility for _give_content_option for v18.
1982 - $show_content = give_get_meta( $form_id, '_give_content_option', true );
1983 2146 }
1984 2147
1985 2148 return $show_content;
1986 2149 }
@@ -1987,14 +2150,13 @@
1987 2150
1988 2151 /**
1989 2152 * Adds Actions to Render Form Content.
1990 2153 *
1991 - * @since 1.0
2154 + * @param int $form_id The form ID.
2155 + * @param array $args An array of form arguments.
1992 2156 *
1993 - * @param int $form_id The form ID.
1994 - * @param array $args An array of form arguments.
1995 - *
1996 2157 * @return void|bool
2158 + * @since 1.0
1997 2159 */
1998 2160 function give_form_content( $form_id, $args ) {
1999 2161
2000 2162 $show_content = give_get_form_content_placement( $form_id, $args );
@@ -2014,14 +2176,13 @@
2014 2176 * Renders Post Form Content.
2015 2177 *
2016 2178 * Displays content for Give forms; fired by action from give_form_content.
2017 2179 *
2018 - * @since 1.0
2180 + * @param int $form_id The form ID.
2181 + * @param array $args An array of form arguments.
2019 2182 *
2020 - * @param int $form_id The form ID.
2021 - * @param array $args An array of form arguments.
2022 - *
2023 2183 * @return void
2184 + * @since 1.0
2024 2185 */
2025 2186 function give_form_display_content( $form_id, $args ) {
2026 2187 $content = give_get_meta( $form_id, '_give_form_content', true );
2027 2188 $show_content = give_get_form_content_placement( $form_id, $args );
@@ -2036,9 +2197,9 @@
2036 2197
2037 2198 $content = apply_filters( 'the_content', $content );
2038 2199
2039 2200 // Restore wpautop after done with blocks parsing.
2040 - if( $priority ) {
2201 + if ( $priority ) {
2041 2202 // Run wpautop manually if parsing block
2042 2203 $content = wpautop( $content );
2043 2204
2044 2205 add_filter( 'the_content', '_restore_wpautop_hook', $priority );
@@ -2056,13 +2217,13 @@
2056 2217
2057 2218 /**
2058 2219 * Filter form content html
2059 2220 *
2060 - * @since 1.0
2061 - *
2062 2221 * @param string $output
2063 2222 * @param int $form_id
2064 2223 * @param array $args
2224 + *
2225 + * @since 1.0
2065 2226 */
2066 2227 echo apply_filters( 'give_form_content_output', $output, $form_id, $args );
2067 2228
2068 2229 // remove action to prevent content output on addition forms on page.
@@ -2072,24 +2233,24 @@
2072 2233
2073 2234 /**
2074 2235 * Renders the hidden Checkout fields.
2075 2236 *
2076 - * @since 1.0
2237 + * @param int $form_id The form ID.
2238 + * @param array $args Shortcode args.
2077 2239 *
2078 - * @param int $form_id The form ID.
2079 - *
2080 2240 * @return void
2241 + * @since 1.0
2081 2242 */
2082 -function give_checkout_hidden_fields( $form_id ) {
2243 +function give_checkout_hidden_fields( $form_id, $args = [] ) {
2083 2244
2084 2245 /**
2085 2246 * Fires while rendering hidden checkout fields, before the fields.
2086 2247 *
2248 + * @param int $form_id The form ID.
2249 + *
2087 2250 * @since 1.0
2088 - *
2089 - * @param int $form_id The form ID.
2090 2251 */
2091 - do_action( 'give_hidden_fields_before', $form_id );
2252 + do_action( 'give_hidden_fields_before', $form_id, $args );
2092 2253
2093 2254 if ( is_user_logged_in() ) {
2094 2255 ?>
2095 2256 <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/>
@@ -2099,13 +2260,13 @@
2099 2260 <?php
2100 2261 /**
2101 2262 * Fires while rendering hidden checkout fields, after the fields.
2102 2263 *
2264 + * @param int $form_id The form ID.
2265 + *
2103 2266 * @since 1.0
2104 - *
2105 - * @param int $form_id The form ID.
2106 2267 */
2107 - do_action( 'give_hidden_fields_after', $form_id );
2268 + do_action( 'give_hidden_fields_after', $form_id, $args );
2108 2269
2109 2270 }
2110 2271
2111 2272 /**
@@ -2112,13 +2273,12 @@
2112 2273 * Filter Success Page Content.
2113 2274 *
2114 2275 * Applies filters to the success page content.
2115 2276 *
2116 - * @since 1.0
2277 + * @param string $content Content before filters.
2117 2278 *
2118 - * @param string $content Content before filters.
2119 - *
2120 2279 * @return string $content Filtered content.
2280 + * @since 1.0
2121 2281 */
2122 2282 function give_filter_success_page_content( $content ) {
2123 2283
2124 2284 $give_options = give_get_settings();
@@ -2154,14 +2314,13 @@
2154 2314 * Members-only Form.
2155 2315 *
2156 2316 * If "Disable Guest Donations" and "Display Register / Login" is set to none.
2157 2317 *
2158 - * @since 1.4.1
2318 + * @param string $final_output
2319 + * @param array $args
2159 2320 *
2160 - * @param string $final_output
2161 - * @param array $args
2162 - *
2163 2321 * @return string
2322 + * @since 1.4.1
2164 2323 */
2165 2324 function give_members_only_form( $final_output, $args ) {
2166 2325
2167 2326 $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0;
@@ -2173,9 +2332,9 @@
2173 2332
2174 2333 // Logged in only and Register / Login set to none.
2175 2334 if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) {
2176 2335
2177 - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false );
2336 + $final_output = Give_Notices::print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false );
2178 2337
2179 2338 return apply_filters( 'give_members_only_output', $final_output, $form_id );
2180 2339
2181 2340 }
@@ -2189,15 +2348,16 @@
2189 2348
2190 2349 /**
2191 2350 * Add donation form hidden fields.
2192 2351 *
2193 - * @since 1.8.17
2194 - *
2195 2352 * @param int $form_id
2196 2353 * @param array $args
2197 2354 * @param Give_Donate_Form $form
2355 + *
2356 + * @since 4.9.0 rename function - PHP 8 compatibility
2357 + * @since 1.8.17
2198 2358 */
2199 -function __give_form_add_donation_hidden_field( $form_id, $args, $form ) {
2359 +function give_form_add_donation_hidden_field( $form_id, $args, $form ) {
2200 2360 $id_prefix = ! empty( $args['id_prefix'] ) ? $args['id_prefix'] : '';
2201 2361 ?>
2202 2362 <input type="hidden" name="give-form-id-prefix" value="<?php echo $id_prefix; ?>"/>
2203 2363 <input type="hidden" name="give-form-id" value="<?php echo intval( $form_id ); ?>"/>
@@ -2211,11 +2371,11 @@
2211 2371 // If custom amount enabled.
2212 2372 if ( give_is_setting_enabled( $custom_amount ) ) {
2213 2373 ?>
2214 2374 <input type="hidden" name="give-form-minimum"
2215 - value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/>
2375 + value="<?php echo give_maybe_sanitize_amount( give_get_form_minimum_price( $form_id ) ); ?>"/>
2216 2376 <input type="hidden" name="give-form-maximum"
2217 - value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/>
2377 + value="<?php echo give_maybe_sanitize_amount( give_get_form_maximum_price( $form_id ) ); ?>"/>
2218 2378 <?php
2219 2379 }
2220 2380
2221 2381 $data_attr = sprintf(
@@ -2244,21 +2404,22 @@
2244 2404 );
2245 2405 }
2246 2406 }
2247 2407
2248 -add_action( 'give_donation_form_top', '__give_form_add_donation_hidden_field', 0, 3 );
2408 +add_action( 'give_donation_form_top', 'give_form_add_donation_hidden_field', 0, 3 );
2249 2409
2250 2410 /**
2251 2411 * Add currency settings on donation form.
2252 2412 *
2253 - * @since 1.8.17
2254 - *
2255 2413 * @param array $form_html_tags
2256 2414 * @param Give_Donate_Form $form
2257 2415 *
2258 2416 * @return array
2417 + *
2418 + * @since 4.9.0 rename function - PHP 8 compatibility
2419 + * @since 1.8.17
2259 2420 */
2260 -function __give_form_add_currency_settings( $form_html_tags, $form ) {
2421 +function give_form_add_currency_settings( $form_html_tags, $form ) {
2261 2422 $form_currency = give_get_currency( $form->ID );
2262 2423 $currency_settings = give_get_currency_formatting_settings( $form_currency );
2263 2424
2264 2425 // Check if currency exist.
@@ -2270,9 +2431,9 @@
2270 2431 $form_html_tags['data-currency_code'] = $form_currency;
2271 2432
2272 2433 if ( ! empty( $currency_settings ) ) {
2273 2434 foreach ( $currency_settings as $key => $value ) {
2274 - $form_html_tags["data-{$key}"] = $value;
2435 + $form_html_tags[ "data-{$key}" ] = $value;
2275 2436 }
2276 2437 }
2277 2438
2278 2439 return $form_html_tags;
@@ -2277,18 +2438,17 @@
2277 2438
2278 2439 return $form_html_tags;
2279 2440 }
2280 2441
2281 -add_filter( 'give_form_html_tags', '__give_form_add_currency_settings', 0, 2 );
2442 +add_filter( 'give_form_html_tags', 'give_form_add_currency_settings', 0, 2 );
2282 2443
2283 2444 /**
2284 2445 * Adds classes to progress bar container.
2285 2446 *
2286 - * @since 2.1
2287 - *
2288 2447 * @param string $class_goal
2289 2448 *
2290 2449 * @return string
2450 + * @since 2.1
2291 2451 */
2292 2452 function add_give_goal_progress_class( $class_goal ) {
2293 2453 $class_goal = 'progress progress-striped active';
2294 2454
@@ -2297,13 +2457,12 @@
2297 2457
2298 2458 /**
2299 2459 * Adds classes to progress bar span tag.
2300 2460 *
2301 - * @since 2.1
2302 - *
2303 2461 * @param string $class_bar
2304 2462 *
2305 2463 * @return string
2464 + * @since 2.1
2306 2465 */
2307 2466 function add_give_goal_progress_bar_class( $class_bar ) {
2308 2467 $class_bar = 'bar';
2309 2468
@@ -2316,11 +2475,10 @@
2316 2475 * @param array $class Array of form wrapper classes.
2317 2476 * @param int $id ID of the form.
2318 2477 * @param array $args Additional args.
2319 2478 *
2479 + * @return array
2320 2480 * @since 2.1
2321 - *
2322 - * @return array
2323 2481 */
2324 2482 function add_class_for_form_grid( $class, $id, $args ) {
2325 2483 $class[] = 'give-form-grid-wrap';
2326 2484
@@ -2353,10 +2511,10 @@
2353 2511 *
2354 2512 * @param string $redirect URL for redirection.
2355 2513 * @param array $args Array of additional args.
2356 2514 *
2515 + * @return string
2357 2516 * @since 2.1
2358 - * @return string
2359 2517 */
2360 2518 function give_redirect_and_popup_form( $redirect, $args ) {
2361 2519
2362 2520 // Check the page has Form Grid.
@@ -2371,16 +2529,17 @@
2371 2529 $redirect = strtok( $redirect, '?' );
2372 2530
2373 2531 // Add query parameters 'form-id' and 'payment-mode'.
2374 2532 $redirect = add_query_arg(
2375 - array(
2533 + [
2376 2534 'form-id' => $form_id,
2377 2535 'payment-mode' => $payment_mode,
2378 - ), $redirect
2536 + ],
2537 + $redirect
2379 2538 );
2380 2539 }
2381 2540
2382 2541 // Return the modified URL.
2383 - return $redirect;
2542 + return esc_url_raw( $redirect );
2384 2543 }
2385 2544
2386 2545 add_filter( 'give_send_back_to_checkout', 'give_redirect_and_popup_form', 10, 2 );