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