PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.0.2
GiveWP – Donation Plugin and Fundraising Platform v2.0.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 / emails / functions.php
give / includes / emails Last commit date
actions.php 8 years ago class-give-email-tags.php 8 years ago class-give-emails.php 8 years ago functions.php 8 years ago template.php 8 years ago
functions.php
270 lines
1 <?php
2 /**
3 * Email Functions
4 *
5 * @package Give
6 * @subpackage Emails
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Email Donation Receipt.
19 *
20 * Email the donation confirmation to the donor via the customizable "Donation Receipt" settings.
21 *
22 * @since 1.0
23 *
24 * @param int $payment_id Payment ID.
25 * @param bool $admin_notice Whether to send the admin email notification or not (default: true).
26 *
27 * @return void
28 */
29 function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
30 $payment = new Give_Payment( $payment_id );
31
32 /**
33 * Fire the action
34 */
35 do_action( 'give_donation-receipt_email_notification', $payment_id );
36
37 // If admin notifications are on, send the admin notice.
38 if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
39 /**
40 * Fires in the donation email receipt.
41 *
42 * When admin email notices are not disabled, you can add new email notices.
43 *
44 * @since 1.0
45 *
46 * @param int $payment_id Payment id.
47 * @param mixed $payment_data Payment meta data.
48 */
49 do_action( 'give_new-donation_email_notification', $payment_id, $payment->payment_meta );
50 }
51 }
52
53 /**
54 * Sends the Admin Sale Notification Email
55 *
56 * @since 1.0
57 *
58 * @param int $payment_id Payment ID (default: 0)
59 *
60 * @return void
61 */
62 function give_admin_email_notice( $payment_id ) {
63 /**
64 * Fires in the donation email receipt.
65 *
66 * When admin email notices are not disabled, you can add new email notices.
67 *
68 * @since 1.0
69 *
70 * @param int $payment_id Payment id.
71 * @param mixed $payment_data Payment meta data.
72 */
73 do_action( 'give_new-donation_email_notification', $payment_id );
74 }
75
76 add_action( 'give_admin_donation_email', 'give_admin_email_notice' );
77
78
79 /**
80 * Get default donation notification email text
81 *
82 * Returns the stored email text if available, the standard email text if not
83 *
84 * @since 1.0
85 * @return string $message
86 */
87 function give_get_default_donation_notification_email() {
88
89 $default_email_body = __( 'Hi there,', 'give' ) . "\n\n";
90 $default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
91 $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
92 $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
93 $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
94 $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
95 $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n";
96 $default_email_body .= '{sitename}' . "\n";
97
98 return apply_filters( 'give_default_donation_notification_email', $default_email_body );
99 }
100
101
102 /**
103 * Get default donation receipt email text
104 *
105 * Returns the stored email text if available, the standard email text if not
106 *
107 * @since 1.3.7
108 * @return string $message
109 */
110 function give_get_default_donation_receipt_email() {
111
112 $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n";
113 $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
114 $default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
115 $default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
116 $default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
117 $default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
118 $default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
119 $default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
120 $default_email_body .= '<strong>' . __( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
121 $default_email_body .= '{receipt_link}' . "\n\n";
122 $default_email_body .= "\n\n";
123 $default_email_body .= __( 'Sincerely,', 'give' ) . "\n";
124 $default_email_body .= '{sitename}' . "\n";
125
126 return apply_filters( 'give_default_donation_receipt_email', $default_email_body );
127 }
128
129 /**
130 * Get various correctly formatted names used in emails
131 *
132 * @since 1.0
133 *
134 * @param $user_info
135 * @param $payment Give_Payment|bool for getting the names.
136 *
137 * @return array $email_names
138 */
139 function give_get_email_names( $user_info, $payment = false ) {
140 $email_names = array();
141
142 if ( is_a( $payment, 'Give_Payment' ) ) {
143
144 if ( $payment->user_id > 0 ) {
145
146 $user_data = get_userdata( $payment->user_id );
147 $email_names['name'] = $payment->first_name;
148 $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
149 $email_names['username'] = $user_data->user_login;
150
151 } elseif ( ! empty( $payment->first_name ) ) {
152
153 $email_names['name'] = $payment->first_name;
154 $email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
155 $email_names['username'] = $payment->first_name;
156
157 } else {
158
159 $email_names['name'] = $payment->email;
160 $email_names['username'] = $payment->email;
161
162 }
163
164 } else {
165
166 // Support for old serialized data.
167 if ( is_serialized( $user_info ) ) {
168
169 // Security check.
170 preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
171 if ( ! empty( $matches ) ) {
172 return array(
173 'name' => '',
174 'fullname' => '',
175 'username' => '',
176 );
177 } else {
178 $user_info = maybe_unserialize( $user_info );
179 }
180
181 }
182
183 if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
184 $user_data = get_userdata( $user_info['id'] );
185 $email_names['name'] = $user_info['first_name'];
186 $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
187 $email_names['username'] = $user_data->user_login;
188 } elseif ( isset( $user_info['first_name'] ) ) {
189 $email_names['name'] = $user_info['first_name'];
190 $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
191 $email_names['username'] = $user_info['first_name'];
192 } else {
193 $email_names['name'] = $user_info['email'];
194 $email_names['username'] = $user_info['email'];
195 }
196
197 }
198
199 return $email_names;
200 }
201
202 /**
203 * Send email to admin when user tries to login and restricted due to user - donor disconnection.
204 *
205 * @param int $user_id User ID.
206 * @param int $donor_id Donor ID.
207 *
208 * @since 1.8.14
209 */
210 function give_admin_email_user_donor_disconnection( $user_id, $donor_id ) {
211
212 $user_id = absint( $user_id );
213 $donor_id = absint( $donor_id );
214
215 // Bail Out, if user id doesn't exists.
216 if ( empty( $user_id ) ) {
217 return;
218 }
219
220 // Bail Out, if donor id doesn't exists.
221 if ( empty( $donor_id ) ) {
222 return;
223 }
224
225 $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
226
227 $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
228
229 /* translators: %s: payment id */
230 $subject = __( 'Attention: User tries to login whose Donor profile is disconnected!', 'give' );
231
232 /**
233 * Filters the Donor-User Disconnection notification subject.
234 *
235 * @since 1.8.14
236 */
237 $subject = apply_filters( 'give_admin_donor_user_disconnection_notification_subject', wp_strip_all_tags( $subject ) );
238
239 $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
240 $headers .= "Reply-To: " . $from_email . "\r\n";
241 $headers .= "Content-Type: text/html; charset=utf-8\r\n";
242
243 /**
244 * Filters the Donor-User Disconnection notification email headers.
245 *
246 * @since 1.8.14
247 */
248 $headers = apply_filters( 'give_admin_donor_user_disconnection_notification_headers', $headers );
249
250 $message = __( 'Hi Admin,', 'give' ) . "\n\n";
251 $message .= __( 'This email is to inform you that a user has tried logging in. But, User was unable to login due to User-Donor profile disconnection.', 'give' ) . "\n\n";
252 $message .= __( 'Do you want to reconnect User and Donor profile again?', 'give' ) . "\n\n";
253 $message .= sprintf(
254 '<a href="%1$s">%2$s</a>',
255 esc_url( admin_url() . 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&user_id=' . $user_id . '&give-message=reconnect-user' ),
256 __( 'Reconnect User', 'give' ) . "\n\n"
257 );
258 $message .= __( 'Thank you,', 'give' ) . "\n\n";
259 $message .= '{sitename}' . "\n";
260
261 $emails = Give()->emails;
262 $emails->__set( 'from_name', $from_name );
263 $emails->__set( 'from_email', $from_email );
264 $emails->__set( 'headers', $headers );
265 $emails->__set( 'heading', __( 'User - Donor Profile Disconnection', 'give' ) );
266
267 $emails->send( give_get_admin_notice_emails(), $subject, give_do_email_tags( $message ) );
268
269 }
270