@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,39 +26,39 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | 30 | |
31 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
31 | + $payment_data = give_get_payment_meta($payment_id); |
|
32 | 32 | |
33 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
34 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
33 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
34 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
35 | 35 | |
36 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
37 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
36 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
37 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
38 | 38 | |
39 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
39 | + $to_email = give_get_payment_user_email($payment_id); |
|
40 | 40 | |
41 | - $subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) ); |
|
42 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
43 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
41 | + $subject = give_get_option('donation_subject', __('Donation Receipt', 'give')); |
|
42 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
43 | + $subject = give_do_email_tags($subject, $payment_id); |
|
44 | 44 | |
45 | - $attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data ); |
|
46 | - $message = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id ); |
|
45 | + $attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data); |
|
46 | + $message = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id); |
|
47 | 47 | |
48 | 48 | $emails = Give()->emails; |
49 | 49 | |
50 | - $emails->__set( 'from_name', $from_name ); |
|
51 | - $emails->__set( 'from_email', $from_email ); |
|
52 | - $emails->__set( 'heading', __( 'Donation Receipt', 'give' ) ); |
|
50 | + $emails->__set('from_name', $from_name); |
|
51 | + $emails->__set('from_email', $from_email); |
|
52 | + $emails->__set('heading', __('Donation Receipt', 'give')); |
|
53 | 53 | |
54 | 54 | |
55 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
56 | - $emails->__set( 'headers', $headers ); |
|
55 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
56 | + $emails->__set('headers', $headers); |
|
57 | 57 | |
58 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
58 | + $emails->send($to_email, $subject, $message, $attachments); |
|
59 | 59 | |
60 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
61 | - do_action( 'give_admin_sale_notice', $payment_id, $payment_data ); |
|
60 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
61 | + do_action('give_admin_sale_notice', $payment_id, $payment_data); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -71,29 +71,29 @@ discard block |
||
71 | 71 | */ |
72 | 72 | function give_email_test_donation_receipt() { |
73 | 73 | |
74 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
75 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, 0, array() ); |
|
74 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
75 | + $from_name = apply_filters('give_purchase_from_name', $from_name, 0, array()); |
|
76 | 76 | |
77 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
78 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, 0, array() ); |
|
77 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
78 | + $from_email = apply_filters('give_purchase_from_address', $from_email, 0, array()); |
|
79 | 79 | |
80 | - $subject = give_get_option( 'donation_subject', __( 'Donation Receipt', 'give' ) ); |
|
81 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 ); |
|
82 | - $subject = give_do_email_tags( $subject, 0 ); |
|
80 | + $subject = give_get_option('donation_subject', __('Donation Receipt', 'give')); |
|
81 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0); |
|
82 | + $subject = give_do_email_tags($subject, 0); |
|
83 | 83 | |
84 | - $attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() ); |
|
84 | + $attachments = apply_filters('give_receipt_attachments', array(), 0, array()); |
|
85 | 85 | |
86 | - $message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
86 | + $message = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
87 | 87 | |
88 | 88 | $emails = Give()->emails; |
89 | - $emails->__set( 'from_name', $from_name ); |
|
90 | - $emails->__set( 'from_email', $from_email ); |
|
91 | - $emails->__set( 'heading', __( 'Donation Receipt', 'give' ) ); |
|
89 | + $emails->__set('from_name', $from_name); |
|
90 | + $emails->__set('from_email', $from_email); |
|
91 | + $emails->__set('heading', __('Donation Receipt', 'give')); |
|
92 | 92 | |
93 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() ); |
|
94 | - $emails->__set( 'headers', $headers ); |
|
93 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array()); |
|
94 | + $emails->__set('headers', $headers); |
|
95 | 95 | |
96 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
96 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -107,49 +107,49 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return void |
109 | 109 | */ |
110 | -function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) { |
|
110 | +function give_admin_email_notice($payment_id = 0, $payment_data = array()) { |
|
111 | 111 | |
112 | - $payment_id = absint( $payment_id ); |
|
112 | + $payment_id = absint($payment_id); |
|
113 | 113 | |
114 | - if ( empty( $payment_id ) ) { |
|
114 | + if (empty($payment_id)) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - if ( ! give_get_payment_by( 'id', $payment_id ) ) { |
|
118 | + if ( ! give_get_payment_by('id', $payment_id)) { |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
123 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
122 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
123 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
124 | 124 | |
125 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
126 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
125 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
126 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
127 | 127 | |
128 | - $subject = give_get_option( 'donation_notification_subject', sprintf( __( 'New Donation - Payment #%1$s', 'give' ), $payment_id ) ); |
|
129 | - $subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
130 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
128 | + $subject = give_get_option('donation_notification_subject', sprintf(__('New Donation - Payment #%1$s', 'give'), $payment_id)); |
|
129 | + $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); |
|
130 | + $subject = give_do_email_tags($subject, $payment_id); |
|
131 | 131 | |
132 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
133 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
132 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
133 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
134 | 134 | //$headers .= "MIME-Version: 1.0\r\n"; |
135 | 135 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
136 | - $headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data ); |
|
136 | + $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); |
|
137 | 137 | |
138 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data ); |
|
138 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); |
|
139 | 139 | |
140 | - $message = give_get_donation_notification_body_content( $payment_id, $payment_data ); |
|
140 | + $message = give_get_donation_notification_body_content($payment_id, $payment_data); |
|
141 | 141 | |
142 | 142 | $emails = Give()->emails; |
143 | - $emails->__set( 'from_name', $from_name ); |
|
144 | - $emails->__set( 'from_email', $from_email ); |
|
145 | - $emails->__set( 'headers', $headers ); |
|
146 | - $emails->__set( 'heading', __( 'New Donation!', 'give' ) ); |
|
143 | + $emails->__set('from_name', $from_name); |
|
144 | + $emails->__set('from_email', $from_email); |
|
145 | + $emails->__set('headers', $headers); |
|
146 | + $emails->__set('heading', __('New Donation!', 'give')); |
|
147 | 147 | |
148 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
148 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | |
152 | -add_action( 'give_admin_sale_notice', 'give_admin_email_notice', 10, 2 ); |
|
152 | +add_action('give_admin_sale_notice', 'give_admin_email_notice', 10, 2); |
|
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Retrieves the emails for which admin notifications are sent to (these can be |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | function give_get_admin_notice_emails() { |
163 | 163 | global $give_options; |
164 | 164 | |
165 | - $emails = isset( $give_options['admin_notice_emails'] ) && strlen( trim( $give_options['admin_notice_emails'] ) ) > 0 ? $give_options['admin_notice_emails'] : get_bloginfo( 'admin_email' ); |
|
166 | - $emails = array_map( 'trim', explode( "\n", $emails ) ); |
|
165 | + $emails = isset($give_options['admin_notice_emails']) && strlen(trim($give_options['admin_notice_emails'])) > 0 ? $give_options['admin_notice_emails'] : get_bloginfo('admin_email'); |
|
166 | + $emails = array_map('trim', explode("\n", $emails)); |
|
167 | 167 | |
168 | - return apply_filters( 'give_admin_notice_emails', $emails ); |
|
168 | + return apply_filters('give_admin_notice_emails', $emails); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return mixed |
179 | 179 | */ |
180 | -function give_admin_notices_disabled( $payment_id = 0 ) { |
|
180 | +function give_admin_notices_disabled($payment_id = 0) { |
|
181 | 181 | |
182 | - $retval = give_get_option( 'disable_admin_notices' ); |
|
182 | + $retval = give_get_option('disable_admin_notices'); |
|
183 | 183 | |
184 | - return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id ); |
|
184 | + return apply_filters('give_admin_notices_disabled', $retval, $payment_id); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -194,17 +194,17 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function give_get_default_donation_notification_email() { |
196 | 196 | |
197 | - $default_email_body = __( 'Hi there,', 'give' ) . "\n\n" . __( '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"; |
|
198 | - $default_email_body .= '<strong>' . __( 'Donor: ', 'give' ) . '</strong> ' . ' {name}' . "\n"; |
|
199 | - $default_email_body .= '<strong>' . __( 'Donation: ', 'give' ) . '</strong> ' . ' {donation}' . "\n"; |
|
200 | - $default_email_body .= '<strong>' . __( 'Amount: ', 'give' ) . '</strong> ' . ' {price}' . "\n"; |
|
201 | - $default_email_body .= '<strong>' . __( 'Payment Method: ', 'give' ) . '</strong> ' . ' {payment_method}' . "\n\n"; |
|
202 | - $default_email_body .= __( 'Thank you,', 'give' ) . "\n\n" . '{sitename}'; |
|
197 | + $default_email_body = __('Hi there,', 'give')."\n\n".__('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"; |
|
198 | + $default_email_body .= '<strong>'.__('Donor: ', 'give').'</strong> '.' {name}'."\n"; |
|
199 | + $default_email_body .= '<strong>'.__('Donation: ', 'give').'</strong> '.' {donation}'."\n"; |
|
200 | + $default_email_body .= '<strong>'.__('Amount: ', 'give').'</strong> '.' {price}'."\n"; |
|
201 | + $default_email_body .= '<strong>'.__('Payment Method: ', 'give').'</strong> '.' {payment_method}'."\n\n"; |
|
202 | + $default_email_body .= __('Thank you,', 'give')."\n\n".'{sitename}'; |
|
203 | 203 | |
204 | - $custom_message = give_get_option( 'donation_notification' ); |
|
205 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
204 | + $custom_message = give_get_option('donation_notification'); |
|
205 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
206 | 206 | |
207 | - return apply_filters( 'give_default_donation_notification_email', $message ); |
|
207 | + return apply_filters('give_default_donation_notification_email', $message); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -218,26 +218,26 @@ discard block |
||
218 | 218 | */ |
219 | 219 | function give_get_default_donation_receipt_email() { |
220 | 220 | |
221 | - $default_email_body = __( 'Dear', 'give' ) . " {name},\n\n"; |
|
222 | - $default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
223 | - $default_email_body .= '<strong>' . __( 'Donor', 'give' ) . ':</strong> ' . '{fullname}' . "\n"; |
|
224 | - $default_email_body .= '<strong>' . __( 'Donation', 'give' ) . ':</strong> ' . '{donation}' . "\n"; |
|
225 | - $default_email_body .= '<strong>' . __( 'Donation Date', 'give' ) . ':</strong> ' . '{date}' . "\n"; |
|
226 | - $default_email_body .= '<strong>' . __( 'Amount', 'give' ) . ':</strong> ' . '{price}' . "\n"; |
|
227 | - $default_email_body .= '<strong>' . __( 'Payment Method', 'give' ) . ':</strong> ' . '{payment_method}' . "\n"; |
|
228 | - $default_email_body .= '<strong>' . __( 'Payment ID', 'give' ) . ':</strong> ' . '{payment_id}' . "\n"; |
|
229 | - $default_email_body .= '<strong>' . __( 'Receipt ID', 'give' ) . ':</strong> ' . '{receipt_id}' . "\n\n"; |
|
230 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
221 | + $default_email_body = __('Dear', 'give')." {name},\n\n"; |
|
222 | + $default_email_body .= __('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
223 | + $default_email_body .= '<strong>'.__('Donor', 'give').':</strong> '.'{fullname}'."\n"; |
|
224 | + $default_email_body .= '<strong>'.__('Donation', 'give').':</strong> '.'{donation}'."\n"; |
|
225 | + $default_email_body .= '<strong>'.__('Donation Date', 'give').':</strong> '.'{date}'."\n"; |
|
226 | + $default_email_body .= '<strong>'.__('Amount', 'give').':</strong> '.'{price}'."\n"; |
|
227 | + $default_email_body .= '<strong>'.__('Payment Method', 'give').':</strong> '.'{payment_method}'."\n"; |
|
228 | + $default_email_body .= '<strong>'.__('Payment ID', 'give').':</strong> '.'{payment_id}'."\n"; |
|
229 | + $default_email_body .= '<strong>'.__('Receipt ID', 'give').':</strong> '.'{receipt_id}'."\n\n"; |
|
230 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
231 | 231 | |
232 | 232 | $default_email_body .= "\n\n"; |
233 | - $default_email_body .= __( 'Sincerely,', 'give' ); |
|
234 | - $default_email_body .= "\n" . '{sitename}' . "\n"; |
|
233 | + $default_email_body .= __('Sincerely,', 'give'); |
|
234 | + $default_email_body .= "\n".'{sitename}'."\n"; |
|
235 | 235 | |
236 | - $custom_message = give_get_option( 'donation_receipt' ); |
|
236 | + $custom_message = give_get_option('donation_receipt'); |
|
237 | 237 | |
238 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
238 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
239 | 239 | |
240 | - return apply_filters( 'give_default_donation_receipt_email', $message ); |
|
240 | + return apply_filters('give_default_donation_receipt_email', $message); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -249,19 +249,19 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return array $email_names |
251 | 251 | */ |
252 | -function give_get_email_names( $user_info ) { |
|
252 | +function give_get_email_names($user_info) { |
|
253 | 253 | $email_names = array(); |
254 | - $user_info = maybe_unserialize( $user_info ); |
|
254 | + $user_info = maybe_unserialize($user_info); |
|
255 | 255 | |
256 | 256 | $email_names['fullname'] = ''; |
257 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
258 | - $user_data = get_userdata( $user_info['id'] ); |
|
257 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
258 | + $user_data = get_userdata($user_info['id']); |
|
259 | 259 | $email_names['name'] = $user_info['first_name']; |
260 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
260 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
261 | 261 | $email_names['username'] = $user_data->user_login; |
262 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
262 | + } elseif (isset($user_info['first_name'])) { |
|
263 | 263 | $email_names['name'] = $user_info['first_name']; |
264 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
264 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
265 | 265 | $email_names['username'] = $user_info['first_name']; |
266 | 266 | } else { |
267 | 267 | $email_names['name'] = $user_info['email']; |