Completed
Branch BUG-10059-allow-multiple-invoi... (fa6f0e)
by
unknown
14:57
created
core/db_classes/EE_Transaction.class.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function
413 413
 	 * for getting attendees and how many registrations they each have for an event)
414 414
 	 *
415
-	 * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT'
415
+	 * @return EE_Base_Class[] EE_Attendee[] by default, int if $output is set to 'COUNT'
416 416
 	 * @throws \EE_Error
417 417
 	 */
418 418
 	public function attendees() {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	 * Gets all the extra meta info on this payment
673 673
 	 *
674 674
 	 * @param array $query_params like EEM_Base::get_all
675
-	 * @return EE_Extra_Meta
675
+	 * @return EE_Base_Class[]
676 676
 	 * @throws \EE_Error
677 677
 	 */
678 678
 	public function extra_meta( $query_params = array() ) {
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 	 * Sets PMD_ID
850 850
 	 *
851 851
 	 * @param int $PMD_ID
852
-	 * @return boolean
852
+	 * @return boolean|null
853 853
 	 * @throws \EE_Error
854 854
 	 */
855 855
 	public function set_payment_method_ID($PMD_ID) {
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 	 * correct invoice payment method for invoice details.  It's not always guaranteed that the default invoice payment
889 889
 	 * method would be correct because our system allows for multiples of the same payment method.
890 890
 	 *
891
-	 * @return EE_Payment_Method|null
891
+	 * @return EE_Base_Class
892 892
 	 */
893 893
 	public function get_most_recent_invoice_payment_method() {
894 894
 		return $this->get_first_related(
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Transaction_Shortcodes.lib.php 1 patch
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 300px, set the width to 300
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
 block discarded – undo
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,26 +373,26 @@  discard block
 block discarded – undo
373 373
 	 * @param EE_Transaction|null $transaction
374 374
 	 * @return \EE_Payment_Method|null
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
 			//See if we can find a transaction
385 385
 			$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
386
-			$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;
386
+			$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;
387 387
 
388
-			if ( $transaction instanceof EE_Transaction ) {
388
+			if ($transaction instanceof EE_Transaction) {
389 389
 				$payment_method = $transaction->get_most_recent_invoice_payment_method();
390
-				if ( $payment_method instanceof EE_Payment_Method ) {
390
+				if ($payment_method instanceof EE_Payment_Method) {
391 391
 					return $payment_method;
392 392
 				}
393 393
 			}
394 394
 			//Still here? Return the first payment method we can find
395
-			return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ) );
395
+			return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
396 396
 		}
397 397
 	}
398 398
 
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 	private function _get_invoice_payee_email() {
410 410
 		$payee_email = null;
411 411
 		$pm = $this->_get_payment_method();
412
-		if ( $pm instanceof EE_Payment_Method ){
413
-			$payee_email = $pm->get_extra_meta( 'pdf_payee_email', true );
412
+		if ($pm instanceof EE_Payment_Method) {
413
+			$payee_email = $pm->get_extra_meta('pdf_payee_email', true);
414 414
 		}
415
-		$payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email;
415
+		$payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email;
416 416
 		return $payee_email;
417 417
 	}
418 418
 
@@ -428,24 +428,24 @@  discard block
 block discarded – undo
428 428
 	 *
429 429
 	 * @return string
430 430
 	 */
431
-	private function _get_invoice_payee_tax_number( $shortcode ) {
431
+	private function _get_invoice_payee_tax_number($shortcode) {
432 432
 		$payee_tax_number = null;
433 433
 		$pm = $this->_get_payment_method();
434
-		if ( $pm instanceof EE_Payment_Method ){
435
-			$payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', true );
434
+		if ($pm instanceof EE_Payment_Method) {
435
+			$payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
436 436
 		}
437
-		$payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
437
+		$payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
438 438
 
439
-		if ( empty( $payee_tax_number ) ) {
439
+		if (empty($payee_tax_number)) {
440 440
 			return '';
441 441
 		}
442 442
 
443 443
 		//any attributes?
444
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
444
+		$attrs = $this->_get_shortcode_attrs($shortcode);
445 445
 
446 446
 		//prefix?
447
-		$prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : esc_html__( 'VAT/Tax Number: ', 'event_espresso' );
448
-		return $prefix . $payee_tax_number;
447
+		$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
448
+		return $prefix.$payee_tax_number;
449 449
 	}
450 450
 
451 451
 
@@ -462,22 +462,22 @@  discard block
 block discarded – undo
462 462
 	private function _get_invoice_payee_address() {
463 463
 		$payee_address = null;
464 464
 		$pm = $this->_get_payment_method();
465
-		if ( $pm instanceof EE_Payment_Method ){
466
-			$payee_address = $pm->get_extra_meta( 'pdf_payee_address', true );
465
+		if ($pm instanceof EE_Payment_Method) {
466
+			$payee_address = $pm->get_extra_meta('pdf_payee_address', true);
467 467
 		}
468
-		if ( empty( $payee_address ) ) {
468
+		if (empty($payee_address)) {
469 469
 			$organization = EE_Registry::instance()->CFG->organization;
470
-			$payee_address = $organization->get_pretty( 'address_1' ) . '<br>';
471
-			$payee_address .= ! empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : '';
472
-			$payee_address .= $organization->get_pretty( 'city' ) . '<br>';
470
+			$payee_address = $organization->get_pretty('address_1').'<br>';
471
+			$payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : '';
472
+			$payee_address .= $organization->get_pretty('city').'<br>';
473 473
 
474 474
 			//state
475
-			$state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID );
476
-			$payee_address .= $state instanceof EE_State ? $state->name()  : '';
475
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
476
+			$payee_address .= $state instanceof EE_State ? $state->name() : '';
477 477
 
478 478
 			//Country
479
-			$payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : '';
480
-			$payee_address .= ! empty( $organization->zip ) ? $organization->zip : '';
479
+			$payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : '';
480
+			$payee_address .= ! empty($organization->zip) ? $organization->zip : '';
481 481
 		}
482 482
 		return $payee_address;
483 483
 	}
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	private function _get_invoice_payment_instructions() {
496 496
 		$instructions = null;
497 497
 		$pm = $this->_get_payment_method();
498
-		return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', true ) : '';
498
+		return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
499 499
 	}
500 500
 
501 501
 
@@ -509,27 +509,27 @@  discard block
 block discarded – undo
509 509
 	 *
510 510
 	 * @return string
511 511
 	 */
512
-	protected function _get_invoice_receipt_switcher( $button = true ) {
512
+	protected function _get_invoice_receipt_switcher($button = true) {
513 513
 		$reg = $this->_data->primary_reg_obj;
514
-		$message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : '';
515
-		if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) {
514
+		$message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
515
+		if ( ! $reg instanceof EE_Registration || empty($message_type)) {
516 516
 			return '';
517 517
 		}
518 518
 
519
-		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type  ? true : false;
520
-		$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' );
521
-		$switch_to_label = ! $switch_to_invoice ? esc_html__( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label;
519
+		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
520
+		$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');
521
+		$switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
522 522
 		$switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
523 523
 
524
-		if ( ! $button ) {
524
+		if ( ! $button) {
525 525
 			return $switch_to_url;
526 526
 		}
527 527
 
528
-		if ( ! empty( $switch_to_url ) ) {
528
+		if ( ! empty($switch_to_url)) {
529 529
 
530 530
 			return  '
531
-	<form method="post" action="' . $switch_to_url . '" >
532
-		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
531
+	<form method="post" action="' . $switch_to_url.'" >
532
+		<input class="print_button" type="submit" value="' . $switch_to_label.'" />
533 533
 	</form>
534 534
 			';
535 535
 		}
@@ -547,10 +547,10 @@  discard block
 block discarded – undo
547 547
 	 *
548 548
 	 * @return int
549 549
 	 */
550
-	private function _get_subtotal( $tax = false ) {
551
-		$grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : null;
550
+	private function _get_subtotal($tax = false) {
551
+		$grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
552 552
 
553
-		if ( ! $grand_total instanceof EE_Line_Item ) {
553
+		if ( ! $grand_total instanceof EE_Line_Item) {
554 554
 			return 0;
555 555
 		}
556 556
 
@@ -569,26 +569,26 @@  discard block
 block discarded – undo
569 569
 	 *
570 570
 	 * @return string parsed.
571 571
 	 */
572
-	private function _get_payment_link_if_needed( $shortcode ) {
573
-		$valid_shortcodes = array( 'transaction' );
574
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
572
+	private function _get_payment_link_if_needed($shortcode) {
573
+		$valid_shortcodes = array('transaction');
574
+		$attrs = $this->_get_shortcode_attrs($shortcode);
575 575
 
576 576
 		//ensure default is set.
577 577
 		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
578 578
 		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0;
579 579
 
580
-		if ( $total_owing > 0 ) {
581
-			$class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout';
582
-			$custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
583
-			$container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p';
584
-			$opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : '';
585
-			$opening_tag .= ! empty( $opening_tag ) && ! empty( $class ) ? ' class="' . $class . '"' : $opening_tag;
586
-			$opening_tag .= ! empty( $opening_tag ) ? '>' : $opening_tag;
587
-			$closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : '';
588
-			$content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag;
580
+		if ($total_owing > 0) {
581
+			$class = isset($attrs['class']) ? $attrs['class'] : 'callout';
582
+			$custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
583
+			$container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
584
+			$opening_tag = ! empty($container_tag) ? '<'.$container_tag : '';
585
+			$opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag;
586
+			$opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
587
+			$closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : '';
588
+			$content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag;
589 589
 
590 590
 			//we need to re run this string through the parser to catch any shortcodes that are in it.
591
-			$owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
591
+			$owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
592 592
 		} else {
593 593
 			return '';
594 594
 		}
@@ -608,31 +608,31 @@  discard block
 block discarded – undo
608 608
 	 * @param EE_Transaction $transaction
609 609
 	 * @return string
610 610
 	 */
611
-	protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) {
611
+	protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) {
612 612
 		//if transaction is paid in full then we can just return an empty string
613
-		if ( $transaction->remaining() === 0 ) {
613
+		if ($transaction->remaining() === 0) {
614 614
 			return '';
615 615
 		}
616 616
 
617
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
618
-		$format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' );
619
-		$days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30;
620
-		$prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : esc_html__( 'Payment in full due by: ', 'event_espresso' );
621
-		$transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' );
617
+		$attrs = $this->_get_shortcode_attrs($shortcode);
618
+		$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
619
+		$days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
620
+		$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : esc_html__('Payment in full due by: ', 'event_espresso');
621
+		$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
622 622
 
623 623
 		//setup date due:
624 624
 		try {
625
-			if ( $transaction_created instanceof DateTime ) {
626
-				$date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format );
625
+			if ($transaction_created instanceof DateTime) {
626
+				$date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format);
627 627
 			} else {
628 628
 				throw new Exception();
629 629
 			}
630
-		} catch( Exception $e ) {
630
+		} catch (Exception $e) {
631 631
 			//format was likely invalid.
632 632
 			$date_due = 'Unable to calculate date due, likely the format string is invalid.';
633 633
 		}
634 634
 
635
-		return $prefix_text . $date_due;
635
+		return $prefix_text.$date_due;
636 636
 	}
637 637
 
638 638
 } //end EE_Transaction Shortcodes library
Please login to merge, or discard this patch.