|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Donor Note Email |
|
4
|
|
|
* |
|
5
|
|
|
* |
|
6
|
|
|
* @package Give |
|
7
|
|
|
* @subpackage Classes/Emails |
|
8
|
|
|
* @copyright Copyright (c) 2018, WordImpress |
|
9
|
|
|
* @license https://opensource.org/licenses/gpl-license GNU Public License |
|
10
|
|
|
* @since 2.3.0 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
// Exit if access directly. |
|
14
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
15
|
|
|
exit; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
if ( ! class_exists( 'Give_Donor_Note_Email' ) ) : |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Give_Donor_Note_Email |
|
22
|
|
|
* |
|
23
|
|
|
* @abstract |
|
24
|
|
|
* @since 2.3.0 |
|
25
|
|
|
*/ |
|
26
|
|
|
class Give_Donor_Note_Email extends Give_Email_Notification { |
|
27
|
|
|
/* @var Give_Payment $payment */ |
|
28
|
|
|
public $payment; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Create a class instance. |
|
32
|
|
|
* |
|
33
|
|
|
* @access public |
|
34
|
|
|
* @since 2.3.0 |
|
35
|
|
|
*/ |
|
36
|
|
|
public function init() { |
|
37
|
|
|
// Initialize empty payment. |
|
38
|
|
|
$this->payment = new Give_Payment( 0 ); |
|
39
|
|
|
|
|
40
|
|
|
$this->load( array( |
|
41
|
|
|
'id' => 'donor-note', |
|
42
|
|
|
'label' => __( 'Donor Note', 'give' ), |
|
43
|
|
|
'description' => __( 'Sent to the donor when new donation note added to there donation.', 'give' ), |
|
44
|
|
|
'notification_status' => 'enabled', |
|
45
|
|
|
'recipient_group_name' => __( 'Donor', 'give' ), |
|
46
|
|
|
'default_email_subject' => sprintf( |
|
47
|
|
|
esc_attr__( 'Note added to your %s donation from %s', 'give' ), |
|
48
|
|
|
'{donation}', |
|
49
|
|
|
'{date}' |
|
50
|
|
|
), |
|
51
|
|
|
'default_email_message' => sprintf( |
|
52
|
|
|
"Hello, a note has just been added to your donation:\n%s\n\nFor your reference, your donation details are below:\n%s", |
|
53
|
|
|
'{donor_note}', |
|
54
|
|
|
'{receipt_link}' |
|
55
|
|
|
), |
|
56
|
|
|
'default_email_header' => __( 'Donor Note', 'give' ), |
|
57
|
|
|
) ); |
|
58
|
|
|
|
|
59
|
|
|
add_action( "give_{$this->config['id']}_email_notification", array( $this, 'send_note' ), 10, 2 ); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Send donor note |
|
64
|
|
|
* |
|
65
|
|
|
* @since 2.3.0 |
|
66
|
|
|
* @access public |
|
67
|
|
|
* |
|
68
|
|
|
* @param int $donation_id Donation ID. |
|
69
|
|
|
* @param int $note_id Donor comment. |
|
70
|
|
|
*/ |
|
71
|
|
|
public function send_note( $note_id, $donation_id ) { |
|
72
|
|
|
$this->recipient_email = give_get_donation_donor_email( $donation_id ); |
|
73
|
|
|
|
|
74
|
|
|
// Send email. |
|
75
|
|
|
$this->send_email_notification( array( |
|
76
|
|
|
'payment_id' => $donation_id, |
|
77
|
|
|
'note_id' => $note_id, |
|
78
|
|
|
) ); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
endif; // End class_exists check |
|
83
|
|
|
|
|
84
|
|
|
return Give_Donor_Note_Email::get_instance(); |
|
85
|
|
|
|