PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.14.2
GiveWP – Donation Plugin and Fundraising Platform v3.14.2
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 4 years ago ajax-handler.php 6 years ago backward-compatibility.php 6 years ago class-donation-receipt-email.php 4 years ago class-donor-note-email.php 6 years ago class-donor-register-email.php 3 years ago class-email-access-email.php 6 years ago class-email-notification-table.php 3 years ago class-email-notification-util.php 6 years ago class-email-notifications.php 4 years ago class-email-setting-field.php 3 years ago class-new-donation-email.php 6 years ago class-new-donor-register-email.php 3 years ago class-new-offline-donation-email.php 6 years ago class-offline-donation-instruction-email.php 6 years ago filters.php 3 years ago
class-donation-receipt-email.php
349 lines
1 <?php
2 /**
3 * Donation Receipt Email
4 *
5 * @package Give
6 * @subpackage Classes/Emails
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 2.0
10 */
11
12 // Exit if access directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 if ( ! class_exists( 'Give_Donation_Receipt_Email' ) ) :
18
19 /**
20 * Give_Donation_Receipt_Email
21 *
22 * @abstract
23 * @since 2.0
24 */
25 class Give_Donation_Receipt_Email extends Give_Email_Notification {
26 /* @var Give_Payment $payment */
27 public $payment;
28
29 /**
30 * Create a class instance.
31 *
32 * @access public
33 * @since 2.0
34 */
35 public function init() {
36 // Initialize empty payment.
37 $this->payment = new Give_Payment( 0 );
38
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 );
52
53 add_action( "give_{$this->config['id']}_email_notification", array( $this, 'send_donation_receipt' ) );
54 add_action( 'give_email_links', array( $this, 'resend_donation_receipt' ) );
55 }
56
57 /**
58 * Get email subject.
59 *
60 * @since 2.0
61 * @access public
62 *
63 * @param int $form_id
64 * @return string
65 */
66 public function get_email_subject( $form_id = null ) {
67 $subject = wp_strip_all_tags(
68 Give_Email_Notification_Util::get_value(
69 $this,
70 Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject',
71 $form_id,
72 $this->config['default_email_subject']
73 )
74 );
75
76 /**
77 * Filters the donation email receipt subject.
78 * Note: This filter will deprecate soon.
79 *
80 * @since 1.0
81 */
82 $subject = apply_filters(
83 'give_donation_subject',
84 $subject,
85 $this->payment->ID
86 );
87
88 /**
89 * Filters the donation email receipt subject.
90 *
91 * @since 2.0
92 */
93 $subject = apply_filters(
94 "give_{$this->config['id']}_get_email_subject",
95 $subject,
96 $this,
97 $form_id
98 );
99
100 return $subject;
101 }
102
103
104 /**
105 * Get email message.
106 *
107 * @since 2.0
108 * @access public
109 *
110 * @param int $form_id
111 * @return string
112 */
113 public function get_email_message( $form_id = null ) {
114 $message = Give_Email_Notification_Util::get_value(
115 $this,
116 Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message',
117 $form_id,
118 $this->config['default_email_message']
119 );
120
121 /**
122 * Filter message on basis of email template
123 * Note: This filter will deprecate soon.
124 *
125 * @since 1.0
126 */
127 $message = apply_filters(
128 'give_donation_receipt_' . Give()->emails->get_template(),
129 $message,
130 $this->payment->ID,
131 $this->payment->payment_meta
132 );
133
134 /**
135 * Filter the message
136 * Note: This filter will deprecate soon.
137 *
138 * @since 1.0
139 */
140 $message = apply_filters(
141 'give_donation_receipt',
142 $message,
143 $this->payment->ID,
144 $this->payment->payment_meta
145 );
146
147 /**
148 * Filter the message
149 *
150 * @since 2.0
151 */
152 $message = apply_filters(
153 "give_{$this->config['id']}_get_email_message",
154 $message,
155 $this,
156 $form_id
157 );
158
159 return $message;
160 }
161
162 /**
163 * Get the recipient attachments.
164 *
165 * @since 2.0
166 * @access public
167 *
168 * @param int $form_id
169 * @return array
170 */
171 public function get_email_attachments( $form_id = null ) {
172 /**
173 * Filter the attachments.
174 * Note: this filter will deprecate soon.
175 *
176 * @since 1.0
177 */
178 $attachments = apply_filters(
179 'give_receipt_attachments',
180 array(),
181 $this->payment->ID,
182 $this->payment->payment_meta
183 );
184
185 /**
186 * Filter the attachments.
187 *
188 * @since 2.0
189 */
190 $attachments = apply_filters(
191 "give_{$this->config['id']}_get_email_attachments",
192 $attachments,
193 $this,
194 $form_id
195 );
196
197 return $attachments;
198 }
199
200
201 /**
202 * Set email data.
203 *
204 * @since 2.0
205 */
206 public function setup_email_data() {
207 // Set recipient email.
208 $this->recipient_email = $this->payment->email;
209
210 /**
211 * Filters the from name.
212 *
213 * @param int $payment_id Payment id.
214 * @param mixed $payment_data Payment meta data.
215 *
216 * @since 1.0
217 */
218 $from_name = apply_filters(
219 'give_donation_from_name',
220 Give()->emails->get_from_name(),
221 $this->payment->ID,
222 $this->payment->payment_meta
223 );
224
225 /**
226 * Filters the from email.
227 *
228 * @param int $payment_id Payment id.
229 * @param mixed $payment_data Payment meta data.
230 *
231 * @since 1.0
232 */
233 $from_email = apply_filters(
234 'give_donation_from_address',
235 Give()->emails->get_from_address(),
236 $this->payment->ID,
237 $this->payment->payment_meta
238 );
239
240 Give()->emails->__set( 'from_name', $from_name );
241 Give()->emails->__set( 'from_email', $from_email );
242
243 /**
244 * Filters the donation receipt's email headers.
245 *
246 * @param int $payment_id Payment id.
247 * @param mixed $payment_data Payment meta data.
248 *
249 * @since 1.0
250 */
251 $headers = apply_filters(
252 'give_receipt_headers',
253 Give()->emails->get_headers(),
254 $this->payment->ID,
255 $this->payment->payment_meta
256 );
257
258 Give()->emails->__set( 'headers', $headers );
259 }
260
261 /**
262 * Send donation receipt
263 *
264 * @since 2.0
265 * @access public
266 *
267 * @param $payment_id
268 */
269 public function send_donation_receipt( $payment_id ) {
270 $this->payment = new Give_Payment( $payment_id );
271
272 if ( ! $this->payment->ID ) {
273 wp_die(
274 esc_html__( 'Cheatin&#8217; uh?', 'give' ),
275 esc_html__( 'Error', 'give' ),
276 array(
277 'response' => 400,
278 )
279 );
280 }
281
282 // Setup email data.
283 $this->setup_email_data();
284
285 // Send email.
286 $this->send_email_notification(
287 array(
288 'payment_id' => $this->payment->ID,
289 )
290 );
291 }
292
293 /**
294 * Resend payment receipt by row action.
295 *
296 * @since 2.0
297 * @access public
298 *
299 * @param array $data Donation details.
300 */
301 public function resend_donation_receipt( $data ) {
302 $purchase_id = absint( $data['purchase_id'] );
303
304 if ( empty( $purchase_id ) ) {
305 return;
306 }
307
308 // Get donation payment information.
309 $this->payment = new Give_Payment( $purchase_id );
310
311 if ( ! current_user_can( 'edit_give_payments', $this->payment->ID ) ) {
312 wp_die(
313 esc_html__( 'Cheatin&#8217; uh?', 'give' ),
314 esc_html__( 'Error', 'give' ),
315 array(
316 'response' => 400,
317 )
318 );
319 }
320
321 // Setup email data.
322 $this->setup_email_data();
323
324 // Send email.
325 $this->send_email_notification(
326 array(
327 'payment_id' => $this->payment->ID,
328 )
329 );
330
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 );
342 exit;
343 }
344 }
345
346 endif; // End class_exists check
347
348 return Give_Donation_Receipt_Email::get_instance();
349