| @@ -2,34 +2,39 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * This template is used to display the donation summary with [give_receipt] |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -global $give_receipt_args, $payment; | |
| 6 | +use Give\Helpers\Frontend\Shortcode as ShortcodeUtils; | |
| 7 | 7 | |
| 8 | -// Validation: Ensure $payment var is set. | |
| 9 | -if ( empty( $payment ) ) { | |
| 10 | - $payment = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0; | |
| 8 | +global $give_receipt_args, $donation; | |
| 9 | + | |
| 10 | +// Validation: Ensure $donation var is set. | |
| 11 | +if ( empty( $donation ) ) { | |
| 12 | + $donation = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0; | |
| 11 | 13 | } |
| 12 | 14 | |
| 13 | -// Double-Validation: Check for $payment global. | |
| 14 | -if ( empty( $payment ) ) { | |
| 15 | - Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) ); | |
| 16 | - | |
| 15 | +/** | |
| 16 | + * Double-Validation: Check for $donation global. | |
| 17 | + * | |
| 18 | + * @since 3.4.0 Add additional validations to check if the form is valid and has the 'published' status. | |
| 19 | + */ | |
| 20 | +if ( ! is_object($donation) || ! ShortcodeUtils::isValidDonation($donation->ID)) { | |
| 21 | + Give_Notices::print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) ); | |
| 17 | 22 | return; |
| 18 | 23 | } |
| 19 | 24 | |
| 20 | -$donation_id = $payment->ID; | |
| 21 | -$donation_number = Give()->seq_donation_number->get_serial_code( $payment->ID ); | |
| 22 | -$form_id = give_get_payment_meta( $donation_id, '_give_payment_form_id', true ); | |
| 23 | -$donation = give_get_donation_form_title( $donation_id ); | |
| 24 | -$user = give_get_payment_meta_user_info( $donation_id ); | |
| 25 | -$email = give_get_payment_user_email( $donation_id ); | |
| 26 | -$status = $payment->post_status; | |
| 27 | -$status_label = give_get_payment_status( $payment, true ); | |
| 28 | -$company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true ); | |
| 25 | +$donation_id = $donation->ID; | |
| 26 | +$donation_number = Give()->seq_donation_number->get_serial_code( $donation_id ); | |
| 27 | +$form_id = give_get_payment_meta( $donation_id, '_give_payment_form_id', true ); | |
| 28 | +$form_name = give_get_donation_form_title( $donation_id ); | |
| 29 | +$user = give_get_payment_meta_user_info( $donation_id ); | |
| 30 | +$email = give_get_payment_user_email( $donation_id ); | |
| 31 | +$status = $donation->post_status; | |
| 32 | +$status_label = give_get_payment_status( $donation_id, true ); | |
| 33 | +$company_name = give_get_payment_meta( $donation_id, '_give_donation_company', true ); | |
| 29 | 34 | |
| 30 | 35 | // Update donor name, if title prefix is set. |
| 31 | -$full_name = give_get_donor_name_with_title_prefixes( $user['title'], "{$user['first_name']} {$user['last_name']}" ); | |
| 36 | +$full_name = give_get_donor_name_with_title_prefixes( $user['title'], "{$user['first_name']} {$user['last_name']}" ); | |
| 32 | 37 | |
| 33 | 38 | /** |
| 34 | 39 | * Generate Donation Receipt Arguments. |
| 35 | 40 | * |
| @@ -37,13 +42,13 @@ | ||
| 37 | 42 | * manage it from single variable |
| 38 | 43 | * |
| 39 | 44 | * @since 1.8.8 |
| 40 | 45 | */ |
| 41 | -$give_receipt_args['donation_receipt']['donor'] = array( | |
| 46 | +$give_receipt_args['donation_receipt']['donor'] = [ | |
| 42 | 47 | 'name' => __( 'Donor', 'give' ), |
| 43 | - 'value' => $full_name, | |
| 48 | + 'value' => esc_html( give_strip_shortcodes_deep( $full_name ) ), | |
| 44 | 49 | 'display' => $give_receipt_args['donor'], |
| 45 | -); | |
| 50 | +]; | |
| 46 | 51 | |
| 47 | 52 | /** |
| 48 | 53 | * Show Company name on Donation receipt Page |
| 49 | 54 | * |
| @@ -52,56 +57,57 @@ | ||
| 52 | 57 | * @param bool show/hide company name in donation receipt page. |
| 53 | 58 | * |
| 54 | 59 | * @return bool show/hide company name in donation receipt page. |
| 55 | 60 | */ |
| 56 | -$give_receipt_args['donation_receipt']['company_name'] = array( | |
| 61 | +$give_receipt_args['donation_receipt']['company_name'] = [ | |
| 57 | 62 | 'name' => __( 'Company Name', 'give' ), |
| 58 | - 'value' => esc_attr( $company_name ), | |
| 63 | + 'value' => esc_html( give_strip_shortcodes_deep( $company_name ) ), | |
| 59 | 64 | // Do not show company field if empty |
| 60 | 65 | 'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'], |
| 61 | -); | |
| 66 | +]; | |
| 62 | 67 | |
| 63 | -$give_receipt_args['donation_receipt']['date'] = array( | |
| 68 | +$give_receipt_args['donation_receipt']['date'] = [ | |
| 64 | 69 | 'name' => __( 'Date', 'give' ), |
| 65 | 70 | 'value' => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ), |
| 66 | 71 | 'display' => $give_receipt_args['date'], |
| 67 | -); | |
| 72 | +]; | |
| 68 | 73 | |
| 69 | -$give_receipt_args['donation_receipt']['total_donation'] = array( | |
| 74 | +$give_receipt_args['donation_receipt']['total_donation'] = [ | |
| 70 | 75 | 'name' => __( 'Total Donation', 'give' ), |
| 71 | - 'value' => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ), | |
| 76 | + 'value' => give_donation_amount( | |
| 77 | + $donation_id, | |
| 78 | + [ | |
| 79 | + 'currency' => true, | |
| 80 | + 'amount' => true, | |
| 81 | + 'type' => 'receipt', | |
| 82 | + ] | |
| 83 | + ), | |
| 72 | 84 | 'display' => $give_receipt_args['price'], |
| 73 | -); | |
| 85 | +]; | |
| 74 | 86 | |
| 75 | -$give_receipt_args['donation_receipt']['donation'] = array( | |
| 87 | +$give_receipt_args['donation_receipt']['donation'] = [ | |
| 76 | 88 | 'name' => __( 'Donation', 'give' ), |
| 77 | - 'value' => $donation, | |
| 89 | + 'value' => $form_name, | |
| 78 | 90 | 'display' => true, |
| 79 | -); | |
| 91 | +]; | |
| 80 | 92 | |
| 81 | -$give_receipt_args['donation_receipt']['donation_status'] = array( | |
| 93 | +$give_receipt_args['donation_receipt']['donation_status'] = [ | |
| 82 | 94 | 'name' => __( 'Donation Status', 'give' ), |
| 83 | 95 | 'value' => esc_attr( $status_label ), |
| 84 | 96 | 'display' => $give_receipt_args['payment_status'], |
| 85 | -); | |
| 97 | +]; | |
| 86 | 98 | |
| 87 | -$give_receipt_args['donation_receipt']['donation_id'] = array( | |
| 99 | +$give_receipt_args['donation_receipt']['donation_id'] = [ | |
| 88 | 100 | 'name' => __( 'Donation ID', 'give' ), |
| 89 | 101 | 'value' => $donation_number, |
| 90 | 102 | 'display' => $give_receipt_args['payment_id'], |
| 91 | -); | |
| 103 | +]; | |
| 92 | 104 | |
| 93 | -$give_receipt_args['donation_receipt']['payment_key'] = array( | |
| 94 | - 'name' => __( 'Payment Key', 'give' ), | |
| 95 | - 'value' => get_post_meta( $donation_id, '_give_payment_purchase_key', true ), | |
| 96 | - 'display' => $give_receipt_args['payment_key'], | |
| 97 | -); | |
| 98 | - | |
| 99 | -$give_receipt_args['donation_receipt']['payment_method'] = array( | |
| 105 | +$give_receipt_args['donation_receipt']['payment_method'] = [ | |
| 100 | 106 | 'name' => __( 'Payment Method', 'give' ), |
| 101 | 107 | 'value' => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ), |
| 102 | 108 | 'display' => $give_receipt_args['payment_method'], |
| 103 | -); | |
| 109 | +]; | |
| 104 | 110 | |
| 105 | 111 | /** |
| 106 | 112 | * Extend Give Donation Receipt |
| 107 | 113 | * |
| @@ -115,9 +121,9 @@ | ||
| 115 | 121 | */ |
| 116 | 122 | $give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id ); |
| 117 | 123 | |
| 118 | 124 | // When the donation were made through offline donation, We won't show receipt and payment status though. |
| 119 | -if ( 'offline' === give_get_payment_gateway( $payment->ID ) && 'pending' === $status ) { | |
| 125 | +if ( 'offline' === give_get_payment_gateway( $donation_id ) && 'pending' === $status ) { | |
| 120 | 126 | |
| 121 | 127 | /** |
| 122 | 128 | * Before the offline donation receipt content starts. |
| 123 | 129 | * |
| @@ -122,12 +128,12 @@ | ||
| 122 | 128 | * Before the offline donation receipt content starts. |
| 123 | 129 | * |
| 124 | 130 | * @since 1.8.14 |
| 125 | 131 | * |
| 126 | - * @param Give_Payment $payment Donation payment object. | |
| 132 | + * @param Give_Payment $donation Donation object. | |
| 127 | 133 | * @param array $give_receipt_args Receipt Arguments. |
| 128 | 134 | */ |
| 129 | - do_action( 'give_receipt_before_offline_payment', $payment, $give_receipt_args ); | |
| 135 | + do_action( 'give_receipt_before_offline_payment', $donation, $give_receipt_args ); | |
| 130 | 136 | ?> |
| 131 | 137 | <h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2> |
| 132 | 138 | <div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>"> |
| 133 | 139 | <?php |
| @@ -139,12 +145,12 @@ | ||
| 139 | 145 | * |
| 140 | 146 | * @since 1.8.14 |
| 141 | 147 | * |
| 142 | 148 | * @param string $offline_instruction Offline instruction content. |
| 143 | - * @param Give_Payment $payment Payment object. | |
| 149 | + * @param Give_Payment $donation Donation object. | |
| 144 | 150 | * @param integer $form_id Donation form id. |
| 145 | 151 | */ |
| 146 | - echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $payment, $form_id ); | |
| 152 | + echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $donation, $form_id ); | |
| 147 | 153 | ?> |
| 148 | 154 | </div> |
| 149 | 155 | <?php |
| 150 | 156 | /** |
| @@ -151,12 +157,12 @@ | ||
| 151 | 157 | * After the offline donation content ends. |
| 152 | 158 | * |
| 153 | 159 | * @since 1.8.14 |
| 154 | 160 | * |
| 155 | - * @param Give_Payment $payment Donation payment object. | |
| 161 | + * @param Give_Payment $donation Donation object. | |
| 156 | 162 | * @param array $give_receipt_args Receipt Arguments. |
| 157 | 163 | */ |
| 158 | - do_action( 'give_receipt_after_offline_payment', $payment, $give_receipt_args ); | |
| 164 | + do_action( 'give_receipt_after_offline_payment', $donation, $give_receipt_args ); | |
| 159 | 165 | |
| 160 | 166 | return; |
| 161 | 167 | } |
| 162 | 168 | |
| @@ -199,38 +205,37 @@ | ||
| 199 | 205 | $notice_type = 'error'; |
| 200 | 206 | break; |
| 201 | 207 | } |
| 202 | 208 | |
| 203 | - if ( ! empty( $notice_message ) ) { | |
| 204 | - /** | |
| 205 | - * Filters payment status notice for receipts. | |
| 206 | - * | |
| 207 | - * By default, a success, warning, or error notice appears on the receipt | |
| 208 | - * with payment status. This filter allows the HTML markup | |
| 209 | - * and messaging for that notice to be customized. | |
| 210 | - * | |
| 211 | - * @since 1.0 | |
| 212 | - * | |
| 213 | - * @param string $notice HTML markup for the default notice. | |
| 214 | - * @param int $id Post ID where the notice is displayed. | |
| 215 | - * @param string $status Payment status. | |
| 216 | - * @param int $donation_id Donation ID. | |
| 217 | - */ | |
| 218 | - echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id ); | |
| 219 | - } | |
| 209 | + /** | |
| 210 | + * Filters payment status notice for receipts. | |
| 211 | + * | |
| 212 | + * By default, a success, warning, or error notice appears on the receipt | |
| 213 | + * with payment status. This filter allows the HTML markup | |
| 214 | + * and messaging for that notice to be customized. | |
| 215 | + * | |
| 216 | + * @since 1.0 | |
| 217 | + * | |
| 218 | + * @param string $notice HTML markup for the default notice. | |
| 219 | + * @param int $id Post ID where the notice is displayed. | |
| 220 | + * @param string $status Payment status. | |
| 221 | + * @param int $donation_id Donation ID. | |
| 222 | + */ | |
| 223 | + echo apply_filters( 'give_receipt_status_notice', Give_Notices::print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id ); | |
| 224 | + | |
| 220 | 225 | }// End if(). |
| 221 | 226 | |
| 222 | 227 | /** |
| 223 | - * Fires in the payment receipt shortcode, before the receipt main table. | |
| 228 | + * Fires in the donation receipt shortcode, before the receipt main table. | |
| 224 | 229 | * |
| 225 | 230 | * Allows you to add elements before the table. |
| 226 | 231 | * |
| 227 | 232 | * @since 1.0 |
| 228 | 233 | * |
| 229 | - * @param object $payment The payment object. | |
| 234 | + * @param object $donation Donation object. | |
| 230 | 235 | * @param array $give_receipt_args Receipt_argument. |
| 231 | 236 | */ |
| 232 | -do_action( 'give_payment_receipt_before_table', $payment, $give_receipt_args ); | |
| 237 | +do_action( 'give_payment_receipt_before_table', $donation, $give_receipt_args ); | |
| 233 | 238 | ?> |
| 234 | 239 | |
| 235 | 240 | <table id="give_donation_receipt" class="give-table"> |
| 236 | 241 | <thead> |
| @@ -235,36 +240,36 @@ | ||
| 235 | 240 | <table id="give_donation_receipt" class="give-table"> |
| 236 | 241 | <thead> |
| 237 | 242 | <?php |
| 238 | 243 | /** |
| 239 | - * Fires in the payment receipt shortcode, before the receipt first header item. | |
| 244 | + * Fires in the donation receipt shortcode, before the receipt first header item. | |
| 240 | 245 | * |
| 241 | 246 | * Allows you to add new <th> elements before the receipt first header item. |
| 242 | 247 | * |
| 243 | 248 | * @since 1.7 |
| 244 | 249 | * |
| 245 | - * @param object $payment The payment object. | |
| 250 | + * @param object $donation Donation object. | |
| 246 | 251 | * @param array $give_receipt_args Receipt_argument. |
| 247 | 252 | */ |
| 248 | - do_action( 'give_payment_receipt_header_before', $payment, $give_receipt_args ); | |
| 253 | + do_action( 'give_payment_receipt_header_before', $donation, $give_receipt_args ); | |
| 249 | 254 | ?> |
| 250 | 255 | <tr> |
| 251 | 256 | <th scope="colgroup" colspan="2"> |
| 252 | - <span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span> | |
| 257 | + <span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ); ?></span> | |
| 253 | 258 | </th> |
| 254 | 259 | </tr> |
| 255 | 260 | <?php |
| 256 | 261 | /** |
| 257 | - * Fires in the payment receipt shortcode, after the receipt last header item. | |
| 262 | + * Fires in the donation receipt shortcode, after the receipt last header item. | |
| 258 | 263 | * |
| 259 | 264 | * Allows you to add new <th> elements after the receipt last header item. |
| 260 | 265 | * |
| 261 | 266 | * @since 1.7 |
| 262 | 267 | * |
| 263 | - * @param object $payment The payment object. | |
| 268 | + * @param object $donation Donation object. | |
| 264 | 269 | * @param array $give_receipt_args Receipt_argument. |
| 265 | 270 | */ |
| 266 | - do_action( 'give_payment_receipt_header_after', $payment, $give_receipt_args ); | |
| 271 | + do_action( 'give_payment_receipt_header_after', $donation, $give_receipt_args ); | |
| 267 | 272 | ?> |
| 268 | 273 | </thead> |
| 269 | 274 | |
| 270 | 275 | <tbody> |
| @@ -269,18 +274,18 @@ | ||
| 269 | 274 | |
| 270 | 275 | <tbody> |
| 271 | 276 | <?php |
| 272 | 277 | /** |
| 273 | - * Fires in the payment receipt shortcode, before the receipt first item. | |
| 278 | + * Fires in the donation receipt shortcode, before the receipt first item. | |
| 274 | 279 | * |
| 275 | 280 | * Allows you to add new <td> elements before the receipt first item. |
| 276 | 281 | * |
| 277 | 282 | * @since 1.7 |
| 278 | 283 | * |
| 279 | - * @param object $payment The payment object. | |
| 284 | + * @param object $donation Donation object. | |
| 280 | 285 | * @param array $give_receipt_args Receipt_argument. |
| 281 | 286 | */ |
| 282 | - do_action( 'give_payment_receipt_before', $payment, $give_receipt_args ); | |
| 287 | + do_action( 'give_payment_receipt_before', $donation, $give_receipt_args ); | |
| 283 | 288 | ?> |
| 284 | 289 | |
| 285 | 290 | <?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?> |
| 286 | 291 | <?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?> |
| @@ -292,18 +297,18 @@ | ||
| 292 | 297 | <?php } ?> |
| 293 | 298 | |
| 294 | 299 | <?php |
| 295 | 300 | /** |
| 296 | - * Fires in the payment receipt shortcode, after the receipt last item. | |
| 301 | + * Fires in the donation receipt shortcode, after the receipt last item. | |
| 297 | 302 | * |
| 298 | 303 | * Allows you to add new <td> elements after the receipt last item. |
| 299 | 304 | * |
| 300 | 305 | * @since 1.7 |
| 301 | 306 | * |
| 302 | - * @param object $payment The payment object. | |
| 307 | + * @param object $donation Donation object. | |
| 303 | 308 | * @param array $give_receipt_args Receipt_argument. |
| 304 | 309 | */ |
| 305 | - do_action( 'give_payment_receipt_after', $payment, $give_receipt_args ); | |
| 310 | + do_action( 'give_payment_receipt_after', $donation, $give_receipt_args ); | |
| 306 | 311 | ?> |
| 307 | 312 | </tbody> |
| 308 | 313 | </table> |
| 309 | 314 | |
| @@ -308,15 +313,15 @@ | ||
| 308 | 313 | </table> |
| 309 | 314 | |
| 310 | 315 | <?php |
| 311 | 316 | /** |
| 312 | - * Fires in the payment receipt shortcode, after the receipt main table. | |
| 317 | + * Fires in the donation receipt shortcode, after the receipt main table. | |
| 313 | 318 | * |
| 314 | 319 | * Allows you to add elements after the table. |
| 315 | 320 | * |
| 316 | 321 | * @since 1.7 |
| 317 | 322 | * |
| 318 | - * @param object $payment The payment object. | |
| 323 | + * @param object $donation Donation object. | |
| 319 | 324 | * @param array $give_receipt_args Receipt_argument. |
| 320 | 325 | */ |
| 321 | -do_action( 'give_payment_receipt_after_table', $payment, $give_receipt_args ); | |
| 326 | +do_action( 'give_payment_receipt_after_table', $donation, $give_receipt_args ); | |
| 322 | 327 | ?> |