PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.2.1
GiveWP – Donation Plugin and Fundraising Platform v2.2.1
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / emails / class-donation-receipt-email.php
give / includes / admin / emails Last commit date
abstract-email-notification.php 7 years ago ajax-handler.php 8 years ago backward-compatibility.php 8 years ago class-donation-receipt-email.php 7 years ago class-donor-register-email.php 7 years ago class-email-access-email.php 7 years ago class-email-notification-table.php 8 years ago class-email-notification-util.php 8 years ago class-email-notifications.php 7 years ago class-email-setting-field.php 8 years ago class-new-donation-email.php 7 years ago class-new-donor-register-email.php 7 years ago class-new-offline-donation-email.php 7 years ago class-offline-donation-instruction-email.php 7 years ago filters.php 8 years ago
class-donation-receipt-email.php
324 lines
1 <?php
2 /**
3 * Donation Receipt Email
4 *
5 *
6 * @package Give
7 * @subpackage Classes/Emails
8 * @copyright Copyright (c) 2016, WordImpress
9 * @license https://opensource.org/licenses/gpl-license GNU Public License
10 * @since 2.0
11 */
12
13 // Exit if access directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Give_Donation_Receipt_Email' ) ) :
19
20 /**
21 * Give_Donation_Receipt_Email
22 *
23 * @abstract
24 * @since 2.0
25 */
26 class Give_Donation_Receipt_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.0
35 */
36 public function init() {
37 // Initialize empty payment.
38 $this->payment = new Give_Payment( 0 );
39
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 ) );
51
52 add_action( "give_{$this->config['id']}_email_notification", array( $this, 'send_donation_receipt' ) );
53 add_action( 'give_email_links', array( $this, 'resend_donation_receipt' ) );
54 }
55
56 /**
57 * Get email subject.
58 *
59 * @since 2.0
60 * @access public
61 *
62 * @param int $form_id
63 * @return string
64 */
65 public function get_email_subject( $form_id = null ) {
66 $subject = wp_strip_all_tags(
67 Give_Email_Notification_Util::get_value(
68 $this,
69 Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject',
70 $form_id,
71 $this->config['default_email_subject']
72 )
73 );
74
75 /**
76 * Filters the donation email receipt subject.
77 * Note: This filter will deprecate soon.
78 *
79 * @since 1.0
80 */
81 $subject = apply_filters(
82 'give_donation_subject',
83 $subject,
84 $this->payment->ID
85 );
86
87 /**
88 * Filters the donation email receipt subject.
89 *
90 * @since 2.0
91 */
92 $subject = apply_filters(
93 "give_{$this->config['id']}_get_email_subject",
94 $subject,
95 $this,
96 $form_id
97 );
98
99 return $subject;
100 }
101
102
103 /**
104 * Get email message.
105 *
106 * @since 2.0
107 * @access public
108 *
109 * @param int $form_id
110 * @return string
111 */
112 public function get_email_message( $form_id = null ) {
113 $message = Give_Email_Notification_Util::get_value(
114 $this,
115 Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message',
116 $form_id,
117 $this->config['default_email_message']
118 );
119
120 /**
121 * Filter message on basis of email template
122 * Note: This filter will deprecate soon.
123 *
124 * @since 1.0
125 */
126 $message = apply_filters(
127 'give_donation_receipt_' . Give()->emails->get_template(),
128 $message,
129 $this->payment->ID,
130 $this->payment->payment_meta
131 );
132
133 /**
134 * Filter the message
135 * Note: This filter will deprecate soon.
136 *
137 * @since 1.0
138 */
139 $message = apply_filters(
140 'give_donation_receipt',
141 $message,
142 $this->payment->ID,
143 $this->payment->payment_meta
144 );
145
146 /**
147 * Filter the message
148 *
149 * @since 2.0
150 */
151 $message = apply_filters(
152 "give_{$this->config['id']}_get_email_message",
153 $message,
154 $this,
155 $form_id
156 );
157
158 return $message;
159 }
160
161 /**
162 * Get the recipient attachments.
163 *
164 * @since 2.0
165 * @access public
166 *
167 * @param int $form_id
168 * @return array
169 */
170 public function get_email_attachments( $form_id = null) {
171 /**
172 * Filter the attachments.
173 * Note: this filter will deprecate soon.
174 *
175 * @since 1.0
176 */
177 $attachments = apply_filters(
178 'give_receipt_attachments',
179 array(),
180 $this->payment->ID,
181 $this->payment->payment_meta
182 );
183
184 /**
185 * Filter the attachments.
186 *
187 * @since 2.0
188 */
189 $attachments = apply_filters(
190 "give_{$this->config['id']}_get_email_attachments",
191 $attachments,
192 $this,
193 $form_id
194 );
195
196 return $attachments;
197 }
198
199
200 /**
201 * Set email data.
202 *
203 * @since 2.0
204 */
205 public function setup_email_data() {
206 // Set recipient email.
207 $this->recipient_email = $this->payment->email;
208
209 /**
210 * Filters the from name.
211 *
212 * @param int $payment_id Payment id.
213 * @param mixed $payment_data Payment meta data.
214 *
215 * @since 1.0
216 */
217 $from_name = apply_filters(
218 'give_donation_from_name',
219 Give()->emails->get_from_name(),
220 $this->payment->ID,
221 $this->payment->payment_meta
222 );
223
224 /**
225 * Filters the from email.
226 *
227 * @param int $payment_id Payment id.
228 * @param mixed $payment_data Payment meta data.
229 *
230 * @since 1.0
231 */
232 $from_email = apply_filters(
233 'give_donation_from_address',
234 Give()->emails->get_from_address(),
235 $this->payment->ID,
236 $this->payment->payment_meta
237 );
238
239 Give()->emails->__set( 'from_name', $from_name );
240 Give()->emails->__set( 'from_email', $from_email );
241
242 /**
243 * Filters the donation receipt's email headers.
244 *
245 * @param int $payment_id Payment id.
246 * @param mixed $payment_data Payment meta data.
247 *
248 * @since 1.0
249 */
250 $headers = apply_filters(
251 'give_receipt_headers',
252 Give()->emails->get_headers(),
253 $this->payment->ID,
254 $this->payment->payment_meta
255 );
256
257 Give()->emails->__set( 'headers', $headers );
258 }
259
260 /**
261 * Send donation receipt
262 *
263 * @since 2.0
264 * @access public
265 *
266 * @param $payment_id
267 */
268 public function send_donation_receipt( $payment_id ) {
269 $this->payment = new Give_Payment( $payment_id );
270
271 // Setup email data.
272 $this->setup_email_data();
273
274 // Send email.
275 $this->send_email_notification( array(
276 'payment_id' => $this->payment->ID,
277 ) );
278 }
279
280 /**
281 * Resend payment receipt by row action.
282 *
283 * @since 2.0
284 * @access public
285 *
286 * @param array $data Donation details.
287 */
288 public function resend_donation_receipt( $data ) {
289 $purchase_id = absint( $data['purchase_id'] );
290
291 if ( empty( $purchase_id ) ) {
292 return;
293 }
294
295 // Get donation payment information.
296 $this->payment = new Give_Payment( $purchase_id );
297
298 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 ) );
302 }
303
304 // Setup email data.
305 $this->setup_email_data();
306
307 // Send email.
308 $this->send_email_notification( array(
309 'payment_id' => $this->payment->ID,
310 ) );
311
312 wp_redirect( add_query_arg( array(
313 'give-messages[]' => 'email-sent',
314 'give-action' => false,
315 'purchase_id' => false,
316 ) ) );
317 exit;
318 }
319 }
320
321 endif; // End class_exists check
322
323 return Give_Donation_Receipt_Email::get_instance();
324