@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param EE_Line_Item $line_item |
74 | 74 | * @param array $options |
75 | 75 | * @param EE_Line_Item $parent_line_item |
76 | - * @return mixed |
|
76 | + * @return string |
|
77 | 77 | * @throws EE_Error |
78 | 78 | */ |
79 | 79 | public function display_line_item( |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * _event_row - basically a Heading row displayed once above each event's ticket rows |
217 | 217 | * |
218 | 218 | * @param EE_Line_Item $line_item |
219 | - * @return mixed |
|
219 | + * @return string |
|
220 | 220 | */ |
221 | 221 | private function _event_row(EE_Line_Item $line_item) |
222 | 222 | { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @param EE_Line_Item $line_item |
244 | 244 | * @param array $options |
245 | - * @return mixed |
|
245 | + * @return string |
|
246 | 246 | * @throws EE_Error |
247 | 247 | */ |
248 | 248 | private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param EE_Line_Item $line_item |
301 | 301 | * @param array $options |
302 | - * @return mixed |
|
302 | + * @return string |
|
303 | 303 | * @throws EE_Error |
304 | 304 | */ |
305 | 305 | private function _item_row(EE_Line_Item $line_item, $options = array()) |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @param EE_Line_Item $line_item |
424 | 424 | * @param array $options |
425 | - * @return mixed |
|
425 | + * @return string |
|
426 | 426 | * @throws EE_Error |
427 | 427 | */ |
428 | 428 | private function _tax_row(EE_Line_Item $line_item, $options = array()) |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param EE_Line_Item $line_item |
468 | 468 | * @param string $text |
469 | - * @return mixed |
|
469 | + * @return string |
|
470 | 470 | * @throws EE_Error |
471 | 471 | */ |
472 | 472 | private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @param EE_Line_Item $line_item |
506 | 506 | * @param string $text |
507 | 507 | * @param array $options |
508 | - * @return mixed |
|
508 | + * @return string |
|
509 | 509 | * @throws EE_Error |
510 | 510 | */ |
511 | 511 | private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @param EE_Line_Item $line_item |
543 | 543 | * @param string $text |
544 | - * @return mixed |
|
544 | + * @return string |
|
545 | 545 | * @throws EE_Error |
546 | 546 | */ |
547 | 547 | private function _total_row(EE_Line_Item $line_item, $text = '') |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @param EE_Line_Item $line_item |
570 | 570 | * @param array $options |
571 | - * @return mixed |
|
571 | + * @return string |
|
572 | 572 | * @throws EE_Error |
573 | 573 | */ |
574 | 574 | private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $html = ''; |
85 | 85 | // set some default options and merge with incoming |
86 | 86 | $default_options = array( |
87 | - 'show_desc' => true, // true false |
|
87 | + 'show_desc' => true, // true false |
|
88 | 88 | 'odd' => false, |
89 | 89 | ); |
90 | 90 | $options = array_merge($default_options, (array) $options); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $text = esc_html__('Sub-Total', 'event_espresso'); |
119 | 119 | if ($line_item->OBJ_type() === 'Event') { |
120 | 120 | $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
121 | - if (! isset($this->_events[ $options['event_id'] ])) { |
|
121 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
122 | 122 | $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
123 | 123 | // if event has default reg status of Not Approved, then don't display info on it |
124 | 124 | if ($event instanceof EE_Event |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | // unless there are registrations for it that are returning to pay |
129 | 129 | if (isset($options['registrations']) && is_array($options['registrations'])) { |
130 | 130 | foreach ($options['registrations'] as $registration) { |
131 | - if (! $registration instanceof EE_Registration) { |
|
131 | + if ( ! $registration instanceof EE_Registration) { |
|
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | $display_event = $registration->event_ID() === $options['event_id'] |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | : $display_event; |
138 | 138 | } |
139 | 139 | } |
140 | - if (! $display_event) { |
|
140 | + if ( ! $display_event) { |
|
141 | 141 | return ''; |
142 | 142 | } |
143 | 143 | } |
144 | - $this->_events[ $options['event_id'] ] = 0; |
|
144 | + $this->_events[$options['event_id']] = 0; |
|
145 | 145 | $html .= $this->_event_row($line_item); |
146 | 146 | $text = esc_html__('Event Sub-Total', 'event_espresso'); |
147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | // recursively feed children back into this method |
153 | 153 | $html .= $this->display_line_item($child_line_item, $options, $line_item); |
154 | 154 | } |
155 | - $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
155 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
156 | 156 | $sub_total += $event_sub_total; |
157 | 157 | if (( |
158 | 158 | // event subtotals |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
261 | 261 | ( |
262 | 262 | $options['show_desc'] |
263 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
263 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
264 | 264 | : '' |
265 | 265 | ), |
266 | 266 | $line_item, |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $line_item->total(), |
290 | 290 | $line_item |
291 | 291 | ); |
292 | - $this->_events[ $options['event_id'] ] += $total; |
|
292 | + $this->_events[$options['event_id']] += $total; |
|
293 | 293 | // total td |
294 | 294 | $html .= EEH_HTML::td( |
295 | 295 | EEH_Template::format_currency($total, false, false), |
@@ -316,18 +316,18 @@ discard block |
||
316 | 316 | // start of row |
317 | 317 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
318 | 318 | $html = EEH_HTML::tr('', '', $row_class); |
319 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
319 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
320 | 320 | // name && desc |
321 | 321 | $name_and_desc = apply_filters( |
322 | 322 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
323 | - $obj_name . $line_item->name(), |
|
323 | + $obj_name.$line_item->name(), |
|
324 | 324 | $line_item |
325 | 325 | ); |
326 | 326 | $name_and_desc .= apply_filters( |
327 | 327 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
328 | 328 | ( |
329 | 329 | $options['show_desc'] |
330 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
330 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
331 | 331 | : '' |
332 | 332 | ), |
333 | 333 | $line_item, |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
339 | 339 | // price td |
340 | 340 | if ($line_item->is_percent()) { |
341 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
341 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
342 | 342 | } else { |
343 | 343 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
344 | 344 | } |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
347 | 347 | // $total = $line_item->total() * $line_item->quantity(); |
348 | 348 | $total = $line_item->total(); |
349 | - if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
350 | - $this->_events[ $options['event_id'] ] += $total; |
|
349 | + if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
350 | + $this->_events[$options['event_id']] += $total; |
|
351 | 351 | } |
352 | 352 | // total td |
353 | 353 | $html .= EEH_HTML::td( |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | // name && desc |
442 | 442 | $name_and_desc = $line_item->name(); |
443 | 443 | $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
444 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
445 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
444 | + . esc_html__(' * taxable items', 'event_espresso').'</span>'; |
|
445 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
446 | 446 | // name td |
447 | 447 | $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
448 | 448 | $name_and_desc, |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | 'item_l sub-item' |
451 | 451 | ); |
452 | 452 | // percent td |
453 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
453 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
454 | 454 | // empty td (price) |
455 | 455 | $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
456 | 456 | // total td |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | $registration_payments += $registration->registration_payments(); |
596 | 596 | } |
597 | 597 | } |
598 | - if (! empty($registration_payments)) { |
|
598 | + if ( ! empty($registration_payments)) { |
|
599 | 599 | foreach ($registration_payments as $registration_payment) { |
600 | 600 | if ($registration_payment instanceof EE_Registration_Payment) { |
601 | 601 | $owing -= $registration_payment->amount(); |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $payment_desc = sprintf( |
606 | 606 | esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
607 | 607 | $payment->txn_id_chq_nmbr() !== '' |
608 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
608 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
609 | 609 | : '', |
610 | 610 | $payment->timestamp() |
611 | 611 | ); |
@@ -12,659 +12,659 @@ |
||
12 | 12 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * array of events |
|
17 | - * |
|
18 | - * @type EE_Line_Item[] $_events |
|
19 | - */ |
|
20 | - private $_events = array(); |
|
21 | - |
|
22 | - /** |
|
23 | - * whether to display the taxes row or not |
|
24 | - * |
|
25 | - * @type bool $_show_taxes |
|
26 | - */ |
|
27 | - private $_show_taxes = false; |
|
28 | - |
|
29 | - /** |
|
30 | - * html for any tax rows |
|
31 | - * |
|
32 | - * @type string $_show_taxes |
|
33 | - */ |
|
34 | - private $_taxes_html = ''; |
|
35 | - |
|
36 | - /** |
|
37 | - * total amount including tax we can bill for at this time |
|
38 | - * |
|
39 | - * @type float $_grand_total |
|
40 | - */ |
|
41 | - private $_grand_total = 0.00; |
|
42 | - |
|
43 | - /** |
|
44 | - * total number of items being billed for |
|
45 | - * |
|
46 | - * @type int $_total_items |
|
47 | - */ |
|
48 | - private $_total_items = 0; |
|
49 | - |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return float |
|
54 | - */ |
|
55 | - public function grand_total() |
|
56 | - { |
|
57 | - return $this->_grand_total; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return int |
|
64 | - */ |
|
65 | - public function total_items() |
|
66 | - { |
|
67 | - return $this->_total_items; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @param EE_Line_Item $line_item |
|
74 | - * @param array $options |
|
75 | - * @param EE_Line_Item $parent_line_item |
|
76 | - * @return mixed |
|
77 | - * @throws EE_Error |
|
78 | - */ |
|
79 | - public function display_line_item( |
|
80 | - EE_Line_Item $line_item, |
|
81 | - $options = array(), |
|
82 | - EE_Line_Item $parent_line_item = null |
|
83 | - ) { |
|
84 | - $html = ''; |
|
85 | - // set some default options and merge with incoming |
|
86 | - $default_options = array( |
|
87 | - 'show_desc' => true, // true false |
|
88 | - 'odd' => false, |
|
89 | - ); |
|
90 | - $options = array_merge($default_options, (array) $options); |
|
91 | - switch ($line_item->type()) { |
|
92 | - case EEM_Line_Item::type_line_item: |
|
93 | - $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
94 | - if ($line_item->OBJ_type() === 'Ticket') { |
|
95 | - // item row |
|
96 | - $html .= $this->_ticket_row($line_item, $options); |
|
97 | - } else { |
|
98 | - // item row |
|
99 | - $html .= $this->_item_row($line_item, $options); |
|
100 | - } |
|
101 | - if (apply_filters( |
|
102 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
103 | - true |
|
104 | - ) |
|
105 | - ) { |
|
106 | - // got any kids? |
|
107 | - foreach ($line_item->children() as $child_line_item) { |
|
108 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
109 | - } |
|
110 | - } |
|
111 | - break; |
|
112 | - case EEM_Line_Item::type_sub_line_item: |
|
113 | - $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
114 | - break; |
|
115 | - case EEM_Line_Item::type_sub_total: |
|
116 | - static $sub_total = 0; |
|
117 | - $event_sub_total = 0; |
|
118 | - $text = esc_html__('Sub-Total', 'event_espresso'); |
|
119 | - if ($line_item->OBJ_type() === 'Event') { |
|
120 | - $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
121 | - if (! isset($this->_events[ $options['event_id'] ])) { |
|
122 | - $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
123 | - // if event has default reg status of Not Approved, then don't display info on it |
|
124 | - if ($event instanceof EE_Event |
|
125 | - && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
126 | - ) { |
|
127 | - $display_event = false; |
|
128 | - // unless there are registrations for it that are returning to pay |
|
129 | - if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
130 | - foreach ($options['registrations'] as $registration) { |
|
131 | - if (! $registration instanceof EE_Registration) { |
|
132 | - continue; |
|
133 | - } |
|
134 | - $display_event = $registration->event_ID() === $options['event_id'] |
|
135 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
136 | - ? true |
|
137 | - : $display_event; |
|
138 | - } |
|
139 | - } |
|
140 | - if (! $display_event) { |
|
141 | - return ''; |
|
142 | - } |
|
143 | - } |
|
144 | - $this->_events[ $options['event_id'] ] = 0; |
|
145 | - $html .= $this->_event_row($line_item); |
|
146 | - $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
147 | - } |
|
148 | - } |
|
149 | - $child_line_items = $line_item->children(); |
|
150 | - // loop thru children |
|
151 | - foreach ($child_line_items as $child_line_item) { |
|
152 | - // recursively feed children back into this method |
|
153 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
154 | - } |
|
155 | - $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
156 | - $sub_total += $event_sub_total; |
|
157 | - if (( |
|
158 | - // event subtotals |
|
159 | - $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
160 | - ) |
|
161 | - || ( |
|
162 | - // pre-tax subtotals |
|
163 | - $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
164 | - ) |
|
165 | - ) { |
|
166 | - $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
167 | - $html .= $this->_sub_total_row($line_item, $text, $options); |
|
168 | - } |
|
169 | - break; |
|
170 | - case EEM_Line_Item::type_tax: |
|
171 | - if ($this->_show_taxes) { |
|
172 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
173 | - } |
|
174 | - break; |
|
175 | - case EEM_Line_Item::type_tax_sub_total: |
|
176 | - if ($this->_show_taxes) { |
|
177 | - $child_line_items = $line_item->children(); |
|
178 | - // loop thru children |
|
179 | - foreach ($child_line_items as $child_line_item) { |
|
180 | - // recursively feed children back into this method |
|
181 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
182 | - } |
|
183 | - if (count($child_line_items) > 1) { |
|
184 | - $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
185 | - } |
|
186 | - } |
|
187 | - break; |
|
188 | - case EEM_Line_Item::type_total: |
|
189 | - // get all child line items |
|
190 | - $children = $line_item->children(); |
|
191 | - // loop thru all non-tax child line items |
|
192 | - foreach ($children as $child_line_item) { |
|
193 | - if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
194 | - // recursively feed children back into this method |
|
195 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
196 | - } |
|
197 | - } |
|
198 | - // now loop thru tax child line items |
|
199 | - foreach ($children as $child_line_item) { |
|
200 | - if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
201 | - // recursively feed children back into this method |
|
202 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | - } |
|
204 | - } |
|
205 | - $html .= $this->_taxes_html; |
|
206 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
207 | - $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
208 | - break; |
|
209 | - } |
|
210 | - return $html; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
217 | - * |
|
218 | - * @param EE_Line_Item $line_item |
|
219 | - * @return mixed |
|
220 | - */ |
|
221 | - private function _event_row(EE_Line_Item $line_item) |
|
222 | - { |
|
223 | - // start of row |
|
224 | - $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
225 | - // event name td |
|
226 | - $html .= EEH_HTML::td( |
|
227 | - EEH_HTML::strong($line_item->name()), |
|
228 | - '', |
|
229 | - 'event-header', |
|
230 | - '', |
|
231 | - ' colspan="4"' |
|
232 | - ); |
|
233 | - // end of row |
|
234 | - $html .= EEH_HTML::trx(); |
|
235 | - return $html; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * _ticket_row |
|
242 | - * |
|
243 | - * @param EE_Line_Item $line_item |
|
244 | - * @param array $options |
|
245 | - * @return mixed |
|
246 | - * @throws EE_Error |
|
247 | - */ |
|
248 | - private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
249 | - { |
|
250 | - // start of row |
|
251 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
252 | - $html = EEH_HTML::tr('', '', $row_class); |
|
253 | - // name && desc |
|
254 | - $name_and_desc = apply_filters( |
|
255 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
256 | - $line_item->name(), |
|
257 | - $line_item |
|
258 | - ); |
|
259 | - $name_and_desc .= apply_filters( |
|
260 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
261 | - ( |
|
262 | - $options['show_desc'] |
|
263 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
264 | - : '' |
|
265 | - ), |
|
266 | - $line_item, |
|
267 | - $options |
|
268 | - ); |
|
269 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
270 | - $name_and_desc = apply_filters( |
|
271 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__name_and_desc', |
|
272 | - $name_and_desc, |
|
273 | - $line_item, |
|
274 | - $options |
|
275 | - ); |
|
276 | - |
|
277 | - // name td |
|
278 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
279 | - $name_and_desc, |
|
280 | - '', |
|
281 | - 'item_l' |
|
282 | - ); |
|
283 | - // price td |
|
284 | - $price = apply_filters( |
|
285 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price', |
|
286 | - $line_item->unit_price_no_code(), |
|
287 | - $line_item |
|
288 | - ); |
|
289 | - $html .= EEH_HTML::td($price, '', 'item_c jst-rght'); |
|
290 | - // quantity td |
|
291 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
292 | - $this->_total_items += $line_item->quantity(); |
|
293 | - // determine total for line item |
|
294 | - $total = apply_filters( |
|
295 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total', |
|
296 | - $line_item->total(), |
|
297 | - $line_item |
|
298 | - ); |
|
299 | - $this->_events[ $options['event_id'] ] += $total; |
|
300 | - // total td |
|
301 | - $html .= EEH_HTML::td( |
|
302 | - EEH_Template::format_currency($total, false, false), |
|
303 | - '', |
|
304 | - 'item_r jst-rght' |
|
305 | - ); |
|
306 | - // end of row |
|
307 | - $html .= EEH_HTML::trx(); |
|
308 | - return $html; |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * _item_row |
|
315 | - * |
|
316 | - * @param EE_Line_Item $line_item |
|
317 | - * @param array $options |
|
318 | - * @return mixed |
|
319 | - * @throws EE_Error |
|
320 | - */ |
|
321 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
322 | - { |
|
323 | - // start of row |
|
324 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
325 | - $html = EEH_HTML::tr('', '', $row_class); |
|
326 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
327 | - // name && desc |
|
328 | - $name_and_desc = apply_filters( |
|
329 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
330 | - $obj_name . $line_item->name(), |
|
331 | - $line_item |
|
332 | - ); |
|
333 | - $name_and_desc .= apply_filters( |
|
334 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
335 | - ( |
|
336 | - $options['show_desc'] |
|
337 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
338 | - : '' |
|
339 | - ), |
|
340 | - $line_item, |
|
341 | - $options |
|
342 | - ); |
|
343 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
344 | - $name_and_desc = apply_filters( |
|
345 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___item_row__name_and_desc', |
|
346 | - $name_and_desc, |
|
347 | - $line_item, |
|
348 | - $options |
|
349 | - ); |
|
350 | - |
|
351 | - // name td |
|
352 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
353 | - // price td |
|
354 | - if ($line_item->is_percent()) { |
|
355 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
356 | - } else { |
|
357 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
358 | - } |
|
359 | - // quantity td |
|
360 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
361 | - // $total = $line_item->total() * $line_item->quantity(); |
|
362 | - $total = $line_item->total(); |
|
363 | - if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
364 | - $this->_events[ $options['event_id'] ] += $total; |
|
365 | - } |
|
366 | - // total td |
|
367 | - $html .= EEH_HTML::td( |
|
368 | - EEH_Template::format_currency($total, false, false), |
|
369 | - '', |
|
370 | - 'item_r jst-rght' |
|
371 | - ); |
|
372 | - // end of row |
|
373 | - $html .= EEH_HTML::trx(); |
|
374 | - return $html; |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * _sub_item_row |
|
381 | - * |
|
382 | - * @param EE_Line_Item $line_item |
|
383 | - * @param array $options |
|
384 | - * @param EE_Line_Item $parent_line_item |
|
385 | - * @return mixed |
|
386 | - * @throws EE_Error |
|
387 | - */ |
|
388 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
389 | - { |
|
390 | - if ($parent_line_item instanceof EE_Line_Item |
|
391 | - && $line_item->children() === array() |
|
392 | - && $line_item->name() === $parent_line_item->name() |
|
393 | - && apply_filters( |
|
394 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
395 | - true |
|
396 | - ) |
|
397 | - ) { |
|
398 | - return ''; |
|
399 | - } |
|
400 | - // start of row |
|
401 | - $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
402 | - // name && desc |
|
403 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
404 | - . $line_item->name(); |
|
405 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
406 | - . $line_item->desc() |
|
407 | - . '</span>' : ''; |
|
408 | - // name td |
|
409 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
410 | - $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
411 | - // discount/surcharge td |
|
412 | - if ($line_item->is_percent()) { |
|
413 | - $html .= EEH_HTML::td( |
|
414 | - EEH_Template::format_currency( |
|
415 | - $line_item->total() / $qty, |
|
416 | - false, |
|
417 | - false |
|
418 | - ), |
|
419 | - '', |
|
420 | - 'item_c jst-rght' |
|
421 | - ); |
|
422 | - } else { |
|
423 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
424 | - } |
|
425 | - // no quantity td |
|
426 | - $html .= EEH_HTML::td(); |
|
427 | - // no total td |
|
428 | - $html .= EEH_HTML::td(); |
|
429 | - // end of row |
|
430 | - $html .= EEH_HTML::trx(); |
|
431 | - $html = apply_filters( |
|
432 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
433 | - $html, |
|
434 | - $line_item, |
|
435 | - $options, |
|
436 | - $parent_line_item |
|
437 | - ); |
|
438 | - return $html; |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * _tax_row |
|
445 | - * |
|
446 | - * @param EE_Line_Item $line_item |
|
447 | - * @param array $options |
|
448 | - * @return mixed |
|
449 | - * @throws EE_Error |
|
450 | - */ |
|
451 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
452 | - { |
|
453 | - // start of row |
|
454 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
455 | - // name && desc |
|
456 | - $name_and_desc = $line_item->name(); |
|
457 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
458 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
459 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
460 | - // name td |
|
461 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
462 | - $name_and_desc, |
|
463 | - '', |
|
464 | - 'item_l sub-item' |
|
465 | - ); |
|
466 | - // percent td |
|
467 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
468 | - // empty td (price) |
|
469 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
470 | - // total td |
|
471 | - $html .= EEH_HTML::td( |
|
472 | - EEH_Template::format_currency( |
|
473 | - $line_item->total(), |
|
474 | - false, |
|
475 | - false |
|
476 | - ), |
|
477 | - '', |
|
478 | - 'item_r jst-rght' |
|
479 | - ); |
|
480 | - // end of row |
|
481 | - $html .= EEH_HTML::trx(); |
|
482 | - return $html; |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * _total_row |
|
489 | - * |
|
490 | - * @param EE_Line_Item $line_item |
|
491 | - * @param string $text |
|
492 | - * @return mixed |
|
493 | - * @throws EE_Error |
|
494 | - */ |
|
495 | - private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
496 | - { |
|
497 | - $html = ''; |
|
498 | - if ($line_item->total()) { |
|
499 | - // start of row |
|
500 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
501 | - // total td |
|
502 | - $html .= EEH_HTML::td( |
|
503 | - $text, |
|
504 | - '', |
|
505 | - 'total_currency total jst-rght', |
|
506 | - '', |
|
507 | - ' colspan="2"' |
|
508 | - ); |
|
509 | - // empty td (price) |
|
510 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
511 | - // total td |
|
512 | - $html .= EEH_HTML::td( |
|
513 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
514 | - '', |
|
515 | - 'total jst-rght' |
|
516 | - ); |
|
517 | - // end of row |
|
518 | - $html .= EEH_HTML::trx(); |
|
519 | - } |
|
520 | - return $html; |
|
521 | - } |
|
522 | - |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * _total_row |
|
527 | - * |
|
528 | - * @param EE_Line_Item $line_item |
|
529 | - * @param string $text |
|
530 | - * @param array $options |
|
531 | - * @return mixed |
|
532 | - * @throws EE_Error |
|
533 | - */ |
|
534 | - private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
535 | - { |
|
536 | - $html = ''; |
|
537 | - if ($line_item->total()) { |
|
538 | - // start of row |
|
539 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
540 | - // total td |
|
541 | - $html .= EEH_HTML::td( |
|
542 | - $text, |
|
543 | - '', |
|
544 | - 'total_currency total jst-rght', |
|
545 | - '', |
|
546 | - ' colspan="3"' |
|
547 | - ); |
|
548 | - // total td |
|
549 | - $html .= EEH_HTML::td( |
|
550 | - EEH_Template::format_currency($options['sub_total'], false, false), |
|
551 | - '', |
|
552 | - 'total jst-rght' |
|
553 | - ); |
|
554 | - // end of row |
|
555 | - $html .= EEH_HTML::trx(); |
|
556 | - } |
|
557 | - return $html; |
|
558 | - } |
|
559 | - |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * _total_row |
|
564 | - * |
|
565 | - * @param EE_Line_Item $line_item |
|
566 | - * @param string $text |
|
567 | - * @return mixed |
|
568 | - * @throws EE_Error |
|
569 | - */ |
|
570 | - private function _total_row(EE_Line_Item $line_item, $text = '') |
|
571 | - { |
|
572 | - // start of row |
|
573 | - $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
574 | - // total td |
|
575 | - $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
576 | - // total td |
|
577 | - $html .= EEH_HTML::td( |
|
578 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
579 | - '', |
|
580 | - 'total jst-rght' |
|
581 | - ); |
|
582 | - // end of row |
|
583 | - $html .= EEH_HTML::trx(); |
|
584 | - return $html; |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * _payments_and_amount_owing_rows |
|
591 | - * |
|
592 | - * @param EE_Line_Item $line_item |
|
593 | - * @param array $options |
|
594 | - * @return mixed |
|
595 | - * @throws EE_Error |
|
596 | - */ |
|
597 | - private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
598 | - { |
|
599 | - $html = ''; |
|
600 | - $owing = $line_item->total(); |
|
601 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
602 | - if ($transaction instanceof EE_Transaction) { |
|
603 | - $registration_payments = array(); |
|
604 | - $registrations = ! empty($options['registrations']) |
|
605 | - ? $options['registrations'] |
|
606 | - : $transaction->registrations(); |
|
607 | - foreach ($registrations as $registration) { |
|
608 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
609 | - $registration_payments += $registration->registration_payments(); |
|
610 | - } |
|
611 | - } |
|
612 | - if (! empty($registration_payments)) { |
|
613 | - foreach ($registration_payments as $registration_payment) { |
|
614 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
615 | - $owing -= $registration_payment->amount(); |
|
616 | - $payment = $registration_payment->payment(); |
|
617 | - $payment_desc = ''; |
|
618 | - if ($payment instanceof EE_Payment) { |
|
619 | - $payment_desc = sprintf( |
|
620 | - esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
621 | - $payment->txn_id_chq_nmbr() !== '' |
|
622 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
623 | - : '', |
|
624 | - $payment->timestamp() |
|
625 | - ); |
|
626 | - } |
|
627 | - // start of row |
|
628 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
629 | - // payment desc |
|
630 | - $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
631 | - // total td |
|
632 | - $html .= EEH_HTML::td( |
|
633 | - EEH_Template::format_currency( |
|
634 | - $registration_payment->amount(), |
|
635 | - false, |
|
636 | - false |
|
637 | - ), |
|
638 | - '', |
|
639 | - 'total jst-rght' |
|
640 | - ); |
|
641 | - // end of row |
|
642 | - $html .= EEH_HTML::trx(); |
|
643 | - } |
|
644 | - } |
|
645 | - if ($line_item->total()) { |
|
646 | - // start of row |
|
647 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
648 | - // total td |
|
649 | - $html .= EEH_HTML::td( |
|
650 | - esc_html__('Amount Owing', 'event_espresso'), |
|
651 | - '', |
|
652 | - 'total_currency total jst-rght', |
|
653 | - '', |
|
654 | - ' colspan="3"' |
|
655 | - ); |
|
656 | - // total td |
|
657 | - $html .= EEH_HTML::td( |
|
658 | - EEH_Template::format_currency($owing, false, false), |
|
659 | - '', |
|
660 | - 'total jst-rght' |
|
661 | - ); |
|
662 | - // end of row |
|
663 | - $html .= EEH_HTML::trx(); |
|
664 | - } |
|
665 | - } |
|
666 | - } |
|
667 | - $this->_grand_total = $owing; |
|
668 | - return $html; |
|
669 | - } |
|
15 | + /** |
|
16 | + * array of events |
|
17 | + * |
|
18 | + * @type EE_Line_Item[] $_events |
|
19 | + */ |
|
20 | + private $_events = array(); |
|
21 | + |
|
22 | + /** |
|
23 | + * whether to display the taxes row or not |
|
24 | + * |
|
25 | + * @type bool $_show_taxes |
|
26 | + */ |
|
27 | + private $_show_taxes = false; |
|
28 | + |
|
29 | + /** |
|
30 | + * html for any tax rows |
|
31 | + * |
|
32 | + * @type string $_show_taxes |
|
33 | + */ |
|
34 | + private $_taxes_html = ''; |
|
35 | + |
|
36 | + /** |
|
37 | + * total amount including tax we can bill for at this time |
|
38 | + * |
|
39 | + * @type float $_grand_total |
|
40 | + */ |
|
41 | + private $_grand_total = 0.00; |
|
42 | + |
|
43 | + /** |
|
44 | + * total number of items being billed for |
|
45 | + * |
|
46 | + * @type int $_total_items |
|
47 | + */ |
|
48 | + private $_total_items = 0; |
|
49 | + |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return float |
|
54 | + */ |
|
55 | + public function grand_total() |
|
56 | + { |
|
57 | + return $this->_grand_total; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return int |
|
64 | + */ |
|
65 | + public function total_items() |
|
66 | + { |
|
67 | + return $this->_total_items; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @param EE_Line_Item $line_item |
|
74 | + * @param array $options |
|
75 | + * @param EE_Line_Item $parent_line_item |
|
76 | + * @return mixed |
|
77 | + * @throws EE_Error |
|
78 | + */ |
|
79 | + public function display_line_item( |
|
80 | + EE_Line_Item $line_item, |
|
81 | + $options = array(), |
|
82 | + EE_Line_Item $parent_line_item = null |
|
83 | + ) { |
|
84 | + $html = ''; |
|
85 | + // set some default options and merge with incoming |
|
86 | + $default_options = array( |
|
87 | + 'show_desc' => true, // true false |
|
88 | + 'odd' => false, |
|
89 | + ); |
|
90 | + $options = array_merge($default_options, (array) $options); |
|
91 | + switch ($line_item->type()) { |
|
92 | + case EEM_Line_Item::type_line_item: |
|
93 | + $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
94 | + if ($line_item->OBJ_type() === 'Ticket') { |
|
95 | + // item row |
|
96 | + $html .= $this->_ticket_row($line_item, $options); |
|
97 | + } else { |
|
98 | + // item row |
|
99 | + $html .= $this->_item_row($line_item, $options); |
|
100 | + } |
|
101 | + if (apply_filters( |
|
102 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
103 | + true |
|
104 | + ) |
|
105 | + ) { |
|
106 | + // got any kids? |
|
107 | + foreach ($line_item->children() as $child_line_item) { |
|
108 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
109 | + } |
|
110 | + } |
|
111 | + break; |
|
112 | + case EEM_Line_Item::type_sub_line_item: |
|
113 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
114 | + break; |
|
115 | + case EEM_Line_Item::type_sub_total: |
|
116 | + static $sub_total = 0; |
|
117 | + $event_sub_total = 0; |
|
118 | + $text = esc_html__('Sub-Total', 'event_espresso'); |
|
119 | + if ($line_item->OBJ_type() === 'Event') { |
|
120 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
121 | + if (! isset($this->_events[ $options['event_id'] ])) { |
|
122 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
123 | + // if event has default reg status of Not Approved, then don't display info on it |
|
124 | + if ($event instanceof EE_Event |
|
125 | + && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
126 | + ) { |
|
127 | + $display_event = false; |
|
128 | + // unless there are registrations for it that are returning to pay |
|
129 | + if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
130 | + foreach ($options['registrations'] as $registration) { |
|
131 | + if (! $registration instanceof EE_Registration) { |
|
132 | + continue; |
|
133 | + } |
|
134 | + $display_event = $registration->event_ID() === $options['event_id'] |
|
135 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
136 | + ? true |
|
137 | + : $display_event; |
|
138 | + } |
|
139 | + } |
|
140 | + if (! $display_event) { |
|
141 | + return ''; |
|
142 | + } |
|
143 | + } |
|
144 | + $this->_events[ $options['event_id'] ] = 0; |
|
145 | + $html .= $this->_event_row($line_item); |
|
146 | + $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
147 | + } |
|
148 | + } |
|
149 | + $child_line_items = $line_item->children(); |
|
150 | + // loop thru children |
|
151 | + foreach ($child_line_items as $child_line_item) { |
|
152 | + // recursively feed children back into this method |
|
153 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
154 | + } |
|
155 | + $event_sub_total += isset($options['event_id']) ? $this->_events[ $options['event_id'] ] : 0; |
|
156 | + $sub_total += $event_sub_total; |
|
157 | + if (( |
|
158 | + // event subtotals |
|
159 | + $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
160 | + ) |
|
161 | + || ( |
|
162 | + // pre-tax subtotals |
|
163 | + $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
164 | + ) |
|
165 | + ) { |
|
166 | + $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
167 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
168 | + } |
|
169 | + break; |
|
170 | + case EEM_Line_Item::type_tax: |
|
171 | + if ($this->_show_taxes) { |
|
172 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
173 | + } |
|
174 | + break; |
|
175 | + case EEM_Line_Item::type_tax_sub_total: |
|
176 | + if ($this->_show_taxes) { |
|
177 | + $child_line_items = $line_item->children(); |
|
178 | + // loop thru children |
|
179 | + foreach ($child_line_items as $child_line_item) { |
|
180 | + // recursively feed children back into this method |
|
181 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
182 | + } |
|
183 | + if (count($child_line_items) > 1) { |
|
184 | + $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
185 | + } |
|
186 | + } |
|
187 | + break; |
|
188 | + case EEM_Line_Item::type_total: |
|
189 | + // get all child line items |
|
190 | + $children = $line_item->children(); |
|
191 | + // loop thru all non-tax child line items |
|
192 | + foreach ($children as $child_line_item) { |
|
193 | + if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
194 | + // recursively feed children back into this method |
|
195 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
196 | + } |
|
197 | + } |
|
198 | + // now loop thru tax child line items |
|
199 | + foreach ($children as $child_line_item) { |
|
200 | + if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
201 | + // recursively feed children back into this method |
|
202 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | + } |
|
204 | + } |
|
205 | + $html .= $this->_taxes_html; |
|
206 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
207 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
208 | + break; |
|
209 | + } |
|
210 | + return $html; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
217 | + * |
|
218 | + * @param EE_Line_Item $line_item |
|
219 | + * @return mixed |
|
220 | + */ |
|
221 | + private function _event_row(EE_Line_Item $line_item) |
|
222 | + { |
|
223 | + // start of row |
|
224 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
225 | + // event name td |
|
226 | + $html .= EEH_HTML::td( |
|
227 | + EEH_HTML::strong($line_item->name()), |
|
228 | + '', |
|
229 | + 'event-header', |
|
230 | + '', |
|
231 | + ' colspan="4"' |
|
232 | + ); |
|
233 | + // end of row |
|
234 | + $html .= EEH_HTML::trx(); |
|
235 | + return $html; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * _ticket_row |
|
242 | + * |
|
243 | + * @param EE_Line_Item $line_item |
|
244 | + * @param array $options |
|
245 | + * @return mixed |
|
246 | + * @throws EE_Error |
|
247 | + */ |
|
248 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
249 | + { |
|
250 | + // start of row |
|
251 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
252 | + $html = EEH_HTML::tr('', '', $row_class); |
|
253 | + // name && desc |
|
254 | + $name_and_desc = apply_filters( |
|
255 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
256 | + $line_item->name(), |
|
257 | + $line_item |
|
258 | + ); |
|
259 | + $name_and_desc .= apply_filters( |
|
260 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
261 | + ( |
|
262 | + $options['show_desc'] |
|
263 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
264 | + : '' |
|
265 | + ), |
|
266 | + $line_item, |
|
267 | + $options |
|
268 | + ); |
|
269 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
270 | + $name_and_desc = apply_filters( |
|
271 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__name_and_desc', |
|
272 | + $name_and_desc, |
|
273 | + $line_item, |
|
274 | + $options |
|
275 | + ); |
|
276 | + |
|
277 | + // name td |
|
278 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
279 | + $name_and_desc, |
|
280 | + '', |
|
281 | + 'item_l' |
|
282 | + ); |
|
283 | + // price td |
|
284 | + $price = apply_filters( |
|
285 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__price', |
|
286 | + $line_item->unit_price_no_code(), |
|
287 | + $line_item |
|
288 | + ); |
|
289 | + $html .= EEH_HTML::td($price, '', 'item_c jst-rght'); |
|
290 | + // quantity td |
|
291 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
292 | + $this->_total_items += $line_item->quantity(); |
|
293 | + // determine total for line item |
|
294 | + $total = apply_filters( |
|
295 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___ticket_row__total', |
|
296 | + $line_item->total(), |
|
297 | + $line_item |
|
298 | + ); |
|
299 | + $this->_events[ $options['event_id'] ] += $total; |
|
300 | + // total td |
|
301 | + $html .= EEH_HTML::td( |
|
302 | + EEH_Template::format_currency($total, false, false), |
|
303 | + '', |
|
304 | + 'item_r jst-rght' |
|
305 | + ); |
|
306 | + // end of row |
|
307 | + $html .= EEH_HTML::trx(); |
|
308 | + return $html; |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * _item_row |
|
315 | + * |
|
316 | + * @param EE_Line_Item $line_item |
|
317 | + * @param array $options |
|
318 | + * @return mixed |
|
319 | + * @throws EE_Error |
|
320 | + */ |
|
321 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
322 | + { |
|
323 | + // start of row |
|
324 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
325 | + $html = EEH_HTML::tr('', '', $row_class); |
|
326 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
327 | + // name && desc |
|
328 | + $name_and_desc = apply_filters( |
|
329 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
330 | + $obj_name . $line_item->name(), |
|
331 | + $line_item |
|
332 | + ); |
|
333 | + $name_and_desc .= apply_filters( |
|
334 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
335 | + ( |
|
336 | + $options['show_desc'] |
|
337 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
338 | + : '' |
|
339 | + ), |
|
340 | + $line_item, |
|
341 | + $options |
|
342 | + ); |
|
343 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
344 | + $name_and_desc = apply_filters( |
|
345 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___item_row__name_and_desc', |
|
346 | + $name_and_desc, |
|
347 | + $line_item, |
|
348 | + $options |
|
349 | + ); |
|
350 | + |
|
351 | + // name td |
|
352 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
353 | + // price td |
|
354 | + if ($line_item->is_percent()) { |
|
355 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
356 | + } else { |
|
357 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
358 | + } |
|
359 | + // quantity td |
|
360 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
361 | + // $total = $line_item->total() * $line_item->quantity(); |
|
362 | + $total = $line_item->total(); |
|
363 | + if (isset($options['event_id'], $this->_events[ $options['event_id'] ])) { |
|
364 | + $this->_events[ $options['event_id'] ] += $total; |
|
365 | + } |
|
366 | + // total td |
|
367 | + $html .= EEH_HTML::td( |
|
368 | + EEH_Template::format_currency($total, false, false), |
|
369 | + '', |
|
370 | + 'item_r jst-rght' |
|
371 | + ); |
|
372 | + // end of row |
|
373 | + $html .= EEH_HTML::trx(); |
|
374 | + return $html; |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * _sub_item_row |
|
381 | + * |
|
382 | + * @param EE_Line_Item $line_item |
|
383 | + * @param array $options |
|
384 | + * @param EE_Line_Item $parent_line_item |
|
385 | + * @return mixed |
|
386 | + * @throws EE_Error |
|
387 | + */ |
|
388 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
389 | + { |
|
390 | + if ($parent_line_item instanceof EE_Line_Item |
|
391 | + && $line_item->children() === array() |
|
392 | + && $line_item->name() === $parent_line_item->name() |
|
393 | + && apply_filters( |
|
394 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__hide_main_sub_line_item', |
|
395 | + true |
|
396 | + ) |
|
397 | + ) { |
|
398 | + return ''; |
|
399 | + } |
|
400 | + // start of row |
|
401 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
402 | + // name && desc |
|
403 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
404 | + . $line_item->name(); |
|
405 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
406 | + . $line_item->desc() |
|
407 | + . '</span>' : ''; |
|
408 | + // name td |
|
409 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
410 | + $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
411 | + // discount/surcharge td |
|
412 | + if ($line_item->is_percent()) { |
|
413 | + $html .= EEH_HTML::td( |
|
414 | + EEH_Template::format_currency( |
|
415 | + $line_item->total() / $qty, |
|
416 | + false, |
|
417 | + false |
|
418 | + ), |
|
419 | + '', |
|
420 | + 'item_c jst-rght' |
|
421 | + ); |
|
422 | + } else { |
|
423 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
424 | + } |
|
425 | + // no quantity td |
|
426 | + $html .= EEH_HTML::td(); |
|
427 | + // no total td |
|
428 | + $html .= EEH_HTML::td(); |
|
429 | + // end of row |
|
430 | + $html .= EEH_HTML::trx(); |
|
431 | + $html = apply_filters( |
|
432 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy___sub_item_row__html', |
|
433 | + $html, |
|
434 | + $line_item, |
|
435 | + $options, |
|
436 | + $parent_line_item |
|
437 | + ); |
|
438 | + return $html; |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * _tax_row |
|
445 | + * |
|
446 | + * @param EE_Line_Item $line_item |
|
447 | + * @param array $options |
|
448 | + * @return mixed |
|
449 | + * @throws EE_Error |
|
450 | + */ |
|
451 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
452 | + { |
|
453 | + // start of row |
|
454 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
455 | + // name && desc |
|
456 | + $name_and_desc = $line_item->name(); |
|
457 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
458 | + . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
459 | + $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
460 | + // name td |
|
461 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
462 | + $name_and_desc, |
|
463 | + '', |
|
464 | + 'item_l sub-item' |
|
465 | + ); |
|
466 | + // percent td |
|
467 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
468 | + // empty td (price) |
|
469 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
470 | + // total td |
|
471 | + $html .= EEH_HTML::td( |
|
472 | + EEH_Template::format_currency( |
|
473 | + $line_item->total(), |
|
474 | + false, |
|
475 | + false |
|
476 | + ), |
|
477 | + '', |
|
478 | + 'item_r jst-rght' |
|
479 | + ); |
|
480 | + // end of row |
|
481 | + $html .= EEH_HTML::trx(); |
|
482 | + return $html; |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * _total_row |
|
489 | + * |
|
490 | + * @param EE_Line_Item $line_item |
|
491 | + * @param string $text |
|
492 | + * @return mixed |
|
493 | + * @throws EE_Error |
|
494 | + */ |
|
495 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
496 | + { |
|
497 | + $html = ''; |
|
498 | + if ($line_item->total()) { |
|
499 | + // start of row |
|
500 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
501 | + // total td |
|
502 | + $html .= EEH_HTML::td( |
|
503 | + $text, |
|
504 | + '', |
|
505 | + 'total_currency total jst-rght', |
|
506 | + '', |
|
507 | + ' colspan="2"' |
|
508 | + ); |
|
509 | + // empty td (price) |
|
510 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
511 | + // total td |
|
512 | + $html .= EEH_HTML::td( |
|
513 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
514 | + '', |
|
515 | + 'total jst-rght' |
|
516 | + ); |
|
517 | + // end of row |
|
518 | + $html .= EEH_HTML::trx(); |
|
519 | + } |
|
520 | + return $html; |
|
521 | + } |
|
522 | + |
|
523 | + |
|
524 | + |
|
525 | + /** |
|
526 | + * _total_row |
|
527 | + * |
|
528 | + * @param EE_Line_Item $line_item |
|
529 | + * @param string $text |
|
530 | + * @param array $options |
|
531 | + * @return mixed |
|
532 | + * @throws EE_Error |
|
533 | + */ |
|
534 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
535 | + { |
|
536 | + $html = ''; |
|
537 | + if ($line_item->total()) { |
|
538 | + // start of row |
|
539 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
540 | + // total td |
|
541 | + $html .= EEH_HTML::td( |
|
542 | + $text, |
|
543 | + '', |
|
544 | + 'total_currency total jst-rght', |
|
545 | + '', |
|
546 | + ' colspan="3"' |
|
547 | + ); |
|
548 | + // total td |
|
549 | + $html .= EEH_HTML::td( |
|
550 | + EEH_Template::format_currency($options['sub_total'], false, false), |
|
551 | + '', |
|
552 | + 'total jst-rght' |
|
553 | + ); |
|
554 | + // end of row |
|
555 | + $html .= EEH_HTML::trx(); |
|
556 | + } |
|
557 | + return $html; |
|
558 | + } |
|
559 | + |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * _total_row |
|
564 | + * |
|
565 | + * @param EE_Line_Item $line_item |
|
566 | + * @param string $text |
|
567 | + * @return mixed |
|
568 | + * @throws EE_Error |
|
569 | + */ |
|
570 | + private function _total_row(EE_Line_Item $line_item, $text = '') |
|
571 | + { |
|
572 | + // start of row |
|
573 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
574 | + // total td |
|
575 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
576 | + // total td |
|
577 | + $html .= EEH_HTML::td( |
|
578 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
579 | + '', |
|
580 | + 'total jst-rght' |
|
581 | + ); |
|
582 | + // end of row |
|
583 | + $html .= EEH_HTML::trx(); |
|
584 | + return $html; |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * _payments_and_amount_owing_rows |
|
591 | + * |
|
592 | + * @param EE_Line_Item $line_item |
|
593 | + * @param array $options |
|
594 | + * @return mixed |
|
595 | + * @throws EE_Error |
|
596 | + */ |
|
597 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
598 | + { |
|
599 | + $html = ''; |
|
600 | + $owing = $line_item->total(); |
|
601 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
602 | + if ($transaction instanceof EE_Transaction) { |
|
603 | + $registration_payments = array(); |
|
604 | + $registrations = ! empty($options['registrations']) |
|
605 | + ? $options['registrations'] |
|
606 | + : $transaction->registrations(); |
|
607 | + foreach ($registrations as $registration) { |
|
608 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
609 | + $registration_payments += $registration->registration_payments(); |
|
610 | + } |
|
611 | + } |
|
612 | + if (! empty($registration_payments)) { |
|
613 | + foreach ($registration_payments as $registration_payment) { |
|
614 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
615 | + $owing -= $registration_payment->amount(); |
|
616 | + $payment = $registration_payment->payment(); |
|
617 | + $payment_desc = ''; |
|
618 | + if ($payment instanceof EE_Payment) { |
|
619 | + $payment_desc = sprintf( |
|
620 | + esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
621 | + $payment->txn_id_chq_nmbr() !== '' |
|
622 | + ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
623 | + : '', |
|
624 | + $payment->timestamp() |
|
625 | + ); |
|
626 | + } |
|
627 | + // start of row |
|
628 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
629 | + // payment desc |
|
630 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
631 | + // total td |
|
632 | + $html .= EEH_HTML::td( |
|
633 | + EEH_Template::format_currency( |
|
634 | + $registration_payment->amount(), |
|
635 | + false, |
|
636 | + false |
|
637 | + ), |
|
638 | + '', |
|
639 | + 'total jst-rght' |
|
640 | + ); |
|
641 | + // end of row |
|
642 | + $html .= EEH_HTML::trx(); |
|
643 | + } |
|
644 | + } |
|
645 | + if ($line_item->total()) { |
|
646 | + // start of row |
|
647 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
648 | + // total td |
|
649 | + $html .= EEH_HTML::td( |
|
650 | + esc_html__('Amount Owing', 'event_espresso'), |
|
651 | + '', |
|
652 | + 'total_currency total jst-rght', |
|
653 | + '', |
|
654 | + ' colspan="3"' |
|
655 | + ); |
|
656 | + // total td |
|
657 | + $html .= EEH_HTML::td( |
|
658 | + EEH_Template::format_currency($owing, false, false), |
|
659 | + '', |
|
660 | + 'total jst-rght' |
|
661 | + ); |
|
662 | + // end of row |
|
663 | + $html .= EEH_HTML::trx(); |
|
664 | + } |
|
665 | + } |
|
666 | + } |
|
667 | + $this->_grand_total = $owing; |
|
668 | + return $html; |
|
669 | + } |
|
670 | 670 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
260 | 260 | 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
261 | 261 | 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
262 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
262 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | 263 | 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
264 | 264 | ); |
265 | 265 | $this->_deregister_wp_hooks(); |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | $invoice_name = $this->_subject; |
324 | 324 | |
325 | 325 | // only load dompdf if nobody else has yet... |
326 | - if (! class_exists('Dompdf\Dompdf')) { |
|
327 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
326 | + if ( ! class_exists('Dompdf\Dompdf')) { |
|
327 | + require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php'); |
|
328 | 328 | Dompdf\Autoloader::register(); |
329 | 329 | } |
330 | 330 | $options = new Dompdf\Options(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $dompdf->loadHtml($content); |
337 | 337 | $dompdf->render(); |
338 | 338 | // forcing the browser to open a download dialog. |
339 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
339 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => true)); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 |
@@ -15,349 +15,349 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * The following are the properties that this messenger requires for generating pdf |
|
20 | - */ |
|
21 | - |
|
22 | - /** |
|
23 | - * This is the pdf body generated by the template via the message type. |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_content; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_subject; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @return EE_Pdf_messenger |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - // set properties |
|
44 | - $this->name = 'pdf'; |
|
45 | - $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
46 | - $this->label = array( |
|
47 | - 'singular' => __('PDF', 'event_espresso'), |
|
48 | - 'plural' => __('PDFs', 'event_espresso') |
|
49 | - ); |
|
50 | - $this->activate_on_install = true; |
|
51 | - |
|
52 | - parent::__construct(); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * PDF Messenger desires execution immediately. |
|
58 | - * @see parent::send_now() for documentation. |
|
59 | - * @since 4.9.0 |
|
60 | - * @return bool |
|
61 | - */ |
|
62 | - public function send_now() |
|
63 | - { |
|
64 | - return true; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * HTML Messenger allows an empty to field. |
|
70 | - * @see parent::allow_empty_to_field() for documentation |
|
71 | - * @since 4.9.0 |
|
72 | - * @return bool |
|
73 | - */ |
|
74 | - public function allow_empty_to_field() |
|
75 | - { |
|
76 | - return true; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @see abstract declaration in EE_messenger for details. |
|
82 | - */ |
|
83 | - protected function _set_admin_pages() |
|
84 | - { |
|
85 | - $this->admin_registered_pages = array('events_edit' => false); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @see abstract declaration in EE_messenger for details. |
|
91 | - */ |
|
92 | - protected function _set_valid_shortcodes() |
|
93 | - { |
|
94 | - $this->_valid_shortcodes = array(); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @see abstract declaration in EE_messenger for details. |
|
100 | - */ |
|
101 | - protected function _set_validator_config() |
|
102 | - { |
|
103 | - $this->_validator_config = array( |
|
104 | - 'subject' => array( |
|
105 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
106 | - ), |
|
107 | - 'content' => array( |
|
108 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
109 | - ), |
|
110 | - 'attendee_list' => array( |
|
111 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
112 | - 'required' => array('[ATTENDEE_LIST]') |
|
113 | - ), |
|
114 | - 'event_list' => array( |
|
115 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
116 | - 'required' => array('[EVENT_LIST]') |
|
117 | - ), |
|
118 | - 'ticket_list' => array( |
|
119 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
120 | - 'required' => array('[TICKET_LIST]') |
|
121 | - ), |
|
122 | - 'datetime_list' => array( |
|
123 | - 'shortcodes' => array('datetime'), |
|
124 | - 'required' => array('[DATETIME_LIST]') |
|
125 | - ), |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
132 | - * |
|
133 | - * @return void. |
|
134 | - */ |
|
135 | - public function enqueue_scripts_styles() |
|
136 | - { |
|
137 | - parent::enqueue_scripts_styles(); |
|
138 | - do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * _set_template_fields |
|
144 | - * This sets up the fields that a messenger requires for the message to go out. |
|
145 | - * |
|
146 | - * @access protected |
|
147 | - * @return void |
|
148 | - */ |
|
149 | - protected function _set_template_fields() |
|
150 | - { |
|
151 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
152 | - $this->_template_fields = array( |
|
153 | - 'subject' => array( |
|
154 | - 'input' => 'text', |
|
155 | - 'label' => __('Page Title', 'event_espresso'), |
|
156 | - 'type' => 'string', |
|
157 | - 'required' => true, |
|
158 | - 'validation' => true, |
|
159 | - 'css_class' => 'large-text', |
|
160 | - 'format' => '%s' |
|
161 | - ), |
|
162 | - 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
163 | - 'extra' => array( |
|
164 | - 'content' => array( |
|
165 | - 'main' => array( |
|
166 | - 'input' => 'wp_editor', |
|
167 | - 'label' => __('Main Content', 'event_espresso'), |
|
168 | - 'type' => 'string', |
|
169 | - 'required' => true, |
|
170 | - 'validation' => true, |
|
171 | - 'format' => '%s', |
|
172 | - 'rows' => '15' |
|
173 | - ), |
|
174 | - 'event_list' => array( |
|
175 | - 'input' => 'wp_editor', |
|
176 | - 'label' => '[EVENT_LIST]', |
|
177 | - 'type' => 'string', |
|
178 | - 'required' => true, |
|
179 | - 'validation' => true, |
|
180 | - 'format' => '%s', |
|
181 | - 'rows' => '15', |
|
182 | - 'shortcodes_required' => array('[EVENT_LIST]') |
|
183 | - ), |
|
184 | - 'attendee_list' => array( |
|
185 | - 'input' => 'textarea', |
|
186 | - 'label' => '[ATTENDEE_LIST]', |
|
187 | - 'type' => 'string', |
|
188 | - 'required' => true, |
|
189 | - 'validation' => true, |
|
190 | - 'format' => '%s', |
|
191 | - 'css_class' => 'large-text', |
|
192 | - 'rows' => '5', |
|
193 | - 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
194 | - ), |
|
195 | - 'ticket_list' => array( |
|
196 | - 'input' => 'textarea', |
|
197 | - 'label' => '[TICKET_LIST]', |
|
198 | - 'type' => 'string', |
|
199 | - 'required' => true, |
|
200 | - 'validation' => true, |
|
201 | - 'format' => '%s', |
|
202 | - 'css_class' => 'large-text', |
|
203 | - 'rows' => '10', |
|
204 | - 'shortcodes_required' => array('[TICKET_LIST]') |
|
205 | - ), |
|
206 | - 'datetime_list' => array( |
|
207 | - 'input' => 'textarea', |
|
208 | - 'label' => '[DATETIME_LIST]', |
|
209 | - 'type' => 'string', |
|
210 | - 'required' => true, |
|
211 | - 'validation' => true, |
|
212 | - 'format' => '%s', |
|
213 | - 'css_class' => 'large-text', |
|
214 | - 'rows' => '10', |
|
215 | - 'shortcodes_required' => array('[DATETIME_LIST]') |
|
216 | - ) |
|
217 | - ) |
|
218 | - ) |
|
219 | - ); |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * @see definition of this method in parent |
|
225 | - * |
|
226 | - * @since 4.5.0 |
|
227 | - * |
|
228 | - */ |
|
229 | - protected function _set_default_message_types() |
|
230 | - { |
|
231 | - // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
232 | - $this->_default_message_types = array(); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * @see definition of this method in parent |
|
238 | - * |
|
239 | - * @since 4.5.0 |
|
240 | - */ |
|
241 | - protected function _set_valid_message_types() |
|
242 | - { |
|
243 | - $this->_valid_message_types = array(); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Generates html version of the message content and then sends it to the pdf generator. |
|
249 | - * |
|
250 | - * |
|
251 | - * @since 4.5.0 |
|
252 | - * |
|
253 | - * @return string. |
|
254 | - */ |
|
255 | - protected function _send_message() |
|
256 | - { |
|
257 | - $this->_template_args = array( |
|
258 | - 'page_title' => $this->_subject, |
|
259 | - 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
260 | - 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
261 | - 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
262 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | - 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
264 | - ); |
|
265 | - $this->_deregister_wp_hooks(); |
|
266 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
267 | - $content = $this->_get_main_template(); |
|
18 | + /** |
|
19 | + * The following are the properties that this messenger requires for generating pdf |
|
20 | + */ |
|
21 | + |
|
22 | + /** |
|
23 | + * This is the pdf body generated by the template via the message type. |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_content; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_subject; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @return EE_Pdf_messenger |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + // set properties |
|
44 | + $this->name = 'pdf'; |
|
45 | + $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
46 | + $this->label = array( |
|
47 | + 'singular' => __('PDF', 'event_espresso'), |
|
48 | + 'plural' => __('PDFs', 'event_espresso') |
|
49 | + ); |
|
50 | + $this->activate_on_install = true; |
|
51 | + |
|
52 | + parent::__construct(); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * PDF Messenger desires execution immediately. |
|
58 | + * @see parent::send_now() for documentation. |
|
59 | + * @since 4.9.0 |
|
60 | + * @return bool |
|
61 | + */ |
|
62 | + public function send_now() |
|
63 | + { |
|
64 | + return true; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * HTML Messenger allows an empty to field. |
|
70 | + * @see parent::allow_empty_to_field() for documentation |
|
71 | + * @since 4.9.0 |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | + public function allow_empty_to_field() |
|
75 | + { |
|
76 | + return true; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @see abstract declaration in EE_messenger for details. |
|
82 | + */ |
|
83 | + protected function _set_admin_pages() |
|
84 | + { |
|
85 | + $this->admin_registered_pages = array('events_edit' => false); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @see abstract declaration in EE_messenger for details. |
|
91 | + */ |
|
92 | + protected function _set_valid_shortcodes() |
|
93 | + { |
|
94 | + $this->_valid_shortcodes = array(); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @see abstract declaration in EE_messenger for details. |
|
100 | + */ |
|
101 | + protected function _set_validator_config() |
|
102 | + { |
|
103 | + $this->_validator_config = array( |
|
104 | + 'subject' => array( |
|
105 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
106 | + ), |
|
107 | + 'content' => array( |
|
108 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
109 | + ), |
|
110 | + 'attendee_list' => array( |
|
111 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
112 | + 'required' => array('[ATTENDEE_LIST]') |
|
113 | + ), |
|
114 | + 'event_list' => array( |
|
115 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
116 | + 'required' => array('[EVENT_LIST]') |
|
117 | + ), |
|
118 | + 'ticket_list' => array( |
|
119 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
120 | + 'required' => array('[TICKET_LIST]') |
|
121 | + ), |
|
122 | + 'datetime_list' => array( |
|
123 | + 'shortcodes' => array('datetime'), |
|
124 | + 'required' => array('[DATETIME_LIST]') |
|
125 | + ), |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
132 | + * |
|
133 | + * @return void. |
|
134 | + */ |
|
135 | + public function enqueue_scripts_styles() |
|
136 | + { |
|
137 | + parent::enqueue_scripts_styles(); |
|
138 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * _set_template_fields |
|
144 | + * This sets up the fields that a messenger requires for the message to go out. |
|
145 | + * |
|
146 | + * @access protected |
|
147 | + * @return void |
|
148 | + */ |
|
149 | + protected function _set_template_fields() |
|
150 | + { |
|
151 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
152 | + $this->_template_fields = array( |
|
153 | + 'subject' => array( |
|
154 | + 'input' => 'text', |
|
155 | + 'label' => __('Page Title', 'event_espresso'), |
|
156 | + 'type' => 'string', |
|
157 | + 'required' => true, |
|
158 | + 'validation' => true, |
|
159 | + 'css_class' => 'large-text', |
|
160 | + 'format' => '%s' |
|
161 | + ), |
|
162 | + 'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
163 | + 'extra' => array( |
|
164 | + 'content' => array( |
|
165 | + 'main' => array( |
|
166 | + 'input' => 'wp_editor', |
|
167 | + 'label' => __('Main Content', 'event_espresso'), |
|
168 | + 'type' => 'string', |
|
169 | + 'required' => true, |
|
170 | + 'validation' => true, |
|
171 | + 'format' => '%s', |
|
172 | + 'rows' => '15' |
|
173 | + ), |
|
174 | + 'event_list' => array( |
|
175 | + 'input' => 'wp_editor', |
|
176 | + 'label' => '[EVENT_LIST]', |
|
177 | + 'type' => 'string', |
|
178 | + 'required' => true, |
|
179 | + 'validation' => true, |
|
180 | + 'format' => '%s', |
|
181 | + 'rows' => '15', |
|
182 | + 'shortcodes_required' => array('[EVENT_LIST]') |
|
183 | + ), |
|
184 | + 'attendee_list' => array( |
|
185 | + 'input' => 'textarea', |
|
186 | + 'label' => '[ATTENDEE_LIST]', |
|
187 | + 'type' => 'string', |
|
188 | + 'required' => true, |
|
189 | + 'validation' => true, |
|
190 | + 'format' => '%s', |
|
191 | + 'css_class' => 'large-text', |
|
192 | + 'rows' => '5', |
|
193 | + 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
194 | + ), |
|
195 | + 'ticket_list' => array( |
|
196 | + 'input' => 'textarea', |
|
197 | + 'label' => '[TICKET_LIST]', |
|
198 | + 'type' => 'string', |
|
199 | + 'required' => true, |
|
200 | + 'validation' => true, |
|
201 | + 'format' => '%s', |
|
202 | + 'css_class' => 'large-text', |
|
203 | + 'rows' => '10', |
|
204 | + 'shortcodes_required' => array('[TICKET_LIST]') |
|
205 | + ), |
|
206 | + 'datetime_list' => array( |
|
207 | + 'input' => 'textarea', |
|
208 | + 'label' => '[DATETIME_LIST]', |
|
209 | + 'type' => 'string', |
|
210 | + 'required' => true, |
|
211 | + 'validation' => true, |
|
212 | + 'format' => '%s', |
|
213 | + 'css_class' => 'large-text', |
|
214 | + 'rows' => '10', |
|
215 | + 'shortcodes_required' => array('[DATETIME_LIST]') |
|
216 | + ) |
|
217 | + ) |
|
218 | + ) |
|
219 | + ); |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * @see definition of this method in parent |
|
225 | + * |
|
226 | + * @since 4.5.0 |
|
227 | + * |
|
228 | + */ |
|
229 | + protected function _set_default_message_types() |
|
230 | + { |
|
231 | + // note currently PDF is only a secondary messenger so it never has any associated message types. |
|
232 | + $this->_default_message_types = array(); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * @see definition of this method in parent |
|
238 | + * |
|
239 | + * @since 4.5.0 |
|
240 | + */ |
|
241 | + protected function _set_valid_message_types() |
|
242 | + { |
|
243 | + $this->_valid_message_types = array(); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Generates html version of the message content and then sends it to the pdf generator. |
|
249 | + * |
|
250 | + * |
|
251 | + * @since 4.5.0 |
|
252 | + * |
|
253 | + * @return string. |
|
254 | + */ |
|
255 | + protected function _send_message() |
|
256 | + { |
|
257 | + $this->_template_args = array( |
|
258 | + 'page_title' => $this->_subject, |
|
259 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation), |
|
260 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation), |
|
261 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation), |
|
262 | + 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
263 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content) |
|
264 | + ); |
|
265 | + $this->_deregister_wp_hooks(); |
|
266 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
267 | + $content = $this->_get_main_template(); |
|
268 | 268 | // die( $content ); |
269 | - $this->_do_pdf($content); |
|
270 | - exit(0); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
276 | - * |
|
277 | - * @since 4.5.0 |
|
278 | - * |
|
279 | - * @return void |
|
280 | - */ |
|
281 | - protected function _deregister_wp_hooks() |
|
282 | - { |
|
283 | - remove_all_actions('wp_head'); |
|
284 | - remove_all_actions('wp_footer'); |
|
285 | - remove_all_actions('wp_print_footer_scripts'); |
|
286 | - remove_all_actions('wp_enqueue_scripts'); |
|
287 | - global $wp_scripts, $wp_styles; |
|
288 | - $wp_scripts = $wp_styles = array(); |
|
289 | - |
|
290 | - // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
291 | - add_action('wp_head', 'wp_enqueue_scripts'); |
|
292 | - add_action('wp_footer', 'wp_print_footer_scripts'); |
|
293 | - add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * Overwrite parent _get_main_template for pdf purposes. |
|
299 | - * |
|
300 | - * @since 4.5.0 |
|
301 | - * |
|
302 | - * @param bool $preview |
|
303 | - * @return string |
|
304 | - */ |
|
305 | - protected function _get_main_template($preview = false) |
|
306 | - { |
|
307 | - $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
308 | - // add message type to template_args |
|
309 | - $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
310 | - return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * This takes care of loading the dompdf library and generating the actual pdf |
|
316 | - * |
|
317 | - * @param string $content This is the generated html content being converted into a pdf. |
|
318 | - * |
|
319 | - * @return void |
|
320 | - */ |
|
321 | - protected function _do_pdf($content = '') |
|
322 | - { |
|
323 | - $invoice_name = $this->_subject; |
|
324 | - |
|
325 | - // only load dompdf if nobody else has yet... |
|
326 | - if (! class_exists('Dompdf\Dompdf')) { |
|
327 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
328 | - Dompdf\Autoloader::register(); |
|
329 | - } |
|
330 | - $options = new Dompdf\Options(); |
|
331 | - $options->set('isRemoteEnabled', true); |
|
332 | - $options->set('isJavascriptEnabled', false); |
|
333 | - if (defined('DOMPDF_FONT_DIR')) { |
|
334 | - $options->setFontDir(DOMPDF_FONT_DIR); |
|
335 | - $options->setFontCache(DOMPDF_FONT_DIR); |
|
336 | - } |
|
337 | - // Allow changing the paper size. |
|
338 | - if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
339 | - $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
340 | - } |
|
341 | - $dompdf = new Dompdf\Dompdf($options); |
|
342 | - // Remove all spaces between HTML tags |
|
343 | - $content = preg_replace('/>\s+</', '><', $content); |
|
344 | - $dompdf->loadHtml($content); |
|
345 | - $dompdf->render(); |
|
346 | - // forcing the browser to open a download dialog. |
|
347 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * @return string |
|
353 | - */ |
|
354 | - protected function _preview() |
|
355 | - { |
|
356 | - return $this->_send_message(); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - protected function _set_admin_settings_fields() |
|
361 | - { |
|
362 | - } |
|
269 | + $this->_do_pdf($content); |
|
270 | + exit(0); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
276 | + * |
|
277 | + * @since 4.5.0 |
|
278 | + * |
|
279 | + * @return void |
|
280 | + */ |
|
281 | + protected function _deregister_wp_hooks() |
|
282 | + { |
|
283 | + remove_all_actions('wp_head'); |
|
284 | + remove_all_actions('wp_footer'); |
|
285 | + remove_all_actions('wp_print_footer_scripts'); |
|
286 | + remove_all_actions('wp_enqueue_scripts'); |
|
287 | + global $wp_scripts, $wp_styles; |
|
288 | + $wp_scripts = $wp_styles = array(); |
|
289 | + |
|
290 | + // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
291 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
292 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
293 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * Overwrite parent _get_main_template for pdf purposes. |
|
299 | + * |
|
300 | + * @since 4.5.0 |
|
301 | + * |
|
302 | + * @param bool $preview |
|
303 | + * @return string |
|
304 | + */ |
|
305 | + protected function _get_main_template($preview = false) |
|
306 | + { |
|
307 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
308 | + // add message type to template_args |
|
309 | + $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
310 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * This takes care of loading the dompdf library and generating the actual pdf |
|
316 | + * |
|
317 | + * @param string $content This is the generated html content being converted into a pdf. |
|
318 | + * |
|
319 | + * @return void |
|
320 | + */ |
|
321 | + protected function _do_pdf($content = '') |
|
322 | + { |
|
323 | + $invoice_name = $this->_subject; |
|
324 | + |
|
325 | + // only load dompdf if nobody else has yet... |
|
326 | + if (! class_exists('Dompdf\Dompdf')) { |
|
327 | + require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
328 | + Dompdf\Autoloader::register(); |
|
329 | + } |
|
330 | + $options = new Dompdf\Options(); |
|
331 | + $options->set('isRemoteEnabled', true); |
|
332 | + $options->set('isJavascriptEnabled', false); |
|
333 | + if (defined('DOMPDF_FONT_DIR')) { |
|
334 | + $options->setFontDir(DOMPDF_FONT_DIR); |
|
335 | + $options->setFontCache(DOMPDF_FONT_DIR); |
|
336 | + } |
|
337 | + // Allow changing the paper size. |
|
338 | + if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
339 | + $options->set('defaultPaperSize', DOMPDF_DEFAULT_PAPER_SIZE); |
|
340 | + } |
|
341 | + $dompdf = new Dompdf\Dompdf($options); |
|
342 | + // Remove all spaces between HTML tags |
|
343 | + $content = preg_replace('/>\s+</', '><', $content); |
|
344 | + $dompdf->loadHtml($content); |
|
345 | + $dompdf->render(); |
|
346 | + // forcing the browser to open a download dialog. |
|
347 | + $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true)); |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * @return string |
|
353 | + */ |
|
354 | + protected function _preview() |
|
355 | + { |
|
356 | + return $this->_send_message(); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + protected function _set_admin_settings_fields() |
|
361 | + { |
|
362 | + } |
|
363 | 363 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | 7 => "union.css", |
84 | 84 | ); |
85 | 85 | // Get the CSS file |
86 | - if (isset($themes[ $theme_requested ])) { |
|
87 | - $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
86 | + if (isset($themes[$theme_requested])) { |
|
87 | + $template_args['invoice_css'] = $themes[$theme_requested]; |
|
88 | 88 | } else { |
89 | 89 | $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
90 | 90 | 'legacy_invoice_css', |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | ); |
94 | 94 | } |
95 | 95 | |
96 | - if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
97 | - $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
96 | + if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) { |
|
97 | + $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/'; |
|
98 | 98 | } else { |
99 | - $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
99 | + $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/'; |
|
100 | 100 | } |
101 | 101 | $primary_attendee = $this->transaction->primary_registration()->attendee(); |
102 | 102 | |
103 | 103 | $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
104 | 104 | $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty( |
105 | 105 | 'address_1' |
106 | - ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2'); |
|
106 | + ) : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2'); |
|
107 | 107 | $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
108 | 108 | $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
109 | 109 | $EE->CFG->organization->STA_ID |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | if ($template_args['amount_pd'] != $template_args['total_cost']) { |
150 | 150 | // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']); |
151 | 151 | $tax_items = $this->transaction->tax_items(); |
152 | - if (! empty($tax_items)) { |
|
152 | + if ( ! empty($tax_items)) { |
|
153 | 153 | foreach ($tax_items as $tax) { |
154 | 154 | $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
155 | 155 | } |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
184 | 184 | array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID())) |
185 | 185 | ); |
186 | - $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
186 | + $ticket_line_items_per_event[$event_id] = $line_items_for_this_event; |
|
187 | 187 | foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
188 | 188 | $ticket = $line_item->ticket(); |
189 | 189 | $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
190 | 190 | array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID())) |
191 | 191 | ); |
192 | - $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
192 | + $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket; |
|
193 | 193 | } |
194 | 194 | $venues_for_events = array_merge($venues_for_events, $event->venues()); |
195 | 195 | } |
@@ -219,21 +219,21 @@ discard block |
||
219 | 219 | // Get the HTML as an object |
220 | 220 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
221 | 221 | $template_header = EEH_Template::locate_template( |
222 | - $templates_relative_path . 'invoice_header.template.php', |
|
222 | + $templates_relative_path.'invoice_header.template.php', |
|
223 | 223 | $template_args, |
224 | 224 | true, |
225 | 225 | true |
226 | 226 | ); |
227 | 227 | if (isset($_GET['receipt'])) { |
228 | 228 | $template_body = EEH_Template::locate_template( |
229 | - $templates_relative_path . 'receipt_body.template.php', |
|
229 | + $templates_relative_path.'receipt_body.template.php', |
|
230 | 230 | $template_args, |
231 | 231 | true, |
232 | 232 | true |
233 | 233 | ); |
234 | 234 | } else { |
235 | 235 | $template_body = EEH_Template::locate_template( |
236 | - $templates_relative_path . 'invoice_body.template.php', |
|
236 | + $templates_relative_path.'invoice_body.template.php', |
|
237 | 237 | $template_args, |
238 | 238 | true, |
239 | 239 | true |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | |
244 | 244 | $template_footer = EEH_Template::locate_template( |
245 | - $templates_relative_path . 'invoice_footer.template.php', |
|
245 | + $templates_relative_path.'invoice_footer.template.php', |
|
246 | 246 | $template_args, |
247 | 247 | true, |
248 | 248 | true |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
258 | 258 | |
259 | 259 | // Check if debugging or mobile is set |
260 | - if (! empty($_REQUEST['html'])) { |
|
260 | + if ( ! empty($_REQUEST['html'])) { |
|
261 | 261 | echo $content; |
262 | 262 | exit(0); |
263 | 263 | } |
264 | - $invoice_name = $template_args['organization'] . ' ' . __( |
|
264 | + $invoice_name = $template_args['organization'].' '.__( |
|
265 | 265 | 'Invoice #', |
266 | 266 | 'event_espresso' |
267 | - ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name']; |
|
267 | + ).$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name']; |
|
268 | 268 | $invoice_name = str_replace(' ', '_', $invoice_name); |
269 | 269 | // Create the PDF |
270 | 270 | if (array_key_exists('html', $_GET)) { |
271 | 271 | echo $content; |
272 | 272 | } else { |
273 | 273 | // only load dompdf if nobody else has yet... |
274 | - if (! class_exists('Dompdf\Dompdf')) { |
|
275 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
274 | + if ( ! class_exists('Dompdf\Dompdf')) { |
|
275 | + require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php'); |
|
276 | 276 | Dompdf\Autoloader::register(); |
277 | 277 | } |
278 | 278 | $options = new Dompdf\Options(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $dompdf = new Dompdf\Dompdf($options); |
282 | 282 | $dompdf->loadHtml($content); |
283 | 283 | $dompdf->render(); |
284 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download)); |
|
284 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => $download)); |
|
285 | 285 | } |
286 | 286 | exit(0); |
287 | 287 | } |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | true, |
320 | 320 | $EE->CFG->organization->logo_url |
321 | 321 | ); |
322 | - if (! empty($invoice_logo_url)) { |
|
322 | + if ( ! empty($invoice_logo_url)) { |
|
323 | 323 | $image_size = getimagesize($invoice_logo_url); |
324 | - $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
324 | + $invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> '; |
|
325 | 325 | } else { |
326 | 326 | $invoice_logo_image = ''; |
327 | 327 | } |
@@ -354,14 +354,14 @@ discard block |
||
354 | 354 | $this->registration->reg_code(), |
355 | 355 | $this->transaction->ID(), |
356 | 356 | $primary_attendee->full_name(), |
357 | - (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
358 | - : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
357 | + (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
358 | + : EE_GATEWAYS_URL.'Invoice/lib/templates/', |
|
359 | 359 | $this->registration->invoice_url(), |
360 | 360 | // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
361 | 361 | $invoice_logo_image, |
362 | 362 | empty($EE->CFG->organization->address_2) |
363 | 363 | ? $EE->CFG->organization->get_pretty('address_1') |
364 | - : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
364 | + : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty( |
|
365 | 365 | 'address_2' |
366 | 366 | ), |
367 | 367 | $EE->CFG->organization->get_pretty('city'), |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | $find = array(' '); |
399 | 399 | $replace = array('-'); |
400 | 400 | $row_id = strtolower(str_replace($find, $replace, $text)); |
401 | - $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
402 | - $html .= '<td class="item_r">' . $text . '</td>'; |
|
403 | - $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
401 | + $html .= '<tr id="'.$row_id.'-tr"><td colspan="4"> </td>'; |
|
402 | + $html .= '<td class="item_r">'.$text.'</td>'; |
|
403 | + $html .= '<td class="item_r">'.$total_cost.'</td>'; |
|
404 | 404 | $html .= '</tr>'; |
405 | 405 | return $html; |
406 | 406 | } |
@@ -9,403 +9,403 @@ |
||
9 | 9 | class Invoice |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * |
|
14 | - * @var EE_Registration |
|
15 | - */ |
|
16 | - private $registration; |
|
17 | - /** |
|
18 | - * |
|
19 | - * @var EE_Transaction |
|
20 | - */ |
|
21 | - private $transaction; |
|
22 | - /** |
|
23 | - * |
|
24 | - * @var EE_Payment_Method |
|
25 | - */ |
|
26 | - private $invoice_payment_method; |
|
27 | - private $EE; |
|
12 | + /** |
|
13 | + * |
|
14 | + * @var EE_Registration |
|
15 | + */ |
|
16 | + private $registration; |
|
17 | + /** |
|
18 | + * |
|
19 | + * @var EE_Transaction |
|
20 | + */ |
|
21 | + private $transaction; |
|
22 | + /** |
|
23 | + * |
|
24 | + * @var EE_Payment_Method |
|
25 | + */ |
|
26 | + private $invoice_payment_method; |
|
27 | + private $EE; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Invoice constructor. |
|
32 | - * |
|
33 | - * @deprecated 4.9.13 |
|
34 | - * @param int $url_link |
|
35 | - */ |
|
36 | - public function __construct($url_link = 0) |
|
37 | - { |
|
38 | - EE_Error::doing_it_wrong( |
|
39 | - __CLASS__, |
|
40 | - esc_html__( |
|
41 | - 'This class has been deprecated and replaced by the new Messages library.', |
|
42 | - 'event_espresso' |
|
43 | - ), |
|
44 | - '4.9.12', |
|
45 | - '5.0.0' |
|
46 | - ); |
|
47 | - if ($this->registration = EE_Registry::instance()->load_model( |
|
48 | - 'Registration' |
|
49 | - )->get_registration_for_reg_url_link($url_link)) { |
|
50 | - $this->transaction = $this->registration->transaction(); |
|
51 | - // get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE); |
|
52 | - $payment_settings = EE_Config::instance()->gateway->payment_settings; |
|
53 | - $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice'); |
|
54 | - } else { |
|
55 | - EE_Error::add_error( |
|
56 | - __( |
|
57 | - 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', |
|
58 | - 'event_espresso' |
|
59 | - ), |
|
60 | - __FILE__, |
|
61 | - __FUNCTION__, |
|
62 | - __LINE__ |
|
63 | - ); |
|
64 | - } |
|
65 | - } |
|
30 | + /** |
|
31 | + * Invoice constructor. |
|
32 | + * |
|
33 | + * @deprecated 4.9.13 |
|
34 | + * @param int $url_link |
|
35 | + */ |
|
36 | + public function __construct($url_link = 0) |
|
37 | + { |
|
38 | + EE_Error::doing_it_wrong( |
|
39 | + __CLASS__, |
|
40 | + esc_html__( |
|
41 | + 'This class has been deprecated and replaced by the new Messages library.', |
|
42 | + 'event_espresso' |
|
43 | + ), |
|
44 | + '4.9.12', |
|
45 | + '5.0.0' |
|
46 | + ); |
|
47 | + if ($this->registration = EE_Registry::instance()->load_model( |
|
48 | + 'Registration' |
|
49 | + )->get_registration_for_reg_url_link($url_link)) { |
|
50 | + $this->transaction = $this->registration->transaction(); |
|
51 | + // get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE); |
|
52 | + $payment_settings = EE_Config::instance()->gateway->payment_settings; |
|
53 | + $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice'); |
|
54 | + } else { |
|
55 | + EE_Error::add_error( |
|
56 | + __( |
|
57 | + 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', |
|
58 | + 'event_espresso' |
|
59 | + ), |
|
60 | + __FILE__, |
|
61 | + __FUNCTION__, |
|
62 | + __LINE__ |
|
63 | + ); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - public function send_invoice($download = false) |
|
68 | - { |
|
69 | - $template_args = array(); |
|
70 | - $EE = EE_Registry::instance(); |
|
67 | + public function send_invoice($download = false) |
|
68 | + { |
|
69 | + $template_args = array(); |
|
70 | + $EE = EE_Registry::instance(); |
|
71 | 71 | |
72 | - // allow the request to override the default theme defined in the invoice settings |
|
73 | - $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint( |
|
74 | - $_REQUEST['theme'] |
|
75 | - ) : null; |
|
76 | - $themes = array( |
|
77 | - 1 => "simple.css", |
|
78 | - 2 => "bauhaus.css", |
|
79 | - 3 => "ejs.css", |
|
80 | - 4 => "horizon.css", |
|
81 | - 5 => "lola.css", |
|
82 | - 6 => "tranquility.css", |
|
83 | - 7 => "union.css", |
|
84 | - ); |
|
85 | - // Get the CSS file |
|
86 | - if (isset($themes[ $theme_requested ])) { |
|
87 | - $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
88 | - } else { |
|
89 | - $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
|
90 | - 'legacy_invoice_css', |
|
91 | - true, |
|
92 | - 'simple.css' |
|
93 | - ); |
|
94 | - } |
|
72 | + // allow the request to override the default theme defined in the invoice settings |
|
73 | + $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint( |
|
74 | + $_REQUEST['theme'] |
|
75 | + ) : null; |
|
76 | + $themes = array( |
|
77 | + 1 => "simple.css", |
|
78 | + 2 => "bauhaus.css", |
|
79 | + 3 => "ejs.css", |
|
80 | + 4 => "horizon.css", |
|
81 | + 5 => "lola.css", |
|
82 | + 6 => "tranquility.css", |
|
83 | + 7 => "union.css", |
|
84 | + ); |
|
85 | + // Get the CSS file |
|
86 | + if (isset($themes[ $theme_requested ])) { |
|
87 | + $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
88 | + } else { |
|
89 | + $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( |
|
90 | + 'legacy_invoice_css', |
|
91 | + true, |
|
92 | + 'simple.css' |
|
93 | + ); |
|
94 | + } |
|
95 | 95 | |
96 | - if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
97 | - $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
98 | - } else { |
|
99 | - $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
100 | - } |
|
101 | - $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
96 | + if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
97 | + $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
98 | + } else { |
|
99 | + $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
100 | + } |
|
101 | + $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
102 | 102 | |
103 | - $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
|
104 | - $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty( |
|
105 | - 'address_1' |
|
106 | - ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2'); |
|
107 | - $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
|
108 | - $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
109 | - $EE->CFG->organization->STA_ID |
|
110 | - ); |
|
111 | - $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID( |
|
112 | - $EE->CFG->organization->CNT_ISO |
|
113 | - ); |
|
114 | - $template_args['zip'] = $EE->CFG->organization->get_pretty('zip'); |
|
115 | - $template_args['email'] = $EE->CFG->organization->get_pretty('email'); |
|
103 | + $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
|
104 | + $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty( |
|
105 | + 'address_1' |
|
106 | + ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2'); |
|
107 | + $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
|
108 | + $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID( |
|
109 | + $EE->CFG->organization->STA_ID |
|
110 | + ); |
|
111 | + $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID( |
|
112 | + $EE->CFG->organization->CNT_ISO |
|
113 | + ); |
|
114 | + $template_args['zip'] = $EE->CFG->organization->get_pretty('zip'); |
|
115 | + $template_args['email'] = $EE->CFG->organization->get_pretty('email'); |
|
116 | 116 | |
117 | - $template_args['registration_code'] = $this->registration->reg_code(); |
|
118 | - $template_args['registration_date'] = $this->registration->date(); |
|
119 | - $template_args['name'] = $primary_attendee->full_name(); |
|
120 | - $template_args['attendee_address'] = $primary_attendee->address(); |
|
121 | - $template_args['attendee_address2'] = $primary_attendee->address2(); |
|
122 | - $template_args['attendee_city'] = $primary_attendee->city(); |
|
123 | - $attendee_state = $primary_attendee->state_obj(); |
|
124 | - if ($attendee_state) { |
|
125 | - $attendee_state_name = $attendee_state->name(); |
|
126 | - } else { |
|
127 | - $attendee_state_name = ''; |
|
128 | - } |
|
129 | - $template_args['attendee_state'] = $attendee_state_name; |
|
130 | - $template_args['attendee_zip'] = $primary_attendee->zip(); |
|
117 | + $template_args['registration_code'] = $this->registration->reg_code(); |
|
118 | + $template_args['registration_date'] = $this->registration->date(); |
|
119 | + $template_args['name'] = $primary_attendee->full_name(); |
|
120 | + $template_args['attendee_address'] = $primary_attendee->address(); |
|
121 | + $template_args['attendee_address2'] = $primary_attendee->address2(); |
|
122 | + $template_args['attendee_city'] = $primary_attendee->city(); |
|
123 | + $attendee_state = $primary_attendee->state_obj(); |
|
124 | + if ($attendee_state) { |
|
125 | + $attendee_state_name = $attendee_state->name(); |
|
126 | + } else { |
|
127 | + $attendee_state_name = ''; |
|
128 | + } |
|
129 | + $template_args['attendee_state'] = $attendee_state_name; |
|
130 | + $template_args['attendee_zip'] = $primary_attendee->zip(); |
|
131 | 131 | |
132 | - $template_args['ship_name'] = $template_args['name']; |
|
133 | - $template_args['ship_address'] = $template_args['attendee_address']; |
|
134 | - $template_args['ship_city'] = $template_args['attendee_city']; |
|
135 | - $template_args['ship_state'] = $template_args['attendee_state']; |
|
136 | - $template_args['ship_zip'] = $template_args['attendee_zip']; |
|
132 | + $template_args['ship_name'] = $template_args['name']; |
|
133 | + $template_args['ship_address'] = $template_args['attendee_address']; |
|
134 | + $template_args['ship_city'] = $template_args['attendee_city']; |
|
135 | + $template_args['ship_state'] = $template_args['attendee_state']; |
|
136 | + $template_args['ship_zip'] = $template_args['attendee_zip']; |
|
137 | 137 | |
138 | - $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', ''); |
|
139 | - $template_args['transaction'] = $this->transaction; |
|
140 | - $template_args['amount_pd'] = $this->transaction->paid(); |
|
141 | - $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid(); |
|
142 | - $template_args['payments'] = $this->transaction->approved_payments(); |
|
143 | - $template_args['net_total'] = ''; |
|
144 | - $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url(); |
|
145 | - $template_args['retry_payment_url'] = $this->registration->payment_overview_url(); |
|
146 | - $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description( |
|
147 | - $this->transaction->total_line_item() |
|
148 | - ); |
|
149 | - if ($template_args['amount_pd'] != $template_args['total_cost']) { |
|
150 | - // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']); |
|
151 | - $tax_items = $this->transaction->tax_items(); |
|
152 | - if (! empty($tax_items)) { |
|
153 | - foreach ($tax_items as $tax) { |
|
154 | - $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
|
155 | - } |
|
156 | - } |
|
138 | + $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', ''); |
|
139 | + $template_args['transaction'] = $this->transaction; |
|
140 | + $template_args['amount_pd'] = $this->transaction->paid(); |
|
141 | + $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid(); |
|
142 | + $template_args['payments'] = $this->transaction->approved_payments(); |
|
143 | + $template_args['net_total'] = ''; |
|
144 | + $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url(); |
|
145 | + $template_args['retry_payment_url'] = $this->registration->payment_overview_url(); |
|
146 | + $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description( |
|
147 | + $this->transaction->total_line_item() |
|
148 | + ); |
|
149 | + if ($template_args['amount_pd'] != $template_args['total_cost']) { |
|
150 | + // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']); |
|
151 | + $tax_items = $this->transaction->tax_items(); |
|
152 | + if (! empty($tax_items)) { |
|
153 | + foreach ($tax_items as $tax) { |
|
154 | + $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
|
155 | + } |
|
156 | + } |
|
157 | 157 | |
158 | - $difference = $template_args['amount_pd'] - $template_args['total_cost']; |
|
159 | - if ($difference < 0) { |
|
160 | - $text = __('Discount', 'event_espresso'); |
|
161 | - } else { |
|
162 | - $text = __('Extra', 'event_espresso'); |
|
163 | - } |
|
164 | - $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference); |
|
165 | - } |
|
158 | + $difference = $template_args['amount_pd'] - $template_args['total_cost']; |
|
159 | + if ($difference < 0) { |
|
160 | + $text = __('Discount', 'event_espresso'); |
|
161 | + } else { |
|
162 | + $text = __('Extra', 'event_espresso'); |
|
163 | + } |
|
164 | + $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference); |
|
165 | + } |
|
166 | 166 | |
167 | - $template_args['currency_symbol'] = $EE->CFG->currency->sign; |
|
168 | - $template_args['template_payment_instructions'] = wpautop( |
|
169 | - stripslashes_deep( |
|
170 | - html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES) |
|
171 | - ) |
|
172 | - ); |
|
173 | - $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true); |
|
174 | - if (isset($_GET['receipt'])) { |
|
175 | - // receipt-specific stuff |
|
176 | - $events_for_txn = EEM_Event::instance()->get_all( |
|
177 | - array(array('Registration.TXN_ID' => $this->transaction->ID())) |
|
178 | - ); |
|
179 | - $ticket_line_items_per_event = array(); |
|
180 | - $registrations_per_line_item = array(); |
|
181 | - $venues_for_events = array(); |
|
182 | - foreach ($events_for_txn as $event_id => $event) { |
|
183 | - $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
|
184 | - array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID())) |
|
185 | - ); |
|
186 | - $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
187 | - foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
|
188 | - $ticket = $line_item->ticket(); |
|
189 | - $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
|
190 | - array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID())) |
|
191 | - ); |
|
192 | - $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
193 | - } |
|
194 | - $venues_for_events = array_merge($venues_for_events, $event->venues()); |
|
195 | - } |
|
196 | - $tax_total_line_item = EEM_Line_Item::instance()->get_one( |
|
197 | - array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total)) |
|
198 | - ); |
|
199 | - $questions_to_skip = array( |
|
200 | - EEM_Attendee::system_question_fname, |
|
201 | - EEM_Attendee::system_question_lname, |
|
202 | - EEM_Attendee::system_question_email, |
|
203 | - ); |
|
167 | + $template_args['currency_symbol'] = $EE->CFG->currency->sign; |
|
168 | + $template_args['template_payment_instructions'] = wpautop( |
|
169 | + stripslashes_deep( |
|
170 | + html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES) |
|
171 | + ) |
|
172 | + ); |
|
173 | + $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true); |
|
174 | + if (isset($_GET['receipt'])) { |
|
175 | + // receipt-specific stuff |
|
176 | + $events_for_txn = EEM_Event::instance()->get_all( |
|
177 | + array(array('Registration.TXN_ID' => $this->transaction->ID())) |
|
178 | + ); |
|
179 | + $ticket_line_items_per_event = array(); |
|
180 | + $registrations_per_line_item = array(); |
|
181 | + $venues_for_events = array(); |
|
182 | + foreach ($events_for_txn as $event_id => $event) { |
|
183 | + $line_items_for_this_event = EEM_Line_Item::instance()->get_all( |
|
184 | + array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID())) |
|
185 | + ); |
|
186 | + $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event; |
|
187 | + foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
|
188 | + $ticket = $line_item->ticket(); |
|
189 | + $registrations_for_this_ticket = EEM_Registration::instance()->get_all( |
|
190 | + array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID())) |
|
191 | + ); |
|
192 | + $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket; |
|
193 | + } |
|
194 | + $venues_for_events = array_merge($venues_for_events, $event->venues()); |
|
195 | + } |
|
196 | + $tax_total_line_item = EEM_Line_Item::instance()->get_one( |
|
197 | + array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total)) |
|
198 | + ); |
|
199 | + $questions_to_skip = array( |
|
200 | + EEM_Attendee::system_question_fname, |
|
201 | + EEM_Attendee::system_question_lname, |
|
202 | + EEM_Attendee::system_question_email, |
|
203 | + ); |
|
204 | 204 | |
205 | 205 | |
206 | - $template_args['events_for_txn'] = $events_for_txn; |
|
207 | - $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event; |
|
208 | - $template_args['registrations_per_line_item'] = $registrations_per_line_item; |
|
209 | - $template_args['venues_for_events'] = $venues_for_events; |
|
210 | - $template_args['tax_total_line_item'] = $tax_total_line_item; |
|
211 | - $template_args['questions_to_skip'] = $questions_to_skip; |
|
212 | - // d($template_args); |
|
213 | - $template_args['download_link'] = $this->registration->receipt_url('download'); |
|
214 | - } else { |
|
215 | - // it's just an invoice we're accessing |
|
216 | - $template_args['download_link'] = $this->registration->invoice_url('download'); |
|
217 | - } |
|
206 | + $template_args['events_for_txn'] = $events_for_txn; |
|
207 | + $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event; |
|
208 | + $template_args['registrations_per_line_item'] = $registrations_per_line_item; |
|
209 | + $template_args['venues_for_events'] = $venues_for_events; |
|
210 | + $template_args['tax_total_line_item'] = $tax_total_line_item; |
|
211 | + $template_args['questions_to_skip'] = $questions_to_skip; |
|
212 | + // d($template_args); |
|
213 | + $template_args['download_link'] = $this->registration->receipt_url('download'); |
|
214 | + } else { |
|
215 | + // it's just an invoice we're accessing |
|
216 | + $template_args['download_link'] = $this->registration->invoice_url('download'); |
|
217 | + } |
|
218 | 218 | |
219 | - // Get the HTML as an object |
|
220 | - $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
221 | - $template_header = EEH_Template::locate_template( |
|
222 | - $templates_relative_path . 'invoice_header.template.php', |
|
223 | - $template_args, |
|
224 | - true, |
|
225 | - true |
|
226 | - ); |
|
227 | - if (isset($_GET['receipt'])) { |
|
228 | - $template_body = EEH_Template::locate_template( |
|
229 | - $templates_relative_path . 'receipt_body.template.php', |
|
230 | - $template_args, |
|
231 | - true, |
|
232 | - true |
|
233 | - ); |
|
234 | - } else { |
|
235 | - $template_body = EEH_Template::locate_template( |
|
236 | - $templates_relative_path . 'invoice_body.template.php', |
|
237 | - $template_args, |
|
238 | - true, |
|
239 | - true |
|
240 | - ); |
|
241 | - } |
|
219 | + // Get the HTML as an object |
|
220 | + $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
221 | + $template_header = EEH_Template::locate_template( |
|
222 | + $templates_relative_path . 'invoice_header.template.php', |
|
223 | + $template_args, |
|
224 | + true, |
|
225 | + true |
|
226 | + ); |
|
227 | + if (isset($_GET['receipt'])) { |
|
228 | + $template_body = EEH_Template::locate_template( |
|
229 | + $templates_relative_path . 'receipt_body.template.php', |
|
230 | + $template_args, |
|
231 | + true, |
|
232 | + true |
|
233 | + ); |
|
234 | + } else { |
|
235 | + $template_body = EEH_Template::locate_template( |
|
236 | + $templates_relative_path . 'invoice_body.template.php', |
|
237 | + $template_args, |
|
238 | + true, |
|
239 | + true |
|
240 | + ); |
|
241 | + } |
|
242 | 242 | |
243 | 243 | |
244 | - $template_footer = EEH_Template::locate_template( |
|
245 | - $templates_relative_path . 'invoice_footer.template.php', |
|
246 | - $template_args, |
|
247 | - true, |
|
248 | - true |
|
249 | - ); |
|
244 | + $template_footer = EEH_Template::locate_template( |
|
245 | + $templates_relative_path . 'invoice_footer.template.php', |
|
246 | + $template_args, |
|
247 | + true, |
|
248 | + true |
|
249 | + ); |
|
250 | 250 | |
251 | - $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1; |
|
251 | + $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1; |
|
252 | 252 | |
253 | - $content = $this->espresso_replace_invoice_shortcodes($template_header); |
|
254 | - for ($x = 1; $x <= $copies; $x++) { |
|
255 | - $content .= $this->espresso_replace_invoice_shortcodes($template_body); |
|
256 | - } |
|
257 | - $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
|
253 | + $content = $this->espresso_replace_invoice_shortcodes($template_header); |
|
254 | + for ($x = 1; $x <= $copies; $x++) { |
|
255 | + $content .= $this->espresso_replace_invoice_shortcodes($template_body); |
|
256 | + } |
|
257 | + $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
|
258 | 258 | |
259 | - // Check if debugging or mobile is set |
|
260 | - if (! empty($_REQUEST['html'])) { |
|
261 | - echo $content; |
|
262 | - exit(0); |
|
263 | - } |
|
264 | - $invoice_name = $template_args['organization'] . ' ' . __( |
|
265 | - 'Invoice #', |
|
266 | - 'event_espresso' |
|
267 | - ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name']; |
|
268 | - $invoice_name = str_replace(' ', '_', $invoice_name); |
|
269 | - // Create the PDF |
|
270 | - if (array_key_exists('html', $_GET)) { |
|
271 | - echo $content; |
|
272 | - } else { |
|
273 | - // only load dompdf if nobody else has yet... |
|
274 | - if (! class_exists('Dompdf\Dompdf')) { |
|
275 | - require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
276 | - Dompdf\Autoloader::register(); |
|
277 | - } |
|
278 | - $options = new Dompdf\Options(); |
|
279 | - $options->set('isRemoteEnabled', true); |
|
280 | - $options->set('isJavascriptEnabled', false); |
|
281 | - if (defined('DOMPDF_FONT_DIR')) { |
|
282 | - $options->setFontDir(DOMPDF_FONT_DIR); |
|
283 | - $options->setFontCache(DOMPDF_FONT_DIR); |
|
284 | - } |
|
285 | - $dompdf = new Dompdf\Dompdf($options); |
|
286 | - $dompdf->loadHtml($content); |
|
287 | - $dompdf->render(); |
|
288 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download)); |
|
289 | - } |
|
290 | - exit(0); |
|
291 | - } |
|
259 | + // Check if debugging or mobile is set |
|
260 | + if (! empty($_REQUEST['html'])) { |
|
261 | + echo $content; |
|
262 | + exit(0); |
|
263 | + } |
|
264 | + $invoice_name = $template_args['organization'] . ' ' . __( |
|
265 | + 'Invoice #', |
|
266 | + 'event_espresso' |
|
267 | + ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name']; |
|
268 | + $invoice_name = str_replace(' ', '_', $invoice_name); |
|
269 | + // Create the PDF |
|
270 | + if (array_key_exists('html', $_GET)) { |
|
271 | + echo $content; |
|
272 | + } else { |
|
273 | + // only load dompdf if nobody else has yet... |
|
274 | + if (! class_exists('Dompdf\Dompdf')) { |
|
275 | + require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php'); |
|
276 | + Dompdf\Autoloader::register(); |
|
277 | + } |
|
278 | + $options = new Dompdf\Options(); |
|
279 | + $options->set('isRemoteEnabled', true); |
|
280 | + $options->set('isJavascriptEnabled', false); |
|
281 | + if (defined('DOMPDF_FONT_DIR')) { |
|
282 | + $options->setFontDir(DOMPDF_FONT_DIR); |
|
283 | + $options->setFontCache(DOMPDF_FONT_DIR); |
|
284 | + } |
|
285 | + $dompdf = new Dompdf\Dompdf($options); |
|
286 | + $dompdf->loadHtml($content); |
|
287 | + $dompdf->render(); |
|
288 | + $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download)); |
|
289 | + } |
|
290 | + exit(0); |
|
291 | + } |
|
292 | 292 | |
293 | - /** |
|
294 | - * Checks if this line item, or any of its children, actually has a description. |
|
295 | - * If none do, then the template can decide to not show any description column |
|
296 | - * |
|
297 | - * @param EE_Line_Item $line_item |
|
298 | - * @return boolean |
|
299 | - */ |
|
300 | - public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) |
|
301 | - { |
|
302 | - if ($line_item->desc()) { |
|
303 | - return true; |
|
304 | - } else { |
|
305 | - foreach ($line_item->children() as $child_line_item) { |
|
306 | - if ($this->check_if_any_line_items_have_a_description($child_line_item)) { |
|
307 | - return true; |
|
308 | - } |
|
309 | - } |
|
310 | - // well, if I and my children don't have descriptions, I guess not |
|
311 | - return false; |
|
312 | - } |
|
313 | - } |
|
293 | + /** |
|
294 | + * Checks if this line item, or any of its children, actually has a description. |
|
295 | + * If none do, then the template can decide to not show any description column |
|
296 | + * |
|
297 | + * @param EE_Line_Item $line_item |
|
298 | + * @return boolean |
|
299 | + */ |
|
300 | + public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) |
|
301 | + { |
|
302 | + if ($line_item->desc()) { |
|
303 | + return true; |
|
304 | + } else { |
|
305 | + foreach ($line_item->children() as $child_line_item) { |
|
306 | + if ($this->check_if_any_line_items_have_a_description($child_line_item)) { |
|
307 | + return true; |
|
308 | + } |
|
309 | + } |
|
310 | + // well, if I and my children don't have descriptions, I guess not |
|
311 | + return false; |
|
312 | + } |
|
313 | + } |
|
314 | 314 | |
315 | 315 | // Perform the shortcode replacement |
316 | - public function espresso_replace_invoice_shortcodes($content) |
|
317 | - { |
|
316 | + public function espresso_replace_invoice_shortcodes($content) |
|
317 | + { |
|
318 | 318 | |
319 | - $EE = EE_Registry::instance(); |
|
320 | - // Create the logo |
|
321 | - $invoice_logo_url = $this->invoice_payment_method->get_extra_meta( |
|
322 | - 'pdf_logo_image', |
|
323 | - true, |
|
324 | - $EE->CFG->organization->logo_url |
|
325 | - ); |
|
326 | - if (! empty($invoice_logo_url)) { |
|
327 | - $image_size = getimagesize($invoice_logo_url); |
|
328 | - $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
329 | - } else { |
|
330 | - $invoice_logo_image = ''; |
|
331 | - } |
|
332 | - $SearchValues = array( |
|
333 | - "[organization]", |
|
334 | - "[registration_code]", |
|
335 | - "[transaction_id]", |
|
336 | - "[name]", |
|
337 | - "[base_url]", |
|
338 | - "[download_link]", |
|
339 | - "[invoice_logo_image]", |
|
340 | - "[street]", |
|
341 | - "[city]", |
|
342 | - "[state]", |
|
343 | - "[zip]", |
|
344 | - "[email]", |
|
345 | - "[vat]", |
|
346 | - "[registration_date]", |
|
347 | - "[instructions]", |
|
348 | - ); |
|
349 | - $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
350 | - $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
351 | - if ($org_state) { |
|
352 | - $org_state_name = $org_state->name(); |
|
353 | - } else { |
|
354 | - $org_state_name = ''; |
|
355 | - } |
|
356 | - $ReplaceValues = array( |
|
357 | - $EE->CFG->organization->get_pretty('name'), |
|
358 | - $this->registration->reg_code(), |
|
359 | - $this->transaction->ID(), |
|
360 | - $primary_attendee->full_name(), |
|
361 | - (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
362 | - : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
363 | - $this->registration->invoice_url(), |
|
364 | - // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
365 | - $invoice_logo_image, |
|
366 | - empty($EE->CFG->organization->address_2) |
|
367 | - ? $EE->CFG->organization->get_pretty('address_1') |
|
368 | - : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
369 | - 'address_2' |
|
370 | - ), |
|
371 | - $EE->CFG->organization->get_pretty('city'), |
|
372 | - $org_state_name, |
|
373 | - $EE->CFG->organization->get_pretty('zip'), |
|
374 | - $EE->CFG->organization->get_pretty('email'), |
|
375 | - $EE->CFG->organization->vat, |
|
376 | - $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), |
|
377 | - $this->invoice_payment_method->get_extra_meta('pdf_instructions', true), |
|
378 | - ); |
|
319 | + $EE = EE_Registry::instance(); |
|
320 | + // Create the logo |
|
321 | + $invoice_logo_url = $this->invoice_payment_method->get_extra_meta( |
|
322 | + 'pdf_logo_image', |
|
323 | + true, |
|
324 | + $EE->CFG->organization->logo_url |
|
325 | + ); |
|
326 | + if (! empty($invoice_logo_url)) { |
|
327 | + $image_size = getimagesize($invoice_logo_url); |
|
328 | + $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
329 | + } else { |
|
330 | + $invoice_logo_image = ''; |
|
331 | + } |
|
332 | + $SearchValues = array( |
|
333 | + "[organization]", |
|
334 | + "[registration_code]", |
|
335 | + "[transaction_id]", |
|
336 | + "[name]", |
|
337 | + "[base_url]", |
|
338 | + "[download_link]", |
|
339 | + "[invoice_logo_image]", |
|
340 | + "[street]", |
|
341 | + "[city]", |
|
342 | + "[state]", |
|
343 | + "[zip]", |
|
344 | + "[email]", |
|
345 | + "[vat]", |
|
346 | + "[registration_date]", |
|
347 | + "[instructions]", |
|
348 | + ); |
|
349 | + $primary_attendee = $this->transaction->primary_registration()->attendee(); |
|
350 | + $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
351 | + if ($org_state) { |
|
352 | + $org_state_name = $org_state->name(); |
|
353 | + } else { |
|
354 | + $org_state_name = ''; |
|
355 | + } |
|
356 | + $ReplaceValues = array( |
|
357 | + $EE->CFG->organization->get_pretty('name'), |
|
358 | + $this->registration->reg_code(), |
|
359 | + $this->transaction->ID(), |
|
360 | + $primary_attendee->full_name(), |
|
361 | + (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' |
|
362 | + : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
363 | + $this->registration->invoice_url(), |
|
364 | + // home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
365 | + $invoice_logo_image, |
|
366 | + empty($EE->CFG->organization->address_2) |
|
367 | + ? $EE->CFG->organization->get_pretty('address_1') |
|
368 | + : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty( |
|
369 | + 'address_2' |
|
370 | + ), |
|
371 | + $EE->CFG->organization->get_pretty('city'), |
|
372 | + $org_state_name, |
|
373 | + $EE->CFG->organization->get_pretty('zip'), |
|
374 | + $EE->CFG->organization->get_pretty('email'), |
|
375 | + $EE->CFG->organization->vat, |
|
376 | + $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), |
|
377 | + $this->invoice_payment_method->get_extra_meta('pdf_instructions', true), |
|
378 | + ); |
|
379 | 379 | |
380 | - return str_replace($SearchValues, $ReplaceValues, $content); |
|
381 | - } |
|
380 | + return str_replace($SearchValues, $ReplaceValues, $content); |
|
381 | + } |
|
382 | 382 | |
383 | - public function espressoLoadData($items) |
|
384 | - { |
|
385 | - $lines = $items; |
|
386 | - $data = array(); |
|
387 | - foreach ($lines as $line) { |
|
388 | - $data[] = explode(';', chop($line)); |
|
389 | - } |
|
383 | + public function espressoLoadData($items) |
|
384 | + { |
|
385 | + $lines = $items; |
|
386 | + $data = array(); |
|
387 | + foreach ($lines as $line) { |
|
388 | + $data[] = explode(';', chop($line)); |
|
389 | + } |
|
390 | 390 | |
391 | - return $data; |
|
392 | - } |
|
391 | + return $data; |
|
392 | + } |
|
393 | 393 | |
394 | 394 | |
395 | - public function espressoInvoiceTotals($text, $total_cost) |
|
396 | - { |
|
395 | + public function espressoInvoiceTotals($text, $total_cost) |
|
396 | + { |
|
397 | 397 | |
398 | - $html = ''; |
|
399 | - if ($total_cost < 0) { |
|
400 | - $total_cost = (-1) * $total_cost; |
|
401 | - } |
|
402 | - $find = array(' '); |
|
403 | - $replace = array('-'); |
|
404 | - $row_id = strtolower(str_replace($find, $replace, $text)); |
|
405 | - $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
406 | - $html .= '<td class="item_r">' . $text . '</td>'; |
|
407 | - $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
408 | - $html .= '</tr>'; |
|
409 | - return $html; |
|
410 | - } |
|
398 | + $html = ''; |
|
399 | + if ($total_cost < 0) { |
|
400 | + $total_cost = (-1) * $total_cost; |
|
401 | + } |
|
402 | + $find = array(' '); |
|
403 | + $replace = array('-'); |
|
404 | + $row_id = strtolower(str_replace($find, $replace, $text)); |
|
405 | + $html .= '<tr id="' . $row_id . '-tr"><td colspan="4"> </td>'; |
|
406 | + $html .= '<td class="item_r">' . $text . '</td>'; |
|
407 | + $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
408 | + $html .= '</tr>'; |
|
409 | + return $html; |
|
410 | + } |
|
411 | 411 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
3 | 3 | $values = EEH_Form_Fields::prep_answer_options( |
4 | - array( |
|
5 | - array('id' => 1, 'text' => __('Yes', 'event_espresso')), |
|
6 | - array('id' => 0, 'text' => __('No', 'event_espresso')), |
|
7 | - ) |
|
4 | + array( |
|
5 | + array('id' => 1, 'text' => __('Yes', 'event_espresso')), |
|
6 | + array('id' => 0, 'text' => __('No', 'event_espresso')), |
|
7 | + ) |
|
8 | 8 | ); |
9 | 9 | ?> |
10 | 10 | |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | <h2 class="ee-admin-settings-hdr"> |
14 | 14 | <?php _e( |
15 | - 'Single Event Pages', |
|
16 | - 'event_espresso' |
|
17 | - ); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?> |
|
15 | + 'Single Event Pages', |
|
16 | + 'event_espresso' |
|
17 | + ); ?><?php // echo EEH_Template::get_help_tab_link('event_single_settings_info');?> |
|
18 | 18 | </h2> |
19 | 19 | <table class="form-table"> |
20 | 20 | <tbody> |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | </th> |
27 | 27 | <td> |
28 | 28 | <?php echo EEH_Form_Fields::select( |
29 | - 'display_status_banner_single', |
|
30 | - $display_status_banner_single, |
|
31 | - $values, |
|
32 | - 'display_status_banner_single', |
|
33 | - 'display_status_banner_single' |
|
34 | - ); ?> |
|
29 | + 'display_status_banner_single', |
|
30 | + $display_status_banner_single, |
|
31 | + $values, |
|
32 | + 'display_status_banner_single', |
|
33 | + 'display_status_banner_single' |
|
34 | + ); ?> |
|
35 | 35 | <p class="description"><?php |
36 | - _e( |
|
37 | - 'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.', |
|
38 | - 'event_espresso' |
|
39 | - ); ?></p> |
|
36 | + _e( |
|
37 | + 'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.', |
|
38 | + 'event_espresso' |
|
39 | + ); ?></p> |
|
40 | 40 | </td> |
41 | 41 | </tr> |
42 | 42 | |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | <th> |
45 | 45 | <label for="display_venue"> |
46 | 46 | <?php _e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
47 | - 'display_addresses_in_reg_form_info' |
|
48 | - ); ?> |
|
47 | + 'display_addresses_in_reg_form_info' |
|
48 | + ); ?> |
|
49 | 49 | </label> |
50 | 50 | </th> |
51 | 51 | <td> |
52 | 52 | <?php echo EEH_Form_Fields::select( |
53 | - 'display_venue', |
|
54 | - $display_venue, |
|
55 | - $values, |
|
56 | - 'display_venue', |
|
57 | - 'display_venue' |
|
58 | - ); ?> |
|
53 | + 'display_venue', |
|
54 | + $display_venue, |
|
55 | + $values, |
|
56 | + 'display_venue', |
|
57 | + 'display_venue' |
|
58 | + ); ?> |
|
59 | 59 | <p class="description"><?php |
60 | - _e( |
|
61 | - 'Do not use this if you are using the venue shortcodes in your event description.', |
|
62 | - 'event_espresso' |
|
63 | - ); ?></p> |
|
60 | + _e( |
|
61 | + 'Do not use this if you are using the venue shortcodes in your event description.', |
|
62 | + 'event_espresso' |
|
63 | + ); ?></p> |
|
64 | 64 | </td> |
65 | 65 | </tr> |
66 | 66 | |
@@ -72,37 +72,37 @@ discard block |
||
72 | 72 | </th> |
73 | 73 | <td> |
74 | 74 | <?php |
75 | - echo EEH_Form_Fields::select( |
|
76 | - 'use_sortable_display_order', |
|
77 | - $use_sortable_display_order, |
|
78 | - $values, |
|
79 | - 'EED_Events_Single_use_sortable_display_order', |
|
80 | - 'EED_Events_Single_use_sortable_display_order' |
|
81 | - ); |
|
82 | - ?> |
|
75 | + echo EEH_Form_Fields::select( |
|
76 | + 'use_sortable_display_order', |
|
77 | + $use_sortable_display_order, |
|
78 | + $values, |
|
79 | + 'EED_Events_Single_use_sortable_display_order', |
|
80 | + 'EED_Events_Single_use_sortable_display_order' |
|
81 | + ); |
|
82 | + ?> |
|
83 | 83 | </td> |
84 | 84 | </tr> |
85 | 85 | |
86 | 86 | <tr> |
87 | 87 | <th> |
88 | 88 | <?php _e('Display Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link( |
89 | - 'display_addresses_in_reg_form_info' |
|
90 | - ); ?> |
|
89 | + 'display_addresses_in_reg_form_info' |
|
90 | + ); ?> |
|
91 | 91 | </th> |
92 | 92 | <td> |
93 | 93 | |
94 | 94 | <?php wp_nonce_field( |
95 | - 'espresso_update_event_single_order', |
|
96 | - 'espresso_update_event_single_order_nonce', |
|
97 | - false |
|
98 | - ); ?> |
|
95 | + 'espresso_update_event_single_order', |
|
96 | + 'espresso_update_event_single_order_nonce', |
|
97 | + false |
|
98 | + ); ?> |
|
99 | 99 | <?php echo $event_single_display_order; ?> |
100 | 100 | |
101 | 101 | <p class="description"><?php |
102 | - _e( |
|
103 | - 'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.', |
|
104 | - 'event_espresso' |
|
105 | - ); ?></p> |
|
102 | + _e( |
|
103 | + 'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.', |
|
104 | + 'event_espresso' |
|
105 | + ); ?></p> |
|
106 | 106 | |
107 | 107 | </td> |
108 | 108 | </tr> |
@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class URLValidator |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns whether or not the URL is valid |
|
21 | - * @since 4.9.68.p |
|
22 | - * @param $url |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function isValid($url) |
|
26 | - { |
|
27 | - return esc_url_raw($url) === $url; |
|
28 | - } |
|
19 | + /** |
|
20 | + * Returns whether or not the URL is valid |
|
21 | + * @since 4.9.68.p |
|
22 | + * @param $url |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function isValid($url) |
|
26 | + { |
|
27 | + return esc_url_raw($url) === $url; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | // End of file URLValidator.php |
31 | 31 | // Location: ${NAMESPACE}/URLValidator.php |
@@ -14,263 +14,263 @@ |
||
14 | 14 | class EEM_Term extends EEM_Base |
15 | 15 | { |
16 | 16 | |
17 | - // private instance of the Attendee object |
|
18 | - protected static $_instance = null; |
|
17 | + // private instance of the Attendee object |
|
18 | + protected static $_instance = null; |
|
19 | 19 | |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - *__construct |
|
24 | - * |
|
25 | - * @param string $timezone |
|
26 | - */ |
|
27 | - protected function __construct($timezone = null) |
|
28 | - { |
|
29 | - $this->singular_item = __('Term', 'event_espresso'); |
|
30 | - $this->plural_item = __('Terms', 'event_espresso'); |
|
31 | - $this->_tables = array( |
|
32 | - 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
33 | - ); |
|
34 | - $this->_fields = array( |
|
35 | - 'Term' => array( |
|
36 | - 'term_id' => new EE_Primary_Key_Int_Field('term_id', __('Term ID', 'event_espresso')), |
|
37 | - 'name' => new EE_Plain_Text_Field('name', __('Term Name', 'event_espresso'), false, ''), |
|
38 | - 'slug' => new EE_Slug_Field('slug', __('Term Slug', 'event_espresso'), false), |
|
39 | - 'term_group' => new EE_Integer_Field('term_group', __("Term Group", "event_espresso"), false, 0), |
|
40 | - ), |
|
41 | - ); |
|
42 | - $this->_model_relations = array( |
|
43 | - 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
44 | - ); |
|
45 | - $this->_wp_core_model = true; |
|
46 | - $path_to_tax_model = 'Term_Taxonomy'; |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
49 | - $path_to_tax_model |
|
50 | - ); |
|
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
52 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
53 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
54 | - // add cap restrictions for editing relating to the "ee_edit_*" |
|
55 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
56 | - array( |
|
57 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | - ) |
|
59 | - ); |
|
60 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | - array( |
|
62 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | - ) |
|
64 | - ); |
|
65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | - array( |
|
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | - ) |
|
69 | - ); |
|
70 | - // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
71 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
72 | - array( |
|
73 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | - ) |
|
75 | - ); |
|
76 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | - array( |
|
78 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | - ) |
|
80 | - ); |
|
81 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | - array( |
|
83 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | - ) |
|
85 | - ); |
|
86 | - parent::__construct($timezone); |
|
87 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
88 | - } |
|
22 | + /** |
|
23 | + *__construct |
|
24 | + * |
|
25 | + * @param string $timezone |
|
26 | + */ |
|
27 | + protected function __construct($timezone = null) |
|
28 | + { |
|
29 | + $this->singular_item = __('Term', 'event_espresso'); |
|
30 | + $this->plural_item = __('Terms', 'event_espresso'); |
|
31 | + $this->_tables = array( |
|
32 | + 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
33 | + ); |
|
34 | + $this->_fields = array( |
|
35 | + 'Term' => array( |
|
36 | + 'term_id' => new EE_Primary_Key_Int_Field('term_id', __('Term ID', 'event_espresso')), |
|
37 | + 'name' => new EE_Plain_Text_Field('name', __('Term Name', 'event_espresso'), false, ''), |
|
38 | + 'slug' => new EE_Slug_Field('slug', __('Term Slug', 'event_espresso'), false), |
|
39 | + 'term_group' => new EE_Integer_Field('term_group', __("Term Group", "event_espresso"), false, 0), |
|
40 | + ), |
|
41 | + ); |
|
42 | + $this->_model_relations = array( |
|
43 | + 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
44 | + ); |
|
45 | + $this->_wp_core_model = true; |
|
46 | + $path_to_tax_model = 'Term_Taxonomy'; |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
48 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
49 | + $path_to_tax_model |
|
50 | + ); |
|
51 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
52 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
53 | + $path_to_tax_model = $path_to_tax_model . '.'; |
|
54 | + // add cap restrictions for editing relating to the "ee_edit_*" |
|
55 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
56 | + array( |
|
57 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | + ) |
|
59 | + ); |
|
60 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | + array( |
|
62 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | + ) |
|
64 | + ); |
|
65 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | + array( |
|
67 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | + ) |
|
69 | + ); |
|
70 | + // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
71 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
72 | + array( |
|
73 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | + ) |
|
75 | + ); |
|
76 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | + array( |
|
78 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | + ) |
|
80 | + ); |
|
81 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | + array( |
|
83 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | + ) |
|
85 | + ); |
|
86 | + parent::__construct($timezone); |
|
87 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * retrieves a list of all EE event categories |
|
94 | - * |
|
95 | - * @access public |
|
96 | - * @param bool $show_uncategorized |
|
97 | - * @return \EE_Base_Class[] |
|
98 | - */ |
|
99 | - public function get_all_ee_categories($show_uncategorized = false) |
|
100 | - { |
|
101 | - $where_params = array( |
|
102 | - 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
103 | - 'NOT' => array('name' => __('Uncategorized', 'event_espresso')), |
|
104 | - ); |
|
105 | - if ($show_uncategorized) { |
|
106 | - unset($where_params['NOT']); |
|
107 | - } |
|
108 | - return EEM_Term::instance()->get_all( |
|
109 | - array( |
|
110 | - $where_params, |
|
111 | - 'order_by' => array('name' => 'ASC'), |
|
112 | - ) |
|
113 | - ); |
|
114 | - } |
|
92 | + /** |
|
93 | + * retrieves a list of all EE event categories |
|
94 | + * |
|
95 | + * @access public |
|
96 | + * @param bool $show_uncategorized |
|
97 | + * @return \EE_Base_Class[] |
|
98 | + */ |
|
99 | + public function get_all_ee_categories($show_uncategorized = false) |
|
100 | + { |
|
101 | + $where_params = array( |
|
102 | + 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
103 | + 'NOT' => array('name' => __('Uncategorized', 'event_espresso')), |
|
104 | + ); |
|
105 | + if ($show_uncategorized) { |
|
106 | + unset($where_params['NOT']); |
|
107 | + } |
|
108 | + return EEM_Term::instance()->get_all( |
|
109 | + array( |
|
110 | + $where_params, |
|
111 | + 'order_by' => array('name' => 'ASC'), |
|
112 | + ) |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * retrieves a list of all post_tags associated with an EE CPT |
|
120 | - * |
|
121 | - * @access public |
|
122 | - * @param string $post_type |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function get_all_CPT_post_tags($post_type = '') |
|
126 | - { |
|
127 | - switch ($post_type) { |
|
128 | - case 'espresso_events': |
|
129 | - return $this->get_all_event_post_tags(); |
|
130 | - break; |
|
131 | - case 'espresso_venues': |
|
132 | - return $this->get_all_venue_post_tags(); |
|
133 | - break; |
|
134 | - default: |
|
135 | - $event_tags = $this->get_all_event_post_tags(); |
|
136 | - $venue_tags = $this->get_all_venue_post_tags(); |
|
137 | - return array_merge($event_tags, $venue_tags); |
|
138 | - } |
|
139 | - } |
|
118 | + /** |
|
119 | + * retrieves a list of all post_tags associated with an EE CPT |
|
120 | + * |
|
121 | + * @access public |
|
122 | + * @param string $post_type |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function get_all_CPT_post_tags($post_type = '') |
|
126 | + { |
|
127 | + switch ($post_type) { |
|
128 | + case 'espresso_events': |
|
129 | + return $this->get_all_event_post_tags(); |
|
130 | + break; |
|
131 | + case 'espresso_venues': |
|
132 | + return $this->get_all_venue_post_tags(); |
|
133 | + break; |
|
134 | + default: |
|
135 | + $event_tags = $this->get_all_event_post_tags(); |
|
136 | + $venue_tags = $this->get_all_venue_post_tags(); |
|
137 | + return array_merge($event_tags, $venue_tags); |
|
138 | + } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | |
142 | - /** |
|
143 | - * returns an EE_Term object for the given tag |
|
144 | - * if it has been utilized by any EE_Events or EE_Venues |
|
145 | - * |
|
146 | - * @param string $tag |
|
147 | - * @return EE_Term|null |
|
148 | - * @throws EE_Error |
|
149 | - * @throws InvalidArgumentException |
|
150 | - * @throws InvalidDataTypeException |
|
151 | - * @throws InvalidInterfaceException |
|
152 | - */ |
|
153 | - public function get_post_tag_for_event_or_venue($tag) |
|
154 | - { |
|
155 | - $post_tag_results = $this->get_all_wpdb_results( |
|
156 | - array( |
|
157 | - array( |
|
158 | - 'slug' => $tag, |
|
159 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
160 | - 'OR' => array( |
|
161 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
162 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
163 | - ), |
|
164 | - ), |
|
165 | - 'default_where_conditions' => 'none', |
|
166 | - 'extra_selects' => array( |
|
167 | - 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
168 | - 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
169 | - ), |
|
170 | - 'group_by' => array( |
|
171 | - 'event_post_type', |
|
172 | - 'venue_post_type', |
|
173 | - ), |
|
174 | - 'limit' => 2 |
|
175 | - ) |
|
176 | - ); |
|
142 | + /** |
|
143 | + * returns an EE_Term object for the given tag |
|
144 | + * if it has been utilized by any EE_Events or EE_Venues |
|
145 | + * |
|
146 | + * @param string $tag |
|
147 | + * @return EE_Term|null |
|
148 | + * @throws EE_Error |
|
149 | + * @throws InvalidArgumentException |
|
150 | + * @throws InvalidDataTypeException |
|
151 | + * @throws InvalidInterfaceException |
|
152 | + */ |
|
153 | + public function get_post_tag_for_event_or_venue($tag) |
|
154 | + { |
|
155 | + $post_tag_results = $this->get_all_wpdb_results( |
|
156 | + array( |
|
157 | + array( |
|
158 | + 'slug' => $tag, |
|
159 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
160 | + 'OR' => array( |
|
161 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
162 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
163 | + ), |
|
164 | + ), |
|
165 | + 'default_where_conditions' => 'none', |
|
166 | + 'extra_selects' => array( |
|
167 | + 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
168 | + 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
169 | + ), |
|
170 | + 'group_by' => array( |
|
171 | + 'event_post_type', |
|
172 | + 'venue_post_type', |
|
173 | + ), |
|
174 | + 'limit' => 2 |
|
175 | + ) |
|
176 | + ); |
|
177 | 177 | |
178 | - $post_types = array(); |
|
179 | - foreach ((array) $post_tag_results as $row) { |
|
180 | - if ($row['event_post_type'] === 'espresso_events') { |
|
181 | - $post_types[] = EEM_Event::instance()->post_type(); |
|
182 | - } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
183 | - $post_types[] = EEM_Venue::instance()->post_type(); |
|
184 | - } |
|
185 | - } |
|
186 | - $post_tag_row = reset($post_tag_results); |
|
187 | - $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
188 | - if (! $post_tag instanceof EE_Term) { |
|
189 | - return null; |
|
190 | - } |
|
178 | + $post_types = array(); |
|
179 | + foreach ((array) $post_tag_results as $row) { |
|
180 | + if ($row['event_post_type'] === 'espresso_events') { |
|
181 | + $post_types[] = EEM_Event::instance()->post_type(); |
|
182 | + } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
183 | + $post_types[] = EEM_Venue::instance()->post_type(); |
|
184 | + } |
|
185 | + } |
|
186 | + $post_tag_row = reset($post_tag_results); |
|
187 | + $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
188 | + if (! $post_tag instanceof EE_Term) { |
|
189 | + return null; |
|
190 | + } |
|
191 | 191 | |
192 | - if ($post_tag->post_type === null) { |
|
193 | - $post_tag->post_type = array(); |
|
194 | - } |
|
195 | - $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
196 | - return $post_tag; |
|
197 | - } |
|
192 | + if ($post_tag->post_type === null) { |
|
193 | + $post_tag->post_type = array(); |
|
194 | + } |
|
195 | + $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
196 | + return $post_tag; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | - /** |
|
202 | - * get_all_event_post_tags |
|
203 | - * |
|
204 | - * @return EE_Base_Class[] |
|
205 | - */ |
|
206 | - public function get_all_event_post_tags() |
|
207 | - { |
|
208 | - $post_tags = EEM_Term::instance()->get_all( |
|
209 | - array( |
|
210 | - array( |
|
211 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
212 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
213 | - ), |
|
214 | - 'order_by' => array('name' => 'ASC'), |
|
215 | - 'force_join' => array('Term_Taxonomy.Event'), |
|
216 | - ) |
|
217 | - ); |
|
218 | - foreach ($post_tags as $key => $post_tag) { |
|
219 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
220 | - $post_tags[ $key ]->post_type = array(); |
|
221 | - } |
|
222 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
223 | - } |
|
224 | - return $post_tags; |
|
225 | - } |
|
201 | + /** |
|
202 | + * get_all_event_post_tags |
|
203 | + * |
|
204 | + * @return EE_Base_Class[] |
|
205 | + */ |
|
206 | + public function get_all_event_post_tags() |
|
207 | + { |
|
208 | + $post_tags = EEM_Term::instance()->get_all( |
|
209 | + array( |
|
210 | + array( |
|
211 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
212 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
213 | + ), |
|
214 | + 'order_by' => array('name' => 'ASC'), |
|
215 | + 'force_join' => array('Term_Taxonomy.Event'), |
|
216 | + ) |
|
217 | + ); |
|
218 | + foreach ($post_tags as $key => $post_tag) { |
|
219 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
220 | + $post_tags[ $key ]->post_type = array(); |
|
221 | + } |
|
222 | + $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
223 | + } |
|
224 | + return $post_tags; |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | 228 | |
229 | - /** |
|
230 | - * get_all_venue_post_tags |
|
231 | - * |
|
232 | - * @return EE_Base_Class[] |
|
233 | - */ |
|
234 | - public function get_all_venue_post_tags() |
|
235 | - { |
|
236 | - $post_tags = EEM_Term::instance()->get_all( |
|
237 | - array( |
|
238 | - array( |
|
239 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
240 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
241 | - ), |
|
242 | - 'order_by' => array('name' => 'ASC'), |
|
243 | - 'force_join' => array('Term_Taxonomy'), |
|
244 | - ) |
|
245 | - ); |
|
246 | - foreach ($post_tags as $key => $post_tag) { |
|
247 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
248 | - $post_tags[ $key ]->post_type = array(); |
|
249 | - } |
|
250 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
251 | - } |
|
252 | - return $post_tags; |
|
253 | - } |
|
229 | + /** |
|
230 | + * get_all_venue_post_tags |
|
231 | + * |
|
232 | + * @return EE_Base_Class[] |
|
233 | + */ |
|
234 | + public function get_all_venue_post_tags() |
|
235 | + { |
|
236 | + $post_tags = EEM_Term::instance()->get_all( |
|
237 | + array( |
|
238 | + array( |
|
239 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
240 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
241 | + ), |
|
242 | + 'order_by' => array('name' => 'ASC'), |
|
243 | + 'force_join' => array('Term_Taxonomy'), |
|
244 | + ) |
|
245 | + ); |
|
246 | + foreach ($post_tags as $key => $post_tag) { |
|
247 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
248 | + $post_tags[ $key ]->post_type = array(); |
|
249 | + } |
|
250 | + $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
251 | + } |
|
252 | + return $post_tags; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | |
256 | 256 | |
257 | - /** |
|
258 | - * Makes sure that during REST API queries, we only return terms |
|
259 | - * for term taxonomies which should be shown in the rest api |
|
260 | - * |
|
261 | - * @param array $model_query_params |
|
262 | - * @param array $querystring_query_params |
|
263 | - * @param EEM_Base $model |
|
264 | - * @return array |
|
265 | - */ |
|
266 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
267 | - { |
|
268 | - if ($model === EEM_Term::instance()) { |
|
269 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
270 | - if (! empty($taxonomies)) { |
|
271 | - $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
272 | - } |
|
273 | - } |
|
274 | - return $model_query_params; |
|
275 | - } |
|
257 | + /** |
|
258 | + * Makes sure that during REST API queries, we only return terms |
|
259 | + * for term taxonomies which should be shown in the rest api |
|
260 | + * |
|
261 | + * @param array $model_query_params |
|
262 | + * @param array $querystring_query_params |
|
263 | + * @param EEM_Base $model |
|
264 | + * @return array |
|
265 | + */ |
|
266 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
267 | + { |
|
268 | + if ($model === EEM_Term::instance()) { |
|
269 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
270 | + if (! empty($taxonomies)) { |
|
271 | + $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
272 | + } |
|
273 | + } |
|
274 | + return $model_query_params; |
|
275 | + } |
|
276 | 276 | } |
@@ -44,43 +44,43 @@ discard block |
||
44 | 44 | ); |
45 | 45 | $this->_wp_core_model = true; |
46 | 46 | $path_to_tax_model = 'Term_Taxonomy'; |
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
47 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
49 | 49 | $path_to_tax_model |
50 | 50 | ); |
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
52 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
53 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
51 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
52 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
53 | + $path_to_tax_model = $path_to_tax_model.'.'; |
|
54 | 54 | // add cap restrictions for editing relating to the "ee_edit_*" |
55 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
55 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
56 | 56 | array( |
57 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
57 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | 58 | ) |
59 | 59 | ); |
60 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
60 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | 61 | array( |
62 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
62 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | 63 | ) |
64 | 64 | ); |
65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
65 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | 66 | array( |
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
67 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | // add cap restrictions for deleting relating to the "ee_deleting_*" |
71 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
71 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
72 | 72 | array( |
73 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
73 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | 74 | ) |
75 | 75 | ); |
76 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
76 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | 77 | array( |
78 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
78 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | 79 | ) |
80 | 80 | ); |
81 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
81 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | 82 | array( |
83 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
83 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | 84 | ) |
85 | 85 | ); |
86 | 86 | parent::__construct($timezone); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | $post_tag_row = reset($post_tag_results); |
187 | 187 | $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
188 | - if (! $post_tag instanceof EE_Term) { |
|
188 | + if ( ! $post_tag instanceof EE_Term) { |
|
189 | 189 | return null; |
190 | 190 | } |
191 | 191 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | ) |
217 | 217 | ); |
218 | 218 | foreach ($post_tags as $key => $post_tag) { |
219 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
220 | - $post_tags[ $key ]->post_type = array(); |
|
219 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
220 | + $post_tags[$key]->post_type = array(); |
|
221 | 221 | } |
222 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
222 | + $post_tags[$key]->post_type[] = 'espresso_events'; |
|
223 | 223 | } |
224 | 224 | return $post_tags; |
225 | 225 | } |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | foreach ($post_tags as $key => $post_tag) { |
247 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
248 | - $post_tags[ $key ]->post_type = array(); |
|
247 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
248 | + $post_tags[$key]->post_type = array(); |
|
249 | 249 | } |
250 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
250 | + $post_tags[$key]->post_type[] = 'espresso_venues'; |
|
251 | 251 | } |
252 | 252 | return $post_tags; |
253 | 253 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | { |
268 | 268 | if ($model === EEM_Term::instance()) { |
269 | 269 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
270 | - if (! empty($taxonomies)) { |
|
270 | + if ( ! empty($taxonomies)) { |
|
271 | 271 | $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
272 | 272 | } |
273 | 273 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public static function add_json_linked_data_for_event(EE_Event $event) |
22 | 22 | { |
23 | 23 | // Check we have a valid datetime for the event |
24 | - if (! $event->primary_datetime() instanceof EE_Datetime) { |
|
24 | + if ( ! $event->primary_datetime() instanceof EE_Datetime) { |
|
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
51 | 51 | foreach ($event->tickets() as $original_ticket) { |
52 | 52 | // clone tickets so that date formats don't override those for the original ticket |
53 | - $ticket= clone $original_ticket; |
|
53 | + $ticket = clone $original_ticket; |
|
54 | 54 | $ID = $ticket->ID(); |
55 | - $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
56 | - $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
57 | - $template_args['event_tickets'][ $ID ]['price'] = number_format( |
|
55 | + $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
56 | + $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
57 | + $template_args['event_tickets'][$ID]['price'] = number_format( |
|
58 | 58 | $ticket->price(), |
59 | 59 | EE_Registry::instance()->CFG->currency->dec_plc, |
60 | 60 | EE_Registry::instance()->CFG->currency->dec_mrk, |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | $availability = null; |
72 | 72 | break; |
73 | 73 | } |
74 | - $template_args['event_tickets'][ $ID ]['availability'] = $availability; |
|
74 | + $template_args['event_tickets'][$ID]['availability'] = $availability; |
|
75 | 75 | unset($ticket); |
76 | 76 | } |
77 | 77 | $VNU_ID = espresso_venue_id(); |
78 | - if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
78 | + if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
79 | 79 | $venue = EEH_Venue_View::get_venue($VNU_ID); |
80 | 80 | $template_args['venue_name'] = get_the_title($VNU_ID); |
81 | 81 | $template_args['venue_url'] = get_permalink($VNU_ID); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $VNU_ID |
91 | 91 | ); |
92 | 92 | extract($template_args, EXTR_OVERWRITE); |
93 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
93 | + include EE_TEMPLATES.'json_linked_data_for_event.template.php'; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public static function name($name = null) |
124 | 124 | { |
125 | - return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
125 | + return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : ''; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | public static function streetAddress(EEI_Address $obj_with_address = null) |
139 | 139 | { |
140 | 140 | return $obj_with_address->address() !== null && $obj_with_address->address() !== '' |
141 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
141 | + ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : ''; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | if (preg_match( |
158 | 158 | "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", |
159 | 159 | $obj_with_address->address2() |
160 | - ) ) { |
|
160 | + )) { |
|
161 | 161 | return $obj_with_address->address2() !== null && $obj_with_address->address2() !== '' |
162 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
162 | + ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : ''; |
|
163 | 163 | } else { |
164 | 164 | return $obj_with_address->address2(); |
165 | 165 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public static function addressLocality(EEI_Address $obj_with_address = null) |
179 | 179 | { |
180 | 180 | return $obj_with_address->city() !== null && $obj_with_address->city() !== '' |
181 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
181 | + ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : ''; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | public static function addressRegion(EEI_Address $obj_with_address = null) |
195 | 195 | { |
196 | 196 | $state = $obj_with_address->state_name(); |
197 | - if (! empty($state)) { |
|
198 | - return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
197 | + if ( ! empty($state)) { |
|
198 | + return '<span itemprop="addressRegion">'.$state.'</span>'; |
|
199 | 199 | } else { |
200 | 200 | return ''; |
201 | 201 | } |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | public static function addressCountry(EEI_Address $obj_with_address = null) |
215 | 215 | { |
216 | 216 | $country = $obj_with_address->country_name(); |
217 | - if (! empty($country)) { |
|
218 | - return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
217 | + if ( ! empty($country)) { |
|
218 | + return '<span itemprop="addressCountry">'.$country.'</span>'; |
|
219 | 219 | } else { |
220 | 220 | return ''; |
221 | 221 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | public static function telephone($phone_nmbr = null) |
252 | 252 | { |
253 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' |
|
253 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' |
|
254 | 254 | : ''; |
255 | 255 | } |
256 | 256 | |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | // Check the URL includes a scheme |
272 | 272 | $parsed_url = parse_url($url); |
273 | 273 | if (empty($parsed_url['scheme'])) { |
274 | - $url = 'http://' . ltrim($url, '/'); |
|
274 | + $url = 'http://'.ltrim($url, '/'); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | $atts = ''; |
278 | 278 | foreach ($attributes as $attribute => $value) { |
279 | - $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
279 | + $atts .= ' '.$attribute.'="'.$value.'"'; |
|
280 | 280 | } |
281 | 281 | $text = $text !== null && $text !== '' ? $text : $url; |
282 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' |
|
282 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' |
|
283 | 283 | : ''; |
284 | 284 | } |
285 | 285 | } |
@@ -12,276 +12,276 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * generates JSON-based linked data for an event |
|
17 | - * |
|
18 | - * @param EE_Event $event |
|
19 | - * @throws EE_Error |
|
20 | - */ |
|
21 | - public static function add_json_linked_data_for_event(EE_Event $event) |
|
22 | - { |
|
23 | - // Check we have a valid datetime for the event |
|
24 | - if (! $event->primary_datetime() instanceof EE_Datetime) { |
|
25 | - return; |
|
26 | - } |
|
27 | - |
|
28 | - $template_args = array( |
|
29 | - 'event_permalink' => '', |
|
30 | - 'event_name' => '', |
|
31 | - 'event_description' => '', |
|
32 | - 'event_start' => '', |
|
33 | - 'event_end' => '', |
|
34 | - 'currency' => '', |
|
35 | - 'event_tickets' => array(), |
|
36 | - 'venue_name' => '', |
|
37 | - 'venue_url' => '', |
|
38 | - 'venue_locality' => '', |
|
39 | - 'venue_region' => '', |
|
40 | - 'venue_address' => '', |
|
41 | - 'event_image' => '', |
|
42 | - ); |
|
43 | - $template_args['event_permalink'] = $event->get_permalink(); |
|
44 | - $template_args['event_name'] = $event->name(); |
|
45 | - $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
46 | - // clone datetime so that date formats don't override those for the original datetime |
|
47 | - $primary_datetime = clone $event->primary_datetime(); |
|
48 | - $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM); |
|
49 | - $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM); |
|
50 | - unset($primary_datetime); |
|
51 | - $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
52 | - foreach ($event->tickets() as $original_ticket) { |
|
53 | - // clone tickets so that date formats don't override those for the original ticket |
|
54 | - $ticket= clone $original_ticket; |
|
55 | - $ID = $ticket->ID(); |
|
56 | - $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
57 | - $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
58 | - $template_args['event_tickets'][ $ID ]['price'] = number_format( |
|
59 | - $ticket->price(), |
|
60 | - EE_Registry::instance()->CFG->currency->dec_plc, |
|
61 | - EE_Registry::instance()->CFG->currency->dec_mrk, |
|
62 | - '' |
|
63 | - ); |
|
64 | - switch ($ticket->ticket_status()) { |
|
65 | - case 'TKO': |
|
66 | - $availability = 'InStock'; |
|
67 | - break; |
|
68 | - case 'TKS': |
|
69 | - $availability = 'SoldOut'; |
|
70 | - break; |
|
71 | - default: |
|
72 | - $availability = null; |
|
73 | - break; |
|
74 | - } |
|
75 | - $template_args['event_tickets'][ $ID ]['availability'] = $availability; |
|
76 | - unset($ticket); |
|
77 | - } |
|
78 | - $VNU_ID = espresso_venue_id(); |
|
79 | - if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
80 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
81 | - $template_args['venue_name'] = get_the_title($VNU_ID); |
|
82 | - $template_args['venue_url'] = get_permalink($VNU_ID); |
|
83 | - $template_args['venue_locality'] = $venue->city(); |
|
84 | - $template_args['venue_region'] = $venue->state_name(); |
|
85 | - $template_args['venue_address'] = $venue->address(); |
|
86 | - } |
|
87 | - $template_args['event_image'] = $event->feature_image_url(); |
|
88 | - $template_args = apply_filters( |
|
89 | - 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
90 | - $template_args, |
|
91 | - $event, |
|
92 | - $VNU_ID |
|
93 | - ); |
|
94 | - extract($template_args, EXTR_OVERWRITE); |
|
95 | - include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * location |
|
101 | - * The location of the event, organization or action. |
|
102 | - * Should include the Venue name AND schema formatted address info |
|
103 | - * |
|
104 | - * @access public |
|
105 | - * @param string $location |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public static function location($location = null) |
|
109 | - { |
|
110 | - return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
111 | - . $location |
|
112 | - . '</div>' : ''; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * name |
|
119 | - * The name of the Event or Venue. |
|
120 | - * |
|
121 | - * @access public |
|
122 | - * @param string $name |
|
123 | - * @return string |
|
124 | - */ |
|
125 | - public static function name($name = null) |
|
126 | - { |
|
127 | - return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * streetAddress |
|
134 | - * The street address. For example, 1600 Amphitheatre Pkwy. |
|
135 | - * |
|
136 | - * @access public |
|
137 | - * @param EEI_Address $obj_with_address |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public static function streetAddress(EEI_Address $obj_with_address = null) |
|
141 | - { |
|
142 | - return $obj_with_address->address() !== null && $obj_with_address->address() !== '' |
|
143 | - ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * postOfficeBoxNumber |
|
150 | - * The post office box number for PO box addresses. |
|
151 | - * |
|
152 | - * @access public |
|
153 | - * @param EEI_Address $obj_with_address |
|
154 | - * @return string |
|
155 | - */ |
|
156 | - public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) |
|
157 | - { |
|
158 | - // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
|
159 | - if (preg_match( |
|
160 | - "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", |
|
161 | - $obj_with_address->address2() |
|
162 | - ) ) { |
|
163 | - return $obj_with_address->address2() !== null && $obj_with_address->address2() !== '' |
|
164 | - ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
165 | - } else { |
|
166 | - return $obj_with_address->address2(); |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * addressLocality |
|
174 | - * The locality (city, town, etc). For example, Mountain View. |
|
175 | - * |
|
176 | - * @access public |
|
177 | - * @param EEI_Address $obj_with_address |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public static function addressLocality(EEI_Address $obj_with_address = null) |
|
181 | - { |
|
182 | - return $obj_with_address->city() !== null && $obj_with_address->city() !== '' |
|
183 | - ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * addressRegion |
|
190 | - * The region (state, province, etc). For example, CA. |
|
191 | - * |
|
192 | - * @access public |
|
193 | - * @param EEI_Address $obj_with_address |
|
194 | - * @return string |
|
195 | - */ |
|
196 | - public static function addressRegion(EEI_Address $obj_with_address = null) |
|
197 | - { |
|
198 | - $state = $obj_with_address->state_name(); |
|
199 | - if (! empty($state)) { |
|
200 | - return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
201 | - } else { |
|
202 | - return ''; |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * addressCountry |
|
210 | - * The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code. |
|
211 | - * |
|
212 | - * @access public |
|
213 | - * @param EEI_Address $obj_with_address |
|
214 | - * @return string |
|
215 | - */ |
|
216 | - public static function addressCountry(EEI_Address $obj_with_address = null) |
|
217 | - { |
|
218 | - $country = $obj_with_address->country_name(); |
|
219 | - if (! empty($country)) { |
|
220 | - return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
221 | - } else { |
|
222 | - return ''; |
|
223 | - } |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * postalCode |
|
230 | - * The postal code. For example, 94043. |
|
231 | - * |
|
232 | - * @access public |
|
233 | - * @param EEI_Address $obj_with_address |
|
234 | - * @return string |
|
235 | - */ |
|
236 | - public static function postalCode(EEI_Address $obj_with_address = null) |
|
237 | - { |
|
238 | - return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
|
239 | - . $obj_with_address->zip() |
|
240 | - . '</span>' : ''; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * telephone |
|
247 | - * The telephone number. |
|
248 | - * |
|
249 | - * @access public |
|
250 | - * @param string $phone_nmbr |
|
251 | - * @return string |
|
252 | - */ |
|
253 | - public static function telephone($phone_nmbr = null) |
|
254 | - { |
|
255 | - return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' |
|
256 | - : ''; |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * URL |
|
263 | - * URL of the item as a clickable link |
|
264 | - * |
|
265 | - * @access public |
|
266 | - * @param string $url - the URL that the link will resolve to |
|
267 | - * @param string $text - the text that will be used for the visible link |
|
268 | - * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
|
269 | - * @return string (link) |
|
270 | - */ |
|
271 | - public static function url($url = null, $text = null, $attributes = array()) |
|
272 | - { |
|
273 | - // Check the URL includes a scheme |
|
274 | - $parsed_url = parse_url($url); |
|
275 | - if (empty($parsed_url['scheme'])) { |
|
276 | - $url = 'http://' . ltrim($url, '/'); |
|
277 | - } |
|
278 | - |
|
279 | - $atts = ''; |
|
280 | - foreach ($attributes as $attribute => $value) { |
|
281 | - $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
282 | - } |
|
283 | - $text = $text !== null && $text !== '' ? $text : $url; |
|
284 | - return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' |
|
285 | - : ''; |
|
286 | - } |
|
15 | + /** |
|
16 | + * generates JSON-based linked data for an event |
|
17 | + * |
|
18 | + * @param EE_Event $event |
|
19 | + * @throws EE_Error |
|
20 | + */ |
|
21 | + public static function add_json_linked_data_for_event(EE_Event $event) |
|
22 | + { |
|
23 | + // Check we have a valid datetime for the event |
|
24 | + if (! $event->primary_datetime() instanceof EE_Datetime) { |
|
25 | + return; |
|
26 | + } |
|
27 | + |
|
28 | + $template_args = array( |
|
29 | + 'event_permalink' => '', |
|
30 | + 'event_name' => '', |
|
31 | + 'event_description' => '', |
|
32 | + 'event_start' => '', |
|
33 | + 'event_end' => '', |
|
34 | + 'currency' => '', |
|
35 | + 'event_tickets' => array(), |
|
36 | + 'venue_name' => '', |
|
37 | + 'venue_url' => '', |
|
38 | + 'venue_locality' => '', |
|
39 | + 'venue_region' => '', |
|
40 | + 'venue_address' => '', |
|
41 | + 'event_image' => '', |
|
42 | + ); |
|
43 | + $template_args['event_permalink'] = $event->get_permalink(); |
|
44 | + $template_args['event_name'] = $event->name(); |
|
45 | + $template_args['event_description'] = wp_strip_all_tags($event->short_description(200)); |
|
46 | + // clone datetime so that date formats don't override those for the original datetime |
|
47 | + $primary_datetime = clone $event->primary_datetime(); |
|
48 | + $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM); |
|
49 | + $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM); |
|
50 | + unset($primary_datetime); |
|
51 | + $template_args['currency'] = EE_Registry::instance()->CFG->currency->code; |
|
52 | + foreach ($event->tickets() as $original_ticket) { |
|
53 | + // clone tickets so that date formats don't override those for the original ticket |
|
54 | + $ticket= clone $original_ticket; |
|
55 | + $ID = $ticket->ID(); |
|
56 | + $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null); |
|
57 | + $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null); |
|
58 | + $template_args['event_tickets'][ $ID ]['price'] = number_format( |
|
59 | + $ticket->price(), |
|
60 | + EE_Registry::instance()->CFG->currency->dec_plc, |
|
61 | + EE_Registry::instance()->CFG->currency->dec_mrk, |
|
62 | + '' |
|
63 | + ); |
|
64 | + switch ($ticket->ticket_status()) { |
|
65 | + case 'TKO': |
|
66 | + $availability = 'InStock'; |
|
67 | + break; |
|
68 | + case 'TKS': |
|
69 | + $availability = 'SoldOut'; |
|
70 | + break; |
|
71 | + default: |
|
72 | + $availability = null; |
|
73 | + break; |
|
74 | + } |
|
75 | + $template_args['event_tickets'][ $ID ]['availability'] = $availability; |
|
76 | + unset($ticket); |
|
77 | + } |
|
78 | + $VNU_ID = espresso_venue_id(); |
|
79 | + if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) { |
|
80 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
81 | + $template_args['venue_name'] = get_the_title($VNU_ID); |
|
82 | + $template_args['venue_url'] = get_permalink($VNU_ID); |
|
83 | + $template_args['venue_locality'] = $venue->city(); |
|
84 | + $template_args['venue_region'] = $venue->state_name(); |
|
85 | + $template_args['venue_address'] = $venue->address(); |
|
86 | + } |
|
87 | + $template_args['event_image'] = $event->feature_image_url(); |
|
88 | + $template_args = apply_filters( |
|
89 | + 'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args', |
|
90 | + $template_args, |
|
91 | + $event, |
|
92 | + $VNU_ID |
|
93 | + ); |
|
94 | + extract($template_args, EXTR_OVERWRITE); |
|
95 | + include EE_TEMPLATES . 'json_linked_data_for_event.template.php'; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * location |
|
101 | + * The location of the event, organization or action. |
|
102 | + * Should include the Venue name AND schema formatted address info |
|
103 | + * |
|
104 | + * @access public |
|
105 | + * @param string $location |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public static function location($location = null) |
|
109 | + { |
|
110 | + return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' |
|
111 | + . $location |
|
112 | + . '</div>' : ''; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * name |
|
119 | + * The name of the Event or Venue. |
|
120 | + * |
|
121 | + * @access public |
|
122 | + * @param string $name |
|
123 | + * @return string |
|
124 | + */ |
|
125 | + public static function name($name = null) |
|
126 | + { |
|
127 | + return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : ''; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * streetAddress |
|
134 | + * The street address. For example, 1600 Amphitheatre Pkwy. |
|
135 | + * |
|
136 | + * @access public |
|
137 | + * @param EEI_Address $obj_with_address |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public static function streetAddress(EEI_Address $obj_with_address = null) |
|
141 | + { |
|
142 | + return $obj_with_address->address() !== null && $obj_with_address->address() !== '' |
|
143 | + ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : ''; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * postOfficeBoxNumber |
|
150 | + * The post office box number for PO box addresses. |
|
151 | + * |
|
152 | + * @access public |
|
153 | + * @param EEI_Address $obj_with_address |
|
154 | + * @return string |
|
155 | + */ |
|
156 | + public static function postOfficeBoxNumber(EEI_Address $obj_with_address = null) |
|
157 | + { |
|
158 | + // regex check for some form of PO Box or P.O. Box, etc, etc, etc |
|
159 | + if (preg_match( |
|
160 | + "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", |
|
161 | + $obj_with_address->address2() |
|
162 | + ) ) { |
|
163 | + return $obj_with_address->address2() !== null && $obj_with_address->address2() !== '' |
|
164 | + ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : ''; |
|
165 | + } else { |
|
166 | + return $obj_with_address->address2(); |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * addressLocality |
|
174 | + * The locality (city, town, etc). For example, Mountain View. |
|
175 | + * |
|
176 | + * @access public |
|
177 | + * @param EEI_Address $obj_with_address |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public static function addressLocality(EEI_Address $obj_with_address = null) |
|
181 | + { |
|
182 | + return $obj_with_address->city() !== null && $obj_with_address->city() !== '' |
|
183 | + ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : ''; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * addressRegion |
|
190 | + * The region (state, province, etc). For example, CA. |
|
191 | + * |
|
192 | + * @access public |
|
193 | + * @param EEI_Address $obj_with_address |
|
194 | + * @return string |
|
195 | + */ |
|
196 | + public static function addressRegion(EEI_Address $obj_with_address = null) |
|
197 | + { |
|
198 | + $state = $obj_with_address->state_name(); |
|
199 | + if (! empty($state)) { |
|
200 | + return '<span itemprop="addressRegion">' . $state . '</span>'; |
|
201 | + } else { |
|
202 | + return ''; |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * addressCountry |
|
210 | + * The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code. |
|
211 | + * |
|
212 | + * @access public |
|
213 | + * @param EEI_Address $obj_with_address |
|
214 | + * @return string |
|
215 | + */ |
|
216 | + public static function addressCountry(EEI_Address $obj_with_address = null) |
|
217 | + { |
|
218 | + $country = $obj_with_address->country_name(); |
|
219 | + if (! empty($country)) { |
|
220 | + return '<span itemprop="addressCountry">' . $country . '</span>'; |
|
221 | + } else { |
|
222 | + return ''; |
|
223 | + } |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * postalCode |
|
230 | + * The postal code. For example, 94043. |
|
231 | + * |
|
232 | + * @access public |
|
233 | + * @param EEI_Address $obj_with_address |
|
234 | + * @return string |
|
235 | + */ |
|
236 | + public static function postalCode(EEI_Address $obj_with_address = null) |
|
237 | + { |
|
238 | + return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">' |
|
239 | + . $obj_with_address->zip() |
|
240 | + . '</span>' : ''; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * telephone |
|
247 | + * The telephone number. |
|
248 | + * |
|
249 | + * @access public |
|
250 | + * @param string $phone_nmbr |
|
251 | + * @return string |
|
252 | + */ |
|
253 | + public static function telephone($phone_nmbr = null) |
|
254 | + { |
|
255 | + return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' |
|
256 | + : ''; |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * URL |
|
263 | + * URL of the item as a clickable link |
|
264 | + * |
|
265 | + * @access public |
|
266 | + * @param string $url - the URL that the link will resolve to |
|
267 | + * @param string $text - the text that will be used for the visible link |
|
268 | + * @param array $attributes - array of additional link attributes in attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' ) |
|
269 | + * @return string (link) |
|
270 | + */ |
|
271 | + public static function url($url = null, $text = null, $attributes = array()) |
|
272 | + { |
|
273 | + // Check the URL includes a scheme |
|
274 | + $parsed_url = parse_url($url); |
|
275 | + if (empty($parsed_url['scheme'])) { |
|
276 | + $url = 'http://' . ltrim($url, '/'); |
|
277 | + } |
|
278 | + |
|
279 | + $atts = ''; |
|
280 | + foreach ($attributes as $attribute => $value) { |
|
281 | + $atts .= ' ' . $attribute . '="' . $value . '"'; |
|
282 | + } |
|
283 | + $text = $text !== null && $text !== '' ? $text : $url; |
|
284 | + return $url !== null && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' |
|
285 | + : ''; |
|
286 | + } |
|
287 | 287 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | <h2 class="ee-admin-settings-hdr"> |
12 | 12 | <?php _e( |
13 | - 'Countries and States/Provinces', |
|
14 | - 'event_espresso' |
|
15 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
13 | + 'Countries and States/Provinces', |
|
14 | + 'event_espresso' |
|
15 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
16 | 16 | <table class="form-table"> |
17 | 17 | <tbody> |
18 | 18 | <?php echo EEH_Form_Fields::generate_form_input($countries); ?> |
@@ -21,38 +21,38 @@ discard block |
||
21 | 21 | <br/> |
22 | 22 | <p> |
23 | 23 | <?php |
24 | - esc_html_e( |
|
25 | - 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | - 'event_espresso' |
|
27 | - ); |
|
28 | - ?> |
|
24 | + esc_html_e( |
|
25 | + 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | + 'event_espresso' |
|
27 | + ); |
|
28 | + ?> |
|
29 | 29 | </p> |
30 | 30 | <p id="country-currency-setting-disabled-pg" style="display: none;"> |
31 | 31 | <span class="reminder-spn"> |
32 | 32 | <?php printf( |
33 | - esc_html__( |
|
34 | - 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | - 'event_espresso' |
|
36 | - ), |
|
37 | - $CNT_name_for_site |
|
38 | - ); ?> |
|
33 | + esc_html__( |
|
34 | + 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | + 'event_espresso' |
|
36 | + ), |
|
37 | + $CNT_name_for_site |
|
38 | + ); ?> |
|
39 | 39 | </span> |
40 | 40 | </p> |
41 | 41 | <div id="country-details-settings-dv"> |
42 | 42 | <h2 class="ee-admin-settings-hdr"> |
43 | 43 | <?php _e( |
44 | - 'Country Details', |
|
45 | - 'event_espresso' |
|
46 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
44 | + 'Country Details', |
|
45 | + 'event_espresso' |
|
46 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
47 | 47 | <div id="country-details-dv"><?php echo $country_details_settings; ?></div> |
48 | 48 | </div> |
49 | 49 | |
50 | 50 | <div id="country-states-settings-dv"> |
51 | 51 | <h2 class="ee-admin-settings-hdr"> |
52 | 52 | <?php _e( |
53 | - 'States/Provinces', |
|
54 | - 'event_espresso' |
|
55 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
53 | + 'States/Provinces', |
|
54 | + 'event_espresso' |
|
55 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
56 | 56 | <div id="country-states-dv"><?php echo $country_states_settings; ?></div> |
57 | 57 | </div> |
58 | 58 |
@@ -8,10 +8,10 @@ |
||
8 | 8 | <table id="general-setting-country-details-tbl" class="form-table"> |
9 | 9 | <tbody> |
10 | 10 | <?php |
11 | - foreach ($inputs as $ID => $input) { |
|
12 | - echo EEH_Form_Fields::generate_form_input($input); |
|
13 | - } |
|
14 | - ?> |
|
11 | + foreach ($inputs as $ID => $input) { |
|
12 | + echo EEH_Form_Fields::generate_form_input($input); |
|
13 | + } |
|
14 | + ?> |
|
15 | 15 | <tr> |
16 | 16 | <th></th> |
17 | 17 | <td> |