← All changes
|
includes/admin/emails/class-donation-receipt-email.php
+53
-28
2.3.0
→
4.17.0
View file →
| @@ -1,12 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Donation Receipt Email |
| 4 | 4 | * |
| 5 | - * | |
| 6 | 5 | * @package Give |
| 7 | 6 | * @subpackage Classes/Emails |
| 8 | - * @copyright Copyright (c) 2016, WordImpress | |
| 7 | + * @copyright Copyright (c) 2016, GiveWP | |
| 9 | 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 10 | 9 | * @since 2.0 |
| 11 | 10 | */ |
| 12 | 11 | |
| @@ -36,19 +35,21 @@ | ||
| 36 | 35 | public function init() { |
| 37 | 36 | // Initialize empty payment. |
| 38 | 37 | $this->payment = new Give_Payment( 0 ); |
| 39 | 38 | |
| 40 | - $this->load( array( | |
| 41 | - 'id' => 'donation-receipt', | |
| 42 | - 'label' => __( 'Donation Receipt', 'give' ), | |
| 43 | - 'description' => __( 'Sent to the donor when their donation completes or a pending donation is marked as complete.', 'give' ), | |
| 44 | - 'notification_status' => 'enabled', | |
| 45 | - 'form_metabox_setting' => true, | |
| 46 | - 'recipient_group_name' => __( 'Donor', 'give' ), | |
| 47 | - 'default_email_subject' => esc_attr__( 'Donation Receipt', 'give' ), | |
| 48 | - 'default_email_message' => give_get_default_donation_receipt_email(), | |
| 49 | - 'default_email_header' => __( 'Donation Receipt', 'give' ), | |
| 50 | - ) ); | |
| 39 | + $this->load( | |
| 40 | + array( | |
| 41 | + 'id' => 'donation-receipt', | |
| 42 | + 'label' => __( 'Donation Receipt', 'give' ), | |
| 43 | + 'description' => __( 'Sent to the donor when their donation completes or a pending donation is marked as complete.', 'give' ), | |
| 44 | + 'notification_status' => 'enabled', | |
| 45 | + 'form_metabox_setting' => true, | |
| 46 | + 'recipient_group_name' => __( 'Donor', 'give' ), | |
| 47 | + 'default_email_subject' => esc_attr__( 'Donation Receipt', 'give' ), | |
| 48 | + 'default_email_message' => give_get_default_donation_receipt_email(), | |
| 49 | + 'default_email_header' => __( 'Donation Receipt', 'give' ), | |
| 50 | + ) | |
| 51 | + ); | |
| 51 | 52 | |
| 52 | 53 | add_action( "give_{$this->config['id']}_email_notification", array( $this, 'send_donation_receipt' ) ); |
| 53 | 54 | add_action( 'give_email_links', array( $this, 'resend_donation_receipt' ) ); |
| 54 | 55 | } |
| @@ -166,9 +167,9 @@ | ||
| 166 | 167 | * |
| 167 | 168 | * @param int $form_id |
| 168 | 169 | * @return array |
| 169 | 170 | */ |
| 170 | - public function get_email_attachments( $form_id = null) { | |
| 171 | + public function get_email_attachments( $form_id = null ) { | |
| 171 | 172 | /** |
| 172 | 173 | * Filter the attachments. |
| 173 | 174 | * Note: this filter will deprecate soon. |
| 174 | 175 | * |
| @@ -267,15 +268,27 @@ | ||
| 267 | 268 | */ |
| 268 | 269 | public function send_donation_receipt( $payment_id ) { |
| 269 | 270 | $this->payment = new Give_Payment( $payment_id ); |
| 270 | 271 | |
| 272 | + if ( ! $this->payment->ID ) { | |
| 273 | + wp_die( | |
| 274 | + esc_html__( 'Cheatin’ uh?', 'give' ), | |
| 275 | + esc_html__( 'Error', 'give' ), | |
| 276 | + array( | |
| 277 | + 'response' => 400, | |
| 278 | + ) | |
| 279 | + ); | |
| 280 | + } | |
| 281 | + | |
| 271 | 282 | // Setup email data. |
| 272 | 283 | $this->setup_email_data(); |
| 273 | 284 | |
| 274 | 285 | // Send email. |
| 275 | - $this->send_email_notification( array( | |
| 276 | - 'payment_id' => $this->payment->ID, | |
| 277 | - ) ); | |
| 286 | + $this->send_email_notification( | |
| 287 | + array( | |
| 288 | + 'payment_id' => $this->payment->ID, | |
| 289 | + ) | |
| 290 | + ); | |
| 278 | 291 | } |
| 279 | 292 | |
| 280 | 293 | /** |
| 281 | 294 | * Resend payment receipt by row action. |
| @@ -295,11 +308,15 @@ | ||
| 295 | 308 | // Get donation payment information. |
| 296 | 309 | $this->payment = new Give_Payment( $purchase_id ); |
| 297 | 310 | |
| 298 | 311 | if ( ! current_user_can( 'edit_give_payments', $this->payment->ID ) ) { |
| 299 | - wp_die( esc_html__( 'You do not have permission to edit donations.', 'give' ), esc_html__( 'Error', 'give' ), array( | |
| 300 | - 'response' => 403, | |
| 301 | - ) ); | |
| 312 | + wp_die( | |
| 313 | + esc_html__( 'Cheatin’ uh?', 'give' ), | |
| 314 | + esc_html__( 'Error', 'give' ), | |
| 315 | + array( | |
| 316 | + 'response' => 400, | |
| 317 | + ) | |
| 318 | + ); | |
| 302 | 319 | } |
| 303 | 320 | |
| 304 | 321 | // Setup email data. |
| 305 | 322 | $this->setup_email_data(); |
| @@ -304,17 +321,25 @@ | ||
| 304 | 321 | // Setup email data. |
| 305 | 322 | $this->setup_email_data(); |
| 306 | 323 | |
| 307 | 324 | // Send email. |
| 308 | - $this->send_email_notification( array( | |
| 309 | - 'payment_id' => $this->payment->ID, | |
| 310 | - ) ); | |
| 325 | + $this->send_email_notification( | |
| 326 | + array( | |
| 327 | + 'payment_id' => $this->payment->ID, | |
| 328 | + ) | |
| 329 | + ); | |
| 311 | 330 | |
| 312 | - wp_redirect( add_query_arg( array( | |
| 313 | - 'give-messages[]' => 'email-sent', | |
| 314 | - 'give-action' => false, | |
| 315 | - 'purchase_id' => false, | |
| 316 | - ) ) ); | |
| 331 | + wp_redirect( | |
| 332 | + esc_url_raw( | |
| 333 | + add_query_arg( | |
| 334 | + array( | |
| 335 | + 'give-messages[]' => 'email-sent', | |
| 336 | + 'give-action' => false, | |
| 337 | + 'purchase_id' => false, | |
| 338 | + ) | |
| 339 | + ) | |
| 340 | + ) | |
| 341 | + ); | |
| 317 | 342 | exit; |
| 318 | 343 | } |
| 319 | 344 | } |
| 320 | 345 | |