emails
6 years ago
global
6 years ago
receipt
7 years ago
single-give-form
6 years ago
email-login-form.php
6 years ago
history-donations.php
6 years ago
payment-processing.php
6 years ago
shortcode-donor-wall.php
5 years ago
shortcode-form-grid.php
6 years ago
shortcode-goal.php
6 years ago
shortcode-login.php
6 years ago
shortcode-profile-editor.php
6 years ago
shortcode-receipt.php
6 years ago
shortcode-register.php
8 years ago
shortcode-totals-progress.php
6 years ago
single-give-form.php
6 years ago
shortcode-donor-wall.php
126 lines
| 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 echo esc_html( $donor_name ); ?> |
| 57 | </h3> |
| 58 | <?php endif; ?> |
| 59 | |
| 60 | <?php if ( true === $atts['show_company_name'] && isset( $donation['_give_donation_company'] ) ) : ?> |
| 61 | <h3 class="give-donor__name"> |
| 62 | <?php echo esc_html( $donation['_give_donation_company'] ); ?> |
| 63 | </h3> |
| 64 | <?php endif; ?> |
| 65 | |
| 66 | <?php if ( true === $atts['show_total'] ) : ?> |
| 67 | <span class="give-donor__total"> |
| 68 | <?php echo esc_html( give_donation_amount( $donation['donation_id'], true ) ); ?> |
| 69 | </span> |
| 70 | <?php endif; ?> |
| 71 | |
| 72 | <?php if ( true === $atts['show_time'] ) : ?> |
| 73 | <span class="give-donor__timestamp"> |
| 74 | <?php echo esc_html( give_get_formatted_date( $donation['donation_date'], give_date_format(), 'Y-m-d H:i:s', true ) ); ?> |
| 75 | </span> |
| 76 | <?php endif; ?> |
| 77 | </div> |
| 78 | </div> |
| 79 | |
| 80 | <?php |
| 81 | if ( |
| 82 | true === $atts['show_comments'] |
| 83 | && absint( $atts['comment_length'] ) |
| 84 | && ! empty( $donation['donor_comment'] ) |
| 85 | && ! $donation['_give_anonymous_donation'] |
| 86 | ) : |
| 87 | ?> |
| 88 | <div class="give-donor__content"> |
| 89 | <?php |
| 90 | $comment = trim( $donation['donor_comment'] ); |
| 91 | $total_chars = strlen( $comment ); |
| 92 | $max_chars = $atts['comment_length']; |
| 93 | |
| 94 | // A truncated excerpt is displayed if the comment is too long. |
| 95 | if ( $max_chars < $total_chars ) { |
| 96 | $excerpt = ''; |
| 97 | $offset = -( $total_chars - $max_chars ); |
| 98 | $last_space = strrpos( $comment, ' ', $offset ); |
| 99 | |
| 100 | if ( $last_space ) { |
| 101 | // Truncate excerpt at last space before limit. |
| 102 | $excerpt = substr( $comment, 0, $last_space ); |
| 103 | } else { |
| 104 | // There are no spaces, so truncate excerpt at limit. |
| 105 | $excerpt = substr( $comment, 0, $max_chars ); |
| 106 | } |
| 107 | |
| 108 | $excerpt = trim( $excerpt, '.!,:;' ); |
| 109 | |
| 110 | echo sprintf( |
| 111 | '<p class="give-donor__excerpt">%s…<span> <a class="give-donor__read-more">%s</a></span></p>', |
| 112 | nl2br( esc_html( $excerpt ) ), |
| 113 | esc_html( $atts['readmore_text'] ) |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 | echo sprintf( |
| 118 | '<p class="give-donor__comment">%s</p>', |
| 119 | nl2br( esc_html( $comment ) ) |
| 120 | ); |
| 121 | ?> |
| 122 | </div> |
| 123 | <?php endif; ?> |
| 124 | </div> |
| 125 | </div> |
| 126 |