| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display a single donor within a loop. |
| 4 |
* |
| 5 |
* Override this template by copying it to yourtheme/charitable/donor-loop/donor.php |
| 6 |
* |
| 7 |
* @package Charitable/Templates/Donor |
| 8 |
* @author WP Charitable LLC |
| 9 |
* @since 1.5.0 |
| 10 |
* @version 1.5.0 |
| 11 |
* @version 1.8.8.6 |
| 12 |
*/ |
| 13 |
|
| 14 |
// Exit if accessed directly. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
/* Donor has to be included in the view args. */ |
| 20 |
if ( ! array_key_exists( 'donor', $view_args ) ) { |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
/* @var Charitable_Donor */ |
| 25 |
$charitable_donor = $view_args['donor']; |
| 26 |
|
| 27 |
/* @var int */ |
| 28 |
$charitable_campaign_id = $view_args['campaign']; |
| 29 |
|
| 30 |
?> |
| 31 |
<li class="donor"> |
| 32 |
<?php |
| 33 |
/** |
| 34 |
* Add output before the donor's avatar, name, etc. |
| 35 |
* |
| 36 |
* @since 1.5.0 |
| 37 |
* |
| 38 |
* @param Charitable_Donor $donor The Donor object. |
| 39 |
* @param array $view_args View arguments. |
| 40 |
*/ |
| 41 |
do_action( 'charitable_donor_loop_before_donor', $charitable_donor, $view_args ); |
| 42 |
|
| 43 |
if ( $view_args['show_avatar'] ) : |
| 44 |
echo $charitable_donor->get_avatar(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 45 |
endif; |
| 46 |
|
| 47 |
if ( $view_args['show_name'] ) : |
| 48 |
?> |
| 49 |
<p class="donor-name"> |
| 50 |
<?php |
| 51 |
/** |
| 52 |
* Filter the name displayed for the donor. |
| 53 |
* |
| 54 |
* @since 1.5.0 |
| 55 |
* |
| 56 |
* @param string $name The name to be displayed. |
| 57 |
* @param array $view_args View arguments. |
| 58 |
*/ |
| 59 |
echo apply_filters( 'charitable_donor_loop_donor_name', $charitable_donor->get_name(), $view_args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 60 |
?> |
| 61 |
</p> |
| 62 |
<?php |
| 63 |
endif; |
| 64 |
|
| 65 |
if ( $view_args['show_location'] && strlen( $charitable_donor->get_location() ) ) : |
| 66 |
?> |
| 67 |
<div class="donor-location"> |
| 68 |
<?php |
| 69 |
/** |
| 70 |
* Filter the location displayed for the donor. |
| 71 |
* |
| 72 |
* @since 1.5.0 |
| 73 |
* |
| 74 |
* @param string $location The location to be displayed. |
| 75 |
* @param array $view_args View arguments. |
| 76 |
*/ |
| 77 |
echo apply_filters( 'charitable_donor_loop_donor_location', $charitable_donor->get_location(), $view_args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 78 |
?> |
| 79 |
</div> |
| 80 |
<?php |
| 81 |
endif; |
| 82 |
|
| 83 |
if ( $view_args['show_amount'] ) : |
| 84 |
?> |
| 85 |
<div class="donor-donation-amount"> |
| 86 |
<?php |
| 87 |
/** |
| 88 |
* Filter the amount displayed for the donor. |
| 89 |
* |
| 90 |
* @since 1.5.0 |
| 91 |
* |
| 92 |
* @param string $amount The amount to be displayed. |
| 93 |
* @param array $view_args View arguments. |
| 94 |
*/ |
| 95 |
echo apply_filters( 'charitable_donor_loop_donor_amount', charitable_format_money( $charitable_donor->get_amount( $charitable_campaign_id ) ), $view_args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 96 |
?> |
| 97 |
</div> |
| 98 |
<?php |
| 99 |
endif; |
| 100 |
|
| 101 |
/** |
| 102 |
* Add output after the donor's avatar, name, etc. |
| 103 |
* |
| 104 |
* @since 1.5.0 |
| 105 |
* |
| 106 |
* @param Charitable_Donor $donor The Donor object. |
| 107 |
* @param array $view_args View arguments. |
| 108 |
*/ |
| 109 |
do_action( 'charitable_donor_loop_after_donor', $charitable_donor, $view_args ); |
| 110 |
?> |
| 111 |
</li><!-- .donor-<?php echo esc_attr( $charitable_donor->donor_id ); ?> --> |
| 112 |
|