@@ -864,8 +864,8 @@ |
||
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | 866 | if ( isset( $this->_data->reg_obj ) |
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | - && $this->_single_message |
|
867 | + && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | + && $this->_single_message |
|
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * EE_Base_Class_Object |
275 | 275 | * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
276 | 276 | */ |
277 | - abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id ); |
|
277 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
278 | 278 | |
279 | 279 | |
280 | 280 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @deprecated 4.9.0 |
302 | 302 | * @return int |
303 | 303 | */ |
304 | - protected function _get_id_for_msg_url( $context, EE_Registration $registration ) { |
|
304 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) { |
|
305 | 305 | return 0; |
306 | 306 | } |
307 | 307 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * sending. |
331 | 331 | * @since 4.9.0 |
332 | 332 | */ |
333 | - public function do_messenger_hooks( $messenger = null ) { |
|
333 | + public function do_messenger_hooks($messenger = null) { |
|
334 | 334 | $this->_active_messenger = $messenger; |
335 | 335 | $this->_do_messenger_hooks(); |
336 | 336 | } |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | * @param mixed $data This sets the data property for the message type with the incoming data used for generating. |
380 | 380 | * @return string (the reference for the data handler) (will be an empty string if could not be determined). |
381 | 381 | */ |
382 | - public function get_data_handler( $data ) { |
|
382 | + public function get_data_handler($data) { |
|
383 | 383 | $this->_data = $data; |
384 | 384 | $this->_set_data_handler(); |
385 | - return apply_filters( 'FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this ); |
|
385 | + return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -419,26 +419,26 @@ discard block |
||
419 | 419 | * @deprecated 4.9.0 Likely 4.9.10 or 4.10.0 will remove this method completely |
420 | 420 | * @return string generated url |
421 | 421 | */ |
422 | - public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) { |
|
422 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) { |
|
423 | 423 | //validate context |
424 | 424 | //valid context? |
425 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
425 | + if ( ! isset($this->_contexts[$context])) { |
|
426 | 426 | throw new EE_Error( |
427 | 427 | sprintf( |
428 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
428 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
429 | 429 | $context, |
430 | - get_class( $this ) |
|
430 | + get_class($this) |
|
431 | 431 | ) |
432 | 432 | ); |
433 | 433 | } |
434 | 434 | //valid sending_messenger? |
435 | 435 | $not_valid_msgr = false; |
436 | - foreach ( $this->_with_messengers as $generating => $sendings ) { |
|
437 | - if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === false ) { |
|
436 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
437 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === false) { |
|
438 | 438 | $not_valid_msgr = true; |
439 | 439 | } |
440 | 440 | } |
441 | - if ( $not_valid_msgr ) { |
|
441 | + if ($not_valid_msgr) { |
|
442 | 442 | throw new EE_Error( |
443 | 443 | sprintf( |
444 | 444 | __( |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | 'event_espresso' |
447 | 447 | ), |
448 | 448 | $sending_messenger, |
449 | - get_class( $this ) |
|
449 | + get_class($this) |
|
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $this->name, |
458 | 458 | $registration, |
459 | 459 | $this->_GRP_ID, |
460 | - $this->_get_id_for_msg_url( $context, $registration ) |
|
460 | + $this->_get_id_for_msg_url($context, $registration) |
|
461 | 461 | ); |
462 | 462 | } |
463 | 463 | |
@@ -476,26 +476,26 @@ discard block |
||
476 | 476 | * EE_Base_Class_Object |
477 | 477 | * @return mixed (EE_Base_Class||EE_Base_Class[]) |
478 | 478 | */ |
479 | - public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) { |
|
479 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) { |
|
480 | 480 | //valid context? |
481 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
481 | + if ( ! isset($this->_contexts[$context])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $context, |
486 | - get_class( $this ) |
|
486 | + get_class($this) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | //get data and apply global and class specific filters on it. |
491 | 491 | $data = apply_filters( |
492 | 492 | 'FHEE__EE_message_type__get_data_for_context__data', |
493 | - $this->_get_data_for_context( $context, $registration, $id ), |
|
493 | + $this->_get_data_for_context($context, $registration, $id), |
|
494 | 494 | $this |
495 | 495 | ); |
496 | - $data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this ); |
|
496 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
497 | 497 | //if empty then something went wrong! |
498 | - if ( empty( $data ) ) { |
|
498 | + if (empty($data)) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | 501 | __( |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | protected function _set_with_messengers() { |
541 | 541 | $this->_with_messengers = array( |
542 | - 'email' => array( 'html' ), |
|
542 | + 'email' => array('html'), |
|
543 | 543 | ); |
544 | 544 | } |
545 | 545 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function with_messengers() { |
555 | 555 | return apply_filters( |
556 | - 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), |
|
556 | + 'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), |
|
557 | 557 | $this->_with_messengers |
558 | 558 | ); |
559 | 559 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $messengers = array() |
581 | 581 | ) { |
582 | 582 | //we can also further refine the context by action (if present). |
583 | - return $this->_get_admin_page_content( $page, $action, $extra, $messengers ); |
|
583 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | public function get_master_templates() { |
616 | 616 | //first class specific filter then filter that by the global filter. |
617 | 617 | $master_templates = apply_filters( |
618 | - 'FHEE__' . get_class( $this ) . '__get_master_templates', |
|
618 | + 'FHEE__'.get_class($this).'__get_master_templates', |
|
619 | 619 | $this->_master_templates |
620 | 620 | ); |
621 | - return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this ); |
|
621 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -632,20 +632,20 @@ discard block |
||
632 | 632 | * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for |
633 | 633 | * that context |
634 | 634 | */ |
635 | - public function get_addressees( EE_Messages_incoming_data $data, $context = '' ) { |
|
635 | + public function get_addressees(EE_Messages_incoming_data $data, $context = '') { |
|
636 | 636 | //override _data |
637 | 637 | $this->_data = $data; |
638 | 638 | $addressees = array(); |
639 | 639 | //if incoming context then limit to that context |
640 | - if ( ! empty( $context ) ) { |
|
641 | - $cntxt = ! empty( $this->_contexts[ $context ] ) ? $this->_contexts[ $context ] : ''; |
|
642 | - if ( ! empty( $cntxt ) ) { |
|
640 | + if ( ! empty($context)) { |
|
641 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
642 | + if ( ! empty($cntxt)) { |
|
643 | 643 | $this->_contexts = array(); |
644 | - $this->_contexts[ $context ] = $cntxt; |
|
644 | + $this->_contexts[$context] = $cntxt; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | $this->_set_default_addressee_data(); |
648 | - if ( $this->_process_data() ) { |
|
648 | + if ($this->_process_data()) { |
|
649 | 649 | $addressees = $this->_addressees; |
650 | 650 | } |
651 | 651 | return $addressees; |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | */ |
662 | 662 | protected function _process_data() { |
663 | 663 | //at a minimum, we NEED EE_Attendee objects. |
664 | - if ( empty( $this->_data->attendees ) ) { |
|
665 | - return false; //there's no data to process! |
|
664 | + if (empty($this->_data->attendees)) { |
|
665 | + return false; //there's no data to process! |
|
666 | 666 | } |
667 | 667 | // process addressees for each context. Child classes will have to have methods for |
668 | 668 | // each context defined to handle the processing of the data object within them |
669 | - foreach ( $this->_contexts as $context => $details ) { |
|
670 | - $xpctd_method = '_' . $context . '_addressees'; |
|
671 | - if ( ! method_exists( $this, $xpctd_method ) ) { |
|
669 | + foreach ($this->_contexts as $context => $details) { |
|
670 | + $xpctd_method = '_'.$context.'_addressees'; |
|
671 | + if ( ! method_exists($this, $xpctd_method)) { |
|
672 | 672 | throw new EE_Error( |
673 | 673 | sprintf( |
674 | 674 | __( |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | ) |
681 | 681 | ); |
682 | 682 | } |
683 | - $this->_addressees[ $context ] = call_user_func( array( $this, $xpctd_method ) ); |
|
683 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
684 | 684 | } |
685 | 685 | return true; //data was processed successfully. |
686 | 686 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | 'grand_total_line_item' => $this->_data->grand_total_line_item, |
703 | 703 | 'txn' => $this->_data->txn, |
704 | 704 | 'payments' => $this->_data->payments, |
705 | - 'payment' => isset( $this->_data->payment ) && $this->_data->payment instanceof EE_Payment |
|
705 | + 'payment' => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment |
|
706 | 706 | ? $this->_data->payment |
707 | 707 | : null, |
708 | 708 | 'reg_objs' => $this->_data->reg_objs, |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | 'txn_status' => $this->_data->txn_status, |
716 | 716 | 'total_ticket_count' => $this->_data->total_ticket_count, |
717 | 717 | ); |
718 | - if ( is_array( $this->_data->primary_attendee_data ) ) { |
|
718 | + if (is_array($this->_data->primary_attendee_data)) { |
|
719 | 719 | $this->_default_addressee_data = array_merge( |
720 | 720 | $this->_default_addressee_data, |
721 | 721 | $this->_data->primary_attendee_data |
@@ -759,24 +759,24 @@ discard block |
||
759 | 759 | 'messenger', |
760 | 760 | ); |
761 | 761 | $contexts = $this->get_contexts(); |
762 | - foreach ( $contexts as $context => $details ) { |
|
763 | - $this->_valid_shortcodes[ $context ] = $all_shortcodes; |
|
762 | + foreach ($contexts as $context => $details) { |
|
763 | + $this->_valid_shortcodes[$context] = $all_shortcodes; |
|
764 | 764 | //make sure non admin context does not include the event_author shortcodes |
765 | - if ( $context != 'admin' ) { |
|
766 | - if ( ( $key = array_search( 'event_author', $this->_valid_shortcodes[ $context ] ) ) !== false ) { |
|
767 | - unset( $this->_valid_shortcodes[ $context ][ $key ] ); |
|
765 | + if ($context != 'admin') { |
|
766 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
767 | + unset($this->_valid_shortcodes[$context][$key]); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | } |
771 | 771 | // make sure admin context does not include the recipient_details shortcodes |
772 | 772 | // IF we have admin context hooked in message types might not have that context. |
773 | - if ( ! empty( $this->_valid_shortcodes['admin'] ) ) { |
|
774 | - if ( ( $key = array_search( 'recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
775 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
773 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
774 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
775 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
776 | 776 | } |
777 | 777 | //make sure admin context does not include the recipient_details shortcodes |
778 | - if ( ( $key = array_search( 'recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
779 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
778 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
779 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | } |
@@ -789,9 +789,9 @@ discard block |
||
789 | 789 | * @param array $new_config array of valid shortcodes (by context) |
790 | 790 | * @return void sets valid_shortcodes property |
791 | 791 | */ |
792 | - public function reset_valid_shortcodes_config( $new_config ) { |
|
793 | - foreach ( $new_config as $context => $shortcodes ) { |
|
794 | - $this->_valid_shortcodes[ $context ] = $shortcodes; |
|
792 | + public function reset_valid_shortcodes_config($new_config) { |
|
793 | + foreach ($new_config as $context => $shortcodes) { |
|
794 | + $this->_valid_shortcodes[$context] = $shortcodes; |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | $addressees = array(); |
809 | 809 | // first we need to get the event admin user id for all the events |
810 | 810 | // and setup an addressee object for each unique admin user. |
811 | - foreach ( $this->_data->events as $line_ref => $event ) { |
|
812 | - $admin_id = $this->_get_event_admin_id( $event['ID'] ); |
|
811 | + foreach ($this->_data->events as $line_ref => $event) { |
|
812 | + $admin_id = $this->_get_event_admin_id($event['ID']); |
|
813 | 813 | //make sure we are just including the events that belong to this admin! |
814 | - $admin_events[ $admin_id ][ $line_ref ] = $event; |
|
814 | + $admin_events[$admin_id][$line_ref] = $event; |
|
815 | 815 | } |
816 | 816 | //k now we can loop through the event_admins and setup the addressee data. |
817 | - foreach ( $admin_events as $admin_id => $event_details ) { |
|
817 | + foreach ($admin_events as $admin_id => $event_details) { |
|
818 | 818 | $aee = array( |
819 | 819 | 'user_id' => $admin_id, |
820 | 820 | 'events' => $event_details, |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | 'recipient_id' => $admin_id, |
823 | 823 | 'recipient_type' => 'WP_User', |
824 | 824 | ); |
825 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
826 | - $addressees[] = new EE_Messages_Addressee( $aee ); |
|
825 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
826 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
827 | 827 | } |
828 | 828 | return $addressees; |
829 | 829 | } |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $aee['recipient_id'] = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0; |
844 | 844 | $aee['recipient_type'] = 'Attendee'; |
845 | 845 | //great now we can instantiate the $addressee object and return (as an array); |
846 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
846 | + $add[] = new EE_Messages_Addressee($aee); |
|
847 | 847 | return $add; |
848 | 848 | } |
849 | 849 | |
@@ -860,25 +860,25 @@ discard block |
||
860 | 860 | //we just have to loop through the attendees. We'll also set the attached events for each attendee. |
861 | 861 | //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
862 | 862 | $already_processed = array(); |
863 | - foreach ( $this->_data->attendees as $att_id => $details ) { |
|
863 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | - if ( isset( $this->_data->reg_obj ) |
|
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
866 | + if (isset($this->_data->reg_obj) |
|
867 | + && ($this->_data->reg_obj->attendee_ID() != $att_id) |
|
868 | 868 | && $this->_single_message |
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
872 | 872 | // is $this->_regs_for_sending present? |
873 | 873 | // If so, let's make sure we ONLY generate addressee for registrations in that array. |
874 | - if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
|
875 | - $regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] ); |
|
876 | - if ( empty( $regs_allowed ) ) { |
|
874 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
875 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
876 | + if (empty($regs_allowed)) { |
|
877 | 877 | continue; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | if ( |
881 | - in_array( $details['attendee_email'], $already_processed ) |
|
881 | + in_array($details['attendee_email'], $already_processed) |
|
882 | 882 | && apply_filters( |
883 | 883 | 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', |
884 | 884 | true, |
@@ -889,14 +889,14 @@ discard block |
||
889 | 889 | continue; |
890 | 890 | } |
891 | 891 | $already_processed[] = $details['attendee_email']; |
892 | - foreach ( $details as $item => $value ) { |
|
893 | - $aee[ $item ] = $value; |
|
894 | - if ( $item == 'line_ref' ) { |
|
895 | - foreach ( $value as $event_id ) { |
|
896 | - $aee['events'][ $event_id ] = $this->_data->events[ $event_id ]; |
|
892 | + foreach ($details as $item => $value) { |
|
893 | + $aee[$item] = $value; |
|
894 | + if ($item == 'line_ref') { |
|
895 | + foreach ($value as $event_id) { |
|
896 | + $aee['events'][$event_id] = $this->_data->events[$event_id]; |
|
897 | 897 | } |
898 | 898 | } |
899 | - if ( $item == 'attendee_email' ) { |
|
899 | + if ($item == 'attendee_email') { |
|
900 | 900 | $aee['attendee_email'] = $value; |
901 | 901 | } |
902 | 902 | /*if ( $item == 'registration_id' ) { |
@@ -905,13 +905,13 @@ discard block |
||
905 | 905 | } |
906 | 906 | // note the FIRST reg object in this array is the one |
907 | 907 | // we'll use for this attendee as the primary registration for this attendee. |
908 | - $aee['reg_obj'] = reset( $this->_data->attendees[ $att_id ]['reg_objs'] ); |
|
908 | + $aee['reg_obj'] = reset($this->_data->attendees[$att_id]['reg_objs']); |
|
909 | 909 | $aee['attendees'] = $this->_data->attendees; |
910 | 910 | $aee['recipient_id'] = $att_id; |
911 | 911 | $aee['recipient_type'] = 'Attendee'; |
912 | 912 | //merge in the primary attendee data |
913 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
914 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
913 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
914 | + $add[] = new EE_Messages_Addressee($aee); |
|
915 | 915 | } |
916 | 916 | return $add; |
917 | 917 | } |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * @param $event_id |
923 | 923 | * @return int |
924 | 924 | */ |
925 | - protected function _get_event_admin_id( $event_id ) { |
|
926 | - $event = EEM_Event::instance()->get_one_by_ID( $event_id ); |
|
925 | + protected function _get_event_admin_id($event_id) { |
|
926 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
927 | 927 | return $event instanceof EE_Event ? $event->wp_user() : 0; |
928 | 928 | } |
929 | 929 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param array $addressee_data We're expecting an incoming array of data that will be used to fill the properties |
261 | 261 | * for the object. |
262 | 262 | */ |
263 | - public function __construct( $addressee_data ) { |
|
263 | + public function __construct($addressee_data) { |
|
264 | 264 | $this->_data = $addressee_data; |
265 | 265 | $this->_set_properties(); |
266 | 266 | } |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | * @return void. |
276 | 276 | */ |
277 | 277 | protected function _set_properties() { |
278 | - foreach ( $this->_data as $prop => $value ) { |
|
279 | - if ( property_exists( $this, $prop ) ) { |
|
278 | + foreach ($this->_data as $prop => $value) { |
|
279 | + if (property_exists($this, $prop)) { |
|
280 | 280 | $this->{$prop} = $value; |
281 | 281 | } |
282 | 282 | } |
283 | 283 | //if user_id present we'll use this to set the fname and lname and admin_email. |
284 | - if ( ! empty( $this->user_id ) ) { |
|
284 | + if ( ! empty($this->user_id)) { |
|
285 | 285 | $this->user_id = (int) $this->user_id; |
286 | - $user = get_userdata( $this->user_id ); |
|
286 | + $user = get_userdata($this->user_id); |
|
287 | 287 | $this->fname = $user->user_firstname; |
288 | 288 | $this->lname = $user->user_lastname; |
289 | 289 | $this->admin_email = $user->user_email; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -40,50 +40,50 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | protected function _init_props() { |
43 | - $this->label = esc_html__( 'Transaction Shortcodes', 'event_espresso' ); |
|
44 | - $this->description = esc_html__( 'All shortcodes specific to transaction related data', 'event_espresso' ); |
|
43 | + $this->label = esc_html__('Transaction Shortcodes', 'event_espresso'); |
|
44 | + $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso'); |
|
45 | 45 | $this->_shortcodes = array( |
46 | - '[TXN_ID]' => esc_html__( 'The transaction id for the purchase.', 'event_espresso' ), |
|
47 | - '[PAYMENT_URL]' => esc_html__( 'This is a link to make a payment for the event', 'event_espresso' ), |
|
48 | - '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso' ) . '<ul>' |
|
49 | - . '<li>' . sprintf( esc_html__( '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
50 | - . '<li>' . sprintf( esc_html__( '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
51 | - . '<li>' . sprintf( esc_html__( '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
46 | + '[TXN_ID]' => esc_html__('The transaction id for the purchase.', 'event_espresso'), |
|
47 | + '[PAYMENT_URL]' => esc_html__('This is a link to make a payment for the event', 'event_espresso'), |
|
48 | + '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
49 | + . '<li>'.sprintf(esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
50 | + . '<li>'.sprintf(esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
51 | + . '<li>'.sprintf(esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
52 | 52 | . '</ul>', |
53 | - '[PAYMENT_DUE_DATE_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
53 | + '[PAYMENT_DUE_DATE_*]' => esc_html__('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
54 | 54 | . '<ul>' |
55 | - . '<li>' . sprintf( esc_html__( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
56 | - . '<li>' . sprintf( esc_html__( '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
57 | - . '<li>' . sprintf( esc_html__( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
58 | - '[INVOICE_LINK]' => esc_html__( 'This is a full html link to the invoice', 'event_espresso' ), |
|
59 | - '[INVOICE_URL]' => esc_html__( 'This is just the url for the invoice', 'event_espresso' ), |
|
60 | - '[INVOICE_LOGO_URL]' => esc_html__( 'This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso' ), |
|
61 | - '[INVOICE_LOGO]' => esc_html__( 'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_NAME]' => esc_html__( 'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_ADDRESS]' => esc_html__( 'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
64 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__( 'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
65 | - '[INVOICE_PAYEE_EMAIL]' => esc_html__( 'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
66 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf( esc_html__( 'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), '<code>', '</code>' ), |
|
67 | - '[TOTAL_COST]' => esc_html__( 'The total cost for the transaction', 'event_espresso' ), |
|
68 | - '[TXN_STATUS]' => esc_html__( 'The transaction status for the transaction.', 'event_espresso' ), |
|
69 | - '[TXN_STATUS_ID]' => esc_html__( 'The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso' ), |
|
70 | - '[PAYMENT_STATUS]' => esc_html__( 'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso' ), |
|
71 | - '[PAYMENT_GATEWAY]' => esc_html__( 'The payment gateway used for the transaction', 'event_espresso' ), |
|
72 | - '[AMOUNT_PAID]' => esc_html__( 'The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso' ), |
|
73 | - '[LAST_AMOUNT_PAID]' => esc_html__( 'This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso' ), |
|
74 | - '[TOTAL_AMOUNT_PAID]' => esc_html__( 'This parses to the total amount paid over all payments', 'event_espresso' ), |
|
75 | - '[TOTAL_OWING]' => esc_html__( 'The total owing on a transaction with no attributes.', 'event_espresso' ), |
|
76 | - '[TXN_SUBTOTAL]' => esc_html__( 'The subtotal for all txn line items.', 'event_espresso' ), |
|
77 | - '[TXN_TAX_SUBTOTAL]' => esc_html__( 'The subtotal for all tax line items.', 'event_espresso' ), |
|
78 | - '[OWING_STATUS_MESSAGE_*]' => esc_html__( 'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso' ) . '<p></ul>' . |
|
79 | - '<li><strong>still_owing</strong>:' . esc_html__( 'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso' ) . sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
80 | - '<li><strong>none_owing</strong>:' . esc_html__( 'If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', 'event_espresso' ) . '</li></ul></p>', |
|
81 | - '[TXN_TOTAL_TICKETS]' => esc_html__( 'The total number of all tickets purchased in a transaction', 'event_espresso' ), |
|
82 | - '[TKT_QTY_PURCHASED]' => sprintf( esc_html__( 'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso' ), '<strong>', '</strong>' ), |
|
83 | - '[TRANSACTION_ADMIN_URL]' => esc_html__( 'The url to the admin page for this transaction', 'event_espresso' ), |
|
84 | - '[RECEIPT_URL]' => esc_html__( 'This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso' ), |
|
85 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso' ), |
|
86 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( esc_html__( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
55 | + . '<li>'.sprintf(esc_html__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
56 | + . '<li>'.sprintf(esc_html__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
57 | + . '<li>'.sprintf(esc_html__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
58 | + '[INVOICE_LINK]' => esc_html__('This is a full html link to the invoice', 'event_espresso'), |
|
59 | + '[INVOICE_URL]' => esc_html__('This is just the url for the invoice', 'event_espresso'), |
|
60 | + '[INVOICE_LOGO_URL]' => esc_html__('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
|
61 | + '[INVOICE_LOGO]' => esc_html__('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_NAME]' => esc_html__('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_ADDRESS]' => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
64 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
65 | + '[INVOICE_PAYEE_EMAIL]' => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
66 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf(esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), '<code>', '</code>'), |
|
67 | + '[TOTAL_COST]' => esc_html__('The total cost for the transaction', 'event_espresso'), |
|
68 | + '[TXN_STATUS]' => esc_html__('The transaction status for the transaction.', 'event_espresso'), |
|
69 | + '[TXN_STATUS_ID]' => esc_html__('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
|
70 | + '[PAYMENT_STATUS]' => esc_html__('The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso'), |
|
71 | + '[PAYMENT_GATEWAY]' => esc_html__('The payment gateway used for the transaction', 'event_espresso'), |
|
72 | + '[AMOUNT_PAID]' => esc_html__('The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso'), |
|
73 | + '[LAST_AMOUNT_PAID]' => esc_html__('This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso'), |
|
74 | + '[TOTAL_AMOUNT_PAID]' => esc_html__('This parses to the total amount paid over all payments', 'event_espresso'), |
|
75 | + '[TOTAL_OWING]' => esc_html__('The total owing on a transaction with no attributes.', 'event_espresso'), |
|
76 | + '[TXN_SUBTOTAL]' => esc_html__('The subtotal for all txn line items.', 'event_espresso'), |
|
77 | + '[TXN_TAX_SUBTOTAL]' => esc_html__('The subtotal for all tax line items.', 'event_espresso'), |
|
78 | + '[OWING_STATUS_MESSAGE_*]' => esc_html__('A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
79 | + '<li><strong>still_owing</strong>:'.esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso').sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
80 | + '<li><strong>none_owing</strong>:'.esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', 'event_espresso').'</li></ul></p>', |
|
81 | + '[TXN_TOTAL_TICKETS]' => esc_html__('The total number of all tickets purchased in a transaction', 'event_espresso'), |
|
82 | + '[TKT_QTY_PURCHASED]' => sprintf(esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso'), '<strong>', '</strong>'), |
|
83 | + '[TRANSACTION_ADMIN_URL]' => esc_html__('The url to the admin page for this transaction', 'event_espresso'), |
|
84 | + '[RECEIPT_URL]' => esc_html__('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
|
85 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
86 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(esc_html__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
87 | 87 | ); |
88 | 88 | } |
89 | 89 | |
@@ -94,40 +94,40 @@ discard block |
||
94 | 94 | * @param string $shortcode the shortcode to be parsed. |
95 | 95 | * @return string parsed shortcode |
96 | 96 | */ |
97 | - protected function _parser( $shortcode ) { |
|
97 | + protected function _parser($shortcode) { |
|
98 | 98 | |
99 | 99 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
100 | 100 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
101 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
101 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
102 | 102 | |
103 | 103 | //payment |
104 | 104 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
105 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
105 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
106 | 106 | |
107 | 107 | |
108 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
108 | + if ( ! $transaction instanceof EE_Transaction) { |
|
109 | 109 | return ''; |
110 | 110 | } |
111 | 111 | |
112 | - switch ( $shortcode ) { |
|
112 | + switch ($shortcode) { |
|
113 | 113 | case '[TXN_ID]' : |
114 | 114 | return $transaction->ID(); |
115 | 115 | break; |
116 | 116 | |
117 | 117 | case '[PAYMENT_URL]' : |
118 | 118 | $payment_url = $transaction->payment_overview_url(); |
119 | - return empty( $payment_url ) ? esc_html__( 'http://dummypaymenturlforpreview.com', 'event_espresso' ) : $payment_url; |
|
119 | + return empty($payment_url) ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case '[INVOICE_LINK]' : |
123 | 123 | $invoice_url = $transaction->invoice_url(); |
124 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
125 | - return sprintf( esc_html__( '%sClick here for Invoice%s', 'event_espresso' ), '<a href="' . $invoice_url . '">', '</a>' ); |
|
124 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
125 | + return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
126 | 126 | break; /**/ |
127 | 127 | |
128 | 128 | case '[INVOICE_URL]' : |
129 | 129 | $invoice_url = $transaction->invoice_url(); |
130 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
130 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
131 | 131 | break; |
132 | 132 | |
133 | 133 | case '[INVOICE_LOGO_URL]' : |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | break; |
136 | 136 | |
137 | 137 | case '[INVOICE_LOGO]' : |
138 | - return $this->_get_invoice_logo( true ); |
|
138 | + return $this->_get_invoice_logo(true); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case '[INVOICE_PAYEE_NAME]' : |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | |
158 | 158 | case '[TOTAL_COST]' : |
159 | 159 | $total = $transaction->total(); |
160 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
160 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
161 | 161 | break; |
162 | 162 | |
163 | 163 | case '[PAYMENT_STATUS]' : |
164 | 164 | $status = $transaction->pretty_status(); |
165 | - return ! empty($status) ? $status : esc_html__( 'Unknown', 'event_espresso' ); |
|
165 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
166 | 166 | break; /**/ |
167 | 167 | |
168 | 168 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
169 | 169 | case '[TXN_STATUS]': |
170 | 170 | $status = $transaction->pretty_status(); |
171 | - return ! empty( $status ) ? $status : esc_html__( 'Unknown', 'event_espresso' ); |
|
171 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
172 | 172 | break; |
173 | 173 | |
174 | 174 | case '[TXN_STATUS_ID]' : |
@@ -176,36 +176,36 @@ discard block |
||
176 | 176 | break; |
177 | 177 | |
178 | 178 | case '[PAYMENT_GATEWAY]' : |
179 | - return $this->_get_payment_gateway( $transaction ); |
|
179 | + return $this->_get_payment_gateway($transaction); |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case '[AMOUNT_PAID]' : |
183 | 183 | return $payment instanceof EE_Payment |
184 | - ? EEH_Template::format_currency( $payment->amount() ) |
|
185 | - : EEH_Template::format_currency( 0 ); |
|
184 | + ? EEH_Template::format_currency($payment->amount()) |
|
185 | + : EEH_Template::format_currency(0); |
|
186 | 186 | break; |
187 | 187 | |
188 | 188 | case '[LAST_AMOUNT_PAID]' : |
189 | 189 | $last_payment = $transaction->last_payment(); |
190 | 190 | return $last_payment instanceof EE_Payment |
191 | - ? EEH_Template::format_currency( $last_payment->amount() ) |
|
192 | - : EEH_Template::format_currency( 0 ); |
|
191 | + ? EEH_Template::format_currency($last_payment->amount()) |
|
192 | + : EEH_Template::format_currency(0); |
|
193 | 193 | |
194 | 194 | case '[TOTAL_AMOUNT_PAID]' : |
195 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
195 | + return EEH_Template::format_currency($transaction->paid()); |
|
196 | 196 | break; |
197 | 197 | |
198 | 198 | case '[TOTAL_OWING]' : |
199 | 199 | $total_owing = $transaction->remaining(); |
200 | - return EEH_Template::format_currency( $total_owing ); |
|
200 | + return EEH_Template::format_currency($total_owing); |
|
201 | 201 | break; |
202 | 202 | |
203 | 203 | case '[TXN_SUBTOTAL]' : |
204 | - return EEH_Template::format_currency( $this->_get_subtotal() ); |
|
204 | + return EEH_Template::format_currency($this->_get_subtotal()); |
|
205 | 205 | break; |
206 | 206 | |
207 | 207 | case '[TXN_TAX_SUBTOTAL]' : |
208 | - return EEH_Template::format_currency( $this->_get_subtotal( true ) ); |
|
208 | + return EEH_Template::format_currency($this->_get_subtotal(true)); |
|
209 | 209 | break; |
210 | 210 | |
211 | 211 | case '[TKT_QTY_PURCHASED]' : |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | break; |
215 | 215 | |
216 | 216 | case '[TRANSACTION_ADMIN_URL]' : |
217 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
218 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
219 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url( 'admin.php' ) ); |
|
217 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
218 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
219 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
220 | 220 | return $url; |
221 | 221 | break; |
222 | 222 | |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | //get primary_registration |
225 | 225 | $reg = $this->_data->primary_reg_obj; |
226 | 226 | |
227 | - if ( ! $reg instanceof EE_Registration ) { |
|
227 | + if ( ! $reg instanceof EE_Registration) { |
|
228 | 228 | return ''; |
229 | 229 | } |
230 | 230 | return $reg->receipt_url(); |
231 | 231 | break; |
232 | 232 | |
233 | 233 | case '[INVOICE_RECEIPT_SWITCHER_URL]' : |
234 | - return $this->_get_invoice_receipt_switcher( false ); |
|
234 | + return $this->_get_invoice_receipt_switcher(false); |
|
235 | 235 | break; |
236 | 236 | |
237 | 237 | case '[INVOICE_RECEIPT_SWITCHER_BUTTON]' : |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | |
242 | 242 | } |
243 | 243 | |
244 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== false ) { |
|
245 | - return $this->_get_custom_total_owing( $shortcode ); |
|
244 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) { |
|
245 | + return $this->_get_custom_total_owing($shortcode); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== false ) { |
|
249 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
248 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) { |
|
249 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== false ) { |
|
253 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
252 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) { |
|
253 | + return $this->_get_payment_link_if_needed($shortcode); |
|
254 | 254 | } |
255 | 255 | |
256 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
257 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
256 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
257 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | return ''; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return string parsed. |
273 | 273 | */ |
274 | - private function _get_custom_total_owing( $shortcode ) { |
|
275 | - $valid_shortcodes = array( 'transaction' ); |
|
276 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
274 | + private function _get_custom_total_owing($shortcode) { |
|
275 | + $valid_shortcodes = array('transaction'); |
|
276 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
277 | 277 | |
278 | 278 | //ensure default is set. |
279 | 279 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
280 | 280 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
281 | 281 | |
282 | - if ( $total_owing > 0 ) { |
|
283 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
284 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
282 | + if ($total_owing > 0) { |
|
283 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
284 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
285 | 285 | } else { |
286 | - $owing_content = ! empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
286 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | return $owing_content; |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @param EE_Transaction $transaction |
296 | 296 | * @return string |
297 | 297 | */ |
298 | - private function _get_payment_gateway( $transaction ) { |
|
299 | - $pm = $this->_get_payment_method( $transaction ); |
|
298 | + private function _get_payment_gateway($transaction) { |
|
299 | + $pm = $this->_get_payment_method($transaction); |
|
300 | 300 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
301 | 301 | } |
302 | 302 | |
@@ -311,37 +311,37 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return string url or html |
313 | 313 | */ |
314 | - private function _get_invoice_logo( $img_tags = false ) { |
|
314 | + private function _get_invoice_logo($img_tags = false) { |
|
315 | 315 | //try to get the invoice payment method's logo for this transaction image first |
316 | 316 | $pm = $this->_get_payment_method(); |
317 | - if ( $pm instanceof EE_Payment_Method ){ |
|
318 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', true ); |
|
317 | + if ($pm instanceof EE_Payment_Method) { |
|
318 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true); |
|
319 | 319 | } else { |
320 | 320 | $invoice_logo_url = null; |
321 | 321 | } |
322 | - if ( empty( $invoice_logo_url ) ){ |
|
322 | + if (empty($invoice_logo_url)) { |
|
323 | 323 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
324 | 324 | } |
325 | 325 | |
326 | - if ( empty( $invoice_logo_url ) ) { |
|
326 | + if (empty($invoice_logo_url)) { |
|
327 | 327 | return ''; |
328 | 328 | } |
329 | 329 | |
330 | - if ( ! $img_tags ) { |
|
330 | + if ( ! $img_tags) { |
|
331 | 331 | return $invoice_logo_url; |
332 | 332 | } |
333 | 333 | |
334 | 334 | //image tags have been requested. |
335 | - $image_size = getimagesize( $invoice_logo_url ); |
|
335 | + $image_size = getimagesize($invoice_logo_url); |
|
336 | 336 | |
337 | 337 | //if image is wider than 200px, set the width to 200 |
338 | - if ( $image_size[0] > 300 ) { |
|
338 | + if ($image_size[0] > 300) { |
|
339 | 339 | $image_width = 300; |
340 | 340 | } else { |
341 | 341 | $image_width = $image_size[0]; |
342 | 342 | } |
343 | 343 | |
344 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
344 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | private function _get_invoice_payee_name() { |
359 | 359 | $payee_name = null; |
360 | 360 | $pm = $this->_get_payment_method(); |
361 | - if ( $pm instanceof EE_Payment_Method ){ |
|
362 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', true ); |
|
361 | + if ($pm instanceof EE_Payment_Method) { |
|
362 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', true); |
|
363 | 363 | } |
364 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
364 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
365 | 365 | return $payee_name; |
366 | 366 | } |
367 | 367 | |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | * @param EE_Transaction|null $transaction |
374 | 374 | * @return \EE_Payment_Method|mixed|null|void |
375 | 375 | */ |
376 | - private function _get_payment_method( $transaction = null ){ |
|
377 | - if ( $transaction instanceof EE_Transaction ) { |
|
376 | + private function _get_payment_method($transaction = null) { |
|
377 | + if ($transaction instanceof EE_Transaction) { |
|
378 | 378 | $payment_method = $transaction->payment_method(); |
379 | - if ( empty( $payment_method ) ) { |
|
380 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ) ); |
|
379 | + if (empty($payment_method)) { |
|
380 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
381 | 381 | } |
382 | 382 | return $payment_method; |
383 | 383 | } else { |
384 | 384 | //get the first payment method we can find |
385 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ) ); |
|
385 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | private function _get_invoice_payee_email() { |
400 | 400 | $payee_email = null; |
401 | 401 | $pm = $this->_get_payment_method(); |
402 | - if ( $pm instanceof EE_Payment_Method ){ |
|
403 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', true ); |
|
402 | + if ($pm instanceof EE_Payment_Method) { |
|
403 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', true); |
|
404 | 404 | } |
405 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
405 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
406 | 406 | return $payee_email; |
407 | 407 | } |
408 | 408 | |
@@ -418,24 +418,24 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
421 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
422 | 422 | $payee_tax_number = null; |
423 | 423 | $pm = $this->_get_payment_method(); |
424 | - if ( $pm instanceof EE_Payment_Method ){ |
|
425 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', true ); |
|
424 | + if ($pm instanceof EE_Payment_Method) { |
|
425 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true); |
|
426 | 426 | } |
427 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
427 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
428 | 428 | |
429 | - if ( empty( $payee_tax_number ) ) { |
|
429 | + if (empty($payee_tax_number)) { |
|
430 | 430 | return ''; |
431 | 431 | } |
432 | 432 | |
433 | 433 | //any attributes? |
434 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
434 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
435 | 435 | |
436 | 436 | //prefix? |
437 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : esc_html__( 'VAT/Tax Number: ', 'event_espresso' ); |
|
438 | - return $prefix . $payee_tax_number; |
|
437 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
438 | + return $prefix.$payee_tax_number; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -452,22 +452,22 @@ discard block |
||
452 | 452 | private function _get_invoice_payee_address() { |
453 | 453 | $payee_address = null; |
454 | 454 | $pm = $this->_get_payment_method(); |
455 | - if ( $pm instanceof EE_Payment_Method ){ |
|
456 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', true ); |
|
455 | + if ($pm instanceof EE_Payment_Method) { |
|
456 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', true); |
|
457 | 457 | } |
458 | - if ( empty( $payee_address ) ) { |
|
458 | + if (empty($payee_address)) { |
|
459 | 459 | $organization = EE_Registry::instance()->CFG->organization; |
460 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
461 | - $payee_address .= ! empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
462 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
460 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
461 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
462 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
463 | 463 | |
464 | 464 | //state |
465 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
466 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
465 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
466 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
467 | 467 | |
468 | 468 | //Country |
469 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
470 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
469 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
470 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
471 | 471 | } |
472 | 472 | return $payee_address; |
473 | 473 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | private function _get_invoice_payment_instructions() { |
486 | 486 | $instructions = null; |
487 | 487 | $pm = $this->_get_payment_method(); |
488 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', true ) : ''; |
|
488 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : ''; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -499,27 +499,27 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - protected function _get_invoice_receipt_switcher( $button = true ) { |
|
502 | + protected function _get_invoice_receipt_switcher($button = true) { |
|
503 | 503 | $reg = $this->_data->primary_reg_obj; |
504 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
505 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
504 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
505 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
506 | 506 | return ''; |
507 | 507 | } |
508 | 508 | |
509 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
510 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__( 'View Invoice', 'event_espresso' ) : esc_html__( 'Switch to Invoice', 'event_espresso' ); |
|
511 | - $switch_to_label = ! $switch_to_invoice ? esc_html__( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
509 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
510 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso'); |
|
511 | + $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
512 | 512 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
513 | 513 | |
514 | - if ( ! $button ) { |
|
514 | + if ( ! $button) { |
|
515 | 515 | return $switch_to_url; |
516 | 516 | } |
517 | 517 | |
518 | - if ( ! empty( $switch_to_url ) ) { |
|
518 | + if ( ! empty($switch_to_url)) { |
|
519 | 519 | |
520 | 520 | return ' |
521 | - <form method="post" action="' . $switch_to_url . '" > |
|
522 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
521 | + <form method="post" action="' . $switch_to_url.'" > |
|
522 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
523 | 523 | </form> |
524 | 524 | '; |
525 | 525 | } |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return int |
561 | 561 | */ |
562 | - private function _get_subtotal( $tax = false ) { |
|
563 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : null; |
|
562 | + private function _get_subtotal($tax = false) { |
|
563 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null; |
|
564 | 564 | |
565 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
565 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
566 | 566 | return 0; |
567 | 567 | } |
568 | 568 | |
@@ -581,26 +581,26 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return string parsed. |
583 | 583 | */ |
584 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
585 | - $valid_shortcodes = array( 'transaction' ); |
|
586 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
584 | + private function _get_payment_link_if_needed($shortcode) { |
|
585 | + $valid_shortcodes = array('transaction'); |
|
586 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
587 | 587 | |
588 | 588 | //ensure default is set. |
589 | 589 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
590 | 590 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
591 | 591 | |
592 | - if ( $total_owing > 0 ) { |
|
593 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
594 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
595 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
596 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
597 | - $opening_tag .= ! empty( $opening_tag ) && ! empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
598 | - $opening_tag .= ! empty( $opening_tag ) ? '>' : $opening_tag; |
|
599 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
600 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
592 | + if ($total_owing > 0) { |
|
593 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
594 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
595 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
596 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
597 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
598 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
599 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
600 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
601 | 601 | |
602 | 602 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
603 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
603 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
604 | 604 | } else { |
605 | 605 | return ''; |
606 | 606 | } |
@@ -620,31 +620,31 @@ discard block |
||
620 | 620 | * @param EE_Transaction $transaction |
621 | 621 | * @return string |
622 | 622 | */ |
623 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
623 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
624 | 624 | //if transaction is paid in full then we can just return an empty string |
625 | - if ( $transaction->remaining() === 0 ) { |
|
625 | + if ($transaction->remaining() === 0) { |
|
626 | 626 | return ''; |
627 | 627 | } |
628 | 628 | |
629 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
630 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
631 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
632 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : esc_html__( 'Payment in full due by: ', 'event_espresso' ); |
|
633 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
629 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
630 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
631 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
632 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : esc_html__('Payment in full due by: ', 'event_espresso'); |
|
633 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
634 | 634 | |
635 | 635 | //setup date due: |
636 | 636 | try { |
637 | - if ( $transaction_created instanceof DateTime ) { |
|
638 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
637 | + if ($transaction_created instanceof DateTime) { |
|
638 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
639 | 639 | } else { |
640 | 640 | throw new Exception(); |
641 | 641 | } |
642 | - } catch( Exception $e ) { |
|
642 | + } catch (Exception $e) { |
|
643 | 643 | //format was likely invalid. |
644 | 644 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
645 | 645 | } |
646 | 646 | |
647 | - return $prefix_text . $date_due; |
|
647 | + return $prefix_text.$date_due; |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | } //end EE_Transaction Shortcodes library |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -49,25 +49,25 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | protected function _init_props() { |
52 | - $this->label = esc_html__( 'Attendee Shortcodes', 'event_espresso' ); |
|
53 | - $this->description = esc_html__( 'All shortcodes specific to attendee related data', 'event_espresso' ); |
|
52 | + $this->label = esc_html__('Attendee Shortcodes', 'event_espresso'); |
|
53 | + $this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso'); |
|
54 | 54 | $this->_shortcodes = array( |
55 | - '[FNAME]' => esc_html__( 'First Name of an attendee.', 'event_espresso' ), |
|
56 | - '[LNAME]' => esc_html__( 'Last Name of an attendee.', 'event_espresso' ), |
|
57 | - '[ATTENDEE_EMAIL]' => esc_html__( 'Email address for the attendee.', 'event_espresso' ), |
|
58 | - '[EDIT_ATTENDEE_LINK]' => esc_html__( 'Edit Registration Link (typically you\'d only use this for messages going to event administrators)', 'event_espresso' ), |
|
59 | - '[REGISTRATION_CODE]' => esc_html__( 'Unique Registration Code for the registration', 'event_espresso' ), |
|
60 | - '[REGISTRATION_STATUS_ID]' => esc_html__( 'Parses to the registration status for the attendee', 'event_espresso' ), |
|
61 | - '[REGISTRATION_STATUS_LABEL]' => esc_html__( 'Parses to the status label for the registrant', 'event_espresso' ), |
|
62 | - '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__( 'Parses to the total amount paid for this registration.', 'event_espresso' ), |
|
63 | - '[FRONTEND_EDIT_REG_LINK]' => esc_html__( 'Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso' ), |
|
64 | - '[PHONE_NUMBER]' => esc_html__( 'The Phone Number for the Registration.', 'event_espresso' ), |
|
65 | - '[ADDRESS]' => esc_html__( 'The Address for the Registration', 'event_espresso' ), |
|
66 | - '[ADDRESS2]' => esc_html__( 'Whatever was in the address 2 field for the registration.', 'event_espresso' ), |
|
67 | - '[CITY]' => esc_html__( 'The city for the registration.', 'event_espresso' ), |
|
68 | - '[ZIP_PC]' => esc_html__( 'The ZIP (or Postal) Code for the Registration.', 'event_espresso' ), |
|
69 | - '[ADDRESS_STATE]' => esc_html__( 'The state/province for the registration.', 'event_espresso' ), |
|
70 | - '[COUNTRY]' => esc_html__( 'The country for the registration.', 'event_espresso' ) |
|
55 | + '[FNAME]' => esc_html__('First Name of an attendee.', 'event_espresso'), |
|
56 | + '[LNAME]' => esc_html__('Last Name of an attendee.', 'event_espresso'), |
|
57 | + '[ATTENDEE_EMAIL]' => esc_html__('Email address for the attendee.', 'event_espresso'), |
|
58 | + '[EDIT_ATTENDEE_LINK]' => esc_html__('Edit Registration Link (typically you\'d only use this for messages going to event administrators)', 'event_espresso'), |
|
59 | + '[REGISTRATION_CODE]' => esc_html__('Unique Registration Code for the registration', 'event_espresso'), |
|
60 | + '[REGISTRATION_STATUS_ID]' => esc_html__('Parses to the registration status for the attendee', 'event_espresso'), |
|
61 | + '[REGISTRATION_STATUS_LABEL]' => esc_html__('Parses to the status label for the registrant', 'event_espresso'), |
|
62 | + '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__('Parses to the total amount paid for this registration.', 'event_espresso'), |
|
63 | + '[FRONTEND_EDIT_REG_LINK]' => esc_html__('Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso'), |
|
64 | + '[PHONE_NUMBER]' => esc_html__('The Phone Number for the Registration.', 'event_espresso'), |
|
65 | + '[ADDRESS]' => esc_html__('The Address for the Registration', 'event_espresso'), |
|
66 | + '[ADDRESS2]' => esc_html__('Whatever was in the address 2 field for the registration.', 'event_espresso'), |
|
67 | + '[CITY]' => esc_html__('The city for the registration.', 'event_espresso'), |
|
68 | + '[ZIP_PC]' => esc_html__('The ZIP (or Postal) Code for the Registration.', 'event_espresso'), |
|
69 | + '[ADDRESS_STATE]' => esc_html__('The state/province for the registration.', 'event_espresso'), |
|
70 | + '[COUNTRY]' => esc_html__('The country for the registration.', 'event_espresso') |
|
71 | 71 | ); |
72 | 72 | } |
73 | 73 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @return string |
82 | 82 | * @throws \EE_Error |
83 | 83 | */ |
84 | - protected function _parser( $shortcode ) { |
|
84 | + protected function _parser($shortcode) { |
|
85 | 85 | |
86 | 86 | |
87 | - $this->_xtra = ! empty( $this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
87 | + $this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
88 | 88 | ? $this->_extra_data['data'] |
89 | 89 | : null; |
90 | 90 | |
@@ -93,34 +93,34 @@ discard block |
||
93 | 93 | ? null |
94 | 94 | : $this->_data; |
95 | 95 | |
96 | - if ( ! $registration instanceof EE_Registration ) { |
|
96 | + if ( ! $registration instanceof EE_Registration) { |
|
97 | 97 | //let's attempt to get the txn_id for the error message. |
98 | - $txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction |
|
98 | + $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction |
|
99 | 99 | ? $this->_xtra->txn->ID() |
100 | - : esc_html__( 'Unknown', 'event_espresso' ); |
|
101 | - $msg = esc_html__( 'There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', 'event_espresso' ); |
|
100 | + : esc_html__('Unknown', 'event_espresso'); |
|
101 | + $msg = esc_html__('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', 'event_espresso'); |
|
102 | 102 | $dev_msg = sprintf( |
103 | - esc_html__( 'The transaction ID for this request is: %s', 'event_espresso' ), |
|
103 | + esc_html__('The transaction ID for this request is: %s', 'event_espresso'), |
|
104 | 104 | $txn_id |
105 | 105 | ); |
106 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
106 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //attendee obj for this registration |
110 | - $attendee = isset( $this->_xtra->registrations[ $registration->ID() ]['att_obj'] ) |
|
111 | - ? $this->_xtra->registrations[ $registration->ID() ]['att_obj'] |
|
112 | - : null ; |
|
110 | + $attendee = isset($this->_xtra->registrations[$registration->ID()]['att_obj']) |
|
111 | + ? $this->_xtra->registrations[$registration->ID()]['att_obj'] |
|
112 | + : null; |
|
113 | 113 | |
114 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
115 | - $msg = esc_html__( 'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', 'event_espresso' ); |
|
114 | + if ( ! $attendee instanceof EE_Attendee) { |
|
115 | + $msg = esc_html__('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', 'event_espresso'); |
|
116 | 116 | $dev_msg = sprintf( |
117 | - esc_html__( 'The registration ID for this request is: %s', 'event_espresso' ), |
|
117 | + esc_html__('The registration ID for this request is: %s', 'event_espresso'), |
|
118 | 118 | $registration->ID() |
119 | 119 | ); |
120 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
120 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
121 | 121 | } |
122 | 122 | |
123 | - switch ( $shortcode ) { |
|
123 | + switch ($shortcode) { |
|
124 | 124 | |
125 | 125 | case '[FNAME]' : |
126 | 126 | return $attendee->fname(); |