1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This template is used to display the donation grid with [give_donor_wall] |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
// Exit if accessed directly. |
7
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
8
|
|
|
exit; |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
/** @var $donor Give_Donor */ |
12
|
|
|
$donation = $args[0]; |
13
|
|
|
|
14
|
|
|
$give_settings = $args[1]; // Give settings. |
15
|
|
|
$atts = $args[2]; // Shortcode attributes. |
16
|
|
|
?> |
17
|
|
|
|
18
|
|
|
<div class="give-grid__item"> |
19
|
|
|
<div class="give-donor give-card"> |
20
|
|
|
<div class="give-donor__header"> |
21
|
|
|
<?php |
22
|
|
|
if( true === $atts['show_avatar'] ) { |
|
|
|
|
23
|
|
|
|
24
|
|
|
// Get anonymous donor image. |
25
|
|
|
$anonymous_donor_img = sprintf( |
26
|
|
|
'<img src="%1$s" alt="%2$s">', |
27
|
|
|
esc_url( GIVE_PLUGIN_URL . 'assets/dist/images/anonymous-user.svg' ), |
28
|
|
|
esc_attr__( 'Anonymous User', 'give' ) |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
// Get donor avatar image based on donation parameter. |
32
|
|
|
$donor_avatar = ! empty( $donation['_give_anonymous_donation'] ) ? $anonymous_donor_img : $donation['name_initial']; |
33
|
|
|
|
34
|
|
|
// Validate donor gravatar. |
35
|
|
|
$validate_gravatar = ! empty( $donation['_give_anonymous_donation'] ) ? 0 : give_validate_gravatar( $donation['_give_payment_donor_email'] ); |
36
|
|
|
|
37
|
|
|
// Maybe display the Avatar. |
38
|
|
|
echo sprintf( |
|
|
|
|
39
|
|
|
'<div class="give-donor__image" data-donor_email="%1$s" data-has-valid-gravatar="%2$s">%3$s</div>', |
40
|
|
|
md5( strtolower( trim( $donation['_give_payment_donor_email'] ) ) ), |
41
|
|
|
absint( $validate_gravatar ), |
42
|
|
|
$donor_avatar |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
?> |
46
|
|
|
|
47
|
|
|
<div class="give-donor__details"> |
48
|
|
|
<?php if ( true === $atts['show_name'] ) : ?> |
49
|
|
|
<h3 class="give-donor__name"> |
50
|
|
|
<?php |
51
|
|
|
// Get donor name based on donation parameter. |
52
|
|
|
$donor_name = ! empty( $donation['_give_anonymous_donation'] ) |
53
|
|
|
? __( 'Anonymous', 'give' ) |
54
|
|
|
: trim( $donation['_give_donor_billing_first_name'] . ' ' . $donation['_give_donor_billing_last_name'] ); |
|
|
|
|
55
|
|
|
?> |
56
|
|
|
<?php esc_html_e( $donor_name ); ?> |
57
|
|
|
</h3> |
58
|
|
|
<?php endif; ?> |
59
|
|
|
|
60
|
|
|
<?php if ( true === $atts['show_total'] ) : ?> |
61
|
|
|
<span class="give-donor__total"> |
62
|
|
|
<?php echo esc_html( give_donation_amount( $donation['donation_id'], true ) ); ?> |
63
|
|
|
</span> |
64
|
|
|
<?php endif; ?> |
65
|
|
|
|
66
|
|
|
<?php if ( true === $atts['show_time'] ) : ?> |
67
|
|
|
<span class="give-donor__timestamp"> |
68
|
|
|
<?php echo esc_html( give_get_formatted_date( $donation[ 'donation_date' ], give_date_format(), 'Y-m-d H:i:s' ) ); ?> |
|
|
|
|
69
|
|
|
</span> |
70
|
|
|
<?php endif; ?> |
71
|
|
|
</div> |
72
|
|
|
</div> |
73
|
|
|
|
74
|
|
|
<?php |
75
|
|
|
if ( |
76
|
|
|
true === $atts['show_comments'] |
77
|
|
|
&& absint( $atts['comment_length'] ) |
78
|
|
|
&& ! empty( $donation['donor_comment'] ) |
79
|
|
|
&& ! $donation['_give_anonymous_donation'] |
80
|
|
|
) : |
81
|
|
|
?> |
82
|
|
|
<div class="give-donor__content"> |
83
|
|
|
<?php |
84
|
|
|
$comment = trim( $donation['donor_comment'] ); |
85
|
|
|
$total_chars = strlen( $comment ); |
86
|
|
|
$max_chars = $atts['comment_length']; |
87
|
|
|
|
88
|
|
|
// A truncated excerpt is displayed if the comment is too long. |
89
|
|
|
if ( $max_chars < $total_chars ) { |
90
|
|
|
$excerpt = ''; |
91
|
|
|
$offset = -( $total_chars - $max_chars ); |
92
|
|
|
$last_space = strrpos( $comment, ' ', $offset ); |
93
|
|
|
|
94
|
|
|
if ( $last_space ) { |
95
|
|
|
// Truncate excerpt at last space before limit. |
96
|
|
|
$excerpt = substr( $comment, 0, $last_space ); |
97
|
|
|
} else { |
98
|
|
|
// There are no spaces, so truncate excerpt at limit. |
99
|
|
|
$excerpt = substr( $comment, 0, $max_chars ); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
$excerpt = trim( $excerpt, '.!,:;' ); |
103
|
|
|
|
104
|
|
|
echo sprintf( |
|
|
|
|
105
|
|
|
'<p class="give-donor__excerpt">%s…<span> <a class="give-donor__read-more">%s</a></span></p>', |
106
|
|
|
nl2br( esc_html( $excerpt ) ), |
107
|
|
|
esc_html( $atts['readmore_text'] ) |
108
|
|
|
); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
echo sprintf( |
|
|
|
|
112
|
|
|
'<p class="give-donor__comment">%s</p>', |
113
|
|
|
nl2br( esc_html( $comment ) ) |
114
|
|
|
); |
115
|
|
|
?> |
116
|
|
|
</div> |
117
|
|
|
<?php endif; ?> |
118
|
|
|
</div> |
119
|
|
|
</div> |
120
|
|
|
|