@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This class handles invoice notificaiton emails. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->invoice_actions = apply_filters( |
29 | 29 | 'getpaid_notification_email_invoice_triggers', |
30 | 30 | array( |
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
31 | + 'getpaid_new_invoice' => array('new_invoice', 'user_invoice'), |
|
32 | 32 | 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
33 | 33 | 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
34 | 34 | 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init_hooks() { |
52 | 52 | |
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
53 | + add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2); |
|
54 | + add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2); |
|
55 | 55 | |
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
56 | + foreach ($this->invoice_actions as $hook => $email_type) { |
|
57 | + $this->init_email_type_hook($hook, $email_type); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param string $hook |
65 | 65 | * @param string|array $email_type |
66 | 66 | */ |
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
67 | + public function init_email_type_hook($hook, $email_type) { |
|
68 | 68 | |
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
69 | + $email_type = wpinv_parse_list($email_type); |
|
70 | 70 | |
71 | - foreach ( $email_type as $type ) { |
|
71 | + foreach ($email_type as $type) { |
|
72 | 72 | |
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
73 | + $email = new GetPaid_Notification_Email($type); |
|
74 | 74 | |
75 | 75 | // Abort if it is not active. |
76 | - if ( ! $email->is_active() ) { |
|
76 | + if (!$email->is_active()) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
80 | + if (method_exists($this, $type)) { |
|
81 | + add_action($hook, array($this, $type), 100, 2); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type, $hook); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param array $merge_tags |
94 | 94 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
95 | 95 | */ |
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
96 | + public function invoice_merge_tags($merge_tags, $object) { |
|
97 | 97 | |
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
98 | + if (is_a($object, 'WPInv_Invoice')) { |
|
99 | 99 | return array_merge( |
100 | 100 | $merge_tags, |
101 | - $this->get_invoice_merge_tags( $object ) |
|
101 | + $this->get_invoice_merge_tags($object) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
105 | + if (is_a($object, 'WPInv_Subscription')) { |
|
106 | 106 | return array_merge( |
107 | 107 | $merge_tags, |
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
108 | + $this->get_invoice_merge_tags($object->get_parent_payment()) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -119,35 +119,35 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
122 | + public function get_invoice_merge_tags($invoice) { |
|
123 | 123 | |
124 | 124 | // Abort if it does not exist. |
125 | - if ( ! $invoice->get_id() ) { |
|
125 | + if (!$invoice->get_id()) { |
|
126 | 126 | return array(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $merge_tags = array( |
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
130 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
131 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
132 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
133 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
134 | + '{email}' => sanitize_email($invoice->get_email()), |
|
135 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
136 | + '{invoice_currency}' => sanitize_text_field($invoice->get_currency()), |
|
137 | + '{invoice_total}' => wpinv_price(wpinv_format_amount($invoice->get_total())), |
|
138 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
139 | + '{invoice_pay_link}' => esc_url($invoice->get_checkout_payment_url()), |
|
140 | + '{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()), |
|
141 | + '{invoice_date}' => getpaid_format_date_value($invoice->get_date_created()), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')), |
|
143 | + '{invoice_quote}' => sanitize_text_field(strtolower($invoice->get_label())), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_label())), |
|
145 | + '{invoice_description}' => wp_kses_post($invoice->get_description()), |
|
146 | + '{subscription_name}' => wp_kses_post($invoice->get_subscription_name()), |
|
147 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
150 | + return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -159,35 +159,35 @@ discard block |
||
159 | 159 | * @param string|array $recipients |
160 | 160 | * @param array $extra_args Extra template args. |
161 | 161 | */ |
162 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
162 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
163 | 163 | |
164 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
164 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
165 | 165 | |
166 | 166 | $mailer = new GetPaid_Notification_Email_Sender(); |
167 | 167 | $merge_tags = $email->get_merge_tags(); |
168 | 168 | |
169 | 169 | $result = $mailer->send( |
170 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
171 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
172 | - $email->get_content( $merge_tags, $extra_args ), |
|
170 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
171 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
172 | + $email->get_content($merge_tags, $extra_args), |
|
173 | 173 | $email->get_attachments() |
174 | 174 | ); |
175 | 175 | |
176 | 176 | // Maybe send a copy to the admin. |
177 | - if ( $email->include_admin_bcc() ) { |
|
177 | + if ($email->include_admin_bcc()) { |
|
178 | 178 | $mailer->send( |
179 | 179 | wpinv_get_admin_email(), |
180 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
181 | - $email->get_content( $merge_tags ), |
|
180 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
181 | + $email->get_content($merge_tags), |
|
182 | 182 | $email->get_attachments() |
183 | 183 | ); |
184 | 184 | } |
185 | 185 | |
186 | - if ( ! $result ) { |
|
187 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
186 | + if (!$result) { |
|
187 | + $invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
188 | 188 | } |
189 | 189 | |
190 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
190 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
191 | 191 | |
192 | 192 | return $result; |
193 | 193 | } |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | * @param array $recipients |
199 | 199 | * @param GetPaid_Notification_Email $email |
200 | 200 | */ |
201 | - public function filter_email_recipients( $recipients, $email ) { |
|
201 | + public function filter_email_recipients($recipients, $email) { |
|
202 | 202 | |
203 | - if ( ! $email->is_admin_email() ) { |
|
203 | + if (!$email->is_admin_email()) { |
|
204 | 204 | $cc = $email->object->get_email_cc(); |
205 | 205 | |
206 | - if ( ! empty( $cc ) ) { |
|
207 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
208 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
206 | + if (!empty($cc)) { |
|
207 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
208 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | } |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @param WPInv_Invoice $invoice |
221 | 221 | */ |
222 | - public function new_invoice( $invoice ) { |
|
222 | + public function new_invoice($invoice) { |
|
223 | 223 | |
224 | 224 | // Only send this email for invoices created via the admin page. |
225 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
225 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
229 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
230 | 230 | $recipient = wpinv_get_admin_email(); |
231 | 231 | |
232 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
232 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param WPInv_Invoice $invoice |
240 | 240 | */ |
241 | - public function cancelled_invoice( $invoice ) { |
|
241 | + public function cancelled_invoice($invoice) { |
|
242 | 242 | |
243 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
243 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
244 | 244 | $recipient = wpinv_get_admin_email(); |
245 | 245 | |
246 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
246 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
247 | 247 | |
248 | 248 | } |
249 | 249 | |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @param WPInv_Invoice $invoice |
254 | 254 | */ |
255 | - public function failed_invoice( $invoice ) { |
|
255 | + public function failed_invoice($invoice) { |
|
256 | 256 | |
257 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
257 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
258 | 258 | $recipient = wpinv_get_admin_email(); |
259 | 259 | |
260 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
260 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
261 | 261 | |
262 | 262 | } |
263 | 263 | |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @param WPInv_Invoice $invoice |
268 | 268 | */ |
269 | - public function onhold_invoice( $invoice ) { |
|
269 | + public function onhold_invoice($invoice) { |
|
270 | 270 | |
271 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
271 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
272 | 272 | $recipient = $invoice->get_email(); |
273 | 273 | |
274 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
274 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
275 | 275 | |
276 | 276 | } |
277 | 277 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @param WPInv_Invoice $invoice |
282 | 282 | */ |
283 | - public function processing_invoice( $invoice ) { |
|
283 | + public function processing_invoice($invoice) { |
|
284 | 284 | |
285 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
285 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
286 | 286 | $recipient = $invoice->get_email(); |
287 | 287 | |
288 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
288 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | |
@@ -294,17 +294,17 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @param WPInv_Invoice $invoice |
296 | 296 | */ |
297 | - public function completed_invoice( $invoice ) { |
|
297 | + public function completed_invoice($invoice) { |
|
298 | 298 | |
299 | 299 | // (Maybe) abort if it is a renewal invoice. |
300 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
300 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
301 | 301 | return; |
302 | 302 | } |
303 | 303 | |
304 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
304 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
305 | 305 | $recipient = $invoice->get_email(); |
306 | 306 | |
307 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
307 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param WPInv_Invoice $invoice |
315 | 315 | */ |
316 | - public function refunded_invoice( $invoice ) { |
|
316 | + public function refunded_invoice($invoice) { |
|
317 | 317 | |
318 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
318 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
319 | 319 | $recipient = $invoice->get_email(); |
320 | 320 | |
321 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
321 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @param WPInv_Invoice $invoice |
329 | 329 | */ |
330 | - public function user_invoice( $invoice ) { |
|
330 | + public function user_invoice($invoice) { |
|
331 | 331 | |
332 | 332 | // Only send this email for invoices created via the admin page. |
333 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
333 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
334 | 334 | return; |
335 | 335 | } |
336 | 336 | |
337 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
337 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
338 | 338 | $recipient = $invoice->get_email(); |
339 | 339 | |
340 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
340 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * @param int $invoice |
348 | 348 | * @return bool |
349 | 349 | */ |
350 | - public function is_payment_form_invoice( $invoice ) { |
|
351 | - return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ); |
|
350 | + public function is_payment_form_invoice($invoice) { |
|
351 | + return empty($_GET['getpaid-admin-action']) && 'payment_form' == get_post_meta($invoice, 'wpinv_created_via', true); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -357,12 +357,12 @@ discard block |
||
357 | 357 | * @param WPInv_Invoice $invoice |
358 | 358 | * @param string $note |
359 | 359 | */ |
360 | - public function user_note( $invoice, $note ) { |
|
360 | + public function user_note($invoice, $note) { |
|
361 | 361 | |
362 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
362 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
363 | 363 | $recipient = $invoice->get_email(); |
364 | 364 | |
365 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
365 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | |
@@ -371,9 +371,9 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @param WPInv_Invoice $invoice |
373 | 373 | */ |
374 | - public function force_send_overdue_notice( $invoice ) { |
|
375 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
376 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
374 | + public function force_send_overdue_notice($invoice) { |
|
375 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
376 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -384,37 +384,37 @@ discard block |
||
384 | 384 | public function overdue() { |
385 | 385 | global $wpdb; |
386 | 386 | |
387 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
387 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
388 | 388 | |
389 | 389 | // Fetch reminder days. |
390 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
390 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
391 | 391 | |
392 | 392 | // Abort if non is set. |
393 | - if ( empty( $reminder_days ) ) { |
|
393 | + if (empty($reminder_days)) { |
|
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | 397 | // Retrieve date query. |
398 | - $date_query = $this->get_date_query( $reminder_days ); |
|
398 | + $date_query = $this->get_date_query($reminder_days); |
|
399 | 399 | |
400 | 400 | // Invoices table. |
401 | 401 | $table = $wpdb->prefix . 'getpaid_invoices'; |
402 | 402 | |
403 | 403 | // Fetch invoices. |
404 | - $invoices = $wpdb->get_col( |
|
404 | + $invoices = $wpdb->get_col( |
|
405 | 405 | "SELECT posts.ID FROM $wpdb->posts as posts |
406 | 406 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
407 | 407 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
408 | 408 | |
409 | - foreach ( $invoices as $invoice ) { |
|
409 | + foreach ($invoices as $invoice) { |
|
410 | 410 | |
411 | 411 | // Only send this email for invoices created via the admin page. |
412 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
413 | - $invoice = new WPInv_Invoice( $invoice ); |
|
412 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
413 | + $invoice = new WPInv_Invoice($invoice); |
|
414 | 414 | $email->object = $invoice; |
415 | 415 | |
416 | - if ( $invoice->needs_payment() ) { |
|
417 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
416 | + if ($invoice->needs_payment()) { |
|
417 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | } |
@@ -429,14 +429,14 @@ discard block |
||
429 | 429 | * @param array $reminder_days |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function get_date_query( $reminder_days ) { |
|
432 | + public function get_date_query($reminder_days) { |
|
433 | 433 | |
434 | 434 | $date_query = array( |
435 | 435 | 'relation' => 'OR' |
436 | 436 | ); |
437 | 437 | |
438 | - foreach ( $reminder_days as $days ) { |
|
439 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
438 | + foreach ($reminder_days as $days) { |
|
439 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
440 | 440 | |
441 | 441 | $date_query[] = array( |
442 | 442 | 'year' => $date['year'], |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | |
447 | 447 | } |
448 | 448 | |
449 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
449 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
450 | 450 | |
451 | 451 | return $date_query->get_sql(); |
452 | 452 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | <?php |
19 | 19 | |
20 | 20 | // Fires when printing the header. |
21 | - do_action( 'getpaid_invoice_header', $invoice ); |
|
21 | + do_action('getpaid_invoice_header', $invoice); |
|
22 | 22 | |
23 | 23 | // Print the opening wrapper. |
24 | 24 | echo '<div class="container bg-white border mt-4 mb-4 p-4 position-relative flex-grow-1">'; |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | wpinv_print_errors(); |
28 | 28 | |
29 | 29 | // Fires when printing the invoice details. |
30 | - do_action( 'getpaid_invoice_details', $invoice ); |
|
30 | + do_action('getpaid_invoice_details', $invoice); |
|
31 | 31 | |
32 | 32 | // Fires when printing the invoice line items. |
33 | - do_action( 'getpaid_invoice_line_items', $invoice ); |
|
33 | + do_action('getpaid_invoice_line_items', $invoice); |
|
34 | 34 | |
35 | 35 | // Print the closing wrapper. |
36 | 36 | echo '</div>'; |
37 | 37 | |
38 | 38 | // Fires when printing the invoice footer. |
39 | - do_action( 'getpaid_invoice_footer', $invoice ); |
|
39 | + do_action('getpaid_invoice_footer', $invoice); |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 |