emails
8 years ago
global
8 years ago
single-give-form
8 years ago
email-login-form.php
8 years ago
give-rtl.css
8 years ago
give-rtl.min.css
8 years ago
give.css
8 years ago
give.min.css
8 years ago
history-donations.php
8 years ago
payment-processing.php
8 years ago
shortcode-form-grid.php
8 years ago
shortcode-goal.php
8 years ago
shortcode-login.php
8 years ago
shortcode-profile-editor.php
8 years ago
shortcode-receipt.php
8 years ago
shortcode-register.php
8 years ago
shortcode-totals-progress.php
8 years ago
single-give-form.php
8 years ago
history-donations.php
253 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 | give_set_error( 'give-limited-throttle', sprintf( |
| 33 | __( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ), |
| 34 | sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value ) |
| 35 | ) ); |
| 36 | |
| 37 | } |
| 38 | |
| 39 | $donations = give_get_users_donations( $email, give_get_limit_display_donations(), true, 'any' ); |
| 40 | } else { |
| 41 | $donations = give_get_users_donations( $email, 20, true, 'any' ); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | Give()->notices->render_frontend_notices( 0 ); |
| 46 | |
| 47 | if ( $donations ) : ?> |
| 48 | <?php |
| 49 | $table_headings = array( |
| 50 | 'id' => __( 'ID', 'give' ), |
| 51 | 'date' => __( 'Date', 'give' ), |
| 52 | 'donor' => __( 'Donor', 'give' ), |
| 53 | 'amount' => __( 'Amount', 'give' ), |
| 54 | 'status' => __( 'Status', 'give' ), |
| 55 | 'payment_method' => __( 'Payment Method', 'give' ), |
| 56 | 'details' => __( 'Details', 'give' ), |
| 57 | ); |
| 58 | ?> |
| 59 | <div class="give_user_history_main" > |
| 60 | <div class="give_user_history_notice"></div> |
| 61 | <table id="give_user_history" class="give-table"> |
| 62 | <thead> |
| 63 | <tr class="give-donation-row"> |
| 64 | <?php |
| 65 | /** |
| 66 | * Fires in current user donation history table, before the header row start. |
| 67 | * |
| 68 | * Allows you to add new <th> elements to the header, before other headers in the row. |
| 69 | * |
| 70 | * @since 1.7 |
| 71 | */ |
| 72 | do_action( 'give_donation_history_header_before' ); |
| 73 | |
| 74 | foreach ( $donation_history_args as $index => $value ) { |
| 75 | if ( filter_var( $donation_history_args[ $index ], FILTER_VALIDATE_BOOLEAN ) ) : |
| 76 | echo sprintf( |
| 77 | '<th scope="col" class="give-donation-%1$s>">%2$s</th>', |
| 78 | $index, |
| 79 | $table_headings[ $index ] |
| 80 | ); |
| 81 | endif; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Fires in current user donation history table, after the header row ends. |
| 86 | * |
| 87 | * Allows you to add new <th> elements to the header, after other headers in the row. |
| 88 | * |
| 89 | * @since 1.7 |
| 90 | */ |
| 91 | do_action( 'give_donation_history_header_after' ); |
| 92 | ?> |
| 93 | </tr> |
| 94 | </thead> |
| 95 | <?php foreach ( $donations as $post ) : |
| 96 | setup_postdata( $post ); |
| 97 | $donation_data = give_get_payment_meta( $post->ID ); ?> |
| 98 | <tr class="give-donation-row"> |
| 99 | <?php |
| 100 | /** |
| 101 | * Fires in current user donation history table, before the row statrs. |
| 102 | * |
| 103 | * Allows you to add new <td> elements to the row, before other elements in the row. |
| 104 | * |
| 105 | * @since 1.7 |
| 106 | * |
| 107 | * @param int $post_id The ID of the post. |
| 108 | * @param mixed $donation_data Payment meta data. |
| 109 | */ |
| 110 | do_action( 'give_donation_history_row_start', $post->ID, $donation_data ); |
| 111 | |
| 112 | if ( filter_var( $donation_history_args['id'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 113 | echo sprintf( |
| 114 | '<td class="give-donation-id"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
| 115 | give_get_payment_number( $post->ID ), esc_html( $table_headings['id'] ) |
| 116 | ); |
| 117 | endif; |
| 118 | |
| 119 | if ( filter_var( $donation_history_args['date'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 120 | echo sprintf( |
| 121 | '<td class="give-donation-date"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
| 122 | date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ), esc_html( $table_headings['date'] ) |
| 123 | ); |
| 124 | endif; |
| 125 | |
| 126 | if ( filter_var( $donation_history_args['donor'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 127 | echo sprintf( |
| 128 | '<td class="give-donation-donor"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
| 129 | give_get_donor_name_by( $post->ID ), $table_headings['donor'] |
| 130 | ); |
| 131 | endif; |
| 132 | ?> |
| 133 | |
| 134 | <?php if ( filter_var( $donation_history_args['amount'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
| 135 | <td class="give-donation-amount"> |
| 136 | <?php printf( '<span class="title-for-mobile">%1$s</span>', esc_html( $table_headings['amount'] ) ); ?> |
| 137 | <span class="give-donation-amount"> |
| 138 | <?php |
| 139 | $currency_code = give_get_payment_currency_code( $post->ID ); |
| 140 | $donation_amount = give_donation_amount( $post->ID, true ); |
| 141 | |
| 142 | /** |
| 143 | * Filters the donation amount on Donation History Page. |
| 144 | * |
| 145 | * @param int $donation_amount Donation Amount. |
| 146 | * @param int $post_id Donation ID. |
| 147 | * |
| 148 | * @since 1.8.13 |
| 149 | * |
| 150 | * @return int |
| 151 | */ |
| 152 | echo apply_filters( 'give_donation_history_row_amount', $donation_amount, $post->ID ); |
| 153 | ?> |
| 154 | </span> |
| 155 | </td> |
| 156 | <?php endif; ?> |
| 157 | |
| 158 | <?php |
| 159 | if ( filter_var( $donation_history_args['status'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 160 | echo sprintf( |
| 161 | '<td class="give-donation-status"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
| 162 | give_get_payment_status( $post, true ), |
| 163 | esc_html( $table_headings['status'] ) |
| 164 | ); |
| 165 | endif; |
| 166 | |
| 167 | if ( filter_var( $donation_history_args['payment_method'], FILTER_VALIDATE_BOOLEAN ) ) : |
| 168 | echo sprintf( |
| 169 | '<td class="give-donation-payment-method"><span class="title-for-mobile">%2$s</span>%1$s</td>', |
| 170 | give_get_gateway_checkout_label( give_get_payment_gateway( $post->ID ) ), |
| 171 | esc_html( $table_headings['payment_method'] ) |
| 172 | ); |
| 173 | endif; |
| 174 | ?> |
| 175 | <td class="give-donation-details"> |
| 176 | <?php |
| 177 | // Display View Receipt or. |
| 178 | if ( 'publish' !== $post->post_status && 'subscription' !== $post->post_status ) : |
| 179 | echo sprintf( |
| 180 | '<span class="title-for-mobile">%4$s</span><a href="%1$s"><span class="give-donation-status %2$s">%3$s</span></a>', |
| 181 | esc_url( |
| 182 | add_query_arg( |
| 183 | 'payment_key', |
| 184 | give_get_payment_key( $post->ID ), |
| 185 | give_get_history_page_uri() |
| 186 | ) |
| 187 | ), |
| 188 | $post->post_status, |
| 189 | __( 'View', 'give' ) . ' ' . give_get_payment_status( $post, true ) . ' »', |
| 190 | esc_html( $table_headings['details'] ) |
| 191 | ); |
| 192 | |
| 193 | else : |
| 194 | echo sprintf( |
| 195 | '<span class="title-for-mobile">%3$s</span><a href="%1$s">%2$s</a>', |
| 196 | esc_url( |
| 197 | add_query_arg( |
| 198 | 'payment_key', |
| 199 | give_get_payment_key( $post->ID ), |
| 200 | give_get_history_page_uri() |
| 201 | ) |
| 202 | ), |
| 203 | __( 'View Receipt »', 'give' ), |
| 204 | esc_html( $table_headings['details'] ) |
| 205 | ); |
| 206 | |
| 207 | endif; |
| 208 | ?> |
| 209 | </td> |
| 210 | <?php |
| 211 | /** |
| 212 | * Fires in current user donation history table, after the row ends. |
| 213 | * |
| 214 | * Allows you to add new <td> elements to the row, after other elements in the row. |
| 215 | * |
| 216 | * @since 1.7 |
| 217 | * |
| 218 | * @param int $post_id The ID of the post. |
| 219 | * @param mixed $donation_data Payment meta data. |
| 220 | */ |
| 221 | do_action( 'give_donation_history_row_end', $post->ID, $donation_data ); |
| 222 | ?> |
| 223 | </tr> |
| 224 | <?php endforeach; ?> |
| 225 | |
| 226 | <?php |
| 227 | /** |
| 228 | * Fires in footer of user donation history table. |
| 229 | * |
| 230 | * Allows you to add new <tfoot> elements to the row, after other elements in the row. |
| 231 | * |
| 232 | * @since 1.8.17 |
| 233 | */ |
| 234 | do_action( 'give_donation_history_table_end' ); |
| 235 | ?> |
| 236 | </table> |
| 237 | <div id="give-donation-history-pagination" class="give_pagination navigation"> |
| 238 | <?php |
| 239 | $big = 999999; |
| 240 | echo paginate_links( array( |
| 241 | 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
| 242 | 'format' => '?paged=%#%', |
| 243 | 'current' => max( 1, get_query_var( 'paged' ) ), |
| 244 | 'total' => ceil( give_count_donations_of_donor() / 20 ), // 20 items per page |
| 245 | ) ); |
| 246 | ?> |
| 247 | </div> |
| 248 | </div> |
| 249 | <?php wp_reset_postdata(); ?> |
| 250 | <?php else : ?> |
| 251 | <?php Give()->notices->print_frontend_notice( __( 'It looks like you haven\'t made any donations.', 'give' ), true, 'success' ); ?> |
| 252 | <?php endif; |
| 253 |