PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.8
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.8
1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 1.8.0 All 210 releases
charitable / includes / public / charitable-template-functions.php

charitable-template-functions.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.6.8, at includes/public/charitable-template-functions.php

1,010 lines 25.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Template Functions.
4 *
5 * Functions used with template hooks.
6 *
7 * @package Charitable/Functions/Templates
8 * @author Eric Daams
9 * @copyright Copyright (c) 2019, Studio 164a
10 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11 * @since 1.0.0
12 * @version 1.5.14
13 */
14
15 // Exit if accessed directly.
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 // //////////////////////////////
21 // HEAD OUTPUT
22 // //////////////////////////////
23 if ( ! function_exists( 'charitable_template_custom_styles' ) ) :
24
25 /**
26 * Add custom styles to the <head> section.
27 *
28 * This is used on the wp_head action.
29 *
30 * @since 1.2.0
31 *
32 * @return void
33 */
34 function charitable_template_custom_styles() {
35 if ( ! apply_filters( 'charitable_add_custom_styles', true ) ) {
36 return;
37 }
38
39 $styles = get_transient( 'charitable_custom_styles' );
40
41 if ( false === $styles ) {
42
43 ob_start();
44
45 charitable_template( 'custom-styles.css.php' );
46
47 $styles = ob_get_clean();
48
49 $styles = charitable_compress_css( $styles );
50
51 set_transient( 'charitable_custom_styles', $styles, 0 );
52 }
53
54 echo $styles;
55 }
56
57 endif;
58
59 if ( ! function_exists( 'charitable_hide_admin_bar' ) ) :
60
61 /**
62 * Hides the admin bar from header.
63 *
64 * This is designed to be used when viewing the campaign widget.
65 *
66 * @since 1.3.0
67 *
68 * @return void
69 */
70 function charitable_hide_admin_bar() {
71 ?>
72 <style type="text/css" media="screen">
73 html { margin-top: 0 !important; }
74 * html body { margin-top: 0 !important; }
75 </style>
76 <?php
77 }
78
79 endif;
80
81 // //////////////////////////////
82 // BODY CLASSES
83 // //////////////////////////////
84 if ( ! function_exists( 'charitable_add_body_classes' ) ) :
85
86 /**
87 * Adds custom body classes to certain templates.
88 *
89 * @since 1.3.0
90 *
91 * @param string[] $classes Body classes.
92 * @return string[]
93 */
94 function charitable_add_body_classes( $classes ) {
95 if ( charitable_is_page( 'donation_receipt_page' ) ) {
96 $classes[] = 'campaign-donation-receipt';
97 }
98
99 if ( charitable_is_page( 'donation_processing_page' ) ) {
100 $classes[] = 'campaign-donation-processing';
101 }
102
103 if ( charitable_is_page( 'campaign_donation_page' ) ) {
104 $classes[] = 'campaign-donation-page';
105 }
106
107 if ( charitable_is_page( 'campaign_widget_page' ) ) {
108 $classes[] = 'campaign-widget';
109 }
110
111 if ( charitable_is_page( 'email_preview' ) ) {
112 $classes[] = 'email-preview';
113 }
114
115 return $classes;
116 }
117
118 endif;
119
120 // //////////////////////////////
121 // SINGLE CAMPAIGN CONTENT
122 // //////////////////////////////
123 if ( ! function_exists( 'charitable_template_campaign_description' ) ) :
124
125 /**
126 * Display the campaign description before the summary and rest of content.
127 *
128 * @since 1.0.0
129 *
130 * @param Charitable_Campaign $campaign The campaign object.
131 * @return void
132 */
133 function charitable_template_campaign_description( $campaign ) {
134 charitable_template( 'campaign/description.php', array( 'campaign' => $campaign ) );
135 }
136
137 endif;
138
139 if ( ! function_exists( 'charitable_template_campaign_finished_notice' ) ) :
140
141 /**
142 * Display the campaign finished notice.
143 *
144 * @since 1.0.0
145 *
146 * @param Charitable_Campaign $campaign The campaign object.
147 * @return void
148 */
149 function charitable_template_campaign_finished_notice( $campaign ) {
150 if ( ! $campaign->has_ended() ) {
151 return;
152 }
153
154 charitable_template( 'campaign/finished-notice.php', array( 'campaign' => $campaign ) );
155 }
156
157 endif;
158
159 if ( ! function_exists( 'charitable_template_campaign_percentage_raised' ) ) :
160
161 /**
162 * Display the percentage that the campaign has raised in summary block.
163 *
164 * @since 1.0.0
165 *
166 * @param Charitable_Campaign $campaign The campaign object.
167 * @return boolean True if the template was displayed. False otherwise.
168 */
169 function charitable_template_campaign_percentage_raised( $campaign ) {
170 if ( ! $campaign->has_goal() ) {
171 return false;
172 }
173
174 charitable_template( 'campaign/summary-percentage-raised.php', array( 'campaign' => $campaign ) );
175
176 return true;
177 }
178
179 endif;
180
181 if ( ! function_exists( 'charitable_template_campaign_donation_summary' ) ) :
182
183 /**
184 * Display campaign goal in summary block.
185 *
186 * @since 1.0.0
187 *
188 * @param Charitable_Campaign $campaign The campaign object.
189 * @return true
190 */
191 function charitable_template_campaign_donation_summary( $campaign ) {
192 charitable_template( 'campaign/summary-donations.php', array( 'campaign' => $campaign ) );
193 return true;
194 }
195
196 endif;
197
198 if ( ! function_exists( 'charitable_template_campaign_donor_count' ) ) :
199
200 /**
201 * Display number of campaign donors in summary block.
202 *
203 * @since 1.0.0
204 *
205 * @param Charitable_Campaign $campaign The campaign object.
206 * @return true
207 */
208 function charitable_template_campaign_donor_count( $campaign ) {
209 charitable_template( 'campaign/summary-donors.php', array( 'campaign' => $campaign ) );
210 return true;
211 }
212
213 endif;
214
215 if ( ! function_exists( 'charitable_template_campaign_time_left' ) ) :
216
217 /**
218 * Display the amount of time left in the campaign in the summary block.
219 *
220 * @since 1.0.0
221 *
222 * @param Charitable_Campaign $campaign The campaign object.
223 * @return boolean True if the template was displayed. False otherwise.
224 */
225 function charitable_template_campaign_time_left( $campaign ) {
226 if ( $campaign->is_endless() ) {
227 return false;
228 }
229
230 charitable_template( 'campaign/summary-time-left.php', array( 'campaign' => $campaign ) );
231 return true;
232 }
233
234 endif;
235
236 if ( ! function_exists( 'charitable_template_donate_button' ) ) :
237
238 /**
239 * Display donate button or link in the campaign summary.
240 *
241 * @since 1.0.0
242 *
243 * @param Charitable_Campaign $campaign The campaign object.
244 * @return boolean True if the template was displayed. False otherwise.
245 */
246 function charitable_template_donate_button( $campaign ) {
247 if ( ! $campaign->can_receive_donations() ) {
248 return false;
249 }
250
251 $campaign->donate_button_template();
252
253 return true;
254 }
255
256 endif;
257
258 if ( ! function_exists( 'charitable_template_campaign_summary' ) ) :
259
260 /**
261 * Display campaign summary before rest of campaign content.
262 *
263 * @since 1.0.0
264 *
265 * @param Charitable_Campaign $campaign The campaign object.
266 * @return void
267 */
268 function charitable_template_campaign_summary( $campaign ) {
269 charitable_template( 'campaign/summary.php', array( 'campaign' => $campaign ) );
270 }
271
272 endif;
273
274 if ( ! function_exists( 'charitable_template_campaign_progress_bar' ) ) :
275
276 /**
277 * Output the campaign progress bar.
278 *
279 * @since 1.0.0
280 *
281 * @param Charitable_Campaign $campaign The campaign object.
282 * @return void
283 */
284 function charitable_template_campaign_progress_bar( $campaign ) {
285 charitable_template( 'campaign/progress-bar.php', array( 'campaign' => $campaign ) );
286 }
287
288 endif;
289
290 if ( ! function_exists( 'charitable_template_campaign_donate_button' ) ) :
291
292 /**
293 * Output the campaign donate button.
294 *
295 * @since 1.0.0
296 *
297 * @param Charitable_Campaign $campaign The campaign object.
298 * @return void
299 */
300 function charitable_template_campaign_donate_button( $campaign ) {
301 charitable_template( 'campaign/donate-button.php', array( 'campaign' => $campaign ) );
302 }
303
304 endif;
305
306 if ( ! function_exists( 'charitable_template_campaign_donate_link' ) ) :
307
308 /**
309 * Output the campaign donate link.
310 *
311 * @since 1.0.0
312 *
313 * @param Charitable_Campaign $campaign The campaign object.
314 * @return void
315 */
316 function charitable_template_campaign_donate_link( $campaign ) {
317 charitable_template( 'campaign/donate-link.php', array( 'campaign' => $campaign ) );
318 }
319
320 endif;
321
322 if ( ! function_exists( 'charitable_template_campaign_status_tag' ) ) :
323
324 /**
325 * Output the campaign status tag.
326 *
327 * @since 1.0.0
328 *
329 * @param Charitable_Campaign $campaign The campaign object.
330 * @return void
331 */
332 function charitable_template_campaign_status_tag( $campaign ) {
333 charitable_template( 'campaign/status-tag.php', array( 'campaign' => $campaign ) );
334 }
335
336 endif;
337
338 if ( ! function_exists( 'charitable_template_campaign_donation_form_in_page' ) ) :
339
340 /**
341 * Add the donation form straight into the campaign page.
342 *
343 * @since 1.0.0
344 * @since 1.5.0 Function now returns true/false depending
345 * on whether the template is rendered.
346 *
347 * @param Charitable_Campaign $campaign The campaign object.
348 * @return boolean
349 */
350 function charitable_template_campaign_donation_form_in_page( Charitable_Campaign $campaign ) {
351 if ( $campaign->can_receive_donations() && 'same_page' == charitable_get_option( 'donation_form_display', 'separate_page' ) ) {
352 $donation_id = get_query_var( 'donation_id', false );
353
354 /* If a donation ID is included, make sure it belongs to the current user. */
355 if ( $donation_id && ! charitable_user_can_access_donation( $donation_id ) ) {
356 return false;
357 }
358
359 charitable_get_current_donation_form()->render();
360 return true;
361 }
362
363 return false;
364 }
365
366 endif;
367
368 if ( ! function_exists( 'charitable_template_campaign_modal_donation_window' ) ) :
369
370 /**
371 * Adds the modal donation window to a campaign page.
372 *
373 * @since 1.0.0
374 * @since 1.5.0 Function now returns true/false depending
375 * on whether the template is rendered.
376 *
377 * @global WP_Query $wp_query
378 * @return boolean
379 */
380 function charitable_template_campaign_modal_donation_window() {
381 global $wp_query;
382
383 if ( Charitable::CAMPAIGN_POST_TYPE != get_post_type() ) {
384 return false;
385 }
386
387 if ( isset( $wp_query->query_vars['donate'] ) ) {
388 return false;
389 }
390
391 $campaign = charitable_get_current_campaign();
392
393 if ( $campaign->can_receive_donations() && 'modal' == charitable_get_option( 'donation_form_display', 'separate_page' ) ) {
394 charitable_template( 'campaign/donate-modal-window.php', array( 'campaign' => $campaign ) );
395 return true;
396 }
397
398 return false;
399 }
400
401 endif;
402
403 // //////////////////////////////
404 // CAMPAIGN LOOP
405 // //////////////////////////////
406 if ( ! function_exists( 'charitable_template_campaign_loop' ) ) :
407
408 /**
409 * Display the campaign loop.
410 *
411 * This is used instead of the_content filter.
412 *
413 * @since 1.0.0
414 *
415 * @param WP_Query $campaigns Query with campaigns.
416 * @param int $columns Number of columns to use for loop.
417 * @return void
418 */
419 function charitable_template_campaign_loop( $campaigns = false, $columns = 1 ) {
420 if ( ! $campaigns ) {
421 global $wp_query;
422 $campaigns = $wp_query;
423 }
424
425 charitable_template( 'campaign-loop.php', array(
426 'campaigns' => $campaigns,
427 'columns' => $columns,
428 ) );
429 }
430
431 endif;
432
433 if ( ! function_exists( 'charitable_template_responsive_styles' ) ) :
434
435 /**
436 * Add responsive styles for the campaign loop.
437 *
438 * @since 1.4.0
439 *
440 * @param WP_Query $campaigns The campaigns that will be displayed.
441 * @param array $args The view arguments.
442 * @return void
443 */
444 function charitable_template_responsive_styles( $campaigns, $args ) {
445 if ( ! isset( $args['responsive'] ) || ! $args['responsive'] ) {
446 return;
447 }
448
449 $breakpoint = '768px';
450
451 if ( preg_match( '/[px|em]/', $args['responsive'] ) ) {
452 $breakpoint = $args['responsive'];
453 }
454 ?>
455 <style type="text/css" media="screen">
456 @media only screen and (max-width: <?php echo $breakpoint; ?>) {
457 .campaign-loop.campaign-grid.masonry { -moz-column-count: 1; -webkit-column-count: 1; column-count: 1; }
458 .campaign-loop.campaign-grid .campaign.hentry { width: 100% !important; }
459 }
460 </style>
461 <?php
462 }
463
464 endif;
465
466 if ( ! function_exists( 'charitable_template_campaign_loop_thumbnail' ) ) :
467
468 /**
469 * Output the campaign thumbnail on campaigns displayed within the loop.
470 *
471 * @since 1.0.0
472 *
473 * @param Charitable_Campaign $campaign The campaign object.
474 * @return void
475 */
476 function charitable_template_campaign_loop_thumbnail( $campaign ) {
477 charitable_template( 'campaign-loop/thumbnail.php', array( 'campaign' => $campaign ) );
478 }
479
480 endif;
481
482 if ( ! function_exists( 'charitable_template_campaign_loop_donation_stats' ) ) :
483
484 /**
485 * Output the campaign donation status on campaigns displayed within the loop.
486 *
487 * @since 1.0.0
488 *
489 * @param Charitable_Campaign $campaign The campaign object.
490 * @return void
491 */
492 function charitable_template_campaign_loop_donation_stats( $campaign ) {
493 charitable_template( 'campaign-loop/donation-stats.php', array( 'campaign' => $campaign ) );
494 }
495
496 endif;
497
498 if ( ! function_exists( 'charitable_template_campaign_loop_donate_link' ) ) :
499
500 /**
501 * Output the campaign donation status on campaigns displayed within the loop.
502 *
503 * @since 1.0.0
504 *
505 * @param Charitable_Campaign $campaign The campaign object.
506 * @param mixed[] $args Optional arguments.
507 * @return void
508 */
509 function charitable_template_campaign_loop_donate_link( $campaign, $args = array() ) {
510 if ( isset( $args['button'] ) && 'donate' != $args['button'] ) {
511 return;
512 }
513
514 $campaign->donate_button_loop_template();
515 }
516
517 endif;
518
519 if ( ! function_exists( 'charitable_template_campaign_loop_more_link' ) ) :
520
521 /**
522 * Output the read more link on campaigns displayed within the loop.
523 *
524 * @since 1.2.3
525 *
526 * @param Charitable_Campaign $campaign The campaign object.
527 * @param mixed[] $args Optional arguments.
528 * @return void
529 */
530 function charitable_template_campaign_loop_more_link( $campaign, $args = array() ) {
531 if ( ! isset( $args['button'] ) || 'details' != $args['button'] ) {
532 return;
533 }
534
535 charitable_template( 'campaign-loop/more-link.php', array( 'campaign' => $campaign ) );
536 }
537
538 endif;
539
540 if ( ! function_exists( 'charitable_template_campaign_loop_add_modal' ) ) :
541
542 /**
543 * Checks if the modal option is enabled and hooks the modal template up to wp_footer if it is.
544 *
545 * @since 1.2.3
546 *
547 * @return void
548 */
549 function charitable_template_campaign_loop_add_modal() {
550 if ( 'modal' == charitable_get_option( 'donation_form_display', 'separate_page' ) ) {
551 add_action( 'wp_footer', 'charitable_template_campaign_loop_modal_donation_window' );
552 }
553 }
554
555 endif;
556
557 if ( ! function_exists( 'charitable_template_campaign_loop_modal_donation_window' ) ) :
558
559 /**
560 * Adds the modal donation window to the campaign loop.
561 *
562 * @since 1.2.3
563 *
564 * @return void
565 */
566 function charitable_template_campaign_loop_modal_donation_window() {
567 charitable_template( 'campaign-loop/donate-modal-window.php' );
568 }
569
570 endif;
571
572 // //////////////////////////////
573 // DONATION RECEIPT
574 // //////////////////////////////
575 if ( ! function_exists( 'charitable_template_donation_receipt_content' ) ) :
576
577 /**
578 * Display the donation form. This is used with the_content filter.
579 *
580 * @since 1.0.0
581 *
582 * @param string $content Page content.
583 * @return string
584 */
585 function charitable_template_donation_receipt_content( $content ) {
586
587 if ( ! in_the_loop() || ! charitable_is_page( 'donation_receipt_page' ) ) {
588 return $content;
589 }
590
591 /* If we are NOT using the automatic option, this is a static page with the shortcode, so don't filter again. */
592 if ( 'auto' != charitable_get_option( 'donation_receipt_page', 'auto' ) ) {
593 return $content;
594 }
595
596 return charitable_template_donation_receipt_output( $content );
597
598 }
599
600 endif;
601
602 if ( ! function_exists( 'charitable_template_donation_receipt_output' ) ) :
603
604 /**
605 * Render the donation receipt. This can be used by the [donation_receipt] shortcode or through `the_content` filter.
606 *
607 * @since 1.0.0
608 * @since 1.5.0 Added $donation argument.
609 *
610 * @param string $content Page content.
611 * @param Charitable_Donation|null $donation Optional. Useful when the donation is not the current donation.
612 * @return string
613 */
614 function charitable_template_donation_receipt_output( $content, $donation = null ) {
615 if ( is_null( $donation ) ) {
616 $donation = charitable_get_current_donation();
617 }
618
619 if ( ! $donation || 'simple' != $donation->get_donation_type() ) {
620 return $content;
621 }
622
623 ob_start();
624
625 if ( ! $donation->is_from_current_user() ) {
626 charitable_template_from_session( 'donation-receipt/not-authorized.php', array( 'content' => $content ), 'donation_receipt', array( 'donation_id' => $donation->ID ) );
627 return ob_get_clean();
628 }
629
630 do_action( 'charitable_donation_receipt_page', $donation );
631
632 charitable_template( 'content-donation-receipt.php', array(
633 'content' => $content,
634 'donation' => $donation,
635 ) );
636
637 $content = ob_get_clean();
638
639 return $content;
640 }
641
642 endif;
643
644 if ( ! function_exists( 'charitable_template_donation_receipt_summary' ) ) :
645
646 /**
647 * Display the donation receipt summary.
648 *
649 * @since 1.0.0
650 *
651 * @param Charitable_Donation $donation The Donation object.
652 * @return void
653 */
654 function charitable_template_donation_receipt_summary( Charitable_Donation $donation ) {
655 charitable_template( 'donation-receipt/summary.php', array( 'donation' => $donation ) );
656 }
657
658 endif;
659
660 if ( ! function_exists( 'charitable_template_donation_receipt_offline_payment_instructions' ) ) :
661
662 /**
663 * Display the offline payment instructions, if applicable.
664 *
665 * @since 1.0.0
666 *
667 * @param Charitable_Donation $donation The Donation object.
668 * @return void
669 */
670 function charitable_template_donation_receipt_offline_payment_instructions( Charitable_Donation $donation ) {
671 if ( 'offline' != $donation->get_gateway() ) {
672 return;
673 }
674
675 charitable_template( 'donation-receipt/offline-payment-instructions.php', array( 'donation' => $donation ) );
676 }
677
678 endif;
679
680 if ( ! function_exists( 'charitable_template_donation_receipt_details' ) ) :
681
682 /**
683 * Display the donation details.
684 *
685 * @since 1.0.0
686 *
687 * @param Charitable_Donation $donation The Donation object.
688 * @return void
689 */
690 function charitable_template_donation_receipt_details( Charitable_Donation $donation ) {
691 charitable_template( 'donation-receipt/details.php', array( 'donation' => $donation ) );
692 }
693
694
695 endif;
696
697 // //////////////////////////////
698 // DONATION FORM
699 // //////////////////////////////
700 if ( ! function_exists( 'charitable_template_donation_form_content' ) ) :
701
702 /**
703 * Display the donation form. This is used with the_content filter.
704 *
705 * @since 1.0.0
706 *
707 * @param string $content Page content.
708 * @return string
709 */
710 function charitable_template_donation_form_content( $content ) {
711
712 if ( ! charitable_is_main_loop() || ! charitable_is_page( 'campaign_donation_page' ) ) {
713 return $content;
714 }
715
716 if ( 'separate_page' != charitable_get_option( 'donation_form_display', 'separate_page' )
717 && false === get_query_var( 'donate', false ) ) {
718 return $content;
719 }
720
721 ob_start();
722
723 charitable_template( 'content-donation-form.php' );
724
725 return ob_get_clean();
726 }
727
728 endif;
729
730 if ( ! function_exists( 'charitable_template_donation_form_login' ) ) :
731
732 /**
733 * Display a prompt to login at the start of the user fields block.
734 *
735 * @since 1.0.0
736 *
737 * @param Charitable_Donation_Form_Interface $form The donation form object.
738 * @return void
739 */
740 function charitable_template_donation_form_login( Charitable_Donation_Form_Interface $form ) {
741
742 $user = $form->get_user();
743
744 if ( $user ) {
745 return;
746 }
747
748 charitable_template( 'donation-form/donor-fields/login-form.php' );
749 }
750
751 endif;
752
753 if ( ! function_exists( 'charitable_template_donation_form_donor_details' ) ) :
754
755 /**
756 * Display the donor's saved details if the user is logged in.
757 *
758 * @since 1.0.0
759 *
760 * @param Charitable_Donation_Form_Interface $form The donation form object.
761 * @return void
762 */
763 function charitable_template_donation_form_donor_details( Charitable_Donation_Form_Interface $form ) {
764 /* Verify that the user is logged in and has all required fields filled out */
765 if ( ! $form->should_hide_user_fields() ) {
766 return;
767 }
768
769 charitable_template( 'donation-form/donor-fields/donor-details.php', array( 'user' => $form->get_user() ) );
770 }
771
772 endif;
773
774 if ( ! function_exists( 'charitable_template_donation_form_donor_fields_hidden_wrapper_start' ) ) :
775
776 /**
777 * If the user is logged in, adds a wrapper around the donor fields that hide them.
778 *
779 * @since 1.0.0
780 *
781 * @param Charitable_Donation_Form_Interface $form The donation form object.
782 * @return void
783 */
784 function charitable_template_donation_form_donor_fields_hidden_wrapper_start( Charitable_Donation_Form_Interface $form ) {
785 /* Verify that the user is logged in and has all required fields filled out */
786 if ( ! $form->should_hide_user_fields() ) {
787 return;
788 }
789
790 charitable_template( 'donation-form/donor-fields/hidden-fields-wrapper-start.php' );
791 }
792
793 endif;
794
795 if ( ! function_exists( 'charitable_template_donation_form_donor_fields_hidden_wrapper_end' ) ) :
796
797 /**
798 * Closes the hidden donor fields wrapper div if the user is logged in.
799 *
800 * @since 1.0.0
801 *
802 * @param Charitable_Donation_Form_Interface $form The donation form object.
803 * @return void
804 */
805 function charitable_template_donation_form_donor_fields_hidden_wrapper_end( Charitable_Donation_Form_Interface $form ) {
806 /* Verify that the user is logged in and has all required fields filled out */
807 if ( ! $form->should_hide_user_fields() ) {
808 return;
809 }
810
811 charitable_template( 'donation-form/donor-fields/hidden-fields-wrapper-end.php' );
812 }
813
814 endif;
815
816 if ( ! function_exists( 'charitable_template_donation_form_current_amount_text' ) ) :
817
818 /**
819 * Display the amount currently selected to donate.
820 *
821 * @since 1.5.0
822 *
823 * @param int|float $amount The current donation amount.
824 * @param string $form_id The current form ID.
825 * @param string $campaign_id The current campaign ID.
826 * @return string
827 */
828 function charitable_template_donation_form_current_amount_text( $amount, $form_id, $campaign_id ) {
829 if ( ! $amount ) {
830 return '';
831 }
832
833 /**
834 * Format the donation amount.
835 *
836 * @since 1.4.14
837 * @since 1.5.0 Third parameter has been changed from an instance of
838 * `Charitable_Donation_Form` to a campaign ID.
839 *
840 * @param string $amount_formatted The formatted amount.
841 * @param int|float $amount The raw amount.
842 * @param int $campaign_id Campaign ID.
843 */
844 $amount_formatted = apply_filters( 'charitable_session_donation_amount_formatted', charitable_format_money( $amount ), $amount, $campaign_id );
845
846 $content = '<p>';
847 /* translators: %s: donation amount */
848 $content .= sprintf( __( 'Your Donation Amount: %s.', 'charitable' ), '<strong>' . $amount_formatted . '</strong>' );
849 $content .= '&nbsp;<a href="#" class="change-donation" data-charitable-toggle="charitable-donation-options-' . esc_attr( $form_id ) . '">' . __( 'Change', 'charitable' ) . '</a>';
850 $content .= '</p>';
851
852 return $content;
853 }
854
855 endif;
856
857
858
859 // //////////////////////////////
860 // DONATION PROCESSING PAGE
861 // //////////////////////////////
862 if ( ! function_exists( 'charitable_template_donation_processing_content' ) ) :
863
864 /**
865 * Render the content of the donation processing page.
866 *
867 * @since 1.2.0
868 *
869 * @param string $content Default content to be rendered.
870 * @return string
871 */
872 function charitable_template_donation_processing_content( $content ) {
873 if ( ! charitable_is_page( 'donation_processing_page' ) ) {
874 return $content;
875 }
876
877 $donation = charitable_get_current_donation();
878
879 if ( ! $donation ) {
880 return $content;
881 }
882
883 $content = apply_filters( 'charitable_processing_donation_' . $donation->get_gateway(), $content, $donation );
884
885 return $content;
886 }
887
888 endif;
889
890 // //////////////////////////////
891 // ACCOUNT PAGES
892 // //////////////////////////////
893 if ( ! function_exists( 'charitable_template_forgot_password_content' ) ) :
894
895 /**
896 * Render the content of the forgot password page.
897 *
898 * @since 1.4.0
899 *
900 * @param string $content Default content to be rendered.
901 * @return string
902 */
903 function charitable_template_forgot_password_content( $content = '' ) {
904 if ( ! charitable_is_page( 'forgot_password_page' ) ) {
905 return $content;
906 }
907
908 ob_start();
909
910 if ( isset( $_GET['email_sent'] ) ) {
911
912 charitable_template( 'account/forgot-password-sent.php' );
913
914 } else {
915
916 charitable_template( 'account/forgot-password.php', array(
917 'form' => new Charitable_Forgot_Password_Form(),
918 ) );
919
920 }
921
922 $content = ob_get_clean();
923
924 return $content;
925 }
926
927 endif;
928
929 if ( ! function_exists( 'charitable_template_reset_password_content' ) ) :
930
931 /**
932 * Render the content of the reset password page.
933 *
934 * @since 1.4.0
935 *
936 * @param string $content Default content to be rendered.
937 * @return string
938 */
939 function charitable_template_reset_password_content( $content = '' ) {
940 if ( ! charitable_is_page( 'reset_password_page' ) ) {
941 return $content;
942 }
943
944 ob_start();
945
946 charitable_template( 'account/reset-password.php', array(
947 'form' => new Charitable_Reset_Password_Form(),
948 ) );
949
950 $content = ob_get_clean();
951
952 return $content;
953 }
954
955 endif;
956
957 if ( ! function_exists( 'charitable_template_form_login_link' ) ) :
958
959 /**
960 * Display a link to the login form.
961 *
962 * @since 1.4.2
963 *
964 * @param Charitable_Registration_Form|null $form Instance of `Charitable_Registration_Form`, or
965 * null in previous versions of Charitable.
966 * @return void
967 */
968 function charitable_template_form_login_link( $form = null ) {
969 /**
970 * For backwards compatibility, since previously the
971 * Form object was not passed to the hook.
972 */
973 if ( is_null( $form ) ) {
974 return;
975 }
976
977 if ( ! $form->get_login_link() ) {
978 return;
979 }
980
981 printf( '<p>%s</p>', $form->get_login_link() );
982 }
983
984 endif;
985
986 // //////////////////////////////
987 // NOTICES
988 // //////////////////////////////
989 if ( ! function_exists( 'charitable_template_notices' ) ) :
990
991 /**
992 * Render any notices.
993 *
994 * @since 1.4.0
995 *
996 * @param array $notices Optional. Notices to be rendered.
997 * @return void
998 */
999 function charitable_template_notices( $notices = array() ) {
1000 if ( empty( $notices ) ) {
1001 $notices = charitable_get_notices()->get_notices();
1002 }
1003
1004 charitable_template_from_session( 'form-fields/notices.php', array(
1005 'notices' => $notices,
1006 ), 'notices' );
1007 }
1008
1009 endif;
1010