@@ -18,93 +18,93 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = __('Payment Shortcodes', 'event_espresso'); |
|
24 | - $this->description = __('All shortcodes specific to payments.', 'event_espresso'); |
|
25 | - $this->_shortcodes = array( |
|
26 | - '[PAYMENT_TIMESTAMP]' => __( |
|
27 | - 'Outputs the date of the payment (using the default date format).', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - '[PAYMENT_METHOD]' => __('Outputs a the payment method.', 'event_espresso'), |
|
31 | - '[PAYMENT_AMOUNT]' => __('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
32 | - '[PAYMENT_GATEWAY]' => __('Outputs the gateway used for the payment.', 'event_espresso'), |
|
33 | - '[PAYMENT_GATEWAY_RESPONSE]' => __('Outputs the payment gateway response.', 'event_espresso'), |
|
34 | - '[PAYMENT_GATEWAY_TXN_ID]' => __( |
|
35 | - 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - '[PAYMENT_PO_NUMBER]' => __('Purchase Order number (if present)', 'event_espresso'), |
|
39 | - '[PAYMENT_EXTRA_ACCOUNTING]' => __( |
|
40 | - 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
41 | - 'event_espresso' |
|
42 | - ), |
|
43 | - '[PAYMENT_STATUS]' => __('The status of the payment.', 'event_espresso'), |
|
44 | - // '[PAYMENT_STATUS_WITH_ICONS]' => __('The status of the payment including icons representing the status.', 'event_espresso') |
|
45 | - ); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - protected function _parser($shortcode) |
|
50 | - { |
|
51 | - // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
52 | - if (! $this->_data instanceof EE_Payment) { |
|
53 | - return ''; |
|
54 | - } |
|
55 | - |
|
56 | - $payment = $this->_data; |
|
57 | - |
|
58 | - switch ($shortcode) { |
|
59 | - case '[PAYMENT_TIMESTAMP]': |
|
60 | - return $payment->timestamp(); |
|
61 | - break; |
|
62 | - |
|
63 | - case '[PAYMENT_METHOD]': |
|
64 | - // previously the column 'PAY_source' was known as 'PAY_method' |
|
65 | - return $payment->source(); |
|
66 | - break; |
|
67 | - |
|
68 | - case '[PAYMENT_AMOUNT]': |
|
69 | - return $payment->amount_no_code(); |
|
70 | - break; |
|
71 | - |
|
72 | - case '[PAYMENT_GATEWAY]': |
|
73 | - // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
74 | - if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
75 | - return $payment->payment_method()->name(); |
|
76 | - } else { |
|
77 | - return __('Unknown', 'event_espresso'); |
|
78 | - } |
|
79 | - break; |
|
80 | - |
|
81 | - case '[PAYMENT_GATEWAY_RESPONSE]': |
|
82 | - return $payment->gateway_response(); |
|
83 | - break; |
|
84 | - |
|
85 | - case '[PAYMENT_GATEWAY_TXN_ID]': |
|
86 | - return $payment->txn_id_chq_nmbr(); |
|
87 | - break; |
|
88 | - |
|
89 | - case '[PAYMENT_PO_NUMBER]': |
|
90 | - return $payment->po_number(); |
|
91 | - break; |
|
92 | - |
|
93 | - case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
94 | - return $payment->extra_accntng(); |
|
95 | - break; |
|
96 | - |
|
97 | - case '[PAYMENT_STATUS]': |
|
98 | - return $payment->pretty_status(); |
|
99 | - break; |
|
100 | - |
|
101 | - case '[PAYMENT_STATUS_WITH_ICONS]': |
|
102 | - return $payment->pretty_status(true); |
|
103 | - break; |
|
104 | - |
|
105 | - default: |
|
106 | - return ''; |
|
107 | - break; |
|
108 | - } |
|
109 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = __('Payment Shortcodes', 'event_espresso'); |
|
24 | + $this->description = __('All shortcodes specific to payments.', 'event_espresso'); |
|
25 | + $this->_shortcodes = array( |
|
26 | + '[PAYMENT_TIMESTAMP]' => __( |
|
27 | + 'Outputs the date of the payment (using the default date format).', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + '[PAYMENT_METHOD]' => __('Outputs a the payment method.', 'event_espresso'), |
|
31 | + '[PAYMENT_AMOUNT]' => __('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
32 | + '[PAYMENT_GATEWAY]' => __('Outputs the gateway used for the payment.', 'event_espresso'), |
|
33 | + '[PAYMENT_GATEWAY_RESPONSE]' => __('Outputs the payment gateway response.', 'event_espresso'), |
|
34 | + '[PAYMENT_GATEWAY_TXN_ID]' => __( |
|
35 | + 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + '[PAYMENT_PO_NUMBER]' => __('Purchase Order number (if present)', 'event_espresso'), |
|
39 | + '[PAYMENT_EXTRA_ACCOUNTING]' => __( |
|
40 | + 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
41 | + 'event_espresso' |
|
42 | + ), |
|
43 | + '[PAYMENT_STATUS]' => __('The status of the payment.', 'event_espresso'), |
|
44 | + // '[PAYMENT_STATUS_WITH_ICONS]' => __('The status of the payment including icons representing the status.', 'event_espresso') |
|
45 | + ); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + protected function _parser($shortcode) |
|
50 | + { |
|
51 | + // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
52 | + if (! $this->_data instanceof EE_Payment) { |
|
53 | + return ''; |
|
54 | + } |
|
55 | + |
|
56 | + $payment = $this->_data; |
|
57 | + |
|
58 | + switch ($shortcode) { |
|
59 | + case '[PAYMENT_TIMESTAMP]': |
|
60 | + return $payment->timestamp(); |
|
61 | + break; |
|
62 | + |
|
63 | + case '[PAYMENT_METHOD]': |
|
64 | + // previously the column 'PAY_source' was known as 'PAY_method' |
|
65 | + return $payment->source(); |
|
66 | + break; |
|
67 | + |
|
68 | + case '[PAYMENT_AMOUNT]': |
|
69 | + return $payment->amount_no_code(); |
|
70 | + break; |
|
71 | + |
|
72 | + case '[PAYMENT_GATEWAY]': |
|
73 | + // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
74 | + if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
75 | + return $payment->payment_method()->name(); |
|
76 | + } else { |
|
77 | + return __('Unknown', 'event_espresso'); |
|
78 | + } |
|
79 | + break; |
|
80 | + |
|
81 | + case '[PAYMENT_GATEWAY_RESPONSE]': |
|
82 | + return $payment->gateway_response(); |
|
83 | + break; |
|
84 | + |
|
85 | + case '[PAYMENT_GATEWAY_TXN_ID]': |
|
86 | + return $payment->txn_id_chq_nmbr(); |
|
87 | + break; |
|
88 | + |
|
89 | + case '[PAYMENT_PO_NUMBER]': |
|
90 | + return $payment->po_number(); |
|
91 | + break; |
|
92 | + |
|
93 | + case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
94 | + return $payment->extra_accntng(); |
|
95 | + break; |
|
96 | + |
|
97 | + case '[PAYMENT_STATUS]': |
|
98 | + return $payment->pretty_status(); |
|
99 | + break; |
|
100 | + |
|
101 | + case '[PAYMENT_STATUS_WITH_ICONS]': |
|
102 | + return $payment->pretty_status(true); |
|
103 | + break; |
|
104 | + |
|
105 | + default: |
|
106 | + return ''; |
|
107 | + break; |
|
108 | + } |
|
109 | + } |
|
110 | 110 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | protected function _parser($shortcode) |
50 | 50 | { |
51 | 51 | // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
52 | - if (! $this->_data instanceof EE_Payment) { |
|
52 | + if ( ! $this->_data instanceof EE_Payment) { |
|
53 | 53 | return ''; |
54 | 54 | } |
55 | 55 |
@@ -19,123 +19,123 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * Will hold the EE_Ticket if available |
|
24 | - * |
|
25 | - * @var EE_Ticket |
|
26 | - */ |
|
27 | - protected $_ticket; |
|
28 | - |
|
29 | - |
|
30 | - protected function _init_props() |
|
31 | - { |
|
32 | - $this->label = __('Ticket Shortcodes', 'event_espresso'); |
|
33 | - $this->description = __('All shortcodes specific to ticket related data', 'event_espresso'); |
|
34 | - $this->_shortcodes = array( |
|
35 | - '[TICKET_ID]' => __('Will be replaced by the ticket ID of a ticket', 'event_espresso'), |
|
36 | - '[TICKET_NAME]' => __('The name of the ticket', 'event_espresso'), |
|
37 | - '[TICKET_DESCRIPTION]' => __('The description of the ticket', 'event_espresso'), |
|
38 | - '[TICKET_PRICE]' => __('The price of the ticket', 'event_espresso'), |
|
39 | - '[TICKET_PRICE_WITH_TAXES]' => __( |
|
40 | - 'The price of the ticket including any taxes that might be on the ticket', |
|
41 | - 'event_espresso' |
|
42 | - ), |
|
43 | - '[TKT_QTY_PURCHASED]' => __( |
|
44 | - 'The total quantity of the current ticket in the list that has been purchased in this transaction', |
|
45 | - 'event_espresso' |
|
46 | - ), |
|
47 | - '[TKT_USES_*]' => __( |
|
48 | - 'This attribute based shortcode parses to show the number of uses the ticket has. The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite. Options are:', |
|
49 | - 'event_espresso' |
|
50 | - ) . |
|
51 | - '<p><ul>' . |
|
52 | - '<li><strong>symbol</strong>:' . __( |
|
53 | - 'This returns the ∞ symbol.', |
|
54 | - 'event_espresso' |
|
55 | - ) . '</li>' . |
|
56 | - '<li><strong>text</strong>:' . __( |
|
57 | - 'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.', |
|
58 | - 'event_espresso' |
|
59 | - ) . '</li>' . |
|
60 | - '<li><strong>{custom}</strong>:' . __( |
|
61 | - 'You can put anything you want as a string instead and that will be used. So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".', |
|
62 | - 'event_espresso' |
|
63 | - ) . '</li>' . |
|
64 | - '</ul></p>', |
|
65 | - ); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - protected function _parser($shortcode) |
|
70 | - { |
|
71 | - |
|
72 | - $this->_ticket = $this->_data instanceof EE_Ticket ? $this->_data : null; |
|
73 | - |
|
74 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
75 | - $aee = ! $aee instanceof EE_Messages_Addressee && is_array( |
|
76 | - $this->_extra_data |
|
77 | - ) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
78 | - ? $this->_extra_data['data'] : $aee; |
|
79 | - |
|
80 | - |
|
81 | - // possible EE_Line_Item may be incoming data |
|
82 | - $this->_ticket = empty($this->_ticket) |
|
83 | - && $this->_data instanceof EE_Line_Item |
|
84 | - && $aee instanceof EE_Messages_Addressee |
|
85 | - && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']) |
|
86 | - && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket |
|
87 | - ? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] |
|
88 | - : $this->_ticket; |
|
89 | - |
|
90 | - // if still no ticket, then let's see if there is a reg_obj. If there IS, then we'll try and grab the ticket from the reg_obj instead. |
|
91 | - if (empty($this->_ticket)) { |
|
92 | - $this->_ticket = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
93 | - ? $aee->reg_obj->ticket() : null; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - // If there is no event object by now then get out. |
|
98 | - if (! $this->_ticket instanceof EE_Ticket) { |
|
99 | - return ''; |
|
100 | - } |
|
101 | - |
|
102 | - switch ($shortcode) { |
|
103 | - case '[TICKET_ID]': |
|
104 | - return $this->_ticket->ID(); |
|
105 | - break; |
|
106 | - |
|
107 | - case '[TICKET_NAME]': |
|
108 | - return $this->_ticket->get('TKT_name'); |
|
109 | - break; |
|
110 | - |
|
111 | - case '[TICKET_DESCRIPTION]': |
|
112 | - return $this->_ticket->get('TKT_description'); |
|
113 | - break; |
|
114 | - |
|
115 | - case '[TICKET_PRICE]': |
|
116 | - return EEH_Template::format_currency($this->_ticket->get('TKT_price')); |
|
117 | - break; |
|
118 | - |
|
119 | - case '[TICKET_PRICE_WITH_TAXES]': |
|
120 | - return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes()); |
|
121 | - break; |
|
122 | - |
|
123 | - case '[TKT_QTY_PURCHASED]': |
|
124 | - return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : ''; |
|
125 | - break; |
|
126 | - } |
|
127 | - |
|
128 | - if (strpos($shortcode, '[TKT_USES_*') !== false) { |
|
129 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
130 | - $schema = empty($attrs['schema']) ? null : $attrs['schema']; |
|
131 | - return $this->_ticket->get_pretty('TKT_uses', $schema); |
|
132 | - } |
|
133 | - return ''; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - public function get_ticket_set() |
|
138 | - { |
|
139 | - return $this->_ticket; |
|
140 | - } |
|
22 | + /** |
|
23 | + * Will hold the EE_Ticket if available |
|
24 | + * |
|
25 | + * @var EE_Ticket |
|
26 | + */ |
|
27 | + protected $_ticket; |
|
28 | + |
|
29 | + |
|
30 | + protected function _init_props() |
|
31 | + { |
|
32 | + $this->label = __('Ticket Shortcodes', 'event_espresso'); |
|
33 | + $this->description = __('All shortcodes specific to ticket related data', 'event_espresso'); |
|
34 | + $this->_shortcodes = array( |
|
35 | + '[TICKET_ID]' => __('Will be replaced by the ticket ID of a ticket', 'event_espresso'), |
|
36 | + '[TICKET_NAME]' => __('The name of the ticket', 'event_espresso'), |
|
37 | + '[TICKET_DESCRIPTION]' => __('The description of the ticket', 'event_espresso'), |
|
38 | + '[TICKET_PRICE]' => __('The price of the ticket', 'event_espresso'), |
|
39 | + '[TICKET_PRICE_WITH_TAXES]' => __( |
|
40 | + 'The price of the ticket including any taxes that might be on the ticket', |
|
41 | + 'event_espresso' |
|
42 | + ), |
|
43 | + '[TKT_QTY_PURCHASED]' => __( |
|
44 | + 'The total quantity of the current ticket in the list that has been purchased in this transaction', |
|
45 | + 'event_espresso' |
|
46 | + ), |
|
47 | + '[TKT_USES_*]' => __( |
|
48 | + 'This attribute based shortcode parses to show the number of uses the ticket has. The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite. Options are:', |
|
49 | + 'event_espresso' |
|
50 | + ) . |
|
51 | + '<p><ul>' . |
|
52 | + '<li><strong>symbol</strong>:' . __( |
|
53 | + 'This returns the ∞ symbol.', |
|
54 | + 'event_espresso' |
|
55 | + ) . '</li>' . |
|
56 | + '<li><strong>text</strong>:' . __( |
|
57 | + 'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.', |
|
58 | + 'event_espresso' |
|
59 | + ) . '</li>' . |
|
60 | + '<li><strong>{custom}</strong>:' . __( |
|
61 | + 'You can put anything you want as a string instead and that will be used. So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".', |
|
62 | + 'event_espresso' |
|
63 | + ) . '</li>' . |
|
64 | + '</ul></p>', |
|
65 | + ); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + protected function _parser($shortcode) |
|
70 | + { |
|
71 | + |
|
72 | + $this->_ticket = $this->_data instanceof EE_Ticket ? $this->_data : null; |
|
73 | + |
|
74 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
75 | + $aee = ! $aee instanceof EE_Messages_Addressee && is_array( |
|
76 | + $this->_extra_data |
|
77 | + ) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
78 | + ? $this->_extra_data['data'] : $aee; |
|
79 | + |
|
80 | + |
|
81 | + // possible EE_Line_Item may be incoming data |
|
82 | + $this->_ticket = empty($this->_ticket) |
|
83 | + && $this->_data instanceof EE_Line_Item |
|
84 | + && $aee instanceof EE_Messages_Addressee |
|
85 | + && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']) |
|
86 | + && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket |
|
87 | + ? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] |
|
88 | + : $this->_ticket; |
|
89 | + |
|
90 | + // if still no ticket, then let's see if there is a reg_obj. If there IS, then we'll try and grab the ticket from the reg_obj instead. |
|
91 | + if (empty($this->_ticket)) { |
|
92 | + $this->_ticket = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
93 | + ? $aee->reg_obj->ticket() : null; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + // If there is no event object by now then get out. |
|
98 | + if (! $this->_ticket instanceof EE_Ticket) { |
|
99 | + return ''; |
|
100 | + } |
|
101 | + |
|
102 | + switch ($shortcode) { |
|
103 | + case '[TICKET_ID]': |
|
104 | + return $this->_ticket->ID(); |
|
105 | + break; |
|
106 | + |
|
107 | + case '[TICKET_NAME]': |
|
108 | + return $this->_ticket->get('TKT_name'); |
|
109 | + break; |
|
110 | + |
|
111 | + case '[TICKET_DESCRIPTION]': |
|
112 | + return $this->_ticket->get('TKT_description'); |
|
113 | + break; |
|
114 | + |
|
115 | + case '[TICKET_PRICE]': |
|
116 | + return EEH_Template::format_currency($this->_ticket->get('TKT_price')); |
|
117 | + break; |
|
118 | + |
|
119 | + case '[TICKET_PRICE_WITH_TAXES]': |
|
120 | + return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes()); |
|
121 | + break; |
|
122 | + |
|
123 | + case '[TKT_QTY_PURCHASED]': |
|
124 | + return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : ''; |
|
125 | + break; |
|
126 | + } |
|
127 | + |
|
128 | + if (strpos($shortcode, '[TKT_USES_*') !== false) { |
|
129 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
130 | + $schema = empty($attrs['schema']) ? null : $attrs['schema']; |
|
131 | + return $this->_ticket->get_pretty('TKT_uses', $schema); |
|
132 | + } |
|
133 | + return ''; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + public function get_ticket_set() |
|
138 | + { |
|
139 | + return $this->_ticket; |
|
140 | + } |
|
141 | 141 | } |
@@ -47,20 +47,20 @@ discard block |
||
47 | 47 | '[TKT_USES_*]' => __( |
48 | 48 | 'This attribute based shortcode parses to show the number of uses the ticket has. The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite. Options are:', |
49 | 49 | 'event_espresso' |
50 | - ) . |
|
51 | - '<p><ul>' . |
|
52 | - '<li><strong>symbol</strong>:' . __( |
|
50 | + ). |
|
51 | + '<p><ul>'. |
|
52 | + '<li><strong>symbol</strong>:'.__( |
|
53 | 53 | 'This returns the ∞ symbol.', |
54 | 54 | 'event_espresso' |
55 | - ) . '</li>' . |
|
56 | - '<li><strong>text</strong>:' . __( |
|
55 | + ).'</li>'. |
|
56 | + '<li><strong>text</strong>:'.__( |
|
57 | 57 | 'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.', |
58 | 58 | 'event_espresso' |
59 | - ) . '</li>' . |
|
60 | - '<li><strong>{custom}</strong>:' . __( |
|
59 | + ).'</li>'. |
|
60 | + '<li><strong>{custom}</strong>:'.__( |
|
61 | 61 | 'You can put anything you want as a string instead and that will be used. So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".', |
62 | 62 | 'event_espresso' |
63 | - ) . '</li>' . |
|
63 | + ).'</li>'. |
|
64 | 64 | '</ul></p>', |
65 | 65 | ); |
66 | 66 | } |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | $this->_ticket = empty($this->_ticket) |
83 | 83 | && $this->_data instanceof EE_Line_Item |
84 | 84 | && $aee instanceof EE_Messages_Addressee |
85 | - && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']) |
|
86 | - && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket |
|
87 | - ? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] |
|
85 | + && ! empty($aee->line_items_with_children[$this->_data->ID()]['EE_Ticket']) |
|
86 | + && $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'] instanceof EE_Ticket |
|
87 | + ? $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'] |
|
88 | 88 | : $this->_ticket; |
89 | 89 | |
90 | 90 | // if still no ticket, then let's see if there is a reg_obj. If there IS, then we'll try and grab the ticket from the reg_obj instead. |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | |
97 | 97 | // If there is no event object by now then get out. |
98 | - if (! $this->_ticket instanceof EE_Ticket) { |
|
98 | + if ( ! $this->_ticket instanceof EE_Ticket) { |
|
99 | 99 | return ''; |
100 | 100 | } |
101 | 101 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | break; |
122 | 122 | |
123 | 123 | case '[TKT_QTY_PURCHASED]': |
124 | - return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : ''; |
|
124 | + return $aee instanceof EE_Messages_Addressee ? $aee->tickets[$this->_ticket->ID()]['count'] : ''; |
|
125 | 125 | break; |
126 | 126 | } |
127 | 127 |
@@ -20,116 +20,116 @@ |
||
20 | 20 | class EE_Event_Author_Shortcodes extends EE_Shortcodes |
21 | 21 | { |
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - parent::__construct(); |
|
26 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - protected function _init_props() |
|
30 | - { |
|
31 | - $this->label = __('Event Author Details Shortcodes', 'event_espresso'); |
|
32 | - $this->description = __('All shortcodes specific to event_author data', 'event_espresso'); |
|
33 | - $this->_shortcodes = array( |
|
34 | - '[EVENT_AUTHOR_FNAME]' => __('Parses to the first name of the event author.', 'event_espresso'), |
|
35 | - '[EVENT_AUTHOR_LNAME]' => __('Parses to the last name of the event author.', 'event_espresso'), |
|
36 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => __( |
|
37 | - 'Parses to a formatted email address of the event author (fname lname <[email protected]>). <strong>NOTE:</strong> If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - '[EVENT_AUTHOR_EMAIL]' => __( |
|
41 | - 'Parses to the unformatted email address of the event author', |
|
42 | - 'event_espresso' |
|
43 | - ), |
|
44 | - ); |
|
45 | - } |
|
29 | + protected function _init_props() |
|
30 | + { |
|
31 | + $this->label = __('Event Author Details Shortcodes', 'event_espresso'); |
|
32 | + $this->description = __('All shortcodes specific to event_author data', 'event_espresso'); |
|
33 | + $this->_shortcodes = array( |
|
34 | + '[EVENT_AUTHOR_FNAME]' => __('Parses to the first name of the event author.', 'event_espresso'), |
|
35 | + '[EVENT_AUTHOR_LNAME]' => __('Parses to the last name of the event author.', 'event_espresso'), |
|
36 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => __( |
|
37 | + 'Parses to a formatted email address of the event author (fname lname <[email protected]>). <strong>NOTE:</strong> If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + '[EVENT_AUTHOR_EMAIL]' => __( |
|
41 | + 'Parses to the unformatted email address of the event author', |
|
42 | + 'event_espresso' |
|
43 | + ), |
|
44 | + ); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - protected function _parser($shortcode) |
|
49 | - { |
|
50 | - // make sure we end up with a copy of the EE_Messages_Addressee object |
|
51 | - $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
52 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
53 | - $this->_data |
|
54 | - ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
55 | - : $recipient; |
|
56 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
57 | - ? $this->_extra_data['data'] : $recipient; |
|
48 | + protected function _parser($shortcode) |
|
49 | + { |
|
50 | + // make sure we end up with a copy of the EE_Messages_Addressee object |
|
51 | + $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
52 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
53 | + $this->_data |
|
54 | + ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
55 | + : $recipient; |
|
56 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
57 | + ? $this->_extra_data['data'] : $recipient; |
|
58 | 58 | |
59 | - // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
|
60 | - $event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
59 | + // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
|
60 | + $event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
61 | 61 | |
62 | - if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
63 | - return ''; |
|
64 | - } |
|
62 | + if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
63 | + return ''; |
|
64 | + } |
|
65 | 65 | |
66 | - switch ($shortcode) { |
|
67 | - case '[EVENT_AUTHOR_FNAME]': |
|
68 | - $fname = ! empty($recipient) ? $recipient->fname : null; |
|
69 | - if (empty($fname) && ! empty($event)) { |
|
70 | - $user = $this->_get_author_for_event($event); |
|
71 | - $fname = $user->first_name; |
|
72 | - } |
|
73 | - return $fname; |
|
74 | - break; |
|
66 | + switch ($shortcode) { |
|
67 | + case '[EVENT_AUTHOR_FNAME]': |
|
68 | + $fname = ! empty($recipient) ? $recipient->fname : null; |
|
69 | + if (empty($fname) && ! empty($event)) { |
|
70 | + $user = $this->_get_author_for_event($event); |
|
71 | + $fname = $user->first_name; |
|
72 | + } |
|
73 | + return $fname; |
|
74 | + break; |
|
75 | 75 | |
76 | - case '[EVENT_AUTHOR_LNAME]': |
|
77 | - $lname = ! empty($recipient) ? $recipient->lname : null; |
|
78 | - if (empty($lname) && ! empty($event)) { |
|
79 | - $user = $this->_get_author_for_event($event); |
|
80 | - $lname = $user->last_name; |
|
81 | - } |
|
82 | - return $lname; |
|
83 | - break; |
|
76 | + case '[EVENT_AUTHOR_LNAME]': |
|
77 | + $lname = ! empty($recipient) ? $recipient->lname : null; |
|
78 | + if (empty($lname) && ! empty($event)) { |
|
79 | + $user = $this->_get_author_for_event($event); |
|
80 | + $lname = $user->last_name; |
|
81 | + } |
|
82 | + return $lname; |
|
83 | + break; |
|
84 | 84 | |
85 | - case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
86 | - if (! empty($recipient)) { |
|
87 | - $email = ! empty($recipient->fname) |
|
88 | - ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
89 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
90 | - 'name' |
|
91 | - ) . '<' . $recipient->admin_email . '>'; |
|
92 | - } else { |
|
93 | - $email = null; |
|
94 | - } |
|
95 | - if (empty($email) && ! empty($event)) { |
|
96 | - $user = $this->_get_author_for_event($event); |
|
97 | - $email = ! empty($user->first_name) |
|
98 | - ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
99 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
100 | - 'name' |
|
101 | - ) . '<' . $user->user_email . '>'; |
|
102 | - } |
|
103 | - return $email; |
|
104 | - break; |
|
85 | + case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
86 | + if (! empty($recipient)) { |
|
87 | + $email = ! empty($recipient->fname) |
|
88 | + ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
89 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
90 | + 'name' |
|
91 | + ) . '<' . $recipient->admin_email . '>'; |
|
92 | + } else { |
|
93 | + $email = null; |
|
94 | + } |
|
95 | + if (empty($email) && ! empty($event)) { |
|
96 | + $user = $this->_get_author_for_event($event); |
|
97 | + $email = ! empty($user->first_name) |
|
98 | + ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
99 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
100 | + 'name' |
|
101 | + ) . '<' . $user->user_email . '>'; |
|
102 | + } |
|
103 | + return $email; |
|
104 | + break; |
|
105 | 105 | |
106 | - case '[EVENT_AUTHOR_EMAIL]': |
|
107 | - $email = ! empty($recipient) ? $recipient->admin_email : null; |
|
108 | - if (empty($email) && ! empty($event)) { |
|
109 | - $user = $this->_get_author_for_event($event); |
|
110 | - $email = $user->user_email; |
|
111 | - } |
|
112 | - return $email; |
|
113 | - break; |
|
106 | + case '[EVENT_AUTHOR_EMAIL]': |
|
107 | + $email = ! empty($recipient) ? $recipient->admin_email : null; |
|
108 | + if (empty($email) && ! empty($event)) { |
|
109 | + $user = $this->_get_author_for_event($event); |
|
110 | + $email = $user->user_email; |
|
111 | + } |
|
112 | + return $email; |
|
113 | + break; |
|
114 | 114 | |
115 | - default: |
|
116 | - return ''; |
|
117 | - break; |
|
118 | - } |
|
119 | - } |
|
115 | + default: |
|
116 | + return ''; |
|
117 | + break; |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | |
122 | - /** |
|
123 | - * Helper method to return the user object for the author of the given EE_Event |
|
124 | - * |
|
125 | - * @param EE_Event $event |
|
126 | - * |
|
127 | - * @return WP_User |
|
128 | - */ |
|
129 | - private function _get_author_for_event(EE_Event $event) |
|
130 | - { |
|
131 | - $author_id = $event->wp_user(); |
|
132 | - $user_data = get_userdata((int) $author_id); |
|
133 | - return $user_data; |
|
134 | - } |
|
122 | + /** |
|
123 | + * Helper method to return the user object for the author of the given EE_Event |
|
124 | + * |
|
125 | + * @param EE_Event $event |
|
126 | + * |
|
127 | + * @return WP_User |
|
128 | + */ |
|
129 | + private function _get_author_for_event(EE_Event $event) |
|
130 | + { |
|
131 | + $author_id = $event->wp_user(); |
|
132 | + $user_data = get_userdata((int) $author_id); |
|
133 | + return $user_data; |
|
134 | + } |
|
135 | 135 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
60 | 60 | $event = $this->_data instanceof EE_Event ? $this->_data : null; |
61 | 61 | |
62 | - if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
62 | + if ( ! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
63 | 63 | return ''; |
64 | 64 | } |
65 | 65 | |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | break; |
84 | 84 | |
85 | 85 | case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
86 | - if (! empty($recipient)) { |
|
86 | + if ( ! empty($recipient)) { |
|
87 | 87 | $email = ! empty($recipient->fname) |
88 | - ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
88 | + ? $recipient->fname.' '.$recipient->lname.'<'.$recipient->admin_email.'>' |
|
89 | 89 | : EE_Registry::instance()->CFG->organization->get_pretty( |
90 | 90 | 'name' |
91 | - ) . '<' . $recipient->admin_email . '>'; |
|
91 | + ).'<'.$recipient->admin_email.'>'; |
|
92 | 92 | } else { |
93 | 93 | $email = null; |
94 | 94 | } |
95 | 95 | if (empty($email) && ! empty($event)) { |
96 | 96 | $user = $this->_get_author_for_event($event); |
97 | 97 | $email = ! empty($user->first_name) |
98 | - ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
98 | + ? $user->first_name.' '.$user->last_name.'<'.$user->user_email.'>' |
|
99 | 99 | : EE_Registry::instance()->CFG->organization->get_pretty( |
100 | 100 | 'name' |
101 | - ) . '<' . $user->user_email . '>'; |
|
101 | + ).'<'.$user->user_email.'>'; |
|
102 | 102 | } |
103 | 103 | return $email; |
104 | 104 | break; |
@@ -20,88 +20,88 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - protected function _init_props() |
|
24 | - { |
|
25 | - $this->label = __('Payment List Shortcodes', 'event_espresso'); |
|
26 | - $this->description = __('All shortcodes specific to payment lists', 'event_espresso'); |
|
27 | - $this->_shortcodes = array( |
|
28 | - '[PAYMENT_LIST_*]' => __( |
|
29 | - 'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults. Attributes that are available are:', |
|
30 | - 'event_espresso' |
|
31 | - ) |
|
32 | - . '<p><ul>' . |
|
33 | - '<li><strong>no_payments</strong>:' . sprintf( |
|
34 | - __( |
|
35 | - 'Indicate with this attribute what will be used if there are no payments present. Default is: "%sNo approved payments have been received.%s"', |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - htmlspecialchars('<td class="aln-cntr" colspan="6">'), |
|
39 | - htmlspecialchars('</td>') |
|
40 | - ) . '</li>' . |
|
41 | - '</ul></p>', |
|
42 | - ); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - protected function _parser($shortcode) |
|
47 | - { |
|
48 | - |
|
49 | - if (strpos($shortcode, '[PAYMENT_LIST_*') !== false) { |
|
50 | - return $this->_get_payment_list($shortcode); |
|
51 | - } |
|
52 | - return ''; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * verify incoming data contains what is needed for retrieving and parsing each payment for transaction. |
|
58 | - * |
|
59 | - * @since 4.5.0 |
|
60 | - * |
|
61 | - * @param string $shortcode The incoming shortcode. |
|
62 | - * |
|
63 | - * @return string parsed ticket line item list. |
|
64 | - */ |
|
65 | - private function _get_payment_list($shortcode) |
|
66 | - { |
|
67 | - $this->_validate_list_requirements(); |
|
68 | - |
|
69 | - |
|
70 | - if (! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | - return ''; |
|
72 | - } |
|
73 | - |
|
74 | - $valid_shortcodes = array('payment'); |
|
75 | - |
|
76 | - $addressee_obj = $this->_data['data']; |
|
77 | - $templates = $this->_extra_data['template']; |
|
78 | - $payments = apply_filters( |
|
79 | - 'FHEE__Payment_List_Shortcodes___get_payments_list__payments', |
|
80 | - $addressee_obj->payments |
|
81 | - ); |
|
82 | - |
|
83 | - // let's get any attributes that may be present and set the defaults. |
|
84 | - $atts = $this->_get_shortcode_attrs($shortcode); |
|
85 | - |
|
86 | - $no_payments_msg = empty($atts['no_payments']) ? __( |
|
87 | - 'No approved payments have been received.', |
|
88 | - 'event_espresso' |
|
89 | - ) : $atts['no_payments']; |
|
90 | - |
|
91 | - // made it here so we have an array of paymnets, so we should have what we need. |
|
92 | - $payment_content = empty($payments) ? $no_payments_msg : ''; |
|
93 | - |
|
94 | - $payments = (array) $payments; |
|
95 | - |
|
96 | - foreach ($payments as $payment) { |
|
97 | - $payment_content .= $this->_shortcode_helper->parse_payment_list_template( |
|
98 | - $templates['payment_list'], |
|
99 | - $payment, |
|
100 | - $valid_shortcodes, |
|
101 | - $this->_extra_data |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - return $payment_content; |
|
106 | - } |
|
23 | + protected function _init_props() |
|
24 | + { |
|
25 | + $this->label = __('Payment List Shortcodes', 'event_espresso'); |
|
26 | + $this->description = __('All shortcodes specific to payment lists', 'event_espresso'); |
|
27 | + $this->_shortcodes = array( |
|
28 | + '[PAYMENT_LIST_*]' => __( |
|
29 | + 'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults. Attributes that are available are:', |
|
30 | + 'event_espresso' |
|
31 | + ) |
|
32 | + . '<p><ul>' . |
|
33 | + '<li><strong>no_payments</strong>:' . sprintf( |
|
34 | + __( |
|
35 | + 'Indicate with this attribute what will be used if there are no payments present. Default is: "%sNo approved payments have been received.%s"', |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + htmlspecialchars('<td class="aln-cntr" colspan="6">'), |
|
39 | + htmlspecialchars('</td>') |
|
40 | + ) . '</li>' . |
|
41 | + '</ul></p>', |
|
42 | + ); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + protected function _parser($shortcode) |
|
47 | + { |
|
48 | + |
|
49 | + if (strpos($shortcode, '[PAYMENT_LIST_*') !== false) { |
|
50 | + return $this->_get_payment_list($shortcode); |
|
51 | + } |
|
52 | + return ''; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * verify incoming data contains what is needed for retrieving and parsing each payment for transaction. |
|
58 | + * |
|
59 | + * @since 4.5.0 |
|
60 | + * |
|
61 | + * @param string $shortcode The incoming shortcode. |
|
62 | + * |
|
63 | + * @return string parsed ticket line item list. |
|
64 | + */ |
|
65 | + private function _get_payment_list($shortcode) |
|
66 | + { |
|
67 | + $this->_validate_list_requirements(); |
|
68 | + |
|
69 | + |
|
70 | + if (! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | + return ''; |
|
72 | + } |
|
73 | + |
|
74 | + $valid_shortcodes = array('payment'); |
|
75 | + |
|
76 | + $addressee_obj = $this->_data['data']; |
|
77 | + $templates = $this->_extra_data['template']; |
|
78 | + $payments = apply_filters( |
|
79 | + 'FHEE__Payment_List_Shortcodes___get_payments_list__payments', |
|
80 | + $addressee_obj->payments |
|
81 | + ); |
|
82 | + |
|
83 | + // let's get any attributes that may be present and set the defaults. |
|
84 | + $atts = $this->_get_shortcode_attrs($shortcode); |
|
85 | + |
|
86 | + $no_payments_msg = empty($atts['no_payments']) ? __( |
|
87 | + 'No approved payments have been received.', |
|
88 | + 'event_espresso' |
|
89 | + ) : $atts['no_payments']; |
|
90 | + |
|
91 | + // made it here so we have an array of paymnets, so we should have what we need. |
|
92 | + $payment_content = empty($payments) ? $no_payments_msg : ''; |
|
93 | + |
|
94 | + $payments = (array) $payments; |
|
95 | + |
|
96 | + foreach ($payments as $payment) { |
|
97 | + $payment_content .= $this->_shortcode_helper->parse_payment_list_template( |
|
98 | + $templates['payment_list'], |
|
99 | + $payment, |
|
100 | + $valid_shortcodes, |
|
101 | + $this->_extra_data |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + return $payment_content; |
|
106 | + } |
|
107 | 107 | } |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | 'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults. Attributes that are available are:', |
30 | 30 | 'event_espresso' |
31 | 31 | ) |
32 | - . '<p><ul>' . |
|
33 | - '<li><strong>no_payments</strong>:' . sprintf( |
|
32 | + . '<p><ul>'. |
|
33 | + '<li><strong>no_payments</strong>:'.sprintf( |
|
34 | 34 | __( |
35 | 35 | 'Indicate with this attribute what will be used if there are no payments present. Default is: "%sNo approved payments have been received.%s"', |
36 | 36 | 'event_espresso' |
37 | 37 | ), |
38 | 38 | htmlspecialchars('<td class="aln-cntr" colspan="6">'), |
39 | 39 | htmlspecialchars('</td>') |
40 | - ) . '</li>' . |
|
40 | + ).'</li>'. |
|
41 | 41 | '</ul></p>', |
42 | 42 | ); |
43 | 43 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->_validate_list_requirements(); |
68 | 68 | |
69 | 69 | |
70 | - if (! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
70 | + if ( ! $this->_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | 71 | return ''; |
72 | 72 | } |
73 | 73 |
@@ -18,208 +18,208 @@ |
||
18 | 18 | class EE_Attendee_Shortcodes extends EE_Shortcodes |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * hold all extra data. |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected $_xtra; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * EE_Attendee_Shortcodes constructor. |
|
31 | - */ |
|
32 | - public function __construct() |
|
33 | - { |
|
34 | - parent::__construct(); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - protected function _init_props() |
|
39 | - { |
|
40 | - $this->label = esc_html__('Attendee Shortcodes', 'event_espresso'); |
|
41 | - $this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso'); |
|
42 | - $this->_shortcodes = array( |
|
43 | - '[FNAME]' => esc_html__('First Name of an attendee.', 'event_espresso'), |
|
44 | - '[LNAME]' => esc_html__('Last Name of an attendee.', 'event_espresso'), |
|
45 | - '[ATTENDEE_EMAIL]' => esc_html__('Email address for the attendee.', 'event_espresso'), |
|
46 | - '[EDIT_ATTENDEE_LINK]' => esc_html__( |
|
47 | - 'Edit Registration Link (typically you\'d only use this for messages going to event administrators)', |
|
48 | - 'event_espresso' |
|
49 | - ), |
|
50 | - '[REGISTRATION_ID]' => esc_html__( |
|
51 | - 'Unique Registration ID for the registration', |
|
52 | - 'event_espresso' |
|
53 | - ), |
|
54 | - '[REGISTRATION_CODE]' => esc_html__( |
|
55 | - 'Unique Registration Code for the registration', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - '[REGISTRATION_STATUS_ID]' => esc_html__( |
|
59 | - 'Parses to the registration status for the attendee', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - '[REGISTRATION_STATUS_LABEL]' => esc_html__( |
|
63 | - 'Parses to the status label for the registrant', |
|
64 | - 'event_espresso' |
|
65 | - ), |
|
66 | - '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__( |
|
67 | - 'Parses to the total amount paid for this registration.', |
|
68 | - 'event_espresso' |
|
69 | - ), |
|
70 | - '[FRONTEND_EDIT_REG_LINK]' => esc_html__( |
|
71 | - 'Generates a link for the given registration to edit this registration details on the frontend.', |
|
72 | - 'event_espresso' |
|
73 | - ), |
|
74 | - '[PHONE_NUMBER]' => esc_html__( |
|
75 | - 'The Phone Number for the Registration.', |
|
76 | - 'event_espresso' |
|
77 | - ), |
|
78 | - '[ADDRESS]' => esc_html__('The Address for the Registration', 'event_espresso'), |
|
79 | - '[ADDRESS2]' => esc_html__( |
|
80 | - 'Whatever was in the address 2 field for the registration.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - '[CITY]' => esc_html__('The city for the registration.', 'event_espresso'), |
|
84 | - '[ZIP_PC]' => esc_html__( |
|
85 | - 'The ZIP (or Postal) Code for the Registration.', |
|
86 | - 'event_espresso' |
|
87 | - ), |
|
88 | - '[ADDRESS_STATE]' => esc_html__( |
|
89 | - 'The state/province for the registration.', |
|
90 | - 'event_espresso' |
|
91 | - ), |
|
92 | - '[COUNTRY]' => esc_html__('The country for the registration.', 'event_espresso'), |
|
93 | - ); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * handles shortcode parsing |
|
99 | - * |
|
100 | - * @access protected |
|
101 | - * @param string $shortcode the shortcode to be parsed. |
|
102 | - * @return string |
|
103 | - * @throws \EE_Error |
|
104 | - */ |
|
105 | - protected function _parser($shortcode) |
|
106 | - { |
|
107 | - |
|
108 | - |
|
109 | - $this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
110 | - ? $this->_extra_data['data'] |
|
111 | - : null; |
|
112 | - |
|
113 | - // incoming object should only be a registration object. |
|
114 | - $registration = ! $this->_data instanceof EE_Registration |
|
115 | - ? null |
|
116 | - : $this->_data; |
|
117 | - |
|
118 | - if (! $registration instanceof EE_Registration) { |
|
119 | - // let's attempt to get the txn_id for the error message. |
|
120 | - $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction |
|
121 | - ? $this->_xtra->txn->ID() |
|
122 | - : esc_html__('Unknown', 'event_espresso'); |
|
123 | - $msg = esc_html__( |
|
124 | - 'There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
|
125 | - 'event_espresso' |
|
126 | - ); |
|
127 | - $dev_msg = sprintf( |
|
128 | - esc_html__('The transaction ID for this request is: %s', 'event_espresso'), |
|
129 | - $txn_id |
|
130 | - ); |
|
131 | - throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
132 | - } |
|
133 | - |
|
134 | - // attendee obj for this registration |
|
135 | - $attendee = isset($this->_xtra->registrations[ $registration->ID() ]['att_obj']) |
|
136 | - ? $this->_xtra->registrations[ $registration->ID() ]['att_obj'] |
|
137 | - : null; |
|
138 | - |
|
139 | - if (! $attendee instanceof EE_Attendee) { |
|
140 | - $msg = esc_html__( |
|
141 | - 'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
|
142 | - 'event_espresso' |
|
143 | - ); |
|
144 | - $dev_msg = sprintf( |
|
145 | - esc_html__('The registration ID for this request is: %s', 'event_espresso'), |
|
146 | - $registration->ID() |
|
147 | - ); |
|
148 | - throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
149 | - } |
|
150 | - |
|
151 | - switch ($shortcode) { |
|
152 | - case '[FNAME]': |
|
153 | - return $attendee->fname(); |
|
154 | - break; |
|
155 | - |
|
156 | - case '[LNAME]': |
|
157 | - return $attendee->lname(); |
|
158 | - break; |
|
159 | - |
|
160 | - case '[ATTENDEE_EMAIL]': |
|
161 | - return $attendee->email(); |
|
162 | - break; |
|
163 | - |
|
164 | - case '[EDIT_ATTENDEE_LINK]': |
|
165 | - return $registration->get_admin_edit_url(); |
|
166 | - break; |
|
167 | - |
|
168 | - case '[REGISTRATION_CODE]': |
|
169 | - return $registration->reg_code(); |
|
170 | - break; |
|
171 | - |
|
172 | - case '[REGISTRATION_ID]': |
|
173 | - return $registration->ID(); |
|
174 | - break; |
|
175 | - |
|
176 | - case '[FRONTEND_EDIT_REG_LINK]': |
|
177 | - return $registration->edit_attendee_information_url(); |
|
178 | - break; |
|
179 | - |
|
180 | - case '[PHONE_NUMBER]': |
|
181 | - return $attendee->phone(); |
|
182 | - break; |
|
183 | - |
|
184 | - case '[ADDRESS]': |
|
185 | - return $attendee->address(); |
|
186 | - break; |
|
187 | - |
|
188 | - case '[ADDRESS2]': |
|
189 | - return $attendee->address2(); |
|
190 | - break; |
|
191 | - |
|
192 | - case '[CITY]': |
|
193 | - return $attendee->city(); |
|
194 | - break; |
|
195 | - |
|
196 | - case '[ZIP_PC]': |
|
197 | - return $attendee->zip(); |
|
198 | - break; |
|
199 | - |
|
200 | - case '[ADDRESS_STATE]': |
|
201 | - $state_obj = $attendee->state_obj(); |
|
202 | - return $state_obj instanceof EE_State ? $state_obj->name() : ''; |
|
203 | - break; |
|
204 | - |
|
205 | - case '[COUNTRY]': |
|
206 | - $country_obj = $attendee->country_obj(); |
|
207 | - return $country_obj instanceof EE_Country ? $country_obj->name() : ''; |
|
208 | - break; |
|
209 | - |
|
210 | - case '[REGISTRATION_STATUS_ID]': |
|
211 | - return $registration->status_ID(); |
|
212 | - break; |
|
213 | - |
|
214 | - case '[REGISTRATION_STATUS_LABEL]': |
|
215 | - return $registration->pretty_status(); |
|
216 | - break; |
|
217 | - |
|
218 | - case '[REGISTRATION_TOTAL_AMOUNT_PAID]': |
|
219 | - return $registration->pretty_paid(); |
|
220 | - break; |
|
221 | - } |
|
222 | - |
|
223 | - return ''; |
|
224 | - } |
|
21 | + /** |
|
22 | + * hold all extra data. |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected $_xtra; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * EE_Attendee_Shortcodes constructor. |
|
31 | + */ |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + parent::__construct(); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + protected function _init_props() |
|
39 | + { |
|
40 | + $this->label = esc_html__('Attendee Shortcodes', 'event_espresso'); |
|
41 | + $this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso'); |
|
42 | + $this->_shortcodes = array( |
|
43 | + '[FNAME]' => esc_html__('First Name of an attendee.', 'event_espresso'), |
|
44 | + '[LNAME]' => esc_html__('Last Name of an attendee.', 'event_espresso'), |
|
45 | + '[ATTENDEE_EMAIL]' => esc_html__('Email address for the attendee.', 'event_espresso'), |
|
46 | + '[EDIT_ATTENDEE_LINK]' => esc_html__( |
|
47 | + 'Edit Registration Link (typically you\'d only use this for messages going to event administrators)', |
|
48 | + 'event_espresso' |
|
49 | + ), |
|
50 | + '[REGISTRATION_ID]' => esc_html__( |
|
51 | + 'Unique Registration ID for the registration', |
|
52 | + 'event_espresso' |
|
53 | + ), |
|
54 | + '[REGISTRATION_CODE]' => esc_html__( |
|
55 | + 'Unique Registration Code for the registration', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + '[REGISTRATION_STATUS_ID]' => esc_html__( |
|
59 | + 'Parses to the registration status for the attendee', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + '[REGISTRATION_STATUS_LABEL]' => esc_html__( |
|
63 | + 'Parses to the status label for the registrant', |
|
64 | + 'event_espresso' |
|
65 | + ), |
|
66 | + '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__( |
|
67 | + 'Parses to the total amount paid for this registration.', |
|
68 | + 'event_espresso' |
|
69 | + ), |
|
70 | + '[FRONTEND_EDIT_REG_LINK]' => esc_html__( |
|
71 | + 'Generates a link for the given registration to edit this registration details on the frontend.', |
|
72 | + 'event_espresso' |
|
73 | + ), |
|
74 | + '[PHONE_NUMBER]' => esc_html__( |
|
75 | + 'The Phone Number for the Registration.', |
|
76 | + 'event_espresso' |
|
77 | + ), |
|
78 | + '[ADDRESS]' => esc_html__('The Address for the Registration', 'event_espresso'), |
|
79 | + '[ADDRESS2]' => esc_html__( |
|
80 | + 'Whatever was in the address 2 field for the registration.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + '[CITY]' => esc_html__('The city for the registration.', 'event_espresso'), |
|
84 | + '[ZIP_PC]' => esc_html__( |
|
85 | + 'The ZIP (or Postal) Code for the Registration.', |
|
86 | + 'event_espresso' |
|
87 | + ), |
|
88 | + '[ADDRESS_STATE]' => esc_html__( |
|
89 | + 'The state/province for the registration.', |
|
90 | + 'event_espresso' |
|
91 | + ), |
|
92 | + '[COUNTRY]' => esc_html__('The country for the registration.', 'event_espresso'), |
|
93 | + ); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * handles shortcode parsing |
|
99 | + * |
|
100 | + * @access protected |
|
101 | + * @param string $shortcode the shortcode to be parsed. |
|
102 | + * @return string |
|
103 | + * @throws \EE_Error |
|
104 | + */ |
|
105 | + protected function _parser($shortcode) |
|
106 | + { |
|
107 | + |
|
108 | + |
|
109 | + $this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
110 | + ? $this->_extra_data['data'] |
|
111 | + : null; |
|
112 | + |
|
113 | + // incoming object should only be a registration object. |
|
114 | + $registration = ! $this->_data instanceof EE_Registration |
|
115 | + ? null |
|
116 | + : $this->_data; |
|
117 | + |
|
118 | + if (! $registration instanceof EE_Registration) { |
|
119 | + // let's attempt to get the txn_id for the error message. |
|
120 | + $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction |
|
121 | + ? $this->_xtra->txn->ID() |
|
122 | + : esc_html__('Unknown', 'event_espresso'); |
|
123 | + $msg = esc_html__( |
|
124 | + 'There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', |
|
125 | + 'event_espresso' |
|
126 | + ); |
|
127 | + $dev_msg = sprintf( |
|
128 | + esc_html__('The transaction ID for this request is: %s', 'event_espresso'), |
|
129 | + $txn_id |
|
130 | + ); |
|
131 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
132 | + } |
|
133 | + |
|
134 | + // attendee obj for this registration |
|
135 | + $attendee = isset($this->_xtra->registrations[ $registration->ID() ]['att_obj']) |
|
136 | + ? $this->_xtra->registrations[ $registration->ID() ]['att_obj'] |
|
137 | + : null; |
|
138 | + |
|
139 | + if (! $attendee instanceof EE_Attendee) { |
|
140 | + $msg = esc_html__( |
|
141 | + 'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
|
142 | + 'event_espresso' |
|
143 | + ); |
|
144 | + $dev_msg = sprintf( |
|
145 | + esc_html__('The registration ID for this request is: %s', 'event_espresso'), |
|
146 | + $registration->ID() |
|
147 | + ); |
|
148 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
149 | + } |
|
150 | + |
|
151 | + switch ($shortcode) { |
|
152 | + case '[FNAME]': |
|
153 | + return $attendee->fname(); |
|
154 | + break; |
|
155 | + |
|
156 | + case '[LNAME]': |
|
157 | + return $attendee->lname(); |
|
158 | + break; |
|
159 | + |
|
160 | + case '[ATTENDEE_EMAIL]': |
|
161 | + return $attendee->email(); |
|
162 | + break; |
|
163 | + |
|
164 | + case '[EDIT_ATTENDEE_LINK]': |
|
165 | + return $registration->get_admin_edit_url(); |
|
166 | + break; |
|
167 | + |
|
168 | + case '[REGISTRATION_CODE]': |
|
169 | + return $registration->reg_code(); |
|
170 | + break; |
|
171 | + |
|
172 | + case '[REGISTRATION_ID]': |
|
173 | + return $registration->ID(); |
|
174 | + break; |
|
175 | + |
|
176 | + case '[FRONTEND_EDIT_REG_LINK]': |
|
177 | + return $registration->edit_attendee_information_url(); |
|
178 | + break; |
|
179 | + |
|
180 | + case '[PHONE_NUMBER]': |
|
181 | + return $attendee->phone(); |
|
182 | + break; |
|
183 | + |
|
184 | + case '[ADDRESS]': |
|
185 | + return $attendee->address(); |
|
186 | + break; |
|
187 | + |
|
188 | + case '[ADDRESS2]': |
|
189 | + return $attendee->address2(); |
|
190 | + break; |
|
191 | + |
|
192 | + case '[CITY]': |
|
193 | + return $attendee->city(); |
|
194 | + break; |
|
195 | + |
|
196 | + case '[ZIP_PC]': |
|
197 | + return $attendee->zip(); |
|
198 | + break; |
|
199 | + |
|
200 | + case '[ADDRESS_STATE]': |
|
201 | + $state_obj = $attendee->state_obj(); |
|
202 | + return $state_obj instanceof EE_State ? $state_obj->name() : ''; |
|
203 | + break; |
|
204 | + |
|
205 | + case '[COUNTRY]': |
|
206 | + $country_obj = $attendee->country_obj(); |
|
207 | + return $country_obj instanceof EE_Country ? $country_obj->name() : ''; |
|
208 | + break; |
|
209 | + |
|
210 | + case '[REGISTRATION_STATUS_ID]': |
|
211 | + return $registration->status_ID(); |
|
212 | + break; |
|
213 | + |
|
214 | + case '[REGISTRATION_STATUS_LABEL]': |
|
215 | + return $registration->pretty_status(); |
|
216 | + break; |
|
217 | + |
|
218 | + case '[REGISTRATION_TOTAL_AMOUNT_PAID]': |
|
219 | + return $registration->pretty_paid(); |
|
220 | + break; |
|
221 | + } |
|
222 | + |
|
223 | + return ''; |
|
224 | + } |
|
225 | 225 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | ? null |
116 | 116 | : $this->_data; |
117 | 117 | |
118 | - if (! $registration instanceof EE_Registration) { |
|
118 | + if ( ! $registration instanceof EE_Registration) { |
|
119 | 119 | // let's attempt to get the txn_id for the error message. |
120 | 120 | $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction |
121 | 121 | ? $this->_xtra->txn->ID() |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | // attendee obj for this registration |
135 | - $attendee = isset($this->_xtra->registrations[ $registration->ID() ]['att_obj']) |
|
136 | - ? $this->_xtra->registrations[ $registration->ID() ]['att_obj'] |
|
135 | + $attendee = isset($this->_xtra->registrations[$registration->ID()]['att_obj']) |
|
136 | + ? $this->_xtra->registrations[$registration->ID()]['att_obj'] |
|
137 | 137 | : null; |
138 | 138 | |
139 | - if (! $attendee instanceof EE_Attendee) { |
|
139 | + if ( ! $attendee instanceof EE_Attendee) { |
|
140 | 140 | $msg = esc_html__( |
141 | 141 | 'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', |
142 | 142 | 'event_espresso' |
@@ -19,167 +19,167 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - public function __construct() |
|
23 | - { |
|
24 | - parent::__construct(); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - protected function _init_props() |
|
29 | - { |
|
30 | - $this->label = esc_html__('Email Shortcodes', 'event_espresso'); |
|
31 | - $this->description = esc_html__('All shortcodes related to emails', 'event_espresso'); |
|
32 | - $this->_shortcodes = array( |
|
33 | - '[SITE_ADMIN_EMAIL]' => esc_html__( |
|
34 | - 'Will be replaced with the admin email for the site that Event Espresso is installed on', |
|
35 | - 'event_espresso' |
|
36 | - ), |
|
37 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf( |
|
38 | - esc_html__( |
|
39 | - 'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
40 | - 'event_espresso' |
|
41 | - ), |
|
42 | - '<strong>', |
|
43 | - '</strong>' |
|
44 | - ), |
|
45 | - '[EVENT_AUTHOR_EMAIL]' => sprintf( |
|
46 | - esc_html__( |
|
47 | - 'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', |
|
48 | - 'event_espresso' |
|
49 | - ), |
|
50 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' |
|
51 | - ), |
|
52 | - '[CO_FORMATTED_EMAIL]' => esc_html__( |
|
53 | - 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
54 | - 'event_espresso' |
|
55 | - ), |
|
56 | - '[CO_EMAIL]' => esc_html__( |
|
57 | - 'This will parse to the email address only for the organization set in Your Organization Settings.', |
|
58 | - 'event_espresso' |
|
59 | - ), |
|
60 | - '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__( |
|
61 | - 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
62 | - 'event_espresso' |
|
63 | - ), |
|
64 | - '[ESPRESSO_ADMIN_EMAIL]' => esc_html__( |
|
65 | - 'This parses to the email address only for the organization set in Your Organization Settings page.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - protected function _parser($shortcode) |
|
73 | - { |
|
74 | - |
|
75 | - switch ($shortcode) { |
|
76 | - case '[SITE_ADMIN_EMAIL]': |
|
77 | - return $this->_get_site_admin_email(); |
|
78 | - break; |
|
79 | - |
|
80 | - case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
81 | - return $this->_get_event_admin_emails(); |
|
82 | - break; |
|
83 | - |
|
84 | - case '[EVENT_AUTHOR_EMAIL]': |
|
85 | - return $this->_get_event_admin_emails(false); |
|
86 | - break; |
|
87 | - |
|
88 | - case '[CO_FORMATTED_EMAIL]': |
|
89 | - case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
|
90 | - return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
91 | - . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
92 | - break; |
|
93 | - |
|
94 | - case '[CO_EMAIL]': |
|
95 | - case '[ESPRESSO_ADMIN_EMAIL]': |
|
96 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
97 | - break; |
|
98 | - |
|
99 | - default: |
|
100 | - return ''; |
|
101 | - break; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode) |
|
108 | - * |
|
109 | - * @access private |
|
110 | - * @return string email address of site admin |
|
111 | - */ |
|
112 | - private function _get_site_admin_email() |
|
113 | - { |
|
114 | - return get_bloginfo('admin_email'); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - private function _get_event_admin_emails($fancy_headers = true) |
|
119 | - { |
|
120 | - |
|
121 | - if (! empty($this->_data->admin_email)) { |
|
122 | - if (! $fancy_headers) { |
|
123 | - return $this->_data->admin_email; |
|
124 | - } |
|
125 | - return ! empty($this->_data->fname) |
|
126 | - ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
127 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
128 | - 'name' |
|
129 | - ) . ' <' . $this->_data->admin_email . '>'; |
|
130 | - } |
|
131 | - |
|
132 | - // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
|
133 | - |
|
134 | - $admin_email = array(); |
|
135 | - |
|
136 | - // loop through events and set the list of event_ids to retrieve so we can do ONE query. |
|
137 | - foreach ($this->_data->events as $event) { |
|
138 | - $ids[] = $event['ID']; |
|
139 | - } |
|
140 | - |
|
141 | - // get all the events |
|
142 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
143 | - |
|
144 | - // now loop through each event and setup the details |
|
145 | - $admin_details = array(); |
|
146 | - $cnt = 0; |
|
147 | - foreach ($events as $event) { |
|
148 | - $user = get_userdata($event->get('EVT_wp_user')); |
|
149 | - $admin_details[ $cnt ] = new stdClass(); |
|
150 | - $admin_details[ $cnt ]->email = $user->user_email; |
|
151 | - $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
152 | - $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
153 | - $cnt++; |
|
154 | - } |
|
155 | - |
|
156 | - // results? |
|
157 | - if (empty($admin_details) || ! is_array($admin_details)) { |
|
158 | - $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso'); |
|
159 | - $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql); |
|
160 | - $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true)); |
|
161 | - $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true)); |
|
162 | - $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
163 | - do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
164 | - } |
|
165 | - |
|
166 | - foreach ($admin_details as $admin) { |
|
167 | - // only add an admin email if it is present. |
|
168 | - if (empty($admin->email) || $admin->email == '') { |
|
169 | - continue; |
|
170 | - } |
|
171 | - |
|
172 | - if (! $fancy_headers) { |
|
173 | - $admin_email[] = $admin->email; |
|
174 | - continue; |
|
175 | - } |
|
176 | - |
|
177 | - $admin_email[] = ! empty($admin->first_name) |
|
178 | - ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
179 | - : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
180 | - } |
|
181 | - |
|
182 | - $admin_email = implode(',', $admin_email); |
|
183 | - return $admin_email; |
|
184 | - } |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + parent::__construct(); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + protected function _init_props() |
|
29 | + { |
|
30 | + $this->label = esc_html__('Email Shortcodes', 'event_espresso'); |
|
31 | + $this->description = esc_html__('All shortcodes related to emails', 'event_espresso'); |
|
32 | + $this->_shortcodes = array( |
|
33 | + '[SITE_ADMIN_EMAIL]' => esc_html__( |
|
34 | + 'Will be replaced with the admin email for the site that Event Espresso is installed on', |
|
35 | + 'event_espresso' |
|
36 | + ), |
|
37 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf( |
|
38 | + esc_html__( |
|
39 | + 'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
40 | + 'event_espresso' |
|
41 | + ), |
|
42 | + '<strong>', |
|
43 | + '</strong>' |
|
44 | + ), |
|
45 | + '[EVENT_AUTHOR_EMAIL]' => sprintf( |
|
46 | + esc_html__( |
|
47 | + 'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', |
|
48 | + 'event_espresso' |
|
49 | + ), |
|
50 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' |
|
51 | + ), |
|
52 | + '[CO_FORMATTED_EMAIL]' => esc_html__( |
|
53 | + 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
54 | + 'event_espresso' |
|
55 | + ), |
|
56 | + '[CO_EMAIL]' => esc_html__( |
|
57 | + 'This will parse to the email address only for the organization set in Your Organization Settings.', |
|
58 | + 'event_espresso' |
|
59 | + ), |
|
60 | + '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__( |
|
61 | + 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
62 | + 'event_espresso' |
|
63 | + ), |
|
64 | + '[ESPRESSO_ADMIN_EMAIL]' => esc_html__( |
|
65 | + 'This parses to the email address only for the organization set in Your Organization Settings page.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + protected function _parser($shortcode) |
|
73 | + { |
|
74 | + |
|
75 | + switch ($shortcode) { |
|
76 | + case '[SITE_ADMIN_EMAIL]': |
|
77 | + return $this->_get_site_admin_email(); |
|
78 | + break; |
|
79 | + |
|
80 | + case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
81 | + return $this->_get_event_admin_emails(); |
|
82 | + break; |
|
83 | + |
|
84 | + case '[EVENT_AUTHOR_EMAIL]': |
|
85 | + return $this->_get_event_admin_emails(false); |
|
86 | + break; |
|
87 | + |
|
88 | + case '[CO_FORMATTED_EMAIL]': |
|
89 | + case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
|
90 | + return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
91 | + . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
92 | + break; |
|
93 | + |
|
94 | + case '[CO_EMAIL]': |
|
95 | + case '[ESPRESSO_ADMIN_EMAIL]': |
|
96 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
97 | + break; |
|
98 | + |
|
99 | + default: |
|
100 | + return ''; |
|
101 | + break; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode) |
|
108 | + * |
|
109 | + * @access private |
|
110 | + * @return string email address of site admin |
|
111 | + */ |
|
112 | + private function _get_site_admin_email() |
|
113 | + { |
|
114 | + return get_bloginfo('admin_email'); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + private function _get_event_admin_emails($fancy_headers = true) |
|
119 | + { |
|
120 | + |
|
121 | + if (! empty($this->_data->admin_email)) { |
|
122 | + if (! $fancy_headers) { |
|
123 | + return $this->_data->admin_email; |
|
124 | + } |
|
125 | + return ! empty($this->_data->fname) |
|
126 | + ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
127 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
128 | + 'name' |
|
129 | + ) . ' <' . $this->_data->admin_email . '>'; |
|
130 | + } |
|
131 | + |
|
132 | + // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
|
133 | + |
|
134 | + $admin_email = array(); |
|
135 | + |
|
136 | + // loop through events and set the list of event_ids to retrieve so we can do ONE query. |
|
137 | + foreach ($this->_data->events as $event) { |
|
138 | + $ids[] = $event['ID']; |
|
139 | + } |
|
140 | + |
|
141 | + // get all the events |
|
142 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
143 | + |
|
144 | + // now loop through each event and setup the details |
|
145 | + $admin_details = array(); |
|
146 | + $cnt = 0; |
|
147 | + foreach ($events as $event) { |
|
148 | + $user = get_userdata($event->get('EVT_wp_user')); |
|
149 | + $admin_details[ $cnt ] = new stdClass(); |
|
150 | + $admin_details[ $cnt ]->email = $user->user_email; |
|
151 | + $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
152 | + $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
153 | + $cnt++; |
|
154 | + } |
|
155 | + |
|
156 | + // results? |
|
157 | + if (empty($admin_details) || ! is_array($admin_details)) { |
|
158 | + $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso'); |
|
159 | + $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql); |
|
160 | + $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true)); |
|
161 | + $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true)); |
|
162 | + $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
163 | + do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
164 | + } |
|
165 | + |
|
166 | + foreach ($admin_details as $admin) { |
|
167 | + // only add an admin email if it is present. |
|
168 | + if (empty($admin->email) || $admin->email == '') { |
|
169 | + continue; |
|
170 | + } |
|
171 | + |
|
172 | + if (! $fancy_headers) { |
|
173 | + $admin_email[] = $admin->email; |
|
174 | + continue; |
|
175 | + } |
|
176 | + |
|
177 | + $admin_email[] = ! empty($admin->first_name) |
|
178 | + ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
179 | + : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
180 | + } |
|
181 | + |
|
182 | + $admin_email = implode(',', $admin_email); |
|
183 | + return $admin_email; |
|
184 | + } |
|
185 | 185 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | |
88 | 88 | case '[CO_FORMATTED_EMAIL]': |
89 | 89 | case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
90 | - return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
91 | - . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
90 | + return EE_Registry::instance()->CFG->organization->get_pretty('name').' <' |
|
91 | + . EE_Registry::instance()->CFG->organization->get_pretty('email').'>'; |
|
92 | 92 | break; |
93 | 93 | |
94 | 94 | case '[CO_EMAIL]': |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | private function _get_event_admin_emails($fancy_headers = true) |
119 | 119 | { |
120 | 120 | |
121 | - if (! empty($this->_data->admin_email)) { |
|
122 | - if (! $fancy_headers) { |
|
121 | + if ( ! empty($this->_data->admin_email)) { |
|
122 | + if ( ! $fancy_headers) { |
|
123 | 123 | return $this->_data->admin_email; |
124 | 124 | } |
125 | 125 | return ! empty($this->_data->fname) |
126 | - ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
126 | + ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>' |
|
127 | 127 | : EE_Registry::instance()->CFG->organization->get_pretty( |
128 | 128 | 'name' |
129 | - ) . ' <' . $this->_data->admin_email . '>'; |
|
129 | + ).' <'.$this->_data->admin_email.'>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | $cnt = 0; |
147 | 147 | foreach ($events as $event) { |
148 | 148 | $user = get_userdata($event->get('EVT_wp_user')); |
149 | - $admin_details[ $cnt ] = new stdClass(); |
|
150 | - $admin_details[ $cnt ]->email = $user->user_email; |
|
151 | - $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
152 | - $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
149 | + $admin_details[$cnt] = new stdClass(); |
|
150 | + $admin_details[$cnt]->email = $user->user_email; |
|
151 | + $admin_details[$cnt]->first_name = $user->user_firstname; |
|
152 | + $admin_details[$cnt]->last_name = $user->user_lastname; |
|
153 | 153 | $cnt++; |
154 | 154 | } |
155 | 155 | |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
172 | - if (! $fancy_headers) { |
|
172 | + if ( ! $fancy_headers) { |
|
173 | 173 | $admin_email[] = $admin->email; |
174 | 174 | continue; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $admin_email[] = ! empty($admin->first_name) |
178 | - ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
179 | - : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
178 | + ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>' |
|
179 | + : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>'; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $admin_email = implode(',', $admin_email); |
@@ -21,154 +21,154 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * Hold array of active messengers indexed by messenger name. |
|
26 | - * |
|
27 | - * @since 4.5.0 |
|
28 | - * |
|
29 | - * @var EE_messenger[] |
|
30 | - */ |
|
31 | - protected $_active_messengers = array(); |
|
32 | - |
|
33 | - |
|
34 | - protected function _init_props() |
|
35 | - { |
|
36 | - $this->label = __('Messenger Shortcodes', 'event_espresso'); |
|
37 | - $this->description = __('All shortcodes that are messenger specific.', 'event_espresso'); |
|
38 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
39 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
40 | - // add messages about what happens when the messenger is active. |
|
41 | - $this->_active_messengers = $message_resource_manager->active_messengers(); |
|
42 | - |
|
43 | - $this->_shortcodes['[DISPLAY_HTML_URL]'] = __( |
|
44 | - 'This will return a link to view the template in a browser if the html messenger is active.', |
|
45 | - 'event_espresso' |
|
46 | - ); |
|
47 | - $this->_shortcodes['[DISPLAY_PDF_URL]'] = __( |
|
48 | - 'This will return a link to generate a pdf for the template if the pdf messenger is active.', |
|
49 | - 'event_espresso' |
|
50 | - ); |
|
51 | - $this->_shortcodes['[DISPLAY_PDF_BUTTON]'] = __( |
|
52 | - 'This will return html for a download pdf button trigger if the pdf messenger is active.', |
|
53 | - 'event_espresso' |
|
54 | - ); |
|
55 | - |
|
56 | - // show error message about buttons/urls not working as expected if messenger deactivated. |
|
57 | - if (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'update_message_template') { |
|
58 | - if (! isset($this->_active_messengers['pdf'])) { |
|
59 | - EE_Error::add_attention( |
|
60 | - __( |
|
61 | - 'Be aware that the pdf messenger is inactive. This means that any pdf related shortcodes will parse to an empty string.', |
|
62 | - 'event_espresso' |
|
63 | - ) |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - if (! isset($this->_active_messengers['html'])) { |
|
68 | - EE_Error::add_attention( |
|
69 | - __( |
|
70 | - 'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - protected function _parser($shortcode) |
|
80 | - { |
|
81 | - // make sure we end up with a copy of the EE_Messages_Addressee object |
|
82 | - $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
83 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
84 | - $this->_data |
|
85 | - ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
86 | - : $recipient; |
|
87 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
88 | - ? $this->_extra_data['data'] : $recipient; |
|
89 | - |
|
90 | - if (! $recipient instanceof EE_Messages_Addressee) { |
|
91 | - return ''; |
|
92 | - } |
|
93 | - |
|
94 | - switch ($shortcode) { |
|
95 | - case '[DISPLAY_HTML_URL]': |
|
96 | - return isset($this->_active_messengers['html']) ? $this->_get_url($recipient, 'html') : ''; |
|
97 | - break; |
|
98 | - case '[DISPLAY_PDF_URL]': |
|
99 | - return isset($this->_active_messengers['pdf']) ? $this->_get_url($recipient, 'pdf') : ''; |
|
100 | - break; |
|
101 | - case '[DISPLAY_PDF_BUTTON]': |
|
102 | - return isset($this->_active_messengers['pdf']) ? $this->_get_button($recipient, 'pdf') : ''; |
|
103 | - break; |
|
104 | - } |
|
105 | - return ''; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * This method takes the incoming data and figures out from it what the message type is and evt_id/grp_id and uses |
|
111 | - * that to generate the html for a button in the template. |
|
112 | - * |
|
113 | - * @since 4.5.0 |
|
114 | - * |
|
115 | - * @param EE_Messages_Addressee $recipient |
|
116 | - * @param string $sending_messenger 'html' or 'pdf' |
|
117 | - * |
|
118 | - * @return string Generated html |
|
119 | - */ |
|
120 | - private function _get_button(EE_Messages_Addressee $recipient, $sending_messenger) |
|
121 | - { |
|
122 | - $download_text = $sending_messenger == 'pdf' |
|
123 | - ? __('Download PDF', 'event_espresso') |
|
124 | - : __( |
|
125 | - 'Show HTML', |
|
126 | - 'event_espresso' |
|
127 | - ); |
|
128 | - $content = ' |
|
24 | + /** |
|
25 | + * Hold array of active messengers indexed by messenger name. |
|
26 | + * |
|
27 | + * @since 4.5.0 |
|
28 | + * |
|
29 | + * @var EE_messenger[] |
|
30 | + */ |
|
31 | + protected $_active_messengers = array(); |
|
32 | + |
|
33 | + |
|
34 | + protected function _init_props() |
|
35 | + { |
|
36 | + $this->label = __('Messenger Shortcodes', 'event_espresso'); |
|
37 | + $this->description = __('All shortcodes that are messenger specific.', 'event_espresso'); |
|
38 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
39 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
40 | + // add messages about what happens when the messenger is active. |
|
41 | + $this->_active_messengers = $message_resource_manager->active_messengers(); |
|
42 | + |
|
43 | + $this->_shortcodes['[DISPLAY_HTML_URL]'] = __( |
|
44 | + 'This will return a link to view the template in a browser if the html messenger is active.', |
|
45 | + 'event_espresso' |
|
46 | + ); |
|
47 | + $this->_shortcodes['[DISPLAY_PDF_URL]'] = __( |
|
48 | + 'This will return a link to generate a pdf for the template if the pdf messenger is active.', |
|
49 | + 'event_espresso' |
|
50 | + ); |
|
51 | + $this->_shortcodes['[DISPLAY_PDF_BUTTON]'] = __( |
|
52 | + 'This will return html for a download pdf button trigger if the pdf messenger is active.', |
|
53 | + 'event_espresso' |
|
54 | + ); |
|
55 | + |
|
56 | + // show error message about buttons/urls not working as expected if messenger deactivated. |
|
57 | + if (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'update_message_template') { |
|
58 | + if (! isset($this->_active_messengers['pdf'])) { |
|
59 | + EE_Error::add_attention( |
|
60 | + __( |
|
61 | + 'Be aware that the pdf messenger is inactive. This means that any pdf related shortcodes will parse to an empty string.', |
|
62 | + 'event_espresso' |
|
63 | + ) |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + if (! isset($this->_active_messengers['html'])) { |
|
68 | + EE_Error::add_attention( |
|
69 | + __( |
|
70 | + 'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + protected function _parser($shortcode) |
|
80 | + { |
|
81 | + // make sure we end up with a copy of the EE_Messages_Addressee object |
|
82 | + $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
83 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
84 | + $this->_data |
|
85 | + ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
86 | + : $recipient; |
|
87 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
88 | + ? $this->_extra_data['data'] : $recipient; |
|
89 | + |
|
90 | + if (! $recipient instanceof EE_Messages_Addressee) { |
|
91 | + return ''; |
|
92 | + } |
|
93 | + |
|
94 | + switch ($shortcode) { |
|
95 | + case '[DISPLAY_HTML_URL]': |
|
96 | + return isset($this->_active_messengers['html']) ? $this->_get_url($recipient, 'html') : ''; |
|
97 | + break; |
|
98 | + case '[DISPLAY_PDF_URL]': |
|
99 | + return isset($this->_active_messengers['pdf']) ? $this->_get_url($recipient, 'pdf') : ''; |
|
100 | + break; |
|
101 | + case '[DISPLAY_PDF_BUTTON]': |
|
102 | + return isset($this->_active_messengers['pdf']) ? $this->_get_button($recipient, 'pdf') : ''; |
|
103 | + break; |
|
104 | + } |
|
105 | + return ''; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * This method takes the incoming data and figures out from it what the message type is and evt_id/grp_id and uses |
|
111 | + * that to generate the html for a button in the template. |
|
112 | + * |
|
113 | + * @since 4.5.0 |
|
114 | + * |
|
115 | + * @param EE_Messages_Addressee $recipient |
|
116 | + * @param string $sending_messenger 'html' or 'pdf' |
|
117 | + * |
|
118 | + * @return string Generated html |
|
119 | + */ |
|
120 | + private function _get_button(EE_Messages_Addressee $recipient, $sending_messenger) |
|
121 | + { |
|
122 | + $download_text = $sending_messenger == 'pdf' |
|
123 | + ? __('Download PDF', 'event_espresso') |
|
124 | + : __( |
|
125 | + 'Show HTML', |
|
126 | + 'event_espresso' |
|
127 | + ); |
|
128 | + $content = ' |
|
129 | 129 | <form method="post" action="' . $this->_get_url($recipient, $sending_messenger) . '" > |
130 | 130 | <input class="print_button" type="submit" value="' . $download_text . '" /> |
131 | 131 | </form> |
132 | 132 | '; |
133 | - return $content; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * This method takes the incoming data and figures out from it what the message type is and |
|
139 | - * evt_id/grp_id and uses that to generate the url for displaying the template in a browser. |
|
140 | - * |
|
141 | - * @since 4.5.0 |
|
142 | - * |
|
143 | - * @param EE_Messages_Addressee $recipient |
|
144 | - * @param string $sending_messenger |
|
145 | - * |
|
146 | - * @return string The generated url for displaying the link. |
|
147 | - * @throws EE_Error |
|
148 | - */ |
|
149 | - private function _get_url(EE_Messages_Addressee $recipient, $sending_messenger) |
|
150 | - { |
|
151 | - |
|
152 | - $reg = $recipient->reg_obj; |
|
153 | - $reg = ! $reg instanceof EE_Registration ? $recipient->primary_reg_obj : $reg; |
|
154 | - |
|
155 | - |
|
156 | - if ($this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message) { |
|
157 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
158 | - try { |
|
159 | - return EEH_MSG_Template::get_url_trigger( |
|
160 | - $this->_message_type, |
|
161 | - $this->_message, |
|
162 | - $reg, |
|
163 | - $sending_messenger |
|
164 | - ); |
|
165 | - } catch (EE_Error $e) { |
|
166 | - if (WP_DEBUG) { |
|
167 | - $e->get_error(); |
|
168 | - } |
|
169 | - } |
|
170 | - } |
|
171 | - |
|
172 | - return ''; |
|
173 | - } |
|
133 | + return $content; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * This method takes the incoming data and figures out from it what the message type is and |
|
139 | + * evt_id/grp_id and uses that to generate the url for displaying the template in a browser. |
|
140 | + * |
|
141 | + * @since 4.5.0 |
|
142 | + * |
|
143 | + * @param EE_Messages_Addressee $recipient |
|
144 | + * @param string $sending_messenger |
|
145 | + * |
|
146 | + * @return string The generated url for displaying the link. |
|
147 | + * @throws EE_Error |
|
148 | + */ |
|
149 | + private function _get_url(EE_Messages_Addressee $recipient, $sending_messenger) |
|
150 | + { |
|
151 | + |
|
152 | + $reg = $recipient->reg_obj; |
|
153 | + $reg = ! $reg instanceof EE_Registration ? $recipient->primary_reg_obj : $reg; |
|
154 | + |
|
155 | + |
|
156 | + if ($this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message) { |
|
157 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
158 | + try { |
|
159 | + return EEH_MSG_Template::get_url_trigger( |
|
160 | + $this->_message_type, |
|
161 | + $this->_message, |
|
162 | + $reg, |
|
163 | + $sending_messenger |
|
164 | + ); |
|
165 | + } catch (EE_Error $e) { |
|
166 | + if (WP_DEBUG) { |
|
167 | + $e->get_error(); |
|
168 | + } |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + return ''; |
|
173 | + } |
|
174 | 174 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | // show error message about buttons/urls not working as expected if messenger deactivated. |
57 | 57 | if (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'update_message_template') { |
58 | - if (! isset($this->_active_messengers['pdf'])) { |
|
58 | + if ( ! isset($this->_active_messengers['pdf'])) { |
|
59 | 59 | EE_Error::add_attention( |
60 | 60 | __( |
61 | 61 | 'Be aware that the pdf messenger is inactive. This means that any pdf related shortcodes will parse to an empty string.', |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ); |
65 | 65 | } |
66 | 66 | |
67 | - if (! isset($this->_active_messengers['html'])) { |
|
67 | + if ( ! isset($this->_active_messengers['html'])) { |
|
68 | 68 | EE_Error::add_attention( |
69 | 69 | __( |
70 | 70 | 'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
88 | 88 | ? $this->_extra_data['data'] : $recipient; |
89 | 89 | |
90 | - if (! $recipient instanceof EE_Messages_Addressee) { |
|
90 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
91 | 91 | return ''; |
92 | 92 | } |
93 | 93 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | 'event_espresso' |
127 | 127 | ); |
128 | 128 | $content = ' |
129 | -<form method="post" action="' . $this->_get_url($recipient, $sending_messenger) . '" > |
|
130 | - <input class="print_button" type="submit" value="' . $download_text . '" /> |
|
129 | +<form method="post" action="' . $this->_get_url($recipient, $sending_messenger).'" > |
|
130 | + <input class="print_button" type="submit" value="' . $download_text.'" /> |
|
131 | 131 | </form> |
132 | 132 | '; |
133 | 133 | return $content; |
@@ -19,206 +19,206 @@ |
||
19 | 19 | interface FormHandlerInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * the absolute top level form section being used on the page |
|
24 | - * |
|
25 | - * @return \EE_Form_Section_Proper |
|
26 | - */ |
|
27 | - public function form(); |
|
22 | + /** |
|
23 | + * the absolute top level form section being used on the page |
|
24 | + * |
|
25 | + * @return \EE_Form_Section_Proper |
|
26 | + */ |
|
27 | + public function form(); |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @param \EE_Form_Section_Proper $form |
|
33 | - */ |
|
34 | - public function setForm(\EE_Form_Section_Proper $form); |
|
31 | + /** |
|
32 | + * @param \EE_Form_Section_Proper $form |
|
33 | + */ |
|
34 | + public function setForm(\EE_Form_Section_Proper $form); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * if set to false, then this form has no displayable content, |
|
40 | - * and will only be used for processing data sent passed via GET or POST |
|
41 | - * |
|
42 | - * @return boolean |
|
43 | - */ |
|
44 | - public function displayable(); |
|
38 | + /** |
|
39 | + * if set to false, then this form has no displayable content, |
|
40 | + * and will only be used for processing data sent passed via GET or POST |
|
41 | + * |
|
42 | + * @return boolean |
|
43 | + */ |
|
44 | + public function displayable(); |
|
45 | 45 | |
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param boolean $displayable |
|
50 | - */ |
|
51 | - public function setDisplayable($displayable = false); |
|
48 | + /** |
|
49 | + * @param boolean $displayable |
|
50 | + */ |
|
51 | + public function setDisplayable($displayable = false); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * a public name for the form that can be displayed on the frontend of a site |
|
57 | - * |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function formName(); |
|
55 | + /** |
|
56 | + * a public name for the form that can be displayed on the frontend of a site |
|
57 | + * |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function formName(); |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * a public name for the form that can be displayed, but only in the admin |
|
66 | - * |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function adminName(); |
|
64 | + /** |
|
65 | + * a public name for the form that can be displayed, but only in the admin |
|
66 | + * |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function adminName(); |
|
70 | 70 | |
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * a URL friendly string that can be used for identifying the form |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function slug(); |
|
73 | + /** |
|
74 | + * a URL friendly string that can be used for identifying the form |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function slug(); |
|
79 | 79 | |
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function submitBtnText(); |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function submitBtnText(); |
|
86 | 86 | |
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * @param string $submit_btn_text |
|
91 | - */ |
|
92 | - public function setSubmitBtnText($submit_btn_text); |
|
89 | + /** |
|
90 | + * @param string $submit_btn_text |
|
91 | + */ |
|
92 | + public function setSubmitBtnText($submit_btn_text); |
|
93 | 93 | |
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function formAction(); |
|
96 | + /** |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function formAction(); |
|
100 | 100 | |
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * @param string $form_action |
|
105 | - */ |
|
106 | - public function setFormAction($form_action); |
|
103 | + /** |
|
104 | + * @param string $form_action |
|
105 | + */ |
|
106 | + public function setFormAction($form_action); |
|
107 | 107 | |
108 | 108 | |
109 | 109 | |
110 | - /** |
|
111 | - * @param array $form_args |
|
112 | - */ |
|
113 | - public function addFormActionArgs($form_args = array()); |
|
110 | + /** |
|
111 | + * @param array $form_args |
|
112 | + */ |
|
113 | + public function addFormActionArgs($form_args = array()); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * if data regarding the form's state needs to be persisted, |
|
119 | - * then this method can be used to retrieve that data |
|
120 | - * |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function formConfig(); |
|
117 | + /** |
|
118 | + * if data regarding the form's state needs to be persisted, |
|
119 | + * then this method can be used to retrieve that data |
|
120 | + * |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function formConfig(); |
|
124 | 124 | |
125 | 125 | |
126 | 126 | |
127 | - /** |
|
128 | - * if data regarding the form's state needs to be persisted, |
|
129 | - * the this method can be used for setting the persisted data locally |
|
130 | - * |
|
131 | - * @param string $form_config |
|
132 | - */ |
|
133 | - public function setFormConfig($form_config); |
|
127 | + /** |
|
128 | + * if data regarding the form's state needs to be persisted, |
|
129 | + * the this method can be used for setting the persisted data locally |
|
130 | + * |
|
131 | + * @param string $form_config |
|
132 | + */ |
|
133 | + public function setFormConfig($form_config); |
|
134 | 134 | |
135 | 135 | |
136 | 136 | |
137 | - /** |
|
138 | - * called after the form is instantiated |
|
139 | - * and used for performing any logic that needs to occur early |
|
140 | - * before any of the other methods are called. |
|
141 | - * returns true if everything is ok to proceed, |
|
142 | - * and false if no further form logic should be implemented |
|
143 | - * |
|
144 | - * @return boolean |
|
145 | - */ |
|
146 | - public function initialize(); |
|
137 | + /** |
|
138 | + * called after the form is instantiated |
|
139 | + * and used for performing any logic that needs to occur early |
|
140 | + * before any of the other methods are called. |
|
141 | + * returns true if everything is ok to proceed, |
|
142 | + * and false if no further form logic should be implemented |
|
143 | + * |
|
144 | + * @return boolean |
|
145 | + */ |
|
146 | + public function initialize(); |
|
147 | 147 | |
148 | 148 | |
149 | 149 | |
150 | - /** |
|
151 | - * used for setting up css and js |
|
152 | - * |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - public function enqueueStylesAndScripts(); |
|
150 | + /** |
|
151 | + * used for setting up css and js |
|
152 | + * |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + public function enqueueStylesAndScripts(); |
|
156 | 156 | |
157 | 157 | |
158 | 158 | |
159 | - /** |
|
160 | - * creates and returns the actual form |
|
161 | - * |
|
162 | - * @return EE_Form_Section_Proper |
|
163 | - */ |
|
164 | - public function generate(); |
|
159 | + /** |
|
160 | + * creates and returns the actual form |
|
161 | + * |
|
162 | + * @return EE_Form_Section_Proper |
|
163 | + */ |
|
164 | + public function generate(); |
|
165 | 165 | |
166 | 166 | |
167 | 167 | |
168 | - /** |
|
169 | - * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
170 | - * returns a string of HTML that can be directly echoed in a template |
|
171 | - * |
|
172 | - * @return string |
|
173 | - */ |
|
174 | - public function display(); |
|
168 | + /** |
|
169 | + * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
170 | + * returns a string of HTML that can be directly echoed in a template |
|
171 | + * |
|
172 | + * @return string |
|
173 | + */ |
|
174 | + public function display(); |
|
175 | 175 | |
176 | 176 | |
177 | 177 | |
178 | - /** |
|
179 | - * handles processing the form submission |
|
180 | - * returns true or false depending on whether the form was processed successfully or not |
|
181 | - * |
|
182 | - * @param array $submitted_form_data |
|
183 | - * @return bool |
|
184 | - */ |
|
185 | - public function process($submitted_form_data = array()); |
|
178 | + /** |
|
179 | + * handles processing the form submission |
|
180 | + * returns true or false depending on whether the form was processed successfully or not |
|
181 | + * |
|
182 | + * @param array $submitted_form_data |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | + public function process($submitted_form_data = array()); |
|
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | - /** |
|
190 | - * creates and returns an EE_Submit_Input labeled "Submit" |
|
191 | - * |
|
192 | - * @param string $text |
|
193 | - * @return \EE_Submit_Input |
|
194 | - */ |
|
195 | - public function generateSubmitButton($text = ''); |
|
189 | + /** |
|
190 | + * creates and returns an EE_Submit_Input labeled "Submit" |
|
191 | + * |
|
192 | + * @param string $text |
|
193 | + * @return \EE_Submit_Input |
|
194 | + */ |
|
195 | + public function generateSubmitButton($text = ''); |
|
196 | 196 | |
197 | 197 | |
198 | 198 | |
199 | - /** |
|
200 | - * calls generateSubmitButton() and appends it onto the form along with a float clearing div |
|
201 | - * |
|
202 | - * @return void |
|
203 | - */ |
|
204 | - public function appendSubmitButton(); |
|
199 | + /** |
|
200 | + * calls generateSubmitButton() and appends it onto the form along with a float clearing div |
|
201 | + * |
|
202 | + * @return void |
|
203 | + */ |
|
204 | + public function appendSubmitButton(); |
|
205 | 205 | |
206 | 206 | |
207 | 207 | |
208 | - /** |
|
209 | - * creates and returns an EE_Submit_Input labeled "Cancel" |
|
210 | - * |
|
211 | - * @param string $text |
|
212 | - * @return \EE_Submit_Input |
|
213 | - */ |
|
214 | - public function generateCancelButton($text = ''); |
|
208 | + /** |
|
209 | + * creates and returns an EE_Submit_Input labeled "Cancel" |
|
210 | + * |
|
211 | + * @param string $text |
|
212 | + * @return \EE_Submit_Input |
|
213 | + */ |
|
214 | + public function generateCancelButton($text = ''); |
|
215 | 215 | |
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * appends a float clearing div onto end of form |
|
220 | - * |
|
221 | - * @return void |
|
222 | - */ |
|
223 | - public function clearFormButtonFloats(); |
|
218 | + /** |
|
219 | + * appends a float clearing div onto end of form |
|
220 | + * |
|
221 | + * @return void |
|
222 | + */ |
|
223 | + public function clearFormButtonFloats(); |
|
224 | 224 | } |
@@ -16,55 +16,55 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @return int |
|
21 | - */ |
|
22 | - public function order(); |
|
19 | + /** |
|
20 | + * @return int |
|
21 | + */ |
|
22 | + public function order(); |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param int $order |
|
28 | - * @throws InvalidArgumentException |
|
29 | - */ |
|
30 | - public function setOrder($order); |
|
26 | + /** |
|
27 | + * @param int $order |
|
28 | + * @throws InvalidArgumentException |
|
29 | + */ |
|
30 | + public function setOrder($order); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function redirectUrl(); |
|
34 | + /** |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function redirectUrl(); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $redirect_url |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws InvalidArgumentException |
|
45 | - */ |
|
46 | - public function setRedirectUrl($redirect_url); |
|
41 | + /** |
|
42 | + * @param string $redirect_url |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws InvalidArgumentException |
|
45 | + */ |
|
46 | + public function setRedirectUrl($redirect_url); |
|
47 | 47 | |
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param array $redirect_args |
|
52 | - * @throws InvalidDataTypeException |
|
53 | - * @throws InvalidArgumentException |
|
54 | - */ |
|
55 | - public function addRedirectArgs($redirect_args = array()); |
|
50 | + /** |
|
51 | + * @param array $redirect_args |
|
52 | + * @throws InvalidDataTypeException |
|
53 | + * @throws InvalidArgumentException |
|
54 | + */ |
|
55 | + public function addRedirectArgs($redirect_args = array()); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function redirectTo(); |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function redirectTo(); |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param string $redirect_to |
|
68 | - */ |
|
69 | - public function setRedirectTo($redirect_to); |
|
66 | + /** |
|
67 | + * @param string $redirect_to |
|
68 | + */ |
|
69 | + public function setRedirectTo($redirect_to); |
|
70 | 70 | } |