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
6 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
history-donations.php
279 lines
| 1 | <?php |
| 2 | /** |
| 3 | * This template is used to display the donation history of the current user. |
| 4 | */ |
| 5 | |
| 6 | $donations = array(); |
| 7 | $donation_history_args = Give()->session->get( 'give_donation_history_args' ); |
| 8 | |
| 9 | // User's Donations. |
| 10 | if ( is_user_logged_in() ) { |
| 11 | $donations = give_get_users_donations( get_current_user_id(), 20, true, 'any' ); |
| 12 | } elseif ( Give()->email_access->token_exists ) { |
| 13 | // Email Access Token? |
| 14 | $donations = give_get_users_donations( 0, 20, true, 'any' ); |
| 15 | } elseif ( |
| 16 | false !== Give()->session->get_session_expiration() || |
| 17 | true === give_get_history_session() |
| 18 | ) { |
| 19 | // Session active? |
| 20 | $email = Give()->session->get( 'give_email' ); |
| 21 | $donor = Give()->donors->get_donor_by( 'email', $email ); |
| 22 | $donations_count = count( explode( ',', $donor->payment_ids ) ); |
| 23 | |
| 24 | if ( $donations_count > give_get_limit_display_donations() ) { |
| 25 | |
| 26 | // Restrict Security Email Access option, if donation count of a donor is less than or equal to limit. |
| 27 | if ( true !== Give_Cache::get( "give_cache_email_throttle_limit_exhausted_{$donor->id}" ) ) { |
| 28 | add_action( 'give_donation_history_table_end', 'give_donation_history_table_end' ); |
| 29 | } else { |
| 30 | $value = Give()->email_access->verify_throttle / 60; |
| 31 | |
| 32 | /** |
| 33 | * Filter to modify email access exceed notices message. |
| 34 | * |
| 35 | * @since 2.1.3 |
| 36 | * |
| 37 | * @param string $message email access exceed notices message |
| 38 | * @param int $value email access exceed times |
| 39 | * |
| 40 | * @return string $message email access exceed notices message |
| 41 | */ |
| 42 | $message = (string) apply_filters( |
| 43 | 'give_email_access_requests_exceed_notice', |
| 44 | sprintf( |
| 45 | __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
| 46 | sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
| 47 | ), |
| 48 | $value |
| 49 | ); |
| 50 | |
| 51 | give_set_error( |
| 52 | 'give-limited-throttle', |
| 53 | $message |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | $donations = give_get_users_donations( $email, give_get_limit_display_donations(), true, 'any' ); |
| 58 | } else { |
| 59 | $donations = give_get_users_donations( $email, 20, true, 'any' ); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | Give()->notices->render_frontend_notices( 0 ); |
| 64 | |
| 65 | if ( $donations ) : ?> |
| 66 | <?php |
| 67 | $table_headings = array( |
| 68 | 'id' => __( 'ID', 'give' ), |
| 69 | 'date' => __( 'Date', 'give' ), |
| 70 | 'donor' => __( 'Donor', 'give' ), |
| 71 | 'amount' => __( 'Amount', 'give' ), |
| 72 | 'status' => __( 'Status', 'give' ), |
| 73 | 'payment_method' => __( 'Payment Method', 'give' ), |
| 74 | 'details' => __( 'Details', 'give' ), |
| 75 | ); |
| 76 | ?> |
| 77 | <div class="give_user_history_main" > |
| 78 | <div class="give_user_history_notice"></div> |
| 79 | <table id="give_user_history" class="give-table"> |
| 80 | <thead> |
| 81 | <tr class="give-donation-row"> |
| 82 | <?php |
| 83 | /** |
| 84 | * Fires in current user donation history table, before the header row start. |
| 85 | * |
| 86 | * Allows you to add new <th> elements to the header, before other headers in the row. |
| 87 | * |
| 88 | * @since 1.7 |
| 89 | */ |
| 90 | do_action( 'give_donation_history_header_before' ); |
| 91 | |
| 92 | foreach ( $donation_history_args as $index => $value ) { |
| 93 | if ( filter_var( $donation_history_args[ $index ], FILTER_VALIDATE_BOOLEAN ) ) : |
| 94 | echo sprintf( |
| 95 | '<th scope="col" class="give-donation-%1$s>">%2$s</th>', |
| 96 | $index, |
| 97 | $table_headings[ $index ] |
| 98 | ); |
| 99 | endif; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Fires in current user donation history table, after the header row ends. |
| 104 | * |
| 105 | * Allows you to add new <th> elements to the header, after other headers in the row. |
| 106 | * |
| 107 | * @since 1.7 |
| 108 | */ |
| 109 | do_action( 'give_donation_history_header_after' ); |
| 110 | ?> |
| 111 | </tr> |
| 112 | </thead> |
| 113 | <?php |
| 114 | foreach ( $donations as $post ) : |
| 115 | setup_postdata( $post ); |
| 116 | $donation_data = give_get_payment_meta( $post->ID ); |
| 117 | ?> |
| 118 | <tr class="give-donation-row"> |
| 119 | <?php |
| 120 | /** |
| 121 | * Fires in current user donation history table, before the row statrs. |
| 122 | * |
| 123 | * Allows you to add new <td> elements to the row, before other elements in the row. |
| 124 | * |
| 125 | * @since 1.7 |
| 126 | * |
| 127 | * @param int $post_id The ID of the post. |
| 128 | * @param mixed $donation_data Payment meta data. |
| 129 | */ |
| 130 | do_action( 'give_donation_history_row_start', $post->ID, $donation_data ); |
| 131 | |
| 132 | if ( filter_var( $donation_history_args['id'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 133 | echo sprintf( |
| 134 | '<td class="give-donation-id"><span class="give-mobile-title">%2$s</span>%1$s</td>', |
| 135 | give_get_payment_number( $post->ID ), |
| 136 | esc_html( $table_headings['id'] ) |
| 137 | ); |
| 138 | endif; |
| 139 | |
| 140 | if ( filter_var( $donation_history_args['date'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 141 | echo sprintf( |
| 142 | '<td class="give-donation-date"><span class="give-mobile-title">%2$s</span>%1$s</td>', |
| 143 | date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ), |
| 144 | esc_html( $table_headings['date'] ) |
| 145 | ); |
| 146 | endif; |
| 147 | |
| 148 | if ( filter_var( $donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 149 | echo sprintf( |
| 150 | '<td class="give-donation-donor"><span class="give-mobile-title">%2$s</span>%1$s</td>', |
| 151 | give_get_donor_name_by( $post->ID ), |
| 152 | $table_headings['donor'] |
| 153 | ); |
| 154 | endif; |
| 155 | ?> |
| 156 | |
| 157 | <?php if ( filter_var( $donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
| 158 | <td class="give-donation-amount"> |
| 159 | <?php printf( '<span class="give-mobile-title">%1$s</span>', esc_html( $table_headings['amount'] ) ); ?> |
| 160 | <span class="give-donation-amount"> |
| 161 | <?php |
| 162 | $currency_code = give_get_payment_currency_code( $post->ID ); |
| 163 | $donation_amount = give_donation_amount( $post->ID, true ); |
| 164 | |
| 165 | /** |
| 166 | * Filters the donation amount on Donation History Page. |
| 167 | * |
| 168 | * @param int $donation_amount Donation Amount. |
| 169 | * @param int $post_id Donation ID. |
| 170 | * |
| 171 | * @since 1.8.13 |
| 172 | * |
| 173 | * @return int |
| 174 | */ |
| 175 | echo apply_filters( 'give_donation_history_row_amount', $donation_amount, $post->ID ); |
| 176 | ?> |
| 177 | </span> |
| 178 | </td> |
| 179 | <?php endif; ?> |
| 180 | |
| 181 | <?php |
| 182 | if ( filter_var( $donation_history_args['status'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 183 | echo sprintf( |
| 184 | '<td class="give-donation-status"><span class="give-mobile-title">%2$s</span>%1$s</td>', |
| 185 | give_get_payment_status( $post, true ), |
| 186 | esc_html( $table_headings['status'] ) |
| 187 | ); |
| 188 | endif; |
| 189 | |
| 190 | if ( filter_var( $donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 191 | echo sprintf( |
| 192 | '<td class="give-donation-payment-method"><span class="give-mobile-title">%2$s</span>%1$s</td>', |
| 193 | give_get_gateway_checkout_label( give_get_payment_gateway( $post->ID ) ), |
| 194 | esc_html( $table_headings['payment_method'] ) |
| 195 | ); |
| 196 | endif; |
| 197 | ?> |
| 198 | <td class="give-donation-details"> |
| 199 | <?php |
| 200 | // Display View Receipt or. |
| 201 | if ( 'publish' !== $post->post_status && 'subscription' !== $post->post_status ) : |
| 202 | echo sprintf( |
| 203 | '<span class="give-mobile-title">%4$s</span><a href="%1$s"><span class="give-donation-status %2$s">%3$s</span></a>', |
| 204 | esc_url( |
| 205 | add_query_arg( |
| 206 | 'donation_id', |
| 207 | $post->ID, |
| 208 | give_get_history_page_uri() |
| 209 | ) |
| 210 | ), |
| 211 | $post->post_status, |
| 212 | __( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »', |
| 213 | esc_html( $table_headings['details'] ) |
| 214 | ); |
| 215 | |
| 216 | else : |
| 217 | echo sprintf( |
| 218 | '<span class="give-mobile-title">%3$s</span><a href="%1$s">%2$s</a>', |
| 219 | esc_url( |
| 220 | add_query_arg( |
| 221 | 'donation_id', |
| 222 | $post->ID, |
| 223 | give_get_history_page_uri() |
| 224 | ) |
| 225 | ), |
| 226 | __( 'View Receipt »', 'give' ), |
| 227 | esc_html( $table_headings['details'] ) |
| 228 | ); |
| 229 | |
| 230 | endif; |
| 231 | ?> |
| 232 | </td> |
| 233 | <?php |
| 234 | /** |
| 235 | * Fires in current user donation history table, after the row ends. |
| 236 | * |
| 237 | * Allows you to add new <td> elements to the row, after other elements in the row. |
| 238 | * |
| 239 | * @since 1.7 |
| 240 | * |
| 241 | * @param int $post_id The ID of the post. |
| 242 | * @param mixed $donation_data Payment meta data. |
| 243 | */ |
| 244 | do_action( 'give_donation_history_row_end', $post->ID, $donation_data ); |
| 245 | ?> |
| 246 | </tr> |
| 247 | <?php endforeach; ?> |
| 248 | |
| 249 | <?php |
| 250 | /** |
| 251 | * Fires in footer of user donation history table. |
| 252 | * |
| 253 | * Allows you to add new <tfoot> elements to the row, after other elements in the row. |
| 254 | * |
| 255 | * @since 1.8.17 |
| 256 | */ |
| 257 | do_action( 'give_donation_history_table_end' ); |
| 258 | ?> |
| 259 | </table> |
| 260 | <div id="give-donation-history-pagination" class="give_pagination navigation"> |
| 261 | <?php |
| 262 | $big = 999999; |
| 263 | echo paginate_links( |
| 264 | array( |
| 265 | 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
| 266 | 'format' => '?paged=%#%', |
| 267 | 'current' => max( 1, get_query_var( 'paged' ) ), |
| 268 | 'total' => ceil( give_count_donations_of_donor() / 20 ), // 20 items per page |
| 269 | ) |
| 270 | ); |
| 271 | ?> |
| 272 | </div> |
| 273 | </div> |
| 274 | <?php wp_reset_postdata(); ?> |
| 275 | <?php else : ?> |
| 276 | <?php Give_Notices::print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
| 277 | <?php |
| 278 | endif; |
| 279 |