@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param string $tag Email tag to be replace in email |
55 | 55 | * @param callable $func Hook to run when email tag is found |
56 | 56 | */ |
57 | - public function add( $tag, $description, $func ) { |
|
58 | - if ( is_callable( $func ) ) { |
|
59 | - $this->tags[ $tag ] = array( |
|
57 | + public function add($tag, $description, $func) { |
|
58 | + if (is_callable($func)) { |
|
59 | + $this->tags[$tag] = array( |
|
60 | 60 | 'tag' => $tag, |
61 | 61 | 'description' => $description, |
62 | 62 | 'func' => $func |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $tag Email tag to remove hook from |
73 | 73 | */ |
74 | - public function remove( $tag ) { |
|
75 | - unset( $this->tags[ $tag ] ); |
|
74 | + public function remove($tag) { |
|
75 | + unset($this->tags[$tag]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function email_tag_exists( $tag ) { |
|
88 | - return array_key_exists( $tag, $this->tags ); |
|
87 | + public function email_tag_exists($tag) { |
|
88 | + return array_key_exists($tag, $this->tags); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Content with email tags filtered out. |
111 | 111 | */ |
112 | - public function do_tags( $content, $payment_id ) { |
|
112 | + public function do_tags($content, $payment_id) { |
|
113 | 113 | |
114 | 114 | // Check if there is atleast one tag added |
115 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
115 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
116 | 116 | return $content; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $this->payment_id = $payment_id; |
120 | 120 | |
121 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
121 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
122 | 122 | |
123 | 123 | $this->payment_id = null; |
124 | 124 | |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - public function do_tag( $m ) { |
|
137 | + public function do_tag($m) { |
|
138 | 138 | |
139 | 139 | // Get tag |
140 | 140 | $tag = $m[1]; |
141 | 141 | |
142 | 142 | // Return tag if tag not set |
143 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
143 | + if ( ! $this->email_tag_exists($tag)) { |
|
144 | 144 | return $m[0]; |
145 | 145 | } |
146 | 146 | |
147 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
147 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $description Description of the email tag added |
159 | 159 | * @param callable $func Hook to run when email tag is found |
160 | 160 | */ |
161 | -function give_add_email_tag( $tag, $description, $func ) { |
|
162 | - Give()->email_tags->add( $tag, $description, $func ); |
|
161 | +function give_add_email_tag($tag, $description, $func) { |
|
162 | + Give()->email_tags->add($tag, $description, $func); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @param string $tag Email tag to remove hook from |
171 | 171 | */ |
172 | -function give_remove_email_tag( $tag ) { |
|
173 | - Give()->email_tags->remove( $tag ); |
|
172 | +function give_remove_email_tag($tag) { |
|
173 | + Give()->email_tags->remove($tag); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool |
184 | 184 | */ |
185 | -function give_email_tag_exists( $tag ) { |
|
186 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
185 | +function give_email_tag_exists($tag) { |
|
186 | + return Give()->email_tags->email_tag_exists($tag); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $email_tags = give_get_email_tags(); |
213 | 213 | |
214 | 214 | // Check |
215 | - if ( count( $email_tags ) > 0 ) { |
|
215 | + if (count($email_tags) > 0) { |
|
216 | 216 | |
217 | 217 | // Loop |
218 | - foreach ( $email_tags as $email_tag ) { |
|
218 | + foreach ($email_tags as $email_tag) { |
|
219 | 219 | |
220 | 220 | // Add email tag to list |
221 | - $list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>'; |
|
221 | + $list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>'; |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string Content with email tags filtered out. |
240 | 240 | */ |
241 | -function give_do_email_tags( $content, $payment_id ) { |
|
241 | +function give_do_email_tags($content, $payment_id) { |
|
242 | 242 | |
243 | 243 | // Replace all tags |
244 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
244 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
245 | 245 | |
246 | 246 | // Maintaining backwards compatibility |
247 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
247 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
248 | 248 | |
249 | 249 | // Return content |
250 | 250 | return $content; |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | * @since 1.0 |
257 | 257 | */ |
258 | 258 | function give_load_email_tags() { |
259 | - do_action( 'give_add_email_tags' ); |
|
259 | + do_action('give_add_email_tags'); |
|
260 | 260 | } |
261 | 261 | |
262 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
262 | +add_action('init', 'give_load_email_tags', - 999); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Add default Give email template tags |
@@ -272,82 +272,82 @@ discard block |
||
272 | 272 | $email_tags = array( |
273 | 273 | array( |
274 | 274 | 'tag' => 'donation', |
275 | - 'description' => __( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ), |
|
275 | + 'description' => __('The name of completed donation form and the donation level chosen if applicable.', 'give'), |
|
276 | 276 | 'function' => 'give_email_tag_donation' |
277 | 277 | ), |
278 | 278 | array( |
279 | 279 | 'tag' => 'name', |
280 | - 'description' => __( 'The donor\'s first name.', 'give' ), |
|
280 | + 'description' => __('The donor\'s first name.', 'give'), |
|
281 | 281 | 'function' => 'give_email_tag_first_name' |
282 | 282 | ), |
283 | 283 | array( |
284 | 284 | 'tag' => 'fullname', |
285 | - 'description' => __( 'The donor\'s full name, first and last.', 'give' ), |
|
285 | + 'description' => __('The donor\'s full name, first and last.', 'give'), |
|
286 | 286 | 'function' => 'give_email_tag_fullname' |
287 | 287 | ), |
288 | 288 | array( |
289 | 289 | 'tag' => 'username', |
290 | - 'description' => __( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
290 | + 'description' => __('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
291 | 291 | 'function' => 'give_email_tag_username' |
292 | 292 | ), |
293 | 293 | array( |
294 | 294 | 'tag' => 'user_email', |
295 | - 'description' => __( 'The donor\'s email address.', 'give' ), |
|
295 | + 'description' => __('The donor\'s email address.', 'give'), |
|
296 | 296 | 'function' => 'give_email_tag_user_email' |
297 | 297 | ), |
298 | 298 | array( |
299 | 299 | 'tag' => 'billing_address', |
300 | - 'description' => __( 'The donor\'s billing address.', 'give' ), |
|
300 | + 'description' => __('The donor\'s billing address.', 'give'), |
|
301 | 301 | 'function' => 'give_email_tag_billing_address' |
302 | 302 | ), |
303 | 303 | array( |
304 | 304 | 'tag' => 'date', |
305 | - 'description' => __( 'The date of the donation.', 'give' ), |
|
305 | + 'description' => __('The date of the donation.', 'give'), |
|
306 | 306 | 'function' => 'give_email_tag_date' |
307 | 307 | ), |
308 | 308 | array( |
309 | 309 | 'tag' => 'price', |
310 | - 'description' => __( 'The total price of the donation.', 'give' ), |
|
310 | + 'description' => __('The total price of the donation.', 'give'), |
|
311 | 311 | 'function' => 'give_email_tag_price' |
312 | 312 | ), |
313 | 313 | array( |
314 | 314 | 'tag' => 'payment_id', |
315 | - 'description' => __( 'The unique ID number for this donation.', 'give' ), |
|
315 | + 'description' => __('The unique ID number for this donation.', 'give'), |
|
316 | 316 | 'function' => 'give_email_tag_payment_id' |
317 | 317 | ), |
318 | 318 | array( |
319 | 319 | 'tag' => 'receipt_id', |
320 | - 'description' => __( 'The unique ID number for this donation receipt.', 'give' ), |
|
320 | + 'description' => __('The unique ID number for this donation receipt.', 'give'), |
|
321 | 321 | 'function' => 'give_email_tag_receipt_id' |
322 | 322 | ), |
323 | 323 | array( |
324 | 324 | 'tag' => 'payment_method', |
325 | - 'description' => __( 'The method of payment used for this donation.', 'give' ), |
|
325 | + 'description' => __('The method of payment used for this donation.', 'give'), |
|
326 | 326 | 'function' => 'give_email_tag_payment_method' |
327 | 327 | ), |
328 | 328 | array( |
329 | 329 | 'tag' => 'sitename', |
330 | - 'description' => __( 'Your site name', 'give' ), |
|
330 | + 'description' => __('Your site name', 'give'), |
|
331 | 331 | 'function' => 'give_email_tag_sitename' |
332 | 332 | ), |
333 | 333 | array( |
334 | 334 | 'tag' => 'receipt_link', |
335 | - 'description' => __( 'Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give' ), |
|
335 | + 'description' => __('Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.', 'give'), |
|
336 | 336 | 'function' => 'give_email_tag_receipt_link' |
337 | 337 | ), |
338 | 338 | ); |
339 | 339 | |
340 | 340 | // Apply give_email_tags filter |
341 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
341 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
342 | 342 | |
343 | 343 | // Add email tags |
344 | - foreach ( $email_tags as $email_tag ) { |
|
345 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
344 | + foreach ($email_tags as $email_tag) { |
|
345 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
350 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
351 | 351 | |
352 | 352 | |
353 | 353 | /** |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string name |
360 | 360 | */ |
361 | -function give_email_tag_first_name( $payment_id ) { |
|
362 | - $payment = new Give_Payment( $payment_id ); |
|
361 | +function give_email_tag_first_name($payment_id) { |
|
362 | + $payment = new Give_Payment($payment_id); |
|
363 | 363 | $user_info = $payment->user_info; |
364 | 364 | |
365 | - if ( empty( $user_info ) ) { |
|
365 | + if (empty($user_info)) { |
|
366 | 366 | return ''; |
367 | 367 | } |
368 | 368 | |
369 | - $email_name = give_get_email_names( $user_info ); |
|
369 | + $email_name = give_get_email_names($user_info); |
|
370 | 370 | |
371 | 371 | return $email_name['name']; |
372 | 372 | } |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return string fullname |
381 | 381 | */ |
382 | -function give_email_tag_fullname( $payment_id ) { |
|
383 | - $payment = new Give_Payment( $payment_id ); |
|
382 | +function give_email_tag_fullname($payment_id) { |
|
383 | + $payment = new Give_Payment($payment_id); |
|
384 | 384 | $user_info = $payment->user_info; |
385 | 385 | |
386 | - if ( empty( $user_info ) ) { |
|
386 | + if (empty($user_info)) { |
|
387 | 387 | return ''; |
388 | 388 | } |
389 | 389 | |
390 | - $email_name = give_get_email_names( $user_info ); |
|
390 | + $email_name = give_get_email_names($user_info); |
|
391 | 391 | |
392 | 392 | return $email_name['fullname']; |
393 | 393 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string username |
402 | 402 | */ |
403 | -function give_email_tag_username( $payment_id ) { |
|
404 | - $payment = new Give_Payment( $payment_id ); |
|
403 | +function give_email_tag_username($payment_id) { |
|
404 | + $payment = new Give_Payment($payment_id); |
|
405 | 405 | $user_info = $payment->user_info; |
406 | 406 | |
407 | - if ( empty( $user_info ) ) { |
|
407 | + if (empty($user_info)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | - $email_name = give_get_email_names( $user_info ); |
|
411 | + $email_name = give_get_email_names($user_info); |
|
412 | 412 | |
413 | 413 | return $email_name['username']; |
414 | 414 | } |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return string user_email |
423 | 423 | */ |
424 | -function give_email_tag_user_email( $payment_id ) { |
|
425 | - $payment = new Give_Payment( $payment_id ); |
|
424 | +function give_email_tag_user_email($payment_id) { |
|
425 | + $payment = new Give_Payment($payment_id); |
|
426 | 426 | |
427 | 427 | return $payment->email; |
428 | 428 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return string billing_address |
437 | 437 | */ |
438 | -function give_email_tag_billing_address( $payment_id ) { |
|
438 | +function give_email_tag_billing_address($payment_id) { |
|
439 | 439 | |
440 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
441 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
440 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
441 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
442 | 442 | 'line1' => '', |
443 | 443 | 'line2' => '', |
444 | 444 | 'city' => '', |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | 'zip' => '' |
448 | 448 | ); |
449 | 449 | |
450 | - $return = $user_address['line1'] . "\n"; |
|
451 | - if ( ! empty( $user_address['line2'] ) ) { |
|
452 | - $return .= $user_address['line2'] . "\n"; |
|
450 | + $return = $user_address['line1']."\n"; |
|
451 | + if ( ! empty($user_address['line2'])) { |
|
452 | + $return .= $user_address['line2']."\n"; |
|
453 | 453 | } |
454 | - $return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n"; |
|
454 | + $return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n"; |
|
455 | 455 | $return .= $user_address['country']; |
456 | 456 | |
457 | 457 | return $return; |
@@ -465,10 +465,10 @@ discard block |
||
465 | 465 | * |
466 | 466 | * @return string date |
467 | 467 | */ |
468 | -function give_email_tag_date( $payment_id ) { |
|
469 | - $payment = new Give_Payment( $payment_id ); |
|
468 | +function give_email_tag_date($payment_id) { |
|
469 | + $payment = new Give_Payment($payment_id); |
|
470 | 470 | |
471 | - return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) ); |
|
471 | + return date_i18n(get_option('date_format'), strtotime($payment->date)); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string price |
481 | 481 | */ |
482 | -function give_email_tag_price( $payment_id ) { |
|
483 | - $payment = new Give_Payment( $payment_id ); |
|
484 | - $price = give_currency_filter( give_format_amount( $payment->total ), $payment->currency ); |
|
482 | +function give_email_tag_price($payment_id) { |
|
483 | + $payment = new Give_Payment($payment_id); |
|
484 | + $price = give_currency_filter(give_format_amount($payment->total), $payment->currency); |
|
485 | 485 | |
486 | - return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' ); |
|
486 | + return html_entity_decode($price, ENT_COMPAT, 'UTF-8'); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * |
495 | 495 | * @return int payment_id |
496 | 496 | */ |
497 | -function give_email_tag_payment_id( $payment_id ) { |
|
498 | - $payment = new Give_Payment( $payment_id ); |
|
497 | +function give_email_tag_payment_id($payment_id) { |
|
498 | + $payment = new Give_Payment($payment_id); |
|
499 | 499 | |
500 | 500 | return $payment->number; |
501 | 501 | } |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @return string receipt_id |
510 | 510 | */ |
511 | -function give_email_tag_receipt_id( $payment_id ) { |
|
512 | - $payment = new Give_Payment( $payment_id ); |
|
511 | +function give_email_tag_receipt_id($payment_id) { |
|
512 | + $payment = new Give_Payment($payment_id); |
|
513 | 513 | |
514 | 514 | return $payment->key; |
515 | 515 | } |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | * |
524 | 524 | * @return string $form_title |
525 | 525 | */ |
526 | -function give_email_tag_donation( $payment_id ) { |
|
527 | - $payment = new Give_Payment( $payment_id ); |
|
528 | - $form_title = strip_tags( give_get_payment_form_title( $payment->meta, false, '-' ) ); |
|
526 | +function give_email_tag_donation($payment_id) { |
|
527 | + $payment = new Give_Payment($payment_id); |
|
528 | + $form_title = strip_tags(give_get_payment_form_title($payment->meta, false, '-')); |
|
529 | 529 | |
530 | - return ! empty( $form_title ) ? $form_title : __( 'There was an error retrieving this donation title.', 'give' ); |
|
530 | + return ! empty($form_title) ? $form_title : __('There was an error retrieving this donation title.', 'give'); |
|
531 | 531 | |
532 | 532 | } |
533 | 533 | |
@@ -539,10 +539,10 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return string gateway |
541 | 541 | */ |
542 | -function give_email_tag_payment_method( $payment_id ) { |
|
543 | - $payment = new Give_Payment( $payment_id ); |
|
542 | +function give_email_tag_payment_method($payment_id) { |
|
543 | + $payment = new Give_Payment($payment_id); |
|
544 | 544 | |
545 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
545 | + return give_get_gateway_checkout_label($payment->gateway); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return string sitename |
555 | 555 | */ |
556 | -function give_email_tag_sitename( $payment_id ) { |
|
557 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
556 | +function give_email_tag_sitename($payment_id) { |
|
557 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | /** |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @return string receipt_link |
568 | 568 | */ |
569 | -function give_email_tag_receipt_link( $payment_id ) { |
|
569 | +function give_email_tag_receipt_link($payment_id) { |
|
570 | 570 | |
571 | - $receipt_url = esc_url( add_query_arg( array( |
|
572 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
571 | + $receipt_url = esc_url(add_query_arg(array( |
|
572 | + 'payment_key' => give_get_payment_key($payment_id), |
|
573 | 573 | 'give_action' => 'view_receipt' |
574 | - ), home_url() ) ); |
|
575 | - $formatted = sprintf( |
|
574 | + ), home_url())); |
|
575 | + $formatted = sprintf( |
|
576 | 576 | '<a href="%1$s">%2$s</a>', |
577 | 577 | $receipt_url, |
578 | - __( 'View it in your browser', 'give' ) |
|
578 | + __('View it in your browser', 'give') |
|
579 | 579 | ); |
580 | 580 | |
581 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
581 | + if (give_get_option('email_template') !== 'none') { |
|
582 | 582 | return $formatted; |
583 | 583 | } else { |
584 | 584 | return $receipt_url; |