@@ -239,7 +239,7 @@ |
||
239 | 239 | * setTicketMinAndMax |
240 | 240 | * |
241 | 241 | * @param int $remaining |
242 | - * @return array |
|
242 | + * @return integer[] |
|
243 | 243 | * @throws \EE_Error |
244 | 244 | */ |
245 | 245 | protected function setTicketMinAndMax($remaining) |
@@ -16,462 +16,462 @@ |
||
16 | 16 | class TicketSelectorRowStandard extends TicketSelectorRow |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var TicketDetails $ticket_details |
|
21 | - */ |
|
22 | - protected $ticket_details; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
26 | - */ |
|
27 | - protected $template_settings; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var \EE_Tax_Config $tax_settings |
|
31 | - */ |
|
32 | - protected $tax_settings; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $required_ticket_sold_out |
|
36 | - */ |
|
37 | - protected $required_ticket_sold_out; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var boolean $prices_displayed_including_taxes |
|
41 | - */ |
|
42 | - protected $prices_displayed_including_taxes; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var string $event_status |
|
46 | - */ |
|
47 | - protected $event_status; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var int $row |
|
51 | - */ |
|
52 | - protected $row; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var int $cols |
|
56 | - */ |
|
57 | - protected $cols; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var boolean $hidden_input_qty |
|
61 | - */ |
|
62 | - protected $hidden_input_qty; |
|
63 | - |
|
64 | - /** |
|
65 | - * @var string $ticket_datetime_classes |
|
66 | - */ |
|
67 | - protected $ticket_datetime_classes; |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * TicketDetails constructor. |
|
73 | - * |
|
74 | - * @param TicketDetails $ticket_details |
|
75 | - * @param \EE_Tax_Config $tax_settings |
|
76 | - * @param int $total_tickets |
|
77 | - * @param int $max_atndz |
|
78 | - * @param int $row |
|
79 | - * @param int $cols |
|
80 | - * @param boolean $required_ticket_sold_out |
|
81 | - * @param string $event_status |
|
82 | - * @param string $ticket_datetime_classes |
|
83 | - */ |
|
84 | - public function __construct( |
|
85 | - TicketDetails $ticket_details, |
|
86 | - \EE_Tax_Config $tax_settings, |
|
87 | - $total_tickets, |
|
88 | - $max_atndz, |
|
89 | - $row, |
|
90 | - $cols, |
|
91 | - $required_ticket_sold_out, |
|
92 | - $event_status, |
|
93 | - $ticket_datetime_classes |
|
94 | - ) { |
|
95 | - $this->ticket = $ticket_details->getTicket(); |
|
96 | - $this->ticket_details = $ticket_details; |
|
97 | - $this->template_settings = $ticket_details->getTemplateSettings(); |
|
98 | - $this->tax_settings = $tax_settings; |
|
99 | - $this->total_tickets = $total_tickets; |
|
100 | - $this->max_atndz = $max_atndz; |
|
101 | - $this->row = $row; |
|
102 | - $this->cols = $cols; |
|
103 | - $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
104 | - $this->event_status = $event_status; |
|
105 | - $this->date_format = $ticket_details->getDateFormat(); |
|
106 | - $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
107 | - parent::__construct($this->ticket, $max_atndz, $this->date_format); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * other ticket rows will need to know if a required ticket is sold out, |
|
114 | - * so that they are not offered for sale |
|
115 | - * |
|
116 | - * @return boolean |
|
117 | - */ |
|
118 | - public function getRequiredTicketSoldOut() |
|
119 | - { |
|
120 | - return $this->required_ticket_sold_out; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return int |
|
127 | - */ |
|
128 | - public function getCols() |
|
129 | - { |
|
130 | - return $this->cols; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * getHtml |
|
137 | - * |
|
138 | - * @return string |
|
139 | - * @throws \EE_Error |
|
140 | - */ |
|
141 | - public function getHtml() |
|
142 | - { |
|
143 | - $min = 0; |
|
144 | - $max = $this->ticket->max(); |
|
145 | - $remaining = $this->ticket->remaining(); |
|
146 | - if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
147 | - list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
148 | - } else { |
|
149 | - // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
150 | - $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
151 | - ? $this->ticket->start_date() |
|
152 | - : $this->required_ticket_sold_out; |
|
153 | - } |
|
154 | - list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
155 | - list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
156 | - /** |
|
157 | - * Allow plugins to hook in and abort the generation and display of this row to do |
|
158 | - * something else if they want. |
|
159 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
160 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
161 | - * current row. |
|
162 | - * |
|
163 | - * @var string|bool |
|
164 | - */ |
|
165 | - $ticket_selector_row_html = apply_filters( |
|
166 | - 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
167 | - false, |
|
168 | - $this->ticket, |
|
169 | - $max, |
|
170 | - $min, |
|
171 | - $this->required_ticket_sold_out, |
|
172 | - $ticket_price, |
|
173 | - $ticket_bundle, |
|
174 | - $ticket_status, |
|
175 | - $status_class |
|
176 | - ); |
|
177 | - if ($ticket_selector_row_html !== false) { |
|
178 | - return $ticket_selector_row_html; |
|
179 | - } |
|
180 | - $ticket_selector_row_html = \EEH_HTML::tr( |
|
181 | - '', '', |
|
182 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
183 | - ); |
|
184 | - /** |
|
185 | - * Allow plugins to hook in and abort the generation and display of the contents of this |
|
186 | - * row to do something else if they want. |
|
187 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
188 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
189 | - * current row. |
|
190 | - * |
|
191 | - * @var string|bool |
|
192 | - */ |
|
193 | - $new_row_cells_content = apply_filters( |
|
194 | - 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
195 | - false, |
|
196 | - $this->ticket, |
|
197 | - $max, |
|
198 | - $min, |
|
199 | - $this->required_ticket_sold_out, |
|
200 | - $ticket_price, |
|
201 | - $ticket_bundle, |
|
202 | - $ticket_status, |
|
203 | - $status_class |
|
204 | - ); |
|
205 | - if ($new_row_cells_content !== false) { |
|
206 | - return $ticket_selector_row_html |
|
207 | - . $new_row_cells_content |
|
208 | - . $this->ticketQtyAndIdHiddenInputs() |
|
209 | - . \EEH_HTML::trx(); |
|
210 | - } |
|
211 | - $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
212 | - |
|
213 | - $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
214 | - $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
215 | - $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
216 | - $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
217 | - if (empty($this->ticket_status_display)) { |
|
218 | - if ($this->max_atndz === 1) { |
|
219 | - // only ONE attendee is allowed to register at a time |
|
220 | - $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
221 | - } else if ($max > 0) { |
|
222 | - $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
223 | - } |
|
224 | - } |
|
225 | - $ticket_selector_row_html .= $this->ticket_status_display; |
|
226 | - $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
227 | - $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
228 | - $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
229 | - $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
230 | - |
|
231 | - |
|
232 | - $this->row++; |
|
233 | - return $ticket_selector_row_html; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * setTicketMinAndMax |
|
240 | - * |
|
241 | - * @param int $remaining |
|
242 | - * @return array |
|
243 | - * @throws \EE_Error |
|
244 | - */ |
|
245 | - protected function setTicketMinAndMax($remaining) |
|
246 | - { |
|
247 | - // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
248 | - $max = min($remaining, $this->max_atndz); |
|
249 | - // but... we also want to restrict the number of tickets by the ticket max setting, |
|
250 | - // however, the max still can't be higher than what was just set above |
|
251 | - $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
252 | - // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
253 | - $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
254 | - // and if the ticket is required, then make sure that min qty is at least 1 |
|
255 | - $min = $this->ticket->required() ? max($min, 1) : $min; |
|
256 | - return array($min, $max); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * getTicketPriceDetails |
|
263 | - * |
|
264 | - * @return array |
|
265 | - * @throws \EE_Error |
|
266 | - */ |
|
267 | - protected function getTicketPriceDetails() |
|
268 | - { |
|
269 | - $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
270 | - ? $this->ticket->get_ticket_total_with_taxes() |
|
271 | - : $this->ticket->get_ticket_subtotal(); |
|
272 | - $ticket_bundle = false; |
|
273 | - $ticket_min = $this->ticket->min(); |
|
274 | - // for ticket bundles, set min and max qty the same |
|
275 | - if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
276 | - $ticket_price *= $ticket_min; |
|
277 | - $ticket_bundle = true; |
|
278 | - } |
|
279 | - $ticket_price = apply_filters( |
|
280 | - 'FHEE__ticket_selector_chart_template__ticket_price', |
|
281 | - $ticket_price, |
|
282 | - $this->ticket |
|
283 | - ); |
|
284 | - return array($ticket_price, $ticket_bundle); |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * getTicketStatusClasses |
|
291 | - * |
|
292 | - * @param int $remaining |
|
293 | - * @return array |
|
294 | - * @throws \EE_Error |
|
295 | - */ |
|
296 | - protected function getTicketStatusClasses($remaining = 0) |
|
297 | - { |
|
298 | - // if a previous required ticket with the same sale start date is sold out, |
|
299 | - // then mark this ticket as sold out as well. |
|
300 | - // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
301 | - $tkt_status = $this->required_ticket_sold_out !== false |
|
302 | - && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
303 | - ? \EE_Ticket::sold_out |
|
304 | - : $this->ticket->ticket_status(); |
|
305 | - $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
306 | - ? \EE_Ticket::sold_out |
|
307 | - : $tkt_status; |
|
308 | - // check ticket status |
|
309 | - switch ($tkt_status) { |
|
310 | - // sold_out |
|
311 | - case \EE_Ticket::sold_out : |
|
312 | - $ticket_status = 'ticket-sales-sold-out'; |
|
313 | - $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
314 | - break; |
|
315 | - // expired |
|
316 | - case \EE_Ticket::expired : |
|
317 | - $ticket_status = 'ticket-sales-expired'; |
|
318 | - $status_class = 'ticket-sales-expired lt-grey-text'; |
|
319 | - break; |
|
320 | - // archived |
|
321 | - case \EE_Ticket::archived : |
|
322 | - $ticket_status = 'archived-ticket'; |
|
323 | - $status_class = 'archived-ticket hidden'; |
|
324 | - break; |
|
325 | - // pending |
|
326 | - case \EE_Ticket::pending : |
|
327 | - $ticket_status = 'ticket-pending'; |
|
328 | - $status_class = 'ticket-pending'; |
|
329 | - break; |
|
330 | - // onsale |
|
331 | - case \EE_Ticket::onsale : |
|
332 | - default : |
|
333 | - $ticket_status = 'ticket-on-sale'; |
|
334 | - $status_class = 'ticket-on-sale'; |
|
335 | - break; |
|
336 | - } |
|
337 | - $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
338 | - return array($tkt_status, $ticket_status, $status_class); |
|
339 | - } |
|
340 | - |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * ticketNameTableCell |
|
345 | - * |
|
346 | - * @return string |
|
347 | - * @throws \EE_Error |
|
348 | - */ |
|
349 | - protected function ticketNameTableCell() |
|
350 | - { |
|
351 | - $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
352 | - $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
353 | - $html .= $this->ticket_details->getShowHideLinks(); |
|
354 | - if ($this->ticket->required()) { |
|
355 | - $html .= \EEH_HTML::p( |
|
356 | - apply_filters( |
|
357 | - 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
358 | - esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
359 | - ), |
|
360 | - '', 'ticket-required-pg' |
|
361 | - ); |
|
362 | - } |
|
363 | - $html .= \EEH_HTML::tdx(); |
|
364 | - return $html; |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * ticketPriceTableCell |
|
371 | - * |
|
372 | - * @param float $ticket_price |
|
373 | - * @param bool $ticket_bundle |
|
374 | - * @return string |
|
375 | - * @throws \EE_Error |
|
376 | - */ |
|
377 | - protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
378 | - { |
|
379 | - $html = ''; |
|
380 | - if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
381 | - $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
382 | - $html .= \EEH_Template::format_currency($ticket_price); |
|
383 | - $html .= $this->ticket->taxable() |
|
384 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
385 | - : ''; |
|
386 | - $html .= ' '; |
|
387 | - $html .= \EEH_HTML::span( |
|
388 | - $ticket_bundle |
|
389 | - ? apply_filters( |
|
390 | - 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
391 | - __(' / bundle', 'event_espresso') |
|
392 | - ) |
|
393 | - : apply_filters( |
|
394 | - 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
395 | - __('', 'event_espresso') |
|
396 | - ), |
|
397 | - '', 'smaller-text no-bold' |
|
398 | - ); |
|
399 | - $html .= ' '; |
|
400 | - $html .= \EEH_HTML::tdx(); |
|
401 | - $this->cols++; |
|
402 | - } |
|
403 | - return $html; |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * onlyOneAttendeeCanRegister |
|
410 | - * |
|
411 | - * @return string |
|
412 | - */ |
|
413 | - protected function onlyOneAttendeeCanRegister() |
|
414 | - { |
|
415 | - // display submit button since we have tickets available |
|
416 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
417 | - $this->hidden_input_qty = false; |
|
418 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
419 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
420 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
421 | - $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
422 | - $html .= ' title=""/>'; |
|
423 | - return $html; |
|
424 | - } |
|
425 | - |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * ticketQuantitySelector |
|
430 | - * |
|
431 | - * @param int $min |
|
432 | - * @param int $max |
|
433 | - * @return string |
|
434 | - * @throws \EE_Error |
|
435 | - */ |
|
436 | - protected function ticketQuantitySelector($min = 0, $max = 0) |
|
437 | - { |
|
438 | - // display submit button since we have tickets available |
|
439 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
440 | - $this->hidden_input_qty = false; |
|
441 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
442 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
443 | - $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
444 | - // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
445 | - if ($min !== 0 && ! $this->ticket->required()) { |
|
446 | - $html .= '<option value="0"> 0 </option>'; |
|
447 | - } |
|
448 | - // offer ticket quantities from the min to the max |
|
449 | - for ($i = $min; $i <= $max; $i++) { |
|
450 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
451 | - } |
|
452 | - $html .= '</select>'; |
|
453 | - return $html; |
|
454 | - } |
|
455 | - |
|
456 | - |
|
457 | - |
|
458 | - /** |
|
459 | - * getHiddenInputs |
|
460 | - * |
|
461 | - * @return string |
|
462 | - * @throws \EE_Error |
|
463 | - */ |
|
464 | - protected function ticketQtyAndIdHiddenInputs() |
|
465 | - { |
|
466 | - $html = ''; |
|
467 | - // depending on group reg we need to change the format for qty |
|
468 | - if ($this->hidden_input_qty) { |
|
469 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
470 | - } |
|
471 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
472 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
473 | - return $html; |
|
474 | - } |
|
19 | + /** |
|
20 | + * @var TicketDetails $ticket_details |
|
21 | + */ |
|
22 | + protected $ticket_details; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
26 | + */ |
|
27 | + protected $template_settings; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var \EE_Tax_Config $tax_settings |
|
31 | + */ |
|
32 | + protected $tax_settings; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $required_ticket_sold_out |
|
36 | + */ |
|
37 | + protected $required_ticket_sold_out; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var boolean $prices_displayed_including_taxes |
|
41 | + */ |
|
42 | + protected $prices_displayed_including_taxes; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var string $event_status |
|
46 | + */ |
|
47 | + protected $event_status; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var int $row |
|
51 | + */ |
|
52 | + protected $row; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var int $cols |
|
56 | + */ |
|
57 | + protected $cols; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var boolean $hidden_input_qty |
|
61 | + */ |
|
62 | + protected $hidden_input_qty; |
|
63 | + |
|
64 | + /** |
|
65 | + * @var string $ticket_datetime_classes |
|
66 | + */ |
|
67 | + protected $ticket_datetime_classes; |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * TicketDetails constructor. |
|
73 | + * |
|
74 | + * @param TicketDetails $ticket_details |
|
75 | + * @param \EE_Tax_Config $tax_settings |
|
76 | + * @param int $total_tickets |
|
77 | + * @param int $max_atndz |
|
78 | + * @param int $row |
|
79 | + * @param int $cols |
|
80 | + * @param boolean $required_ticket_sold_out |
|
81 | + * @param string $event_status |
|
82 | + * @param string $ticket_datetime_classes |
|
83 | + */ |
|
84 | + public function __construct( |
|
85 | + TicketDetails $ticket_details, |
|
86 | + \EE_Tax_Config $tax_settings, |
|
87 | + $total_tickets, |
|
88 | + $max_atndz, |
|
89 | + $row, |
|
90 | + $cols, |
|
91 | + $required_ticket_sold_out, |
|
92 | + $event_status, |
|
93 | + $ticket_datetime_classes |
|
94 | + ) { |
|
95 | + $this->ticket = $ticket_details->getTicket(); |
|
96 | + $this->ticket_details = $ticket_details; |
|
97 | + $this->template_settings = $ticket_details->getTemplateSettings(); |
|
98 | + $this->tax_settings = $tax_settings; |
|
99 | + $this->total_tickets = $total_tickets; |
|
100 | + $this->max_atndz = $max_atndz; |
|
101 | + $this->row = $row; |
|
102 | + $this->cols = $cols; |
|
103 | + $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
104 | + $this->event_status = $event_status; |
|
105 | + $this->date_format = $ticket_details->getDateFormat(); |
|
106 | + $this->ticket_datetime_classes = $ticket_datetime_classes; |
|
107 | + parent::__construct($this->ticket, $max_atndz, $this->date_format); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * other ticket rows will need to know if a required ticket is sold out, |
|
114 | + * so that they are not offered for sale |
|
115 | + * |
|
116 | + * @return boolean |
|
117 | + */ |
|
118 | + public function getRequiredTicketSoldOut() |
|
119 | + { |
|
120 | + return $this->required_ticket_sold_out; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return int |
|
127 | + */ |
|
128 | + public function getCols() |
|
129 | + { |
|
130 | + return $this->cols; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * getHtml |
|
137 | + * |
|
138 | + * @return string |
|
139 | + * @throws \EE_Error |
|
140 | + */ |
|
141 | + public function getHtml() |
|
142 | + { |
|
143 | + $min = 0; |
|
144 | + $max = $this->ticket->max(); |
|
145 | + $remaining = $this->ticket->remaining(); |
|
146 | + if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) { |
|
147 | + list($min, $max) = $this->setTicketMinAndMax($remaining); |
|
148 | + } else { |
|
149 | + // set flag if ticket is required (flag is set to start date so that future tickets are not blocked) |
|
150 | + $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining |
|
151 | + ? $this->ticket->start_date() |
|
152 | + : $this->required_ticket_sold_out; |
|
153 | + } |
|
154 | + list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails(); |
|
155 | + list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining); |
|
156 | + /** |
|
157 | + * Allow plugins to hook in and abort the generation and display of this row to do |
|
158 | + * something else if they want. |
|
159 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
160 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
161 | + * current row. |
|
162 | + * |
|
163 | + * @var string|bool |
|
164 | + */ |
|
165 | + $ticket_selector_row_html = apply_filters( |
|
166 | + 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
167 | + false, |
|
168 | + $this->ticket, |
|
169 | + $max, |
|
170 | + $min, |
|
171 | + $this->required_ticket_sold_out, |
|
172 | + $ticket_price, |
|
173 | + $ticket_bundle, |
|
174 | + $ticket_status, |
|
175 | + $status_class |
|
176 | + ); |
|
177 | + if ($ticket_selector_row_html !== false) { |
|
178 | + return $ticket_selector_row_html; |
|
179 | + } |
|
180 | + $ticket_selector_row_html = \EEH_HTML::tr( |
|
181 | + '', '', |
|
182 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
183 | + ); |
|
184 | + /** |
|
185 | + * Allow plugins to hook in and abort the generation and display of the contents of this |
|
186 | + * row to do something else if they want. |
|
187 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
188 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
189 | + * current row. |
|
190 | + * |
|
191 | + * @var string|bool |
|
192 | + */ |
|
193 | + $new_row_cells_content = apply_filters( |
|
194 | + 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
195 | + false, |
|
196 | + $this->ticket, |
|
197 | + $max, |
|
198 | + $min, |
|
199 | + $this->required_ticket_sold_out, |
|
200 | + $ticket_price, |
|
201 | + $ticket_bundle, |
|
202 | + $ticket_status, |
|
203 | + $status_class |
|
204 | + ); |
|
205 | + if ($new_row_cells_content !== false) { |
|
206 | + return $ticket_selector_row_html |
|
207 | + . $new_row_cells_content |
|
208 | + . $this->ticketQtyAndIdHiddenInputs() |
|
209 | + . \EEH_HTML::trx(); |
|
210 | + } |
|
211 | + $this->hidden_input_qty = $this->max_atndz > 1 ? true : false; |
|
212 | + |
|
213 | + $ticket_selector_row_html .= $this->ticketNameTableCell(); |
|
214 | + $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle); |
|
215 | + $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr'); |
|
216 | + $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining); |
|
217 | + if (empty($this->ticket_status_display)) { |
|
218 | + if ($this->max_atndz === 1) { |
|
219 | + // only ONE attendee is allowed to register at a time |
|
220 | + $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister(); |
|
221 | + } else if ($max > 0) { |
|
222 | + $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max); |
|
223 | + } |
|
224 | + } |
|
225 | + $ticket_selector_row_html .= $this->ticket_status_display; |
|
226 | + $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs(); |
|
227 | + $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols); |
|
228 | + $ticket_selector_row_html .= \EEH_HTML::tdx(); |
|
229 | + $ticket_selector_row_html .= \EEH_HTML::trx(); |
|
230 | + |
|
231 | + |
|
232 | + $this->row++; |
|
233 | + return $ticket_selector_row_html; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * setTicketMinAndMax |
|
240 | + * |
|
241 | + * @param int $remaining |
|
242 | + * @return array |
|
243 | + * @throws \EE_Error |
|
244 | + */ |
|
245 | + protected function setTicketMinAndMax($remaining) |
|
246 | + { |
|
247 | + // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller |
|
248 | + $max = min($remaining, $this->max_atndz); |
|
249 | + // but... we also want to restrict the number of tickets by the ticket max setting, |
|
250 | + // however, the max still can't be higher than what was just set above |
|
251 | + $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max; |
|
252 | + // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
253 | + $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0; |
|
254 | + // and if the ticket is required, then make sure that min qty is at least 1 |
|
255 | + $min = $this->ticket->required() ? max($min, 1) : $min; |
|
256 | + return array($min, $max); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * getTicketPriceDetails |
|
263 | + * |
|
264 | + * @return array |
|
265 | + * @throws \EE_Error |
|
266 | + */ |
|
267 | + protected function getTicketPriceDetails() |
|
268 | + { |
|
269 | + $ticket_price = $this->tax_settings->prices_displayed_including_taxes |
|
270 | + ? $this->ticket->get_ticket_total_with_taxes() |
|
271 | + : $this->ticket->get_ticket_subtotal(); |
|
272 | + $ticket_bundle = false; |
|
273 | + $ticket_min = $this->ticket->min(); |
|
274 | + // for ticket bundles, set min and max qty the same |
|
275 | + if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) { |
|
276 | + $ticket_price *= $ticket_min; |
|
277 | + $ticket_bundle = true; |
|
278 | + } |
|
279 | + $ticket_price = apply_filters( |
|
280 | + 'FHEE__ticket_selector_chart_template__ticket_price', |
|
281 | + $ticket_price, |
|
282 | + $this->ticket |
|
283 | + ); |
|
284 | + return array($ticket_price, $ticket_bundle); |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * getTicketStatusClasses |
|
291 | + * |
|
292 | + * @param int $remaining |
|
293 | + * @return array |
|
294 | + * @throws \EE_Error |
|
295 | + */ |
|
296 | + protected function getTicketStatusClasses($remaining = 0) |
|
297 | + { |
|
298 | + // if a previous required ticket with the same sale start date is sold out, |
|
299 | + // then mark this ticket as sold out as well. |
|
300 | + // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
301 | + $tkt_status = $this->required_ticket_sold_out !== false |
|
302 | + && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
303 | + ? \EE_Ticket::sold_out |
|
304 | + : $this->ticket->ticket_status(); |
|
305 | + $tkt_status = $this->event_status === \EE_Datetime::sold_out |
|
306 | + ? \EE_Ticket::sold_out |
|
307 | + : $tkt_status; |
|
308 | + // check ticket status |
|
309 | + switch ($tkt_status) { |
|
310 | + // sold_out |
|
311 | + case \EE_Ticket::sold_out : |
|
312 | + $ticket_status = 'ticket-sales-sold-out'; |
|
313 | + $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
314 | + break; |
|
315 | + // expired |
|
316 | + case \EE_Ticket::expired : |
|
317 | + $ticket_status = 'ticket-sales-expired'; |
|
318 | + $status_class = 'ticket-sales-expired lt-grey-text'; |
|
319 | + break; |
|
320 | + // archived |
|
321 | + case \EE_Ticket::archived : |
|
322 | + $ticket_status = 'archived-ticket'; |
|
323 | + $status_class = 'archived-ticket hidden'; |
|
324 | + break; |
|
325 | + // pending |
|
326 | + case \EE_Ticket::pending : |
|
327 | + $ticket_status = 'ticket-pending'; |
|
328 | + $status_class = 'ticket-pending'; |
|
329 | + break; |
|
330 | + // onsale |
|
331 | + case \EE_Ticket::onsale : |
|
332 | + default : |
|
333 | + $ticket_status = 'ticket-on-sale'; |
|
334 | + $status_class = 'ticket-on-sale'; |
|
335 | + break; |
|
336 | + } |
|
337 | + $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status); |
|
338 | + return array($tkt_status, $ticket_status, $status_class); |
|
339 | + } |
|
340 | + |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * ticketNameTableCell |
|
345 | + * |
|
346 | + * @return string |
|
347 | + * @throws \EE_Error |
|
348 | + */ |
|
349 | + protected function ticketNameTableCell() |
|
350 | + { |
|
351 | + $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name'); |
|
352 | + $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name')); |
|
353 | + $html .= $this->ticket_details->getShowHideLinks(); |
|
354 | + if ($this->ticket->required()) { |
|
355 | + $html .= \EEH_HTML::p( |
|
356 | + apply_filters( |
|
357 | + 'FHEE__ticket_selector_chart_template__ticket_required_message', |
|
358 | + esc_html__('This ticket is required and must be purchased.', 'event_espresso') |
|
359 | + ), |
|
360 | + '', 'ticket-required-pg' |
|
361 | + ); |
|
362 | + } |
|
363 | + $html .= \EEH_HTML::tdx(); |
|
364 | + return $html; |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * ticketPriceTableCell |
|
371 | + * |
|
372 | + * @param float $ticket_price |
|
373 | + * @param bool $ticket_bundle |
|
374 | + * @return string |
|
375 | + * @throws \EE_Error |
|
376 | + */ |
|
377 | + protected function ticketPriceTableCell($ticket_price, $ticket_bundle) |
|
378 | + { |
|
379 | + $html = ''; |
|
380 | + if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
381 | + $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
|
382 | + $html .= \EEH_Template::format_currency($ticket_price); |
|
383 | + $html .= $this->ticket->taxable() |
|
384 | + ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
385 | + : ''; |
|
386 | + $html .= ' '; |
|
387 | + $html .= \EEH_HTML::span( |
|
388 | + $ticket_bundle |
|
389 | + ? apply_filters( |
|
390 | + 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', |
|
391 | + __(' / bundle', 'event_espresso') |
|
392 | + ) |
|
393 | + : apply_filters( |
|
394 | + 'FHEE__ticket_selector_chart_template__per_ticket_text', |
|
395 | + __('', 'event_espresso') |
|
396 | + ), |
|
397 | + '', 'smaller-text no-bold' |
|
398 | + ); |
|
399 | + $html .= ' '; |
|
400 | + $html .= \EEH_HTML::tdx(); |
|
401 | + $this->cols++; |
|
402 | + } |
|
403 | + return $html; |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * onlyOneAttendeeCanRegister |
|
410 | + * |
|
411 | + * @return string |
|
412 | + */ |
|
413 | + protected function onlyOneAttendeeCanRegister() |
|
414 | + { |
|
415 | + // display submit button since we have tickets available |
|
416 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
417 | + $this->hidden_input_qty = false; |
|
418 | + $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
419 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
420 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
421 | + $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
|
422 | + $html .= ' title=""/>'; |
|
423 | + return $html; |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * ticketQuantitySelector |
|
430 | + * |
|
431 | + * @param int $min |
|
432 | + * @param int $max |
|
433 | + * @return string |
|
434 | + * @throws \EE_Error |
|
435 | + */ |
|
436 | + protected function ticketQuantitySelector($min = 0, $max = 0) |
|
437 | + { |
|
438 | + // display submit button since we have tickets available |
|
439 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
440 | + $this->hidden_input_qty = false; |
|
441 | + $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
442 | + $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
443 | + $html .= ' class="ticket-selector-tbl-qty-slct">'; |
|
444 | + // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
|
445 | + if ($min !== 0 && ! $this->ticket->required()) { |
|
446 | + $html .= '<option value="0"> 0 </option>'; |
|
447 | + } |
|
448 | + // offer ticket quantities from the min to the max |
|
449 | + for ($i = $min; $i <= $max; $i++) { |
|
450 | + $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
451 | + } |
|
452 | + $html .= '</select>'; |
|
453 | + return $html; |
|
454 | + } |
|
455 | + |
|
456 | + |
|
457 | + |
|
458 | + /** |
|
459 | + * getHiddenInputs |
|
460 | + * |
|
461 | + * @return string |
|
462 | + * @throws \EE_Error |
|
463 | + */ |
|
464 | + protected function ticketQtyAndIdHiddenInputs() |
|
465 | + { |
|
466 | + $html = ''; |
|
467 | + // depending on group reg we need to change the format for qty |
|
468 | + if ($this->hidden_input_qty) { |
|
469 | + $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
470 | + } |
|
471 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
472 | + $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
473 | + return $html; |
|
474 | + } |
|
475 | 475 | |
476 | 476 | } |
477 | 477 | // End of file TicketSelectorRowStandard.php |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | } |
180 | 180 | $ticket_selector_row_html = \EEH_HTML::tr( |
181 | 181 | '', '', |
182 | - "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket) |
|
182 | + "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} ".espresso_get_object_css_class($this->ticket) |
|
183 | 183 | ); |
184 | 184 | /** |
185 | 185 | * Allow plugins to hook in and abort the generation and display of the contents of this |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght'); |
382 | 382 | $html .= \EEH_Template::format_currency($ticket_price); |
383 | 383 | $html .= $this->ticket->taxable() |
384 | - ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' ) |
|
384 | + ? \EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text') |
|
385 | 385 | : ''; |
386 | 386 | $html .= ' '; |
387 | 387 | $html .= \EEH_HTML::span( |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | // display submit button since we have tickets available |
416 | 416 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
417 | 417 | $this->hidden_input_qty = false; |
418 | - $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"'; |
|
419 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
420 | - $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"'; |
|
418 | + $html = '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"'; |
|
419 | + $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"'; |
|
420 | + $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"'; |
|
421 | 421 | $html .= $this->total_tickets === 1 ? ' checked="checked"' : ''; |
422 | 422 | $html .= ' title=""/>'; |
423 | 423 | return $html; |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | // display submit button since we have tickets available |
439 | 439 | add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
440 | 440 | $this->hidden_input_qty = false; |
441 | - $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"'; |
|
442 | - $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"'; |
|
441 | + $html = '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"'; |
|
442 | + $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"'; |
|
443 | 443 | $html .= ' class="ticket-selector-tbl-qty-slct">'; |
444 | 444 | // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased |
445 | 445 | if ($min !== 0 && ! $this->ticket->required()) { |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | } |
448 | 448 | // offer ticket quantities from the min to the max |
449 | 449 | for ($i = $min; $i <= $max; $i++) { |
450 | - $html .= '<option value="' . $i . '"> ' . $i . ' </option>'; |
|
450 | + $html .= '<option value="'.$i.'"> '.$i.' </option>'; |
|
451 | 451 | } |
452 | 452 | $html .= '</select>'; |
453 | 453 | return $html; |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | $html = ''; |
467 | 467 | // depending on group reg we need to change the format for qty |
468 | 468 | if ($this->hidden_input_qty) { |
469 | - $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>'; |
|
469 | + $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>'; |
|
470 | 470 | } |
471 | - $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"'; |
|
472 | - $html .= ' value="' . $this->ticket->ID() . '"/>'; |
|
471 | + $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"'; |
|
472 | + $html .= ' value="'.$this->ticket->ID().'"/>'; |
|
473 | 473 | return $html; |
474 | 474 | } |
475 | 475 |
@@ -17,198 +17,198 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @var \EE_Ticket $ticket |
|
22 | - */ |
|
23 | - protected $ticket; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | - */ |
|
28 | - protected $template_settings; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string $date_format |
|
32 | - */ |
|
33 | - protected $date_format; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $time_format |
|
37 | - */ |
|
38 | - protected $time_format; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var boolean $event_is_expired |
|
42 | - */ |
|
43 | - protected $event_is_expired; |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * TicketDetails constructor. |
|
49 | - * |
|
50 | - * @param \EE_Ticket $ticket |
|
51 | - * @param \EE_Ticket_Selector_Config $template_settings |
|
52 | - * @param array $template_args |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - \EE_Ticket $ticket, |
|
56 | - \EE_Ticket_Selector_Config $template_settings, |
|
57 | - array $template_args |
|
58 | - ) |
|
59 | - { |
|
60 | - $this->ticket = $ticket; |
|
61 | - $this->template_settings = $template_settings; |
|
62 | - $this->date_format = $template_args['date_format']; |
|
63 | - $this->time_format = $template_args['time_format']; |
|
64 | - $this->event_is_expired = $template_args['event_is_expired']; |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return \EE_Ticket |
|
71 | - */ |
|
72 | - public function getTicket() |
|
73 | - { |
|
74 | - return $this->ticket; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function showTicketDetails() |
|
83 | - { |
|
84 | - return $this->template_settings->show_ticket_details; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @return \EE_Ticket_Selector_Config |
|
91 | - */ |
|
92 | - public function getTemplateSettings() |
|
93 | - { |
|
94 | - return $this->template_settings; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function getDateFormat() |
|
103 | - { |
|
104 | - return $this->date_format; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getTimeFormat() |
|
113 | - { |
|
114 | - return $this->time_format; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function getShowHideLinks() |
|
123 | - { |
|
124 | - if ( ! $this->showTicketDetails()) { |
|
125 | - return ''; |
|
126 | - } |
|
127 | - return \EEH_HTML::link( |
|
128 | - '', |
|
129 | - sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
130 | - esc_attr( |
|
131 | - apply_filters( |
|
132 | - 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
133 | - __('click to show additional ticket details', 'event_espresso') |
|
134 | - ) |
|
135 | - ), |
|
136 | - "display-{$this->cssId()}", |
|
137 | - 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
138 | - '', |
|
139 | - 'rel="' . $this->cssId() . '"' |
|
140 | - ) . \EEH_HTML::link( |
|
141 | - '', |
|
142 | - sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
143 | - esc_attr( |
|
144 | - apply_filters( |
|
145 | - 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
146 | - __('click to hide additional ticket details', 'event_espresso') |
|
147 | - ) |
|
148 | - ), |
|
149 | - "hide-{$this->cssId()}", |
|
150 | - 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
151 | - 'display:none;', |
|
152 | - 'rel="' . $this->cssId() . '"' |
|
153 | - ); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - public function cssId() |
|
162 | - { |
|
163 | - return apply_filters( |
|
164 | - 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
165 | - "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
166 | - ); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param float $ticket_price |
|
173 | - * @param int $remaining |
|
174 | - * @param int $cols |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function display( |
|
178 | - $ticket_price = 0.00, |
|
179 | - $remaining, |
|
180 | - $cols = 2 |
|
181 | - ) { |
|
182 | - $template_args = array(); |
|
183 | - $template_args['ticket'] = $this->ticket; |
|
184 | - $template_args['ticket_price'] = $ticket_price; |
|
185 | - $template_args['remaining'] = $remaining; |
|
186 | - $template_args['cols'] = $cols; |
|
187 | - $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
188 | - $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
189 | - $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
190 | - $template_args['ticket_details_css_id'] = $this->cssId(); |
|
191 | - $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
192 | - 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
193 | - true |
|
194 | - ); |
|
195 | - $template_args['price_breakdown_heading'] = apply_filters( |
|
196 | - 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
197 | - esc_html__('Price', 'event_espresso') |
|
198 | - ); |
|
199 | - $template_args['date_format'] = $this->date_format; |
|
200 | - $template_args['time_format'] = $this->time_format; |
|
201 | - $template_args['event_is_expired'] = $this->event_is_expired; |
|
202 | - |
|
203 | - return \EEH_Template::locate_template( |
|
204 | - apply_filters( |
|
205 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
206 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
207 | - $this->ticket |
|
208 | - ), |
|
209 | - $template_args |
|
210 | - ); |
|
211 | - } |
|
20 | + /** |
|
21 | + * @var \EE_Ticket $ticket |
|
22 | + */ |
|
23 | + protected $ticket; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
27 | + */ |
|
28 | + protected $template_settings; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string $date_format |
|
32 | + */ |
|
33 | + protected $date_format; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $time_format |
|
37 | + */ |
|
38 | + protected $time_format; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var boolean $event_is_expired |
|
42 | + */ |
|
43 | + protected $event_is_expired; |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * TicketDetails constructor. |
|
49 | + * |
|
50 | + * @param \EE_Ticket $ticket |
|
51 | + * @param \EE_Ticket_Selector_Config $template_settings |
|
52 | + * @param array $template_args |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + \EE_Ticket $ticket, |
|
56 | + \EE_Ticket_Selector_Config $template_settings, |
|
57 | + array $template_args |
|
58 | + ) |
|
59 | + { |
|
60 | + $this->ticket = $ticket; |
|
61 | + $this->template_settings = $template_settings; |
|
62 | + $this->date_format = $template_args['date_format']; |
|
63 | + $this->time_format = $template_args['time_format']; |
|
64 | + $this->event_is_expired = $template_args['event_is_expired']; |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return \EE_Ticket |
|
71 | + */ |
|
72 | + public function getTicket() |
|
73 | + { |
|
74 | + return $this->ticket; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function showTicketDetails() |
|
83 | + { |
|
84 | + return $this->template_settings->show_ticket_details; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @return \EE_Ticket_Selector_Config |
|
91 | + */ |
|
92 | + public function getTemplateSettings() |
|
93 | + { |
|
94 | + return $this->template_settings; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function getDateFormat() |
|
103 | + { |
|
104 | + return $this->date_format; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getTimeFormat() |
|
113 | + { |
|
114 | + return $this->time_format; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function getShowHideLinks() |
|
123 | + { |
|
124 | + if ( ! $this->showTicketDetails()) { |
|
125 | + return ''; |
|
126 | + } |
|
127 | + return \EEH_HTML::link( |
|
128 | + '', |
|
129 | + sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
130 | + esc_attr( |
|
131 | + apply_filters( |
|
132 | + 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
133 | + __('click to show additional ticket details', 'event_espresso') |
|
134 | + ) |
|
135 | + ), |
|
136 | + "display-{$this->cssId()}", |
|
137 | + 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
138 | + '', |
|
139 | + 'rel="' . $this->cssId() . '"' |
|
140 | + ) . \EEH_HTML::link( |
|
141 | + '', |
|
142 | + sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
143 | + esc_attr( |
|
144 | + apply_filters( |
|
145 | + 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
146 | + __('click to hide additional ticket details', 'event_espresso') |
|
147 | + ) |
|
148 | + ), |
|
149 | + "hide-{$this->cssId()}", |
|
150 | + 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
151 | + 'display:none;', |
|
152 | + 'rel="' . $this->cssId() . '"' |
|
153 | + ); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + public function cssId() |
|
162 | + { |
|
163 | + return apply_filters( |
|
164 | + 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
165 | + "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
166 | + ); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param float $ticket_price |
|
173 | + * @param int $remaining |
|
174 | + * @param int $cols |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function display( |
|
178 | + $ticket_price = 0.00, |
|
179 | + $remaining, |
|
180 | + $cols = 2 |
|
181 | + ) { |
|
182 | + $template_args = array(); |
|
183 | + $template_args['ticket'] = $this->ticket; |
|
184 | + $template_args['ticket_price'] = $ticket_price; |
|
185 | + $template_args['remaining'] = $remaining; |
|
186 | + $template_args['cols'] = $cols; |
|
187 | + $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
188 | + $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
189 | + $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
190 | + $template_args['ticket_details_css_id'] = $this->cssId(); |
|
191 | + $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
192 | + 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
193 | + true |
|
194 | + ); |
|
195 | + $template_args['price_breakdown_heading'] = apply_filters( |
|
196 | + 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
197 | + esc_html__('Price', 'event_espresso') |
|
198 | + ); |
|
199 | + $template_args['date_format'] = $this->date_format; |
|
200 | + $template_args['time_format'] = $this->time_format; |
|
201 | + $template_args['event_is_expired'] = $this->event_is_expired; |
|
202 | + |
|
203 | + return \EEH_Template::locate_template( |
|
204 | + apply_filters( |
|
205 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
206 | + TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
207 | + $this->ticket |
|
208 | + ), |
|
209 | + $template_args |
|
210 | + ); |
|
211 | + } |
|
212 | 212 | |
213 | 213 | } |
214 | 214 | // End of file TicketDetails.php |
@@ -16,201 +16,201 @@ |
||
16 | 16 | abstract class TicketSelectorRow |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Ticket $ticket |
|
21 | - */ |
|
22 | - protected $ticket; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var int $total_tickets |
|
26 | - */ |
|
27 | - protected $total_tickets; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var int $max_atndz |
|
31 | - */ |
|
32 | - protected $max_atndz; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string $date_format |
|
36 | - */ |
|
37 | - protected $date_format; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var int $EVT_ID |
|
41 | - */ |
|
42 | - protected $EVT_ID; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var string $ticket_status_display |
|
46 | - */ |
|
47 | - protected $ticket_status_display; |
|
48 | - |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * TicketDetails constructor. |
|
53 | - * |
|
54 | - * @param \EE_Ticket $ticket |
|
55 | - * @param int $max_atndz |
|
56 | - * @param string $date_format |
|
57 | - */ |
|
58 | - public function __construct( |
|
59 | - \EE_Ticket $ticket, |
|
60 | - $max_atndz, |
|
61 | - $date_format |
|
62 | - ) { |
|
63 | - $this->ticket = $ticket; |
|
64 | - $this->max_atndz = $max_atndz; |
|
65 | - $this->date_format = $date_format; |
|
66 | - $this->EVT_ID = $this->ticket->get_event_ID(); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getTicketStatusDisplay() |
|
75 | - { |
|
76 | - return $this->ticket_status_display; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * setTicketStatusDisplay |
|
83 | - * |
|
84 | - * @param string $tkt_status |
|
85 | - * @param string $ticket_status |
|
86 | - * @param int $remaining |
|
87 | - * @throws \EE_Error |
|
88 | - */ |
|
89 | - protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
90 | - $this->ticket_status_display = ''; |
|
91 | - // now depending on the ticket and other circumstances... |
|
92 | - if ($this->max_atndz === 0) { |
|
93 | - // registration is CLOSED because admin set max attendees to ZERO |
|
94 | - $this->ticket_status_display = $this->registrationClosed(); |
|
95 | - } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
96 | - // SOLD OUT - no tickets remaining |
|
97 | - $this->ticket_status_display = $this->ticketsSoldOut(); |
|
98 | - } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
99 | - // expired or archived ticket |
|
100 | - $this->ticket_status_display = $ticket_status; |
|
101 | - } else if ($tkt_status === \EE_Ticket::pending) { |
|
102 | - // ticket not on sale yet |
|
103 | - $this->ticket_status_display = $this->ticketsSalesPending(); |
|
104 | - } else if ($this->ticket->min() > $remaining) { |
|
105 | - // min qty purchasable is less than tickets available |
|
106 | - $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * registrationClosed |
|
114 | - */ |
|
115 | - protected function registrationClosed() |
|
116 | - { |
|
117 | - return \EEH_HTML::span( |
|
118 | - apply_filters( |
|
119 | - 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
120 | - __('Closed', 'event_espresso') |
|
121 | - ), |
|
122 | - '', 'sold-out' |
|
123 | - ); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * ticketsSoldOut |
|
130 | - */ |
|
131 | - protected function ticketsSoldOut() |
|
132 | - { |
|
133 | - return \EEH_HTML::span( |
|
134 | - apply_filters( |
|
135 | - 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
136 | - __('Sold Out', 'event_espresso') |
|
137 | - ), |
|
138 | - '', 'sold-out' |
|
139 | - ); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * ticketsSalesPending |
|
146 | - * |
|
147 | - * @throws \EE_Error |
|
148 | - */ |
|
149 | - protected function ticketsSalesPending() |
|
150 | - { |
|
151 | - return \EEH_HTML::span( |
|
152 | - \EEH_HTML::span( |
|
153 | - apply_filters( |
|
154 | - 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
155 | - __('Goes On Sale', 'event_espresso') |
|
156 | - ), |
|
157 | - '', 'ticket-pending' |
|
158 | - ) |
|
159 | - . \EEH_HTML::br() |
|
160 | - . \EEH_HTML::span( |
|
161 | - $this->ticket->get_i18n_datetime( |
|
162 | - 'TKT_start_date', |
|
163 | - apply_filters( |
|
164 | - 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
165 | - $this->date_format |
|
166 | - ) |
|
167 | - ), |
|
168 | - '', 'small-text' |
|
169 | - ), |
|
170 | - '', 'ticket-pending-pg' |
|
171 | - ); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * notEnoughTicketsAvailable |
|
178 | - */ |
|
179 | - protected function notEnoughTicketsAvailable() |
|
180 | - { |
|
181 | - return \EEH_HTML::div( |
|
182 | - \EEH_HTML::span( |
|
183 | - apply_filters( |
|
184 | - 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
185 | - __('Not Available', 'event_espresso') |
|
186 | - ), |
|
187 | - '', 'archived-ticket small-text' |
|
188 | - ) |
|
189 | - . \EEH_HTML::br(), |
|
190 | - '', 'archived-ticket-pg' |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * getHiddenInputs |
|
198 | - * |
|
199 | - * @param string $anchor_id |
|
200 | - * @param int $row |
|
201 | - * @param int $max_atndz |
|
202 | - * @return string |
|
203 | - */ |
|
204 | - protected function getHiddenInputs($anchor_id, $row, $max_atndz) |
|
205 | - { |
|
206 | - $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
207 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->EVT_ID . '"'; |
|
208 | - $html .= ' value="' . \EEH_URL::current_url() . $anchor_id . '"/>'; |
|
209 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->EVT_ID . '" value="' . $row - 1 . '"/>'; |
|
210 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->EVT_ID . '" value="' . $max_atndz . '"/>'; |
|
211 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->EVT_ID . '"/>'; |
|
212 | - return $html; |
|
213 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Ticket $ticket |
|
21 | + */ |
|
22 | + protected $ticket; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var int $total_tickets |
|
26 | + */ |
|
27 | + protected $total_tickets; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var int $max_atndz |
|
31 | + */ |
|
32 | + protected $max_atndz; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string $date_format |
|
36 | + */ |
|
37 | + protected $date_format; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var int $EVT_ID |
|
41 | + */ |
|
42 | + protected $EVT_ID; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var string $ticket_status_display |
|
46 | + */ |
|
47 | + protected $ticket_status_display; |
|
48 | + |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * TicketDetails constructor. |
|
53 | + * |
|
54 | + * @param \EE_Ticket $ticket |
|
55 | + * @param int $max_atndz |
|
56 | + * @param string $date_format |
|
57 | + */ |
|
58 | + public function __construct( |
|
59 | + \EE_Ticket $ticket, |
|
60 | + $max_atndz, |
|
61 | + $date_format |
|
62 | + ) { |
|
63 | + $this->ticket = $ticket; |
|
64 | + $this->max_atndz = $max_atndz; |
|
65 | + $this->date_format = $date_format; |
|
66 | + $this->EVT_ID = $this->ticket->get_event_ID(); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getTicketStatusDisplay() |
|
75 | + { |
|
76 | + return $this->ticket_status_display; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * setTicketStatusDisplay |
|
83 | + * |
|
84 | + * @param string $tkt_status |
|
85 | + * @param string $ticket_status |
|
86 | + * @param int $remaining |
|
87 | + * @throws \EE_Error |
|
88 | + */ |
|
89 | + protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
90 | + $this->ticket_status_display = ''; |
|
91 | + // now depending on the ticket and other circumstances... |
|
92 | + if ($this->max_atndz === 0) { |
|
93 | + // registration is CLOSED because admin set max attendees to ZERO |
|
94 | + $this->ticket_status_display = $this->registrationClosed(); |
|
95 | + } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
96 | + // SOLD OUT - no tickets remaining |
|
97 | + $this->ticket_status_display = $this->ticketsSoldOut(); |
|
98 | + } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
99 | + // expired or archived ticket |
|
100 | + $this->ticket_status_display = $ticket_status; |
|
101 | + } else if ($tkt_status === \EE_Ticket::pending) { |
|
102 | + // ticket not on sale yet |
|
103 | + $this->ticket_status_display = $this->ticketsSalesPending(); |
|
104 | + } else if ($this->ticket->min() > $remaining) { |
|
105 | + // min qty purchasable is less than tickets available |
|
106 | + $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * registrationClosed |
|
114 | + */ |
|
115 | + protected function registrationClosed() |
|
116 | + { |
|
117 | + return \EEH_HTML::span( |
|
118 | + apply_filters( |
|
119 | + 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
120 | + __('Closed', 'event_espresso') |
|
121 | + ), |
|
122 | + '', 'sold-out' |
|
123 | + ); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * ticketsSoldOut |
|
130 | + */ |
|
131 | + protected function ticketsSoldOut() |
|
132 | + { |
|
133 | + return \EEH_HTML::span( |
|
134 | + apply_filters( |
|
135 | + 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
136 | + __('Sold Out', 'event_espresso') |
|
137 | + ), |
|
138 | + '', 'sold-out' |
|
139 | + ); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * ticketsSalesPending |
|
146 | + * |
|
147 | + * @throws \EE_Error |
|
148 | + */ |
|
149 | + protected function ticketsSalesPending() |
|
150 | + { |
|
151 | + return \EEH_HTML::span( |
|
152 | + \EEH_HTML::span( |
|
153 | + apply_filters( |
|
154 | + 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
155 | + __('Goes On Sale', 'event_espresso') |
|
156 | + ), |
|
157 | + '', 'ticket-pending' |
|
158 | + ) |
|
159 | + . \EEH_HTML::br() |
|
160 | + . \EEH_HTML::span( |
|
161 | + $this->ticket->get_i18n_datetime( |
|
162 | + 'TKT_start_date', |
|
163 | + apply_filters( |
|
164 | + 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
165 | + $this->date_format |
|
166 | + ) |
|
167 | + ), |
|
168 | + '', 'small-text' |
|
169 | + ), |
|
170 | + '', 'ticket-pending-pg' |
|
171 | + ); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * notEnoughTicketsAvailable |
|
178 | + */ |
|
179 | + protected function notEnoughTicketsAvailable() |
|
180 | + { |
|
181 | + return \EEH_HTML::div( |
|
182 | + \EEH_HTML::span( |
|
183 | + apply_filters( |
|
184 | + 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
185 | + __('Not Available', 'event_espresso') |
|
186 | + ), |
|
187 | + '', 'archived-ticket small-text' |
|
188 | + ) |
|
189 | + . \EEH_HTML::br(), |
|
190 | + '', 'archived-ticket-pg' |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * getHiddenInputs |
|
198 | + * |
|
199 | + * @param string $anchor_id |
|
200 | + * @param int $row |
|
201 | + * @param int $max_atndz |
|
202 | + * @return string |
|
203 | + */ |
|
204 | + protected function getHiddenInputs($anchor_id, $row, $max_atndz) |
|
205 | + { |
|
206 | + $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
207 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->EVT_ID . '"'; |
|
208 | + $html .= ' value="' . \EEH_URL::current_url() . $anchor_id . '"/>'; |
|
209 | + $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->EVT_ID . '" value="' . $row - 1 . '"/>'; |
|
210 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->EVT_ID . '" value="' . $max_atndz . '"/>'; |
|
211 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->EVT_ID . '"/>'; |
|
212 | + return $html; |
|
213 | + } |
|
214 | 214 | |
215 | 215 | |
216 | 216 |
@@ -98,14 +98,14 @@ |
||
98 | 98 | </th> |
99 | 99 | <td> |
100 | 100 | <?php |
101 | - $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | - if( $disabled ){ |
|
103 | - $disabled_attr = 'disabled="disabled"'; |
|
104 | - $id = '_disabled'; |
|
105 | - } else { |
|
106 | - $disabled_attr = ''; |
|
107 | - $id = ''; |
|
108 | - } |
|
101 | + $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | + if( $disabled ){ |
|
103 | + $disabled_attr = 'disabled="disabled"'; |
|
104 | + $id = '_disabled'; |
|
105 | + } else { |
|
106 | + $disabled_attr = ''; |
|
107 | + $id = ''; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr ); |
111 | 111 | if( $disabled ) { ?> |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | //does question have any answers? cause if it does then we have to disable type |
16 | 16 | $has_answers = $question->has_answers(); |
17 | 17 | |
18 | -if ( $QST_system === 'country' ) { |
|
18 | +if ($QST_system === 'country') { |
|
19 | 19 | echo EEH_HTML::div( |
20 | - EEH_HTML::h4( '<span class="dashicons dashicons-info"></span>' . esc_html__( 'Did you know...', 'event_espresso' ) ) . |
|
20 | + EEH_HTML::h4('<span class="dashicons dashicons-info"></span>'.esc_html__('Did you know...', 'event_espresso')). |
|
21 | 21 | EEH_HTML::p( |
22 | 22 | esc_html__( |
23 | 23 | 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | <tbody> |
35 | 35 | <tr> |
36 | 36 | <th> |
37 | - <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info');?> |
|
37 | + <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info'); ?> |
|
38 | 38 | </th> |
39 | 39 | <td> |
40 | 40 | <input type="text" class="regular-text" id="QST_display_text" name="QST_display_text" value="<?php $question->f('QST_display_text')?>"/> |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | |
45 | 45 | <tr> |
46 | 46 | <th> |
47 | - <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info');?> |
|
47 | + <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info'); ?> |
|
48 | 48 | </th> |
49 | 49 | <td> |
50 | 50 | <?php |
51 | - $disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
52 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
51 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
52 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
53 | 53 | ?> |
54 | 54 | <input type="text" class="regular-text" id="QST_admin_label<?php echo $id?>" name="QST_admin_label<?php echo $id?>" value="<?php $question->f('QST_admin_label')?>"<?php echo $disabled_attr?>/> |
55 | 55 | <input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" name = "QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>" /> |
56 | - <?php if ( ! empty( $QST_system )) { ?> |
|
56 | + <?php if ( ! empty($QST_system)) { ?> |
|
57 | 57 | <input type="hidden" id="QST_admin_label" name="QST_admin_label" value="<?php echo $question->admin_label()?>"/> |
58 | 58 | <?php } ?> |
59 | 59 | <br/> |
60 | 60 | <p class="description"> |
61 | - <?php if ( ! empty( $QST_system )) { ?> |
|
61 | + <?php if ( ! empty($QST_system)) { ?> |
|
62 | 62 | <span class="description" style="color:#D54E21;"> |
63 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
63 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
64 | 64 | </span> |
65 | 65 | <?php } ?> |
66 | 66 | |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | |
71 | 71 | <tr> |
72 | 72 | <th> |
73 | - <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info');?> |
|
73 | + <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info'); ?> |
|
74 | 74 | </th> |
75 | 75 | <td> |
76 | 76 | <?php |
77 | - $disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
78 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
77 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
78 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
79 | 79 | $admin_only = $question->get('QST_admin_only'); |
80 | - $checked = !empty( $admin_only ) ? ' checked="checked"' : ''; |
|
80 | + $checked = ! empty($admin_only) ? ' checked="checked"' : ''; |
|
81 | 81 | ?> |
82 | 82 | <input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" name = "QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled_attr; echo $checked; ?>/> |
83 | 83 | <br/> |
84 | 84 | <p class="description"> |
85 | - <?php if ( ! empty( $QST_system )) { ?> |
|
85 | + <?php if ( ! empty($QST_system)) { ?> |
|
86 | 86 | <span class="description" style="color:#D54E21;"> |
87 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
87 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
88 | 88 | </span> |
89 | 89 | <?php } ?> |
90 | 90 | |
@@ -94,28 +94,28 @@ discard block |
||
94 | 94 | |
95 | 95 | <tr> |
96 | 96 | <th> |
97 | - <label for="QST_type"><?php echo $fields['QST_type']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info');?> |
|
97 | + <label for="QST_type"><?php echo $fields['QST_type']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info'); ?> |
|
98 | 98 | </th> |
99 | 99 | <td> |
100 | 100 | <?php |
101 | - $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | - if( $disabled ){ |
|
103 | - $disabled_attr = 'disabled="disabled"'; |
|
104 | - $id = '_disabled'; |
|
101 | + $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | + if ($disabled) { |
|
103 | + $disabled_attr = 'disabled="disabled"'; |
|
104 | + $id = '_disabled'; |
|
105 | 105 | } else { |
106 | 106 | $disabled_attr = ''; |
107 | 107 | $id = ''; |
108 | 108 | } |
109 | 109 | |
110 | - echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr ); |
|
111 | - if( $disabled ) { ?> |
|
110 | + echo EEH_Form_Fields::select_input('QST_type'.$id, $question_types, $question->type(), 'id="QST_type'.$id.'"'.$disabled_attr); |
|
111 | + if ($disabled) { ?> |
|
112 | 112 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
113 | 113 | <?php |
114 | - $explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso'); |
|
115 | - }else{ |
|
116 | - $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
|
114 | + $explanatory_text = esc_html__('System question! This field cannot be changed.', 'event_espresso'); |
|
115 | + } else { |
|
116 | + $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', 'event_espresso'); |
|
117 | 117 | } |
118 | - if ( $disabled || $has_answers ) { ?> |
|
118 | + if ($disabled || $has_answers) { ?> |
|
119 | 119 | <p><span class="description" style="color:#D54E21;"> |
120 | 120 | <?php echo $explanatory_text; ?> |
121 | 121 | </span></p> |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | <tr id="text_input_question_options"> |
129 | 129 | <th> |
130 | 130 | <label> |
131 | - <?php esc_html_e( 'Maximum Allowed Response Size', 'event_espresso' );?> |
|
131 | + <?php esc_html_e('Maximum Allowed Response Size', 'event_espresso'); ?> |
|
132 | 132 | </label> |
133 | 133 | </th> |
134 | 134 | <td> |
135 | - <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'";?> value="<?php $question->f( 'QST_max' );?>" min="1"> |
|
135 | + <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1"> |
|
136 | 136 | <p> |
137 | 137 | <span class="description"> |
138 | - <?php esc_html_e( 'Maximum number of characters allowed when answering this question', 'event_espresso' );?> |
|
138 | + <?php esc_html_e('Maximum number of characters allowed when answering this question', 'event_espresso'); ?> |
|
139 | 139 | </span> |
140 | 140 | </p> |
141 | - <?php if ( $QST_system ) { ?> |
|
141 | + <?php if ($QST_system) { ?> |
|
142 | 142 | <p> |
143 | 143 | <span class="description" style="color:#D54E21;"> |
144 | 144 | <?php printf( |
145 | - esc_html__( 'System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso' ), |
|
146 | - $max_max );?> |
|
145 | + esc_html__('System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso'), |
|
146 | + $max_max ); ?> |
|
147 | 147 | </span> |
148 | 148 | </p> |
149 | 149 | <?php } ?> |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | <tr id="question_options"> |
153 | 153 | <th> |
154 | 154 | <label> |
155 | - <?php esc_html_e('Answer Options','event_espresso')?> |
|
155 | + <?php esc_html_e('Answer Options', 'event_espresso')?> |
|
156 | 156 | </label> |
157 | 157 | </th> |
158 | 158 | <td> |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | <thead> |
162 | 162 | <tr> |
163 | 163 | <th class="option-value-header"> |
164 | - <?php esc_html_e('Value','event_espresso')?> |
|
164 | + <?php esc_html_e('Value', 'event_espresso')?> |
|
165 | 165 | </th> |
166 | 166 | <th class="option-desc-header"> |
167 | - <?php esc_html_e('Description (optional, only shown on registration form)','event_espresso')?> |
|
167 | + <?php esc_html_e('Description (optional, only shown on registration form)', 'event_espresso')?> |
|
168 | 168 | </th> |
169 | 169 | <th> |
170 | 170 | </th> |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | </tr> |
188 | 188 | |
189 | 189 | <?php |
190 | - $count=0; |
|
190 | + $count = 0; |
|
191 | 191 | $question_options = $question->options(); |
192 | - if ( ! empty( $question_options )) { |
|
193 | - foreach( $question_options as $option_id => $option ) { |
|
194 | - $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
192 | + if ( ! empty($question_options)) { |
|
193 | + foreach ($question_options as $option_id => $option) { |
|
194 | + $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
195 | 195 | ?> |
196 | 196 | <tr class="question-option ee-options-sortable"> |
197 | 197 | <td class="option-value-cell"> |
198 | 198 | <input type="hidden" class="QSO_order" name="question_options[<?php echo $count; ?>][QSO_order]" value="<?php echo $count; ?>"> |
199 | 199 | <input type="text" class="option-value regular-text" name="question_options[<?php echo $count?>][QSO_value]" value="<?php $option->f('QSO_value')?>"<?php echo $disabled_attr; ?>> |
200 | - <?php if ( $has_answers ) : ?> |
|
200 | + <?php if ($has_answers) : ?> |
|
201 | 201 | <input type="hidden" name="question_options[<?php echo $count; ?>][QSO_value]" value="<?php echo $option->f('QSO_value'); ?>" > |
202 | 202 | <?php endif; ?> |
203 | 203 | </td> |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | <input type="text" class="option-desc regular-text" name="question_options[<?php echo $count?>][QSO_desc]" value="<?php $option->f('QSO_desc')?>"> |
206 | 206 | </td> |
207 | 207 | <td> |
208 | - <?php if ( ! $option->system() ) { ?> |
|
208 | + <?php if ( ! $option->system()) { ?> |
|
209 | 209 | <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span> |
210 | 210 | <?php } ?> |
211 | 211 | <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span> |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | </table> |
245 | 245 | |
246 | 246 | <a id="new-question-option" class="button" style="margin:0 0 1em 3px;"> |
247 | - <?php esc_html_e('Add Another Answer Option','event_espresso')?> |
|
247 | + <?php esc_html_e('Add Another Answer Option', 'event_espresso')?> |
|
248 | 248 | </a><br/> |
249 | 249 | |
250 | 250 | <p class="description"> |
251 | - <?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.','event_espresso')?> |
|
251 | + <?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', 'event_espresso')?> |
|
252 | 252 | </p> |
253 | - <?php if ( $has_answers ) : ?> |
|
253 | + <?php if ($has_answers) : ?> |
|
254 | 254 | <p class="description" style="color:#D54E21;"> |
255 | 255 | <?php esc_html_e('Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', 'event_espresso'); ?> |
256 | 256 | </p> |
@@ -261,32 +261,32 @@ discard block |
||
261 | 261 | |
262 | 262 | <tr> |
263 | 263 | <th> |
264 | - <label for="QST_required"><?php echo $fields['QST_required']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info');?> |
|
264 | + <label for="QST_required"><?php echo $fields['QST_required']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info'); ?> |
|
265 | 265 | </th> |
266 | 266 | <td> |
267 | 267 | <?php |
268 | - $system_required = array( 'fname', 'email' ); |
|
269 | - $disabled_attr = in_array( $QST_system, $system_required ) ? ' disabled="disabled"' : ''; |
|
268 | + $system_required = array('fname', 'email'); |
|
269 | + $disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
270 | 270 | $required_on = $question->get('QST_admin_only'); |
271 | 271 | $show_required_msg = $required_on ? '' : ' display:none;'; |
272 | - $disabled_attr = $required_on || ! empty( $disabled_attr ) ? ' disabled="disabled"' : ''; |
|
273 | - $id = ! empty( $disabled_attr ) && in_array( $QST_system, $system_required) ? '_disabled' : ''; |
|
274 | - $requiredOptions=array( |
|
275 | - array( 'text'=> esc_html__( 'Optional', 'event_espresso' ), 'id'=>0 ), |
|
276 | - array( 'text'=> esc_html__( 'Required', 'event_espresso' ), 'id'=>1 ) |
|
272 | + $disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : ''; |
|
273 | + $id = ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
274 | + $requiredOptions = array( |
|
275 | + array('text'=> esc_html__('Optional', 'event_espresso'), 'id'=>0), |
|
276 | + array('text'=> esc_html__('Required', 'event_espresso'), 'id'=>1) |
|
277 | 277 | ); |
278 | - echo EEH_Form_Fields::select_input('QST_required' . $id, $requiredOptions, $question->required(), 'id="QST_required' . $id . '"' . $disabled_attr ); |
|
278 | + echo EEH_Form_Fields::select_input('QST_required'.$id, $requiredOptions, $question->required(), 'id="QST_required'.$id.'"'.$disabled_attr); |
|
279 | 279 | ?> |
280 | 280 | <p><span id="required_toggled_on" class="description" style="color:#D54E21;<?php echo $show_required_msg; ?>"> |
281 | - <?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.','event_espresso')?> |
|
281 | + <?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.', 'event_espresso')?> |
|
282 | 282 | </span></p> |
283 | 283 | <p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;"> |
284 | - <?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only','event_espresso')?> |
|
284 | + <?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only', 'event_espresso')?> |
|
285 | 285 | </span></p> |
286 | - <?php if (! empty( $disabled_attr ) && in_array( $QST_system, $system_required ) ) { ?> |
|
286 | + <?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?> |
|
287 | 287 | <input type="hidden" id="QST_required" name="QST_required" value="1"/> |
288 | 288 | <p><span class="description" style="color:#D54E21;"> |
289 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
289 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
290 | 290 | </span></p> |
291 | 291 | <?php } ?> |
292 | 292 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | <tr> |
297 | 297 | <th> |
298 | - <label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info');?> |
|
298 | + <label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?> |
|
299 | 299 | </th> |
300 | 300 | <td> |
301 | 301 | <input type="text" maxlength="100" class="regular-text" id="QST_required_text" name="QST_required_text" value="<?php $question->f('QST_required_text')?>"/> |
@@ -112,7 +112,7 @@ |
||
112 | 112 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
113 | 113 | <?php |
114 | 114 | $explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso'); |
115 | - }else{ |
|
115 | + } else{ |
|
116 | 116 | $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
117 | 117 | } |
118 | 118 | if ( $disabled || $has_answers ) { ?> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -28,599 +28,599 @@ discard block |
||
28 | 28 | class Registration_Form_Admin_Page extends EE_Admin_Page |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * _question |
|
33 | - * holds the specific question object for the question details screen |
|
34 | - * |
|
35 | - * @var EE_Question $_question |
|
36 | - */ |
|
37 | - protected $_question; |
|
38 | - |
|
39 | - /** |
|
40 | - * _question_group |
|
41 | - * holds the specific question group object for the question group details screen |
|
42 | - * |
|
43 | - * @var EE_Question_Group $_question_group |
|
44 | - */ |
|
45 | - protected $_question_group; |
|
46 | - |
|
47 | - /** |
|
48 | - *_question_model EEM_Question model instance (for queries) |
|
49 | - * |
|
50 | - * @var EEM_Question $_question_model ; |
|
51 | - */ |
|
52 | - protected $_question_model; |
|
53 | - |
|
54 | - /** |
|
55 | - * _question_group_model EEM_Question_group instance (for queries) |
|
56 | - * |
|
57 | - * @var EEM_Question_Group $_question_group_model |
|
58 | - */ |
|
59 | - protected $_question_group_model; |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @Constructor |
|
64 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
65 | - * @access public |
|
66 | - */ |
|
67 | - public function __construct($routing = true) |
|
68 | - { |
|
69 | - require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | - require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
71 | - $this->_question_model = EEM_Question::instance(); |
|
72 | - $this->_question_group_model = EEM_Question_Group::instance(); |
|
73 | - parent::__construct($routing); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - protected function _init_page_props() |
|
78 | - { |
|
79 | - $this->page_slug = REGISTRATION_FORM_PG_SLUG; |
|
80 | - $this->page_label = esc_html__('Registration Form', 'event_espresso'); |
|
81 | - $this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL; |
|
82 | - $this->_admin_base_path = REGISTRATION_FORM_ADMIN; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - protected function _ajax_hooks() |
|
87 | - { |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - protected function _define_page_props() |
|
92 | - { |
|
93 | - $this->_admin_page_title = esc_html__('Registration Form', 'event_espresso'); |
|
94 | - $this->_labels = array( |
|
95 | - 'buttons' => array( |
|
96 | - 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
97 | - ), |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - *_set_page_routes |
|
104 | - */ |
|
105 | - protected function _set_page_routes() |
|
106 | - { |
|
107 | - $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
108 | - $this->_page_routes = array( |
|
109 | - 'default' => array( |
|
110 | - 'func' => '_questions_overview_list_table', |
|
111 | - 'capability' => 'ee_read_questions', |
|
112 | - ), |
|
113 | - |
|
114 | - 'edit_question' => array( |
|
115 | - 'func' => '_edit_question', |
|
116 | - 'capability' => 'ee_edit_question', |
|
117 | - 'obj_id' => $qst_id, |
|
118 | - 'args' => array('edit'), |
|
119 | - ), |
|
120 | - |
|
121 | - 'question_groups' => array( |
|
122 | - 'func' => '_questions_groups_preview', |
|
123 | - 'capability' => 'ee_read_question_groups', |
|
124 | - ), |
|
125 | - |
|
126 | - 'update_question' => array( |
|
127 | - 'func' => '_insert_or_update_question', |
|
128 | - 'args' => array('new_question' => false), |
|
129 | - 'capability' => 'ee_edit_question', |
|
130 | - 'obj_id' => $qst_id, |
|
131 | - 'noheader' => true, |
|
132 | - ), |
|
133 | - ); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - protected function _set_page_config() |
|
138 | - { |
|
139 | - $this->_page_config = array( |
|
140 | - 'default' => array( |
|
141 | - 'nav' => array( |
|
142 | - 'label' => esc_html__('Questions', 'event_espresso'), |
|
143 | - 'order' => 10, |
|
144 | - ), |
|
145 | - 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
|
146 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
147 | - 'help_tabs' => array( |
|
148 | - 'registration_form_questions_overview_help_tab' => array( |
|
149 | - 'title' => esc_html__('Questions Overview', 'event_espresso'), |
|
150 | - 'filename' => 'registration_form_questions_overview', |
|
151 | - ), |
|
152 | - 'registration_form_questions_overview_table_column_headings_help_tab' => array( |
|
153 | - 'title' => esc_html__('Questions Overview Table Column Headings', 'event_espresso'), |
|
154 | - 'filename' => 'registration_form_questions_overview_table_column_headings', |
|
155 | - ), |
|
156 | - 'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array( |
|
157 | - 'title' => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'), |
|
158 | - 'filename' => 'registration_form_questions_overview_views_bulk_actions_search', |
|
159 | - ), |
|
160 | - ), |
|
161 | - 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
162 | - 'require_nonce' => false, |
|
163 | - 'qtips' => array( |
|
164 | - 'EE_Registration_Form_Tips', |
|
165 | - )/**/ |
|
166 | - ), |
|
167 | - |
|
168 | - 'question_groups' => array( |
|
169 | - 'nav' => array( |
|
170 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
171 | - 'order' => 20, |
|
172 | - ), |
|
173 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
174 | - 'help_tabs' => array( |
|
175 | - 'registration_form_question_groups_help_tab' => array( |
|
176 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
177 | - 'filename' => 'registration_form_question_groups', |
|
178 | - ), |
|
179 | - ), |
|
180 | - 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
181 | - 'require_nonce' => false, |
|
182 | - ), |
|
183 | - |
|
184 | - 'edit_question' => array( |
|
185 | - 'nav' => array( |
|
186 | - 'label' => esc_html__('Edit Question', 'event_espresso'), |
|
187 | - 'order' => 15, |
|
188 | - 'persistent' => false, |
|
189 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), |
|
190 | - $this->_current_page_view_url) : $this->_admin_base_url, |
|
191 | - ), |
|
192 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
193 | - 'help_tabs' => array( |
|
194 | - 'registration_form_edit_question_group_help_tab' => array( |
|
195 | - 'title' => esc_html__('Edit Question', 'event_espresso'), |
|
196 | - 'filename' => 'registration_form_edit_question', |
|
197 | - ), |
|
198 | - ), |
|
199 | - 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
200 | - 'require_nonce' => false, |
|
201 | - ), |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - protected function _add_screen_options() |
|
207 | - { |
|
208 | - //todo |
|
209 | - } |
|
210 | - |
|
211 | - protected function _add_screen_options_default() |
|
212 | - { |
|
213 | - $page_title = $this->_admin_page_title; |
|
214 | - $this->_admin_page_title = esc_html__('Questions', 'event_espresso'); |
|
215 | - $this->_per_page_screen_option(); |
|
216 | - $this->_admin_page_title = $page_title; |
|
217 | - } |
|
218 | - |
|
219 | - protected function _add_screen_options_question_groups() |
|
220 | - { |
|
221 | - $page_title = $this->_admin_page_title; |
|
222 | - $this->_admin_page_title = esc_html__('Question Groups', 'event_espresso'); |
|
223 | - $this->_per_page_screen_option(); |
|
224 | - $this->_admin_page_title = $page_title; |
|
225 | - } |
|
226 | - |
|
227 | - //none of the below group are currently used for Event Categories |
|
228 | - protected function _add_feature_pointers() |
|
229 | - { |
|
230 | - } |
|
231 | - |
|
232 | - public function load_scripts_styles() |
|
233 | - { |
|
234 | - wp_register_style('espresso_registration', |
|
235 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | - wp_enqueue_style('espresso_registration'); |
|
237 | - } |
|
238 | - |
|
239 | - public function admin_init() |
|
240 | - { |
|
241 | - } |
|
242 | - |
|
243 | - public function admin_notices() |
|
244 | - { |
|
245 | - } |
|
246 | - |
|
247 | - public function admin_footer_scripts() |
|
248 | - { |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - public function load_scripts_styles_default() |
|
253 | - { |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - public function load_scripts_styles_add_question() |
|
258 | - { |
|
259 | - $this->load_scripts_styles_forms(); |
|
260 | - wp_register_script('espresso_registration_form_single', |
|
261 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | - EVENT_ESPRESSO_VERSION, true); |
|
263 | - wp_enqueue_script('espresso_registration_form_single'); |
|
264 | - } |
|
265 | - |
|
266 | - public function load_scripts_styles_edit_question() |
|
267 | - { |
|
268 | - $this->load_scripts_styles_forms(); |
|
269 | - wp_register_script('espresso_registration_form_single', |
|
270 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | - EVENT_ESPRESSO_VERSION, true); |
|
272 | - wp_enqueue_script('espresso_registration_form_single'); |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - public function recaptcha_info_help_tab() |
|
277 | - { |
|
278 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
279 | - EEH_Template::display_template($template, array()); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - public function load_scripts_styles_forms() |
|
284 | - { |
|
285 | - //styles |
|
286 | - wp_enqueue_style('espresso-ui-theme'); |
|
287 | - //scripts |
|
288 | - wp_enqueue_script('ee_admin_js'); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - protected function _set_list_table_views_default() |
|
293 | - { |
|
294 | - $this->_views = array( |
|
295 | - 'all' => array( |
|
296 | - 'slug' => 'all', |
|
297 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
298 | - 'count' => 0, |
|
31 | + /** |
|
32 | + * _question |
|
33 | + * holds the specific question object for the question details screen |
|
34 | + * |
|
35 | + * @var EE_Question $_question |
|
36 | + */ |
|
37 | + protected $_question; |
|
38 | + |
|
39 | + /** |
|
40 | + * _question_group |
|
41 | + * holds the specific question group object for the question group details screen |
|
42 | + * |
|
43 | + * @var EE_Question_Group $_question_group |
|
44 | + */ |
|
45 | + protected $_question_group; |
|
46 | + |
|
47 | + /** |
|
48 | + *_question_model EEM_Question model instance (for queries) |
|
49 | + * |
|
50 | + * @var EEM_Question $_question_model ; |
|
51 | + */ |
|
52 | + protected $_question_model; |
|
53 | + |
|
54 | + /** |
|
55 | + * _question_group_model EEM_Question_group instance (for queries) |
|
56 | + * |
|
57 | + * @var EEM_Question_Group $_question_group_model |
|
58 | + */ |
|
59 | + protected $_question_group_model; |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @Constructor |
|
64 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
65 | + * @access public |
|
66 | + */ |
|
67 | + public function __construct($routing = true) |
|
68 | + { |
|
69 | + require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | + require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
71 | + $this->_question_model = EEM_Question::instance(); |
|
72 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
73 | + parent::__construct($routing); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + protected function _init_page_props() |
|
78 | + { |
|
79 | + $this->page_slug = REGISTRATION_FORM_PG_SLUG; |
|
80 | + $this->page_label = esc_html__('Registration Form', 'event_espresso'); |
|
81 | + $this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL; |
|
82 | + $this->_admin_base_path = REGISTRATION_FORM_ADMIN; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + protected function _ajax_hooks() |
|
87 | + { |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + protected function _define_page_props() |
|
92 | + { |
|
93 | + $this->_admin_page_title = esc_html__('Registration Form', 'event_espresso'); |
|
94 | + $this->_labels = array( |
|
95 | + 'buttons' => array( |
|
96 | + 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
97 | + ), |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + *_set_page_routes |
|
104 | + */ |
|
105 | + protected function _set_page_routes() |
|
106 | + { |
|
107 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
108 | + $this->_page_routes = array( |
|
109 | + 'default' => array( |
|
110 | + 'func' => '_questions_overview_list_table', |
|
111 | + 'capability' => 'ee_read_questions', |
|
112 | + ), |
|
113 | + |
|
114 | + 'edit_question' => array( |
|
115 | + 'func' => '_edit_question', |
|
116 | + 'capability' => 'ee_edit_question', |
|
117 | + 'obj_id' => $qst_id, |
|
118 | + 'args' => array('edit'), |
|
119 | + ), |
|
120 | + |
|
121 | + 'question_groups' => array( |
|
122 | + 'func' => '_questions_groups_preview', |
|
123 | + 'capability' => 'ee_read_question_groups', |
|
124 | + ), |
|
125 | + |
|
126 | + 'update_question' => array( |
|
127 | + 'func' => '_insert_or_update_question', |
|
128 | + 'args' => array('new_question' => false), |
|
129 | + 'capability' => 'ee_edit_question', |
|
130 | + 'obj_id' => $qst_id, |
|
131 | + 'noheader' => true, |
|
132 | + ), |
|
133 | + ); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + protected function _set_page_config() |
|
138 | + { |
|
139 | + $this->_page_config = array( |
|
140 | + 'default' => array( |
|
141 | + 'nav' => array( |
|
142 | + 'label' => esc_html__('Questions', 'event_espresso'), |
|
143 | + 'order' => 10, |
|
144 | + ), |
|
145 | + 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
|
146 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
147 | + 'help_tabs' => array( |
|
148 | + 'registration_form_questions_overview_help_tab' => array( |
|
149 | + 'title' => esc_html__('Questions Overview', 'event_espresso'), |
|
150 | + 'filename' => 'registration_form_questions_overview', |
|
151 | + ), |
|
152 | + 'registration_form_questions_overview_table_column_headings_help_tab' => array( |
|
153 | + 'title' => esc_html__('Questions Overview Table Column Headings', 'event_espresso'), |
|
154 | + 'filename' => 'registration_form_questions_overview_table_column_headings', |
|
155 | + ), |
|
156 | + 'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array( |
|
157 | + 'title' => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'), |
|
158 | + 'filename' => 'registration_form_questions_overview_views_bulk_actions_search', |
|
159 | + ), |
|
160 | + ), |
|
161 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
162 | + 'require_nonce' => false, |
|
163 | + 'qtips' => array( |
|
164 | + 'EE_Registration_Form_Tips', |
|
165 | + )/**/ |
|
166 | + ), |
|
167 | + |
|
168 | + 'question_groups' => array( |
|
169 | + 'nav' => array( |
|
170 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
171 | + 'order' => 20, |
|
172 | + ), |
|
173 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
174 | + 'help_tabs' => array( |
|
175 | + 'registration_form_question_groups_help_tab' => array( |
|
176 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
177 | + 'filename' => 'registration_form_question_groups', |
|
178 | + ), |
|
179 | + ), |
|
180 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
181 | + 'require_nonce' => false, |
|
182 | + ), |
|
183 | + |
|
184 | + 'edit_question' => array( |
|
185 | + 'nav' => array( |
|
186 | + 'label' => esc_html__('Edit Question', 'event_espresso'), |
|
187 | + 'order' => 15, |
|
188 | + 'persistent' => false, |
|
189 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), |
|
190 | + $this->_current_page_view_url) : $this->_admin_base_url, |
|
191 | + ), |
|
192 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
193 | + 'help_tabs' => array( |
|
194 | + 'registration_form_edit_question_group_help_tab' => array( |
|
195 | + 'title' => esc_html__('Edit Question', 'event_espresso'), |
|
196 | + 'filename' => 'registration_form_edit_question', |
|
197 | + ), |
|
198 | + ), |
|
199 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
200 | + 'require_nonce' => false, |
|
201 | + ), |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + protected function _add_screen_options() |
|
207 | + { |
|
208 | + //todo |
|
209 | + } |
|
210 | + |
|
211 | + protected function _add_screen_options_default() |
|
212 | + { |
|
213 | + $page_title = $this->_admin_page_title; |
|
214 | + $this->_admin_page_title = esc_html__('Questions', 'event_espresso'); |
|
215 | + $this->_per_page_screen_option(); |
|
216 | + $this->_admin_page_title = $page_title; |
|
217 | + } |
|
218 | + |
|
219 | + protected function _add_screen_options_question_groups() |
|
220 | + { |
|
221 | + $page_title = $this->_admin_page_title; |
|
222 | + $this->_admin_page_title = esc_html__('Question Groups', 'event_espresso'); |
|
223 | + $this->_per_page_screen_option(); |
|
224 | + $this->_admin_page_title = $page_title; |
|
225 | + } |
|
226 | + |
|
227 | + //none of the below group are currently used for Event Categories |
|
228 | + protected function _add_feature_pointers() |
|
229 | + { |
|
230 | + } |
|
231 | + |
|
232 | + public function load_scripts_styles() |
|
233 | + { |
|
234 | + wp_register_style('espresso_registration', |
|
235 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | + wp_enqueue_style('espresso_registration'); |
|
237 | + } |
|
238 | + |
|
239 | + public function admin_init() |
|
240 | + { |
|
241 | + } |
|
242 | + |
|
243 | + public function admin_notices() |
|
244 | + { |
|
245 | + } |
|
246 | + |
|
247 | + public function admin_footer_scripts() |
|
248 | + { |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + public function load_scripts_styles_default() |
|
253 | + { |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + public function load_scripts_styles_add_question() |
|
258 | + { |
|
259 | + $this->load_scripts_styles_forms(); |
|
260 | + wp_register_script('espresso_registration_form_single', |
|
261 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | + EVENT_ESPRESSO_VERSION, true); |
|
263 | + wp_enqueue_script('espresso_registration_form_single'); |
|
264 | + } |
|
265 | + |
|
266 | + public function load_scripts_styles_edit_question() |
|
267 | + { |
|
268 | + $this->load_scripts_styles_forms(); |
|
269 | + wp_register_script('espresso_registration_form_single', |
|
270 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | + EVENT_ESPRESSO_VERSION, true); |
|
272 | + wp_enqueue_script('espresso_registration_form_single'); |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + public function recaptcha_info_help_tab() |
|
277 | + { |
|
278 | + $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
279 | + EEH_Template::display_template($template, array()); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + public function load_scripts_styles_forms() |
|
284 | + { |
|
285 | + //styles |
|
286 | + wp_enqueue_style('espresso-ui-theme'); |
|
287 | + //scripts |
|
288 | + wp_enqueue_script('ee_admin_js'); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + protected function _set_list_table_views_default() |
|
293 | + { |
|
294 | + $this->_views = array( |
|
295 | + 'all' => array( |
|
296 | + 'slug' => 'all', |
|
297 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
298 | + 'count' => 0, |
|
299 | 299 | // 'bulk_action' => array( |
300 | 300 | // 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
301 | 301 | // ) |
302 | - ), |
|
303 | - ); |
|
304 | - |
|
305 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
306 | - 'espresso_registration_form_trash_questions') |
|
307 | - ) { |
|
308 | - $this->_views['trash'] = array( |
|
309 | - 'slug' => 'trash', |
|
310 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
311 | - 'count' => 0, |
|
302 | + ), |
|
303 | + ); |
|
304 | + |
|
305 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
306 | + 'espresso_registration_form_trash_questions') |
|
307 | + ) { |
|
308 | + $this->_views['trash'] = array( |
|
309 | + 'slug' => 'trash', |
|
310 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
311 | + 'count' => 0, |
|
312 | 312 | // 'bulk_action' => array( |
313 | 313 | // 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
314 | 314 | // 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
315 | - ); |
|
316 | - } |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * This just previews the question groups tab that comes in caffeinated. |
|
321 | - * |
|
322 | - * @return string html |
|
323 | - */ |
|
324 | - protected function _questions_groups_preview() |
|
325 | - { |
|
326 | - $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
|
327 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | - 'event_espresso') . '" />'; |
|
329 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | - 'event_espresso') . '</strong>'; |
|
331 | - $this->display_admin_caf_preview_page('question_groups_tab'); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * Extracts the question field's values from the POST request to update or insert them |
|
337 | - * |
|
338 | - * @param \EEM_Base $model |
|
339 | - * @return array where each key is the name of a model's field/db column, and each value is its value. |
|
340 | - */ |
|
341 | - protected function _set_column_values_for(EEM_Base $model) |
|
342 | - { |
|
343 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
344 | - $set_column_values = array(); |
|
345 | - |
|
346 | - //some initial checks for proper values. |
|
347 | - //if QST_admin_only, then no matter what QST_required is we disable. |
|
348 | - if (! empty($this->_req_data['QST_admin_only'])) { |
|
349 | - $this->_req_data['QST_required'] = 0; |
|
350 | - } |
|
351 | - foreach ($model->field_settings() as $fieldName => $settings) { |
|
352 | - // basically if QSG_identifier is empty or not set |
|
353 | - if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
354 | - $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
355 | - $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
315 | + ); |
|
316 | + } |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * This just previews the question groups tab that comes in caffeinated. |
|
321 | + * |
|
322 | + * @return string html |
|
323 | + */ |
|
324 | + protected function _questions_groups_preview() |
|
325 | + { |
|
326 | + $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
|
327 | + $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | + 'event_espresso') . '" />'; |
|
329 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | + 'event_espresso') . '</strong>'; |
|
331 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * Extracts the question field's values from the POST request to update or insert them |
|
337 | + * |
|
338 | + * @param \EEM_Base $model |
|
339 | + * @return array where each key is the name of a model's field/db column, and each value is its value. |
|
340 | + */ |
|
341 | + protected function _set_column_values_for(EEM_Base $model) |
|
342 | + { |
|
343 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
344 | + $set_column_values = array(); |
|
345 | + |
|
346 | + //some initial checks for proper values. |
|
347 | + //if QST_admin_only, then no matter what QST_required is we disable. |
|
348 | + if (! empty($this->_req_data['QST_admin_only'])) { |
|
349 | + $this->_req_data['QST_required'] = 0; |
|
350 | + } |
|
351 | + foreach ($model->field_settings() as $fieldName => $settings) { |
|
352 | + // basically if QSG_identifier is empty or not set |
|
353 | + if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
354 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
355 | + $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
356 | 356 | // dd($set_column_values); |
357 | - } //if the admin label is blank, use a slug version of the question text |
|
358 | - else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
359 | - $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
360 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
361 | - } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
362 | - $set_column_values[$fieldName] = 0; |
|
363 | - } else if ($fieldName === 'QST_max') { |
|
364 | - $qst_system = EEM_Question::instance()->get_var( |
|
365 | - array( |
|
366 | - array( |
|
367 | - 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0, |
|
368 | - ), |
|
369 | - ), |
|
370 | - 'QST_system'); |
|
371 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | - if (empty($this->_req_data['QST_max']) || |
|
373 | - $this->_req_data['QST_max'] > $max_max |
|
374 | - ) { |
|
375 | - $set_column_values[$fieldName] = $max_max; |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - //only add a property to the array if it's not null (otherwise the model should just use the default value) |
|
381 | - if ( |
|
382 | - ! isset($set_column_values[$fieldName]) && |
|
383 | - isset($this->_req_data[$fieldName]) |
|
384 | - ) { |
|
385 | - $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
386 | - } |
|
387 | - |
|
388 | - } |
|
389 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - *_questions_overview_list_table |
|
395 | - */ |
|
396 | - protected function _questions_overview_list_table() |
|
397 | - { |
|
398 | - $this->_search_btn_label = esc_html__('Questions', 'event_espresso'); |
|
399 | - $this->display_admin_list_table_page_with_sidebar(); |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * _edit_question |
|
405 | - */ |
|
406 | - protected function _edit_question() |
|
407 | - { |
|
408 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
409 | - $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : false; |
|
410 | - |
|
411 | - switch ($this->_req_action) { |
|
412 | - case 'add_question' : |
|
413 | - $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
414 | - break; |
|
415 | - case 'edit_question' : |
|
416 | - $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
417 | - break; |
|
418 | - default : |
|
419 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
420 | - } |
|
421 | - |
|
422 | - // add PRC_ID to title if editing |
|
423 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
424 | - if ($ID) { |
|
425 | - $question = $this->_question_model->get_one_by_ID($ID); |
|
426 | - $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
427 | - $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
|
428 | - } else { |
|
429 | - $question = EE_Question::new_instance(); |
|
430 | - $question->set_order_to_latest(); |
|
431 | - $this->_set_add_edit_form_tags('insert_question'); |
|
432 | - } |
|
433 | - if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
434 | - $question_types = array_intersect_key( |
|
435 | - EEM_Question::instance()->allowed_question_types(), |
|
436 | - array_flip( |
|
437 | - array( |
|
438 | - EEM_Question::QST_type_text, |
|
439 | - EEM_Question::QST_type_us_phone |
|
440 | - ) |
|
441 | - ) |
|
442 | - ); |
|
443 | - } else { |
|
444 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
445 | - } |
|
446 | - $this->_template_args['QST_ID'] = $ID; |
|
447 | - $this->_template_args['question'] = $question; |
|
448 | - $this->_template_args['question_types'] = $question_types; |
|
449 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( |
|
450 | - $question->system_ID() |
|
451 | - ); |
|
452 | - $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
|
453 | - $this->_set_publish_post_box_vars('id', $ID); |
|
454 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
455 | - REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
456 | - $this->_template_args, true |
|
457 | - ); |
|
458 | - |
|
459 | - // the details template wrapper |
|
460 | - $this->display_admin_page_with_sidebar(); |
|
461 | - } |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * @return string |
|
466 | - */ |
|
467 | - protected function _get_question_type_descriptions() |
|
468 | - { |
|
469 | - EE_Registry::instance()->load_helper('HTML'); |
|
470 | - $descriptions = ''; |
|
471 | - $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
|
472 | - foreach ($question_type_descriptions as $type => $question_type_description) { |
|
473 | - if ($type == 'HTML_TEXTAREA') { |
|
474 | - $html = new EE_Simple_HTML_Validation_Strategy(); |
|
475 | - $question_type_description .= sprintf( |
|
476 | - esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
477 | - '<br/>', |
|
478 | - $html->get_list_of_allowed_tags() |
|
479 | - ); |
|
480 | - } |
|
481 | - $descriptions .= EEH_HTML::p( |
|
482 | - $question_type_description, |
|
483 | - 'question_type_description-' . $type, |
|
484 | - 'question_type_description description', |
|
485 | - 'display:none;' |
|
486 | - ); |
|
487 | - } |
|
488 | - return $descriptions; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * @param bool|true $new_question |
|
494 | - * @throws \EE_Error |
|
495 | - */ |
|
496 | - protected function _insert_or_update_question($new_question = true) |
|
497 | - { |
|
498 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
499 | - $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
500 | - if ($new_question) { |
|
501 | - $ID = $this->_question_model->insert($set_column_values); |
|
502 | - $success = $ID ? true : false; |
|
503 | - $action_desc = 'added'; |
|
504 | - } else { |
|
505 | - $ID = absint($this->_req_data['QST_ID']); |
|
506 | - $pk = $this->_question_model->primary_key_name(); |
|
507 | - $wheres = array($pk => $ID); |
|
508 | - unset($set_column_values[$pk]); |
|
509 | - $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
510 | - $action_desc = 'updated'; |
|
511 | - } |
|
512 | - |
|
513 | - if ($ID) { |
|
514 | - //save the related options |
|
515 | - //trash removed options, save old ones |
|
516 | - //get list of all options |
|
517 | - /** @type EE_Question $question */ |
|
518 | - $question = $this->_question_model->get_one_by_ID($ID); |
|
519 | - $options = $question->options(); |
|
520 | - if (! empty($options)) { |
|
521 | - foreach ($options as $option_ID => $option) { |
|
522 | - $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
523 | - if ($option_req_index !== false) { |
|
524 | - $option->save($this->_req_data['question_options'][$option_req_index]); |
|
525 | - } else { |
|
526 | - //not found, remove it |
|
527 | - $option->delete(); |
|
528 | - } |
|
529 | - } |
|
530 | - } |
|
531 | - //save new related options |
|
532 | - foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
|
533 | - //skip $index that is from our sample |
|
534 | - if ( $index === 'xxcountxx' ) { |
|
535 | - continue; |
|
536 | - } |
|
537 | - //note we allow saving blank options. |
|
538 | - if (empty($option_req_data['QSO_ID']) |
|
539 | - ) {//no ID! save it! |
|
540 | - $new_option = EE_Question_Option::new_instance(array( |
|
541 | - 'QSO_value' => $option_req_data['QSO_value'], |
|
542 | - 'QSO_desc' => $option_req_data['QSO_desc'], |
|
543 | - 'QSO_order' => $option_req_data['QSO_order'], |
|
544 | - 'QST_ID' => $question->ID(), |
|
545 | - )); |
|
546 | - $new_option->save(); |
|
547 | - } |
|
548 | - } |
|
549 | - } |
|
550 | - $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
551 | - if ($success !== false) { |
|
552 | - $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
553 | - $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), |
|
554 | - $this->_question_model->item_name()); |
|
555 | - EE_Error::add_success($msg); |
|
556 | - } |
|
557 | - |
|
558 | - $this->_redirect_after_action(false, '', $action_desc, $query_args, true); |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not |
|
564 | - * by ID |
|
565 | - * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously). |
|
566 | - * So, this function gets the index in that request data array called question_options. Returns FALSE if not found. |
|
567 | - * |
|
568 | - * @param int $ID of the question option to find |
|
569 | - * @return int index in question_options array if successful, FALSE if unsuccessful |
|
570 | - */ |
|
571 | - protected function _get_option_req_data_index($ID) |
|
572 | - { |
|
573 | - $req_data_for_question_options = $this->_req_data['question_options']; |
|
574 | - foreach ($req_data_for_question_options as $num => $option_data) { |
|
575 | - if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
576 | - return $num; |
|
577 | - } |
|
578 | - } |
|
579 | - return false; |
|
580 | - } |
|
581 | - |
|
582 | - |
|
583 | - |
|
584 | - |
|
585 | - /***********/ |
|
586 | - /* QUERIES */ |
|
587 | - /** |
|
588 | - * For internal use in getting all the query parameters |
|
589 | - * (because it's pretty well the same between question, question groups, |
|
590 | - * and for both when searching for trashed and untrashed ones) |
|
591 | - * |
|
592 | - * @param EEM_Base $model either EEM_Question or EEM_Question_Group |
|
593 | - * @param int $per_page |
|
594 | - * @param int $current_page |
|
595 | - * @return array lik EEM_Base::get_all's $query_params parameter |
|
596 | - */ |
|
597 | - protected function get_query_params($model, $per_page = 10, $current_page = 10) |
|
598 | - { |
|
599 | - $query_params = array(); |
|
600 | - $offset = ($current_page - 1) * $per_page; |
|
601 | - $query_params['limit'] = array($offset, $per_page); |
|
602 | - $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
603 | - $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
|
604 | - $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
|
605 | - $query_params['order_by'] = array($field_to_order_by => $order); |
|
606 | - $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
607 | - if (! empty($search_string)) { |
|
608 | - if ($model instanceof EEM_Question_Group) { |
|
609 | - $query_params[0] = array( |
|
610 | - 'OR' => array( |
|
611 | - 'QSG_name' => array('LIKE', "%$search_string%"), |
|
612 | - 'QSG_desc' => array('LIKE', "%$search_string%"), |
|
613 | - ), |
|
614 | - ); |
|
615 | - } else { |
|
616 | - $query_params[0] = array( |
|
617 | - 'QST_display_text' => array('LIKE', "%$search_string%"), |
|
618 | - ); |
|
619 | - } |
|
620 | - } |
|
621 | - |
|
622 | - //capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented) |
|
623 | - /*if ( $model instanceof EEM_Question_Group ) { |
|
357 | + } //if the admin label is blank, use a slug version of the question text |
|
358 | + else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
359 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
360 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
361 | + } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
362 | + $set_column_values[$fieldName] = 0; |
|
363 | + } else if ($fieldName === 'QST_max') { |
|
364 | + $qst_system = EEM_Question::instance()->get_var( |
|
365 | + array( |
|
366 | + array( |
|
367 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0, |
|
368 | + ), |
|
369 | + ), |
|
370 | + 'QST_system'); |
|
371 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | + if (empty($this->_req_data['QST_max']) || |
|
373 | + $this->_req_data['QST_max'] > $max_max |
|
374 | + ) { |
|
375 | + $set_column_values[$fieldName] = $max_max; |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + //only add a property to the array if it's not null (otherwise the model should just use the default value) |
|
381 | + if ( |
|
382 | + ! isset($set_column_values[$fieldName]) && |
|
383 | + isset($this->_req_data[$fieldName]) |
|
384 | + ) { |
|
385 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
386 | + } |
|
387 | + |
|
388 | + } |
|
389 | + return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + *_questions_overview_list_table |
|
395 | + */ |
|
396 | + protected function _questions_overview_list_table() |
|
397 | + { |
|
398 | + $this->_search_btn_label = esc_html__('Questions', 'event_espresso'); |
|
399 | + $this->display_admin_list_table_page_with_sidebar(); |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * _edit_question |
|
405 | + */ |
|
406 | + protected function _edit_question() |
|
407 | + { |
|
408 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
409 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : false; |
|
410 | + |
|
411 | + switch ($this->_req_action) { |
|
412 | + case 'add_question' : |
|
413 | + $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
414 | + break; |
|
415 | + case 'edit_question' : |
|
416 | + $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
417 | + break; |
|
418 | + default : |
|
419 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
420 | + } |
|
421 | + |
|
422 | + // add PRC_ID to title if editing |
|
423 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
424 | + if ($ID) { |
|
425 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
426 | + $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
427 | + $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
|
428 | + } else { |
|
429 | + $question = EE_Question::new_instance(); |
|
430 | + $question->set_order_to_latest(); |
|
431 | + $this->_set_add_edit_form_tags('insert_question'); |
|
432 | + } |
|
433 | + if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
434 | + $question_types = array_intersect_key( |
|
435 | + EEM_Question::instance()->allowed_question_types(), |
|
436 | + array_flip( |
|
437 | + array( |
|
438 | + EEM_Question::QST_type_text, |
|
439 | + EEM_Question::QST_type_us_phone |
|
440 | + ) |
|
441 | + ) |
|
442 | + ); |
|
443 | + } else { |
|
444 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
445 | + } |
|
446 | + $this->_template_args['QST_ID'] = $ID; |
|
447 | + $this->_template_args['question'] = $question; |
|
448 | + $this->_template_args['question_types'] = $question_types; |
|
449 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( |
|
450 | + $question->system_ID() |
|
451 | + ); |
|
452 | + $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
|
453 | + $this->_set_publish_post_box_vars('id', $ID); |
|
454 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
455 | + REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
456 | + $this->_template_args, true |
|
457 | + ); |
|
458 | + |
|
459 | + // the details template wrapper |
|
460 | + $this->display_admin_page_with_sidebar(); |
|
461 | + } |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * @return string |
|
466 | + */ |
|
467 | + protected function _get_question_type_descriptions() |
|
468 | + { |
|
469 | + EE_Registry::instance()->load_helper('HTML'); |
|
470 | + $descriptions = ''; |
|
471 | + $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
|
472 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
473 | + if ($type == 'HTML_TEXTAREA') { |
|
474 | + $html = new EE_Simple_HTML_Validation_Strategy(); |
|
475 | + $question_type_description .= sprintf( |
|
476 | + esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
477 | + '<br/>', |
|
478 | + $html->get_list_of_allowed_tags() |
|
479 | + ); |
|
480 | + } |
|
481 | + $descriptions .= EEH_HTML::p( |
|
482 | + $question_type_description, |
|
483 | + 'question_type_description-' . $type, |
|
484 | + 'question_type_description description', |
|
485 | + 'display:none;' |
|
486 | + ); |
|
487 | + } |
|
488 | + return $descriptions; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * @param bool|true $new_question |
|
494 | + * @throws \EE_Error |
|
495 | + */ |
|
496 | + protected function _insert_or_update_question($new_question = true) |
|
497 | + { |
|
498 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
499 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
500 | + if ($new_question) { |
|
501 | + $ID = $this->_question_model->insert($set_column_values); |
|
502 | + $success = $ID ? true : false; |
|
503 | + $action_desc = 'added'; |
|
504 | + } else { |
|
505 | + $ID = absint($this->_req_data['QST_ID']); |
|
506 | + $pk = $this->_question_model->primary_key_name(); |
|
507 | + $wheres = array($pk => $ID); |
|
508 | + unset($set_column_values[$pk]); |
|
509 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
510 | + $action_desc = 'updated'; |
|
511 | + } |
|
512 | + |
|
513 | + if ($ID) { |
|
514 | + //save the related options |
|
515 | + //trash removed options, save old ones |
|
516 | + //get list of all options |
|
517 | + /** @type EE_Question $question */ |
|
518 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
519 | + $options = $question->options(); |
|
520 | + if (! empty($options)) { |
|
521 | + foreach ($options as $option_ID => $option) { |
|
522 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
523 | + if ($option_req_index !== false) { |
|
524 | + $option->save($this->_req_data['question_options'][$option_req_index]); |
|
525 | + } else { |
|
526 | + //not found, remove it |
|
527 | + $option->delete(); |
|
528 | + } |
|
529 | + } |
|
530 | + } |
|
531 | + //save new related options |
|
532 | + foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
|
533 | + //skip $index that is from our sample |
|
534 | + if ( $index === 'xxcountxx' ) { |
|
535 | + continue; |
|
536 | + } |
|
537 | + //note we allow saving blank options. |
|
538 | + if (empty($option_req_data['QSO_ID']) |
|
539 | + ) {//no ID! save it! |
|
540 | + $new_option = EE_Question_Option::new_instance(array( |
|
541 | + 'QSO_value' => $option_req_data['QSO_value'], |
|
542 | + 'QSO_desc' => $option_req_data['QSO_desc'], |
|
543 | + 'QSO_order' => $option_req_data['QSO_order'], |
|
544 | + 'QST_ID' => $question->ID(), |
|
545 | + )); |
|
546 | + $new_option->save(); |
|
547 | + } |
|
548 | + } |
|
549 | + } |
|
550 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
551 | + if ($success !== false) { |
|
552 | + $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
553 | + $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), |
|
554 | + $this->_question_model->item_name()); |
|
555 | + EE_Error::add_success($msg); |
|
556 | + } |
|
557 | + |
|
558 | + $this->_redirect_after_action(false, '', $action_desc, $query_args, true); |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not |
|
564 | + * by ID |
|
565 | + * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously). |
|
566 | + * So, this function gets the index in that request data array called question_options. Returns FALSE if not found. |
|
567 | + * |
|
568 | + * @param int $ID of the question option to find |
|
569 | + * @return int index in question_options array if successful, FALSE if unsuccessful |
|
570 | + */ |
|
571 | + protected function _get_option_req_data_index($ID) |
|
572 | + { |
|
573 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
574 | + foreach ($req_data_for_question_options as $num => $option_data) { |
|
575 | + if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
576 | + return $num; |
|
577 | + } |
|
578 | + } |
|
579 | + return false; |
|
580 | + } |
|
581 | + |
|
582 | + |
|
583 | + |
|
584 | + |
|
585 | + /***********/ |
|
586 | + /* QUERIES */ |
|
587 | + /** |
|
588 | + * For internal use in getting all the query parameters |
|
589 | + * (because it's pretty well the same between question, question groups, |
|
590 | + * and for both when searching for trashed and untrashed ones) |
|
591 | + * |
|
592 | + * @param EEM_Base $model either EEM_Question or EEM_Question_Group |
|
593 | + * @param int $per_page |
|
594 | + * @param int $current_page |
|
595 | + * @return array lik EEM_Base::get_all's $query_params parameter |
|
596 | + */ |
|
597 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) |
|
598 | + { |
|
599 | + $query_params = array(); |
|
600 | + $offset = ($current_page - 1) * $per_page; |
|
601 | + $query_params['limit'] = array($offset, $per_page); |
|
602 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
603 | + $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
|
604 | + $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
|
605 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
606 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
607 | + if (! empty($search_string)) { |
|
608 | + if ($model instanceof EEM_Question_Group) { |
|
609 | + $query_params[0] = array( |
|
610 | + 'OR' => array( |
|
611 | + 'QSG_name' => array('LIKE', "%$search_string%"), |
|
612 | + 'QSG_desc' => array('LIKE', "%$search_string%"), |
|
613 | + ), |
|
614 | + ); |
|
615 | + } else { |
|
616 | + $query_params[0] = array( |
|
617 | + 'QST_display_text' => array('LIKE', "%$search_string%"), |
|
618 | + ); |
|
619 | + } |
|
620 | + } |
|
621 | + |
|
622 | + //capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented) |
|
623 | + /*if ( $model instanceof EEM_Question_Group ) { |
|
624 | 624 | if ( ! EE_Registry::instance()->CAP->current_user_can( 'edit_others_question_groups', 'espresso_registration_form_edit_question_group' ) ) { |
625 | 625 | $query_params[0] = array( |
626 | 626 | 'AND' => array( |
@@ -650,62 +650,62 @@ discard block |
||
650 | 650 | } |
651 | 651 | }/**/ |
652 | 652 | |
653 | - return $query_params; |
|
654 | - |
|
655 | - } |
|
656 | - |
|
657 | - |
|
658 | - /** |
|
659 | - * @param int $per_page |
|
660 | - * @param int $current_page |
|
661 | - * @param bool|false $count |
|
662 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
663 | - */ |
|
664 | - public function get_questions($per_page = 10, $current_page = 1, $count = false) |
|
665 | - { |
|
666 | - $QST = EEM_Question::instance(); |
|
667 | - $query_params = $this->get_query_params($QST, $per_page, $current_page); |
|
668 | - if ($count) { |
|
669 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
670 | - $results = $QST->count($where); |
|
671 | - } else { |
|
672 | - $results = $QST->get_all($query_params); |
|
673 | - } |
|
674 | - return $results; |
|
675 | - |
|
676 | - } |
|
677 | - |
|
678 | - |
|
679 | - /** |
|
680 | - * @param $per_page |
|
681 | - * @param int $current_page |
|
682 | - * @param bool|false $count |
|
683 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
684 | - */ |
|
685 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
686 | - { |
|
687 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
688 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
689 | - $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
690 | - return $questions; |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * @param $per_page |
|
696 | - * @param int $current_page |
|
697 | - * @param bool|false $count |
|
698 | - * @return \EE_Soft_Delete_Base_Class[] |
|
699 | - */ |
|
700 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
701 | - { |
|
702 | - /** @type EEM_Question_Group $questionGroupModel */ |
|
703 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
704 | - //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
705 | - return $questionGroupModel->get_all( |
|
706 | - $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
707 | - ); |
|
708 | - } |
|
653 | + return $query_params; |
|
654 | + |
|
655 | + } |
|
656 | + |
|
657 | + |
|
658 | + /** |
|
659 | + * @param int $per_page |
|
660 | + * @param int $current_page |
|
661 | + * @param bool|false $count |
|
662 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
663 | + */ |
|
664 | + public function get_questions($per_page = 10, $current_page = 1, $count = false) |
|
665 | + { |
|
666 | + $QST = EEM_Question::instance(); |
|
667 | + $query_params = $this->get_query_params($QST, $per_page, $current_page); |
|
668 | + if ($count) { |
|
669 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
670 | + $results = $QST->count($where); |
|
671 | + } else { |
|
672 | + $results = $QST->get_all($query_params); |
|
673 | + } |
|
674 | + return $results; |
|
675 | + |
|
676 | + } |
|
677 | + |
|
678 | + |
|
679 | + /** |
|
680 | + * @param $per_page |
|
681 | + * @param int $current_page |
|
682 | + * @param bool|false $count |
|
683 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
684 | + */ |
|
685 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
686 | + { |
|
687 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
688 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
689 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
690 | + return $questions; |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * @param $per_page |
|
696 | + * @param int $current_page |
|
697 | + * @param bool|false $count |
|
698 | + * @return \EE_Soft_Delete_Base_Class[] |
|
699 | + */ |
|
700 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
701 | + { |
|
702 | + /** @type EEM_Question_Group $questionGroupModel */ |
|
703 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
704 | + //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
705 | + return $questionGroupModel->get_all( |
|
706 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
707 | + ); |
|
708 | + } |
|
709 | 709 | |
710 | 710 | |
711 | 711 | } //ends Registration_Form_Admin_Page class |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct($routing = true) |
68 | 68 | { |
69 | - require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | - require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
69 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
70 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
71 | 71 | $this->_question_model = EEM_Question::instance(); |
72 | 72 | $this->_question_group_model = EEM_Question_Group::instance(); |
73 | 73 | parent::__construct($routing); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public function load_scripts_styles() |
233 | 233 | { |
234 | 234 | wp_register_style('espresso_registration', |
235 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
235 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | 236 | wp_enqueue_style('espresso_registration'); |
237 | 237 | } |
238 | 238 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | { |
259 | 259 | $this->load_scripts_styles_forms(); |
260 | 260 | wp_register_script('espresso_registration_form_single', |
261 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
261 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | 262 | EVENT_ESPRESSO_VERSION, true); |
263 | 263 | wp_enqueue_script('espresso_registration_form_single'); |
264 | 264 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | { |
268 | 268 | $this->load_scripts_styles_forms(); |
269 | 269 | wp_register_script('espresso_registration_form_single', |
270 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
270 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | 271 | EVENT_ESPRESSO_VERSION, true); |
272 | 272 | wp_enqueue_script('espresso_registration_form_single'); |
273 | 273 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | public function recaptcha_info_help_tab() |
277 | 277 | { |
278 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
278 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
279 | 279 | EEH_Template::display_template($template, array()); |
280 | 280 | } |
281 | 281 | |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | protected function _questions_groups_preview() |
325 | 325 | { |
326 | 326 | $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
327 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | - 'event_espresso') . '" />'; |
|
329 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | - 'event_espresso') . '</strong>'; |
|
327 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | + 'event_espresso').'" />'; |
|
329 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | + 'event_espresso').'</strong>'; |
|
331 | 331 | $this->display_admin_caf_preview_page('question_groups_tab'); |
332 | 332 | } |
333 | 333 | |
@@ -345,20 +345,20 @@ discard block |
||
345 | 345 | |
346 | 346 | //some initial checks for proper values. |
347 | 347 | //if QST_admin_only, then no matter what QST_required is we disable. |
348 | - if (! empty($this->_req_data['QST_admin_only'])) { |
|
348 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
349 | 349 | $this->_req_data['QST_required'] = 0; |
350 | 350 | } |
351 | 351 | foreach ($model->field_settings() as $fieldName => $settings) { |
352 | 352 | // basically if QSG_identifier is empty or not set |
353 | 353 | if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
354 | 354 | $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
355 | - $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
355 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true); |
|
356 | 356 | // dd($set_column_values); |
357 | 357 | } //if the admin label is blank, use a slug version of the question text |
358 | 358 | else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
359 | 359 | $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
360 | 360 | $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
361 | - } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
361 | + } else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
362 | 362 | $set_column_values[$fieldName] = 0; |
363 | 363 | } else if ($fieldName === 'QST_max') { |
364 | 364 | $qst_system = EEM_Question::instance()->get_var( |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | ), |
369 | 369 | ), |
370 | 370 | 'QST_system'); |
371 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
371 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | 372 | if (empty($this->_req_data['QST_max']) || |
373 | 373 | $this->_req_data['QST_max'] > $max_max |
374 | 374 | ) { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | } |
389 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
389 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | // add PRC_ID to title if editing |
423 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
423 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
424 | 424 | if ($ID) { |
425 | 425 | $question = $this->_question_model->get_one_by_ID($ID); |
426 | 426 | $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $question->set_order_to_latest(); |
431 | 431 | $this->_set_add_edit_form_tags('insert_question'); |
432 | 432 | } |
433 | - if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
433 | + if ($question->system_ID() === EEM_Attendee::system_question_phone) { |
|
434 | 434 | $question_types = array_intersect_key( |
435 | 435 | EEM_Question::instance()->allowed_question_types(), |
436 | 436 | array_flip( |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
453 | 453 | $this->_set_publish_post_box_vars('id', $ID); |
454 | 454 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
455 | - REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
455 | + REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', |
|
456 | 456 | $this->_template_args, true |
457 | 457 | ); |
458 | 458 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | } |
481 | 481 | $descriptions .= EEH_HTML::p( |
482 | 482 | $question_type_description, |
483 | - 'question_type_description-' . $type, |
|
483 | + 'question_type_description-'.$type, |
|
484 | 484 | 'question_type_description description', |
485 | 485 | 'display:none;' |
486 | 486 | ); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | /** @type EE_Question $question */ |
518 | 518 | $question = $this->_question_model->get_one_by_ID($ID); |
519 | 519 | $options = $question->options(); |
520 | - if (! empty($options)) { |
|
520 | + if ( ! empty($options)) { |
|
521 | 521 | foreach ($options as $option_ID => $option) { |
522 | 522 | $option_req_index = $this->_get_option_req_data_index($option_ID); |
523 | 523 | if ($option_req_index !== false) { |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | //save new related options |
532 | 532 | foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
533 | 533 | //skip $index that is from our sample |
534 | - if ( $index === 'xxcountxx' ) { |
|
534 | + if ($index === 'xxcountxx') { |
|
535 | 535 | continue; |
536 | 536 | } |
537 | 537 | //note we allow saving blank options. |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | { |
573 | 573 | $req_data_for_question_options = $this->_req_data['question_options']; |
574 | 574 | foreach ($req_data_for_question_options as $num => $option_data) { |
575 | - if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
575 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
576 | 576 | return $num; |
577 | 577 | } |
578 | 578 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
605 | 605 | $query_params['order_by'] = array($field_to_order_by => $order); |
606 | 606 | $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
607 | - if (! empty($search_string)) { |
|
607 | + if ( ! empty($search_string)) { |
|
608 | 608 | if ($model instanceof EEM_Question_Group) { |
609 | 609 | $query_params[0] = array( |
610 | 610 | 'OR' => array( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Event Espresso |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | |
17 | 17 | |
18 | 18 | if ( ! function_exists('espresso_get_template_part')) { |
19 | - /** |
|
20 | - * espresso_get_template_part |
|
21 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | - * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | - * |
|
24 | - * @param string $slug The slug name for the generic template. |
|
25 | - * @param string $name The name of the specialised template. |
|
26 | - * @return string the html output for the formatted money value |
|
27 | - */ |
|
28 | - function espresso_get_template_part($slug = null, $name = null) |
|
29 | - { |
|
30 | - EEH_Template::get_template_part($slug, $name); |
|
31 | - } |
|
19 | + /** |
|
20 | + * espresso_get_template_part |
|
21 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | + * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | + * |
|
24 | + * @param string $slug The slug name for the generic template. |
|
25 | + * @param string $name The name of the specialised template. |
|
26 | + * @return string the html output for the formatted money value |
|
27 | + */ |
|
28 | + function espresso_get_template_part($slug = null, $name = null) |
|
29 | + { |
|
30 | + EEH_Template::get_template_part($slug, $name); |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | if ( ! function_exists('espresso_get_object_css_class')) { |
36 | - /** |
|
37 | - * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | - * |
|
39 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | - * @param string $prefix added to the beginning of the generated class |
|
41 | - * @param string $suffix added to the end of the generated class |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | - { |
|
46 | - return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | - } |
|
36 | + /** |
|
37 | + * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | + * |
|
39 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | + * @param string $prefix added to the beginning of the generated class |
|
41 | + * @param string $suffix added to the end of the generated class |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | + { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -59,650 +59,650 @@ discard block |
||
59 | 59 | class EEH_Template |
60 | 60 | { |
61 | 61 | |
62 | - private static $_espresso_themes = array(); |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | - * |
|
68 | - * @return boolean |
|
69 | - */ |
|
70 | - public static function is_espresso_theme() |
|
71 | - { |
|
72 | - return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | - * load it's functions.php file ( if not already loaded ) |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public static function load_espresso_theme_functions() |
|
82 | - { |
|
83 | - if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | - * |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public static function get_espresso_themes() |
|
97 | - { |
|
98 | - if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | - if (empty($espresso_themes)) { |
|
101 | - return array(); |
|
102 | - } |
|
103 | - if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | - unset($espresso_themes[$key]); |
|
105 | - } |
|
106 | - EEH_Template::$_espresso_themes = array(); |
|
107 | - foreach ($espresso_themes as $espresso_theme) { |
|
108 | - EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | - } |
|
110 | - } |
|
111 | - return EEH_Template::$_espresso_themes; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * EEH_Template::get_template_part |
|
117 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | - * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | - * filtering based off of the entire template part name |
|
120 | - * |
|
121 | - * @param string $slug The slug name for the generic template. |
|
122 | - * @param string $name The name of the specialised template. |
|
123 | - * @param array $template_args |
|
124 | - * @param bool $return_string |
|
125 | - * @return string the html output for the formatted money value |
|
126 | - */ |
|
127 | - public static function get_template_part( |
|
128 | - $slug = null, |
|
129 | - $name = null, |
|
130 | - $template_args = array(), |
|
131 | - $return_string = false |
|
132 | - ) { |
|
133 | - do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | - $templates = array(); |
|
135 | - $name = (string)$name; |
|
136 | - if ($name != '') { |
|
137 | - $templates[] = "{$slug}-{$name}.php"; |
|
138 | - } |
|
139 | - // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | - if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | - EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * locate_template |
|
148 | - * locate a template file by looking in the following places, in the following order: |
|
149 | - * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | - * <assumed full absolute server path> |
|
151 | - * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | - * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | - * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | - * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | - * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | - * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | - * Example: |
|
158 | - * You are using the WordPress Twenty Sixteen theme, |
|
159 | - * and you want to customize the "some-event.template.php" template, |
|
160 | - * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | - * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | - * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | - * /relative/path/to/some-event.template.php |
|
165 | - * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | - * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | - * Had you passed an absolute path to your template that was in some other location, |
|
171 | - * ie: "/absolute/path/to/some-event.template.php" |
|
172 | - * then the search would have been : |
|
173 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | - * /absolute/path/to/some-event.template.php |
|
175 | - * and stopped there upon finding it in the second location |
|
176 | - * |
|
177 | - * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | - * @param boolean $load whether to pass the located template path on to the |
|
180 | - * EEH_Template::display_template() method or simply return it |
|
181 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | - * string |
|
183 | - * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | - * generate a custom template or not. Used in places where you don't actually |
|
185 | - * load the template, you just want to know if there's a custom version of it. |
|
186 | - * @return mixed |
|
187 | - */ |
|
188 | - public static function locate_template( |
|
189 | - $templates = array(), |
|
190 | - $template_args = array(), |
|
191 | - $load = true, |
|
192 | - $return_string = true, |
|
193 | - $check_if_custom = false |
|
194 | - ) { |
|
195 | - // first use WP locate_template to check for template in the current theme folder |
|
196 | - $template_path = locate_template($templates); |
|
197 | - |
|
198 | - if ($check_if_custom && ! empty($template_path)) { |
|
199 | - return true; |
|
200 | - } |
|
201 | - |
|
202 | - // not in the theme |
|
203 | - if (empty($template_path)) { |
|
204 | - // not even a template to look for ? |
|
205 | - if (empty($templates)) { |
|
206 | - // get post_type |
|
207 | - $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | - // get array of EE Custom Post Types |
|
209 | - $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | - // build template name based on request |
|
211 | - if (isset($EE_CPTs[$post_type])) { |
|
212 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | - } |
|
216 | - } |
|
217 | - // currently active EE template theme |
|
218 | - $current_theme = EE_Config::get_current_theme(); |
|
219 | - |
|
220 | - // array of paths to folders that may contain templates |
|
221 | - $template_folder_paths = array( |
|
222 | - // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | - // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | - ); |
|
227 | - |
|
228 | - //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | - if ( ! $check_if_custom) { |
|
230 | - $core_paths = array( |
|
231 | - // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | - EE_PUBLIC . $current_theme, |
|
233 | - // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | - EE_TEMPLATES . $current_theme, |
|
235 | - // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | - EE_PLUGIN_DIR_PATH, |
|
237 | - ); |
|
238 | - $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | - } |
|
240 | - |
|
241 | - // now filter that array |
|
242 | - $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | - $template_folder_paths); |
|
244 | - $templates = is_array($templates) ? $templates : array($templates); |
|
245 | - $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | - // array to hold all possible template paths |
|
247 | - $full_template_paths = array(); |
|
248 | - |
|
249 | - // loop through $templates |
|
250 | - foreach ($templates as $template) { |
|
251 | - // normalize directory separators |
|
252 | - $template = EEH_File::standardise_directory_separators($template); |
|
253 | - $file_name = basename($template); |
|
254 | - $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | - // while looping through all template folder paths |
|
256 | - foreach ($template_folder_paths as $template_folder_path) { |
|
257 | - // normalize directory separators |
|
258 | - $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | - // determine if any common base path exists between the two paths |
|
260 | - $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | - array($template_folder_path, $template_path_minus_file_name) |
|
262 | - ); |
|
263 | - if ($common_base_path !== '') { |
|
264 | - // both paths have a common base, so just tack the filename onto our search path |
|
265 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | - } else { |
|
267 | - // no common base path, so let's just concatenate |
|
268 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | - } |
|
270 | - // build up our template locations array by adding our resolved paths |
|
271 | - $full_template_paths[] = $resolved_path; |
|
272 | - } |
|
273 | - // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | - array_unshift($full_template_paths, $template); |
|
275 | - // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | - } |
|
278 | - // filter final array of full template paths |
|
279 | - $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | - $full_template_paths, $file_name); |
|
281 | - // now loop through our final array of template location paths and check each location |
|
282 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | - if (is_readable($full_template_path)) { |
|
284 | - $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - } |
|
289 | - |
|
290 | - // hook that can be used to display the full template path that will be used |
|
291 | - do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
292 | - |
|
293 | - // if we got it and you want to see it... |
|
294 | - if ($template_path && $load && ! $check_if_custom) { |
|
295 | - if ($return_string) { |
|
296 | - return EEH_Template::display_template($template_path, $template_args, true); |
|
297 | - } else { |
|
298 | - EEH_Template::display_template($template_path, $template_args, false); |
|
299 | - } |
|
300 | - } |
|
301 | - return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * _find_common_base_path |
|
307 | - * given two paths, this determines if there is a common base path between the two |
|
308 | - * |
|
309 | - * @param array $paths |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - protected static function _find_common_base_path($paths) |
|
313 | - { |
|
314 | - $last_offset = 0; |
|
315 | - $common_base_path = ''; |
|
316 | - while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
317 | - $dir_length = $index - $last_offset + 1; |
|
318 | - $directory = substr($paths[0], $last_offset, $dir_length); |
|
319 | - foreach ($paths as $path) { |
|
320 | - if (substr($path, $last_offset, $dir_length) != $directory) { |
|
321 | - return $common_base_path; |
|
322 | - } |
|
323 | - } |
|
324 | - $common_base_path .= $directory; |
|
325 | - $last_offset = $index + 1; |
|
326 | - } |
|
327 | - return substr($common_base_path, 0, -1); |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * load and display a template |
|
333 | - * |
|
334 | - * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
335 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
336 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
337 | - * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
338 | - * not found or is not readable |
|
339 | - * @return mixed string |
|
340 | - * @throws \DomainException |
|
341 | - */ |
|
62 | + private static $_espresso_themes = array(); |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | + * |
|
68 | + * @return boolean |
|
69 | + */ |
|
70 | + public static function is_espresso_theme() |
|
71 | + { |
|
72 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | + * load it's functions.php file ( if not already loaded ) |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public static function load_espresso_theme_functions() |
|
82 | + { |
|
83 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | + if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | + require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | + * |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public static function get_espresso_themes() |
|
97 | + { |
|
98 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | + $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | + if (empty($espresso_themes)) { |
|
101 | + return array(); |
|
102 | + } |
|
103 | + if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | + unset($espresso_themes[$key]); |
|
105 | + } |
|
106 | + EEH_Template::$_espresso_themes = array(); |
|
107 | + foreach ($espresso_themes as $espresso_theme) { |
|
108 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | + } |
|
110 | + } |
|
111 | + return EEH_Template::$_espresso_themes; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * EEH_Template::get_template_part |
|
117 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | + * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | + * filtering based off of the entire template part name |
|
120 | + * |
|
121 | + * @param string $slug The slug name for the generic template. |
|
122 | + * @param string $name The name of the specialised template. |
|
123 | + * @param array $template_args |
|
124 | + * @param bool $return_string |
|
125 | + * @return string the html output for the formatted money value |
|
126 | + */ |
|
127 | + public static function get_template_part( |
|
128 | + $slug = null, |
|
129 | + $name = null, |
|
130 | + $template_args = array(), |
|
131 | + $return_string = false |
|
132 | + ) { |
|
133 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | + $templates = array(); |
|
135 | + $name = (string)$name; |
|
136 | + if ($name != '') { |
|
137 | + $templates[] = "{$slug}-{$name}.php"; |
|
138 | + } |
|
139 | + // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | + EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * locate_template |
|
148 | + * locate a template file by looking in the following places, in the following order: |
|
149 | + * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | + * <assumed full absolute server path> |
|
151 | + * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | + * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | + * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | + * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | + * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | + * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | + * Example: |
|
158 | + * You are using the WordPress Twenty Sixteen theme, |
|
159 | + * and you want to customize the "some-event.template.php" template, |
|
160 | + * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | + * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | + * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | + * /relative/path/to/some-event.template.php |
|
165 | + * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | + * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | + * Had you passed an absolute path to your template that was in some other location, |
|
171 | + * ie: "/absolute/path/to/some-event.template.php" |
|
172 | + * then the search would have been : |
|
173 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | + * /absolute/path/to/some-event.template.php |
|
175 | + * and stopped there upon finding it in the second location |
|
176 | + * |
|
177 | + * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | + * @param boolean $load whether to pass the located template path on to the |
|
180 | + * EEH_Template::display_template() method or simply return it |
|
181 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | + * string |
|
183 | + * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | + * generate a custom template or not. Used in places where you don't actually |
|
185 | + * load the template, you just want to know if there's a custom version of it. |
|
186 | + * @return mixed |
|
187 | + */ |
|
188 | + public static function locate_template( |
|
189 | + $templates = array(), |
|
190 | + $template_args = array(), |
|
191 | + $load = true, |
|
192 | + $return_string = true, |
|
193 | + $check_if_custom = false |
|
194 | + ) { |
|
195 | + // first use WP locate_template to check for template in the current theme folder |
|
196 | + $template_path = locate_template($templates); |
|
197 | + |
|
198 | + if ($check_if_custom && ! empty($template_path)) { |
|
199 | + return true; |
|
200 | + } |
|
201 | + |
|
202 | + // not in the theme |
|
203 | + if (empty($template_path)) { |
|
204 | + // not even a template to look for ? |
|
205 | + if (empty($templates)) { |
|
206 | + // get post_type |
|
207 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | + // get array of EE Custom Post Types |
|
209 | + $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | + // build template name based on request |
|
211 | + if (isset($EE_CPTs[$post_type])) { |
|
212 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | + $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | + } |
|
216 | + } |
|
217 | + // currently active EE template theme |
|
218 | + $current_theme = EE_Config::get_current_theme(); |
|
219 | + |
|
220 | + // array of paths to folders that may contain templates |
|
221 | + $template_folder_paths = array( |
|
222 | + // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | + EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | + // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | + ); |
|
227 | + |
|
228 | + //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | + if ( ! $check_if_custom) { |
|
230 | + $core_paths = array( |
|
231 | + // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | + EE_PUBLIC . $current_theme, |
|
233 | + // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | + EE_TEMPLATES . $current_theme, |
|
235 | + // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | + EE_PLUGIN_DIR_PATH, |
|
237 | + ); |
|
238 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | + } |
|
240 | + |
|
241 | + // now filter that array |
|
242 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | + $template_folder_paths); |
|
244 | + $templates = is_array($templates) ? $templates : array($templates); |
|
245 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | + // array to hold all possible template paths |
|
247 | + $full_template_paths = array(); |
|
248 | + |
|
249 | + // loop through $templates |
|
250 | + foreach ($templates as $template) { |
|
251 | + // normalize directory separators |
|
252 | + $template = EEH_File::standardise_directory_separators($template); |
|
253 | + $file_name = basename($template); |
|
254 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | + // while looping through all template folder paths |
|
256 | + foreach ($template_folder_paths as $template_folder_path) { |
|
257 | + // normalize directory separators |
|
258 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | + // determine if any common base path exists between the two paths |
|
260 | + $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | + array($template_folder_path, $template_path_minus_file_name) |
|
262 | + ); |
|
263 | + if ($common_base_path !== '') { |
|
264 | + // both paths have a common base, so just tack the filename onto our search path |
|
265 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | + } else { |
|
267 | + // no common base path, so let's just concatenate |
|
268 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | + } |
|
270 | + // build up our template locations array by adding our resolved paths |
|
271 | + $full_template_paths[] = $resolved_path; |
|
272 | + } |
|
273 | + // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | + array_unshift($full_template_paths, $template); |
|
275 | + // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | + array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | + } |
|
278 | + // filter final array of full template paths |
|
279 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | + $full_template_paths, $file_name); |
|
281 | + // now loop through our final array of template location paths and check each location |
|
282 | + foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | + if (is_readable($full_template_path)) { |
|
284 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + } |
|
289 | + |
|
290 | + // hook that can be used to display the full template path that will be used |
|
291 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
292 | + |
|
293 | + // if we got it and you want to see it... |
|
294 | + if ($template_path && $load && ! $check_if_custom) { |
|
295 | + if ($return_string) { |
|
296 | + return EEH_Template::display_template($template_path, $template_args, true); |
|
297 | + } else { |
|
298 | + EEH_Template::display_template($template_path, $template_args, false); |
|
299 | + } |
|
300 | + } |
|
301 | + return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * _find_common_base_path |
|
307 | + * given two paths, this determines if there is a common base path between the two |
|
308 | + * |
|
309 | + * @param array $paths |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + protected static function _find_common_base_path($paths) |
|
313 | + { |
|
314 | + $last_offset = 0; |
|
315 | + $common_base_path = ''; |
|
316 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
317 | + $dir_length = $index - $last_offset + 1; |
|
318 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
319 | + foreach ($paths as $path) { |
|
320 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
321 | + return $common_base_path; |
|
322 | + } |
|
323 | + } |
|
324 | + $common_base_path .= $directory; |
|
325 | + $last_offset = $index + 1; |
|
326 | + } |
|
327 | + return substr($common_base_path, 0, -1); |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * load and display a template |
|
333 | + * |
|
334 | + * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
335 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
336 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
337 | + * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
338 | + * not found or is not readable |
|
339 | + * @return mixed string |
|
340 | + * @throws \DomainException |
|
341 | + */ |
|
342 | 342 | public static function display_template( |
343 | - $template_path = false, |
|
344 | - $template_args = array(), |
|
345 | - $return_string = false, |
|
346 | - $throw_exceptions = false |
|
347 | - ) { |
|
348 | - |
|
349 | - /** |
|
350 | - * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
351 | - * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
352 | - * the display_template method are templates we DON'T want modified (usually because of js |
|
353 | - * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
354 | - * using this. |
|
355 | - * |
|
356 | - * @since 4.6.0 |
|
357 | - */ |
|
358 | - $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
359 | - $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
360 | - |
|
361 | - // you gimme nuttin - YOU GET NUTTIN !! |
|
362 | - if ( ! $template_path || ! is_readable($template_path)) { |
|
363 | - return ''; |
|
364 | - } |
|
365 | - // if $template_args are not in an array, then make it so |
|
366 | - if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
367 | - $template_args = array($template_args); |
|
368 | - } |
|
369 | - extract( $template_args, EXTR_SKIP ); |
|
370 | - // ignore whether template is accessible ? |
|
371 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
372 | - throw new \DomainException( |
|
373 | - esc_html__( |
|
374 | - 'Invalid, unreadable, or missing file.', |
|
375 | - 'event_espresso' |
|
376 | - ) |
|
377 | - ); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - if ($return_string) { |
|
382 | - // because we want to return a string, we are going to capture the output |
|
383 | - ob_start(); |
|
384 | - include($template_path); |
|
385 | - return ob_get_clean(); |
|
386 | - } else { |
|
387 | - include($template_path); |
|
388 | - } |
|
389 | - return ''; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
395 | - * |
|
396 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
397 | - * @param string $prefix added to the beginning of the generated class |
|
398 | - * @param string $suffix added to the end of the generated class |
|
399 | - * @return string |
|
400 | - */ |
|
401 | - public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
402 | - { |
|
403 | - // in the beginning... |
|
404 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
405 | - // da muddle |
|
406 | - $class = ''; |
|
407 | - // the end |
|
408 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
409 | - // is the passed object an EE object ? |
|
410 | - if ($object instanceof EE_Base_Class) { |
|
411 | - // grab the exact type of object |
|
412 | - $obj_class = get_class($object); |
|
413 | - // depending on the type of object... |
|
414 | - switch ($obj_class) { |
|
415 | - // no specifics just yet... |
|
416 | - default : |
|
417 | - $class = strtolower(str_replace('_', '-', $obj_class)); |
|
418 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
419 | - |
|
420 | - } |
|
421 | - } |
|
422 | - return $prefix . $class . $suffix; |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * EEH_Template::format_currency |
|
429 | - * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
430 | - * the country currency settings from the supplied country ISO code |
|
431 | - * |
|
432 | - * @param float $amount raw money value |
|
433 | - * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
434 | - * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
435 | - * @param string $CNT_ISO 2 letter ISO code for a country |
|
436 | - * @param string $cur_code_span_class |
|
437 | - * @return string the html output for the formatted money value |
|
438 | - * @throws \EE_Error |
|
439 | - */ |
|
440 | - public static function format_currency( |
|
441 | - $amount = null, |
|
442 | - $return_raw = false, |
|
443 | - $display_code = true, |
|
444 | - $CNT_ISO = '', |
|
445 | - $cur_code_span_class = 'currency-code' |
|
446 | - ) { |
|
447 | - // ensure amount was received |
|
448 | - if ($amount === null) { |
|
449 | - $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
450 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
451 | - return ''; |
|
452 | - } |
|
453 | - //ensure amount is float |
|
454 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
455 | - $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
456 | - // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
457 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
458 | - // still a number or was amount converted to a string like "free" ? |
|
459 | - if (is_float($amount_formatted)) { |
|
460 | - // was a country ISO code passed ? if so generate currency config object for that country |
|
461 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
462 | - // verify results |
|
463 | - if ( ! $mny instanceof EE_Currency_Config) { |
|
464 | - // set default config country currency settings |
|
465 | - $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
466 | - ? EE_Registry::instance()->CFG->currency |
|
467 | - : new EE_Currency_Config(); |
|
468 | - } |
|
469 | - // format float |
|
470 | - $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
471 | - // add formatting ? |
|
472 | - if ( ! $return_raw) { |
|
473 | - // add currency sign |
|
474 | - if ($mny->sign_b4) { |
|
475 | - if ($amount >= 0) { |
|
476 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
477 | - } else { |
|
478 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
479 | - } |
|
480 | - |
|
481 | - } else { |
|
482 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
483 | - } |
|
484 | - |
|
485 | - // filter to allow global setting of display_code |
|
486 | - $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
487 | - |
|
488 | - // add currency code ? |
|
489 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
490 | - } |
|
491 | - // filter results |
|
492 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
493 | - $amount_formatted, $mny, $return_raw); |
|
494 | - } |
|
495 | - // clean up vars |
|
496 | - unset($mny); |
|
497 | - // return formatted currency amount |
|
498 | - return $amount_formatted; |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - /** |
|
503 | - * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
504 | - * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
505 | - * related status model or model object (i.e. in documentation etc.) |
|
506 | - * |
|
507 | - * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
508 | - * match, then 'Unknown' will be returned. |
|
509 | - * @param boolean $plural Whether to return plural or not |
|
510 | - * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
511 | - * @return string The localized label for the status id. |
|
512 | - */ |
|
513 | - public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
514 | - { |
|
515 | - /** @type EEM_Status $EEM_Status */ |
|
516 | - $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
517 | - $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
518 | - $schema); |
|
519 | - return $status[$status_id]; |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * This helper just returns a button or link for the given parameters |
|
525 | - * |
|
526 | - * @param string $url the url for the link |
|
527 | - * @param string $label What is the label you want displayed for the button |
|
528 | - * @param string $class what class is used for the button (defaults to 'button-primary') |
|
529 | - * @param string $icon |
|
530 | - * @param string $title |
|
531 | - * @return string the html output for the button |
|
532 | - */ |
|
533 | - public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
534 | - { |
|
535 | - $icon_html = ''; |
|
536 | - if ( ! empty($icon)) { |
|
537 | - $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
538 | - $dashicons = array_filter($dashicons); |
|
539 | - $count = count($dashicons); |
|
540 | - $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
541 | - foreach ($dashicons as $dashicon) { |
|
542 | - $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
543 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
544 | - } |
|
545 | - $icon_html .= $count > 1 ? '</span>' : ''; |
|
546 | - } |
|
547 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
549 | - return $button; |
|
550 | - } |
|
551 | - |
|
552 | - |
|
553 | - /** |
|
554 | - * This returns a generated link that will load the related help tab on admin pages. |
|
555 | - * |
|
556 | - * @param string $help_tab_id the id for the connected help tab |
|
557 | - * @param bool|string $page The page identifier for the page the help tab is on |
|
558 | - * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
559 | - * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
560 | - * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
561 | - * @return string generated link |
|
562 | - */ |
|
563 | - public static function get_help_tab_link( |
|
564 | - $help_tab_id, |
|
565 | - $page = false, |
|
566 | - $action = false, |
|
567 | - $icon_style = false, |
|
568 | - $help_text = false |
|
569 | - ) { |
|
570 | - |
|
571 | - if ( ! $page) { |
|
572 | - $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
573 | - } |
|
574 | - |
|
575 | - if ( ! $action) { |
|
576 | - $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
577 | - } |
|
578 | - |
|
579 | - $action = empty($action) ? 'default' : $action; |
|
580 | - |
|
581 | - |
|
582 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
583 | - $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
584 | - $help_text = ! $help_text ? '' : $help_text; |
|
585 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - /** |
|
591 | - * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
592 | - * |
|
593 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
594 | - * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
595 | - * @param EE_Help_Tour |
|
596 | - * @return string html |
|
597 | - */ |
|
598 | - public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
599 | - { |
|
600 | - $id = $tour->get_slug(); |
|
601 | - $stops = $tour->get_stops(); |
|
602 | - |
|
603 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
604 | - |
|
605 | - foreach ($stops as $stop) { |
|
606 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
608 | - |
|
609 | - //if container is set to modal then let's make sure we set the options accordingly |
|
610 | - if (empty($data_id) && empty($data_class)) { |
|
611 | - $stop['options']['modal'] = true; |
|
612 | - $stop['options']['expose'] = true; |
|
613 | - } |
|
614 | - |
|
615 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
617 | - $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
618 | - |
|
619 | - //options |
|
620 | - if (isset($stop['options']) && is_array($stop['options'])) { |
|
621 | - $options = ' data-options="'; |
|
622 | - foreach ($stop['options'] as $option => $value) { |
|
623 | - $options .= $option . ':' . $value . ';'; |
|
624 | - } |
|
625 | - $options .= '"'; |
|
626 | - } else { |
|
627 | - $options = ''; |
|
628 | - } |
|
629 | - |
|
630 | - //let's put all together |
|
631 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
632 | - } |
|
633 | - |
|
634 | - $content .= '</ol>'; |
|
635 | - return $content; |
|
636 | - } |
|
637 | - |
|
638 | - |
|
639 | - /** |
|
640 | - * This is a helper method to generate a status legend for a given status array. |
|
641 | - * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
642 | - * status_array. |
|
643 | - * |
|
644 | - * @param array $status_array array of statuses that will make up the legend. In format: |
|
645 | - * array( |
|
646 | - * 'status_item' => 'status_name' |
|
647 | - * ) |
|
648 | - * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
649 | - * the legend. |
|
650 | - * @throws EE_Error |
|
651 | - * @return string html structure for status. |
|
652 | - */ |
|
653 | - public static function status_legend($status_array, $active_status = '') |
|
654 | - { |
|
655 | - if ( ! is_array($status_array)) { |
|
656 | - throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
657 | - 'event_espresso')); |
|
658 | - } |
|
659 | - |
|
660 | - $setup_array = array(); |
|
661 | - foreach ($status_array as $item => $status) { |
|
662 | - $setup_array[$item] = array( |
|
663 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
664 | - 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
665 | - 'status' => $status, |
|
666 | - ); |
|
667 | - } |
|
668 | - |
|
669 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
672 | - foreach ($setup_array as $item => $details) { |
|
673 | - $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
674 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | - $content .= '</dt>' . "\n"; |
|
678 | - } |
|
679 | - $content .= '</dl>' . "\n"; |
|
680 | - $content .= '</div>' . "\n"; |
|
681 | - return $content; |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - /** |
|
686 | - * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
687 | - * that's nice for presenting in the wp admin |
|
688 | - * |
|
689 | - * @param mixed $data |
|
690 | - * @return string |
|
691 | - */ |
|
692 | - public static function layout_array_as_table($data) |
|
693 | - { |
|
694 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
695 | - $data = (array)$data; |
|
696 | - } |
|
697 | - ob_start(); |
|
698 | - if (is_array($data)) { |
|
699 | - if (EEH_Array::is_associative_array($data)) { |
|
700 | - ?> |
|
343 | + $template_path = false, |
|
344 | + $template_args = array(), |
|
345 | + $return_string = false, |
|
346 | + $throw_exceptions = false |
|
347 | + ) { |
|
348 | + |
|
349 | + /** |
|
350 | + * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
351 | + * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
352 | + * the display_template method are templates we DON'T want modified (usually because of js |
|
353 | + * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
354 | + * using this. |
|
355 | + * |
|
356 | + * @since 4.6.0 |
|
357 | + */ |
|
358 | + $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
359 | + $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
360 | + |
|
361 | + // you gimme nuttin - YOU GET NUTTIN !! |
|
362 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
363 | + return ''; |
|
364 | + } |
|
365 | + // if $template_args are not in an array, then make it so |
|
366 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
367 | + $template_args = array($template_args); |
|
368 | + } |
|
369 | + extract( $template_args, EXTR_SKIP ); |
|
370 | + // ignore whether template is accessible ? |
|
371 | + if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
372 | + throw new \DomainException( |
|
373 | + esc_html__( |
|
374 | + 'Invalid, unreadable, or missing file.', |
|
375 | + 'event_espresso' |
|
376 | + ) |
|
377 | + ); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + if ($return_string) { |
|
382 | + // because we want to return a string, we are going to capture the output |
|
383 | + ob_start(); |
|
384 | + include($template_path); |
|
385 | + return ob_get_clean(); |
|
386 | + } else { |
|
387 | + include($template_path); |
|
388 | + } |
|
389 | + return ''; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
395 | + * |
|
396 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
397 | + * @param string $prefix added to the beginning of the generated class |
|
398 | + * @param string $suffix added to the end of the generated class |
|
399 | + * @return string |
|
400 | + */ |
|
401 | + public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
402 | + { |
|
403 | + // in the beginning... |
|
404 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
405 | + // da muddle |
|
406 | + $class = ''; |
|
407 | + // the end |
|
408 | + $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
409 | + // is the passed object an EE object ? |
|
410 | + if ($object instanceof EE_Base_Class) { |
|
411 | + // grab the exact type of object |
|
412 | + $obj_class = get_class($object); |
|
413 | + // depending on the type of object... |
|
414 | + switch ($obj_class) { |
|
415 | + // no specifics just yet... |
|
416 | + default : |
|
417 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
418 | + $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
419 | + |
|
420 | + } |
|
421 | + } |
|
422 | + return $prefix . $class . $suffix; |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * EEH_Template::format_currency |
|
429 | + * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
430 | + * the country currency settings from the supplied country ISO code |
|
431 | + * |
|
432 | + * @param float $amount raw money value |
|
433 | + * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
434 | + * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
435 | + * @param string $CNT_ISO 2 letter ISO code for a country |
|
436 | + * @param string $cur_code_span_class |
|
437 | + * @return string the html output for the formatted money value |
|
438 | + * @throws \EE_Error |
|
439 | + */ |
|
440 | + public static function format_currency( |
|
441 | + $amount = null, |
|
442 | + $return_raw = false, |
|
443 | + $display_code = true, |
|
444 | + $CNT_ISO = '', |
|
445 | + $cur_code_span_class = 'currency-code' |
|
446 | + ) { |
|
447 | + // ensure amount was received |
|
448 | + if ($amount === null) { |
|
449 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
450 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
451 | + return ''; |
|
452 | + } |
|
453 | + //ensure amount is float |
|
454 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
455 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
456 | + // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
457 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
458 | + // still a number or was amount converted to a string like "free" ? |
|
459 | + if (is_float($amount_formatted)) { |
|
460 | + // was a country ISO code passed ? if so generate currency config object for that country |
|
461 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
462 | + // verify results |
|
463 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
464 | + // set default config country currency settings |
|
465 | + $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
466 | + ? EE_Registry::instance()->CFG->currency |
|
467 | + : new EE_Currency_Config(); |
|
468 | + } |
|
469 | + // format float |
|
470 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
471 | + // add formatting ? |
|
472 | + if ( ! $return_raw) { |
|
473 | + // add currency sign |
|
474 | + if ($mny->sign_b4) { |
|
475 | + if ($amount >= 0) { |
|
476 | + $amount_formatted = $mny->sign . $amount_formatted; |
|
477 | + } else { |
|
478 | + $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
479 | + } |
|
480 | + |
|
481 | + } else { |
|
482 | + $amount_formatted = $amount_formatted . $mny->sign; |
|
483 | + } |
|
484 | + |
|
485 | + // filter to allow global setting of display_code |
|
486 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
487 | + |
|
488 | + // add currency code ? |
|
489 | + $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
490 | + } |
|
491 | + // filter results |
|
492 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
493 | + $amount_formatted, $mny, $return_raw); |
|
494 | + } |
|
495 | + // clean up vars |
|
496 | + unset($mny); |
|
497 | + // return formatted currency amount |
|
498 | + return $amount_formatted; |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + /** |
|
503 | + * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
504 | + * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
505 | + * related status model or model object (i.e. in documentation etc.) |
|
506 | + * |
|
507 | + * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
508 | + * match, then 'Unknown' will be returned. |
|
509 | + * @param boolean $plural Whether to return plural or not |
|
510 | + * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
511 | + * @return string The localized label for the status id. |
|
512 | + */ |
|
513 | + public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
514 | + { |
|
515 | + /** @type EEM_Status $EEM_Status */ |
|
516 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
517 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
518 | + $schema); |
|
519 | + return $status[$status_id]; |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * This helper just returns a button or link for the given parameters |
|
525 | + * |
|
526 | + * @param string $url the url for the link |
|
527 | + * @param string $label What is the label you want displayed for the button |
|
528 | + * @param string $class what class is used for the button (defaults to 'button-primary') |
|
529 | + * @param string $icon |
|
530 | + * @param string $title |
|
531 | + * @return string the html output for the button |
|
532 | + */ |
|
533 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
534 | + { |
|
535 | + $icon_html = ''; |
|
536 | + if ( ! empty($icon)) { |
|
537 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
538 | + $dashicons = array_filter($dashicons); |
|
539 | + $count = count($dashicons); |
|
540 | + $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
541 | + foreach ($dashicons as $dashicon) { |
|
542 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
543 | + $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
544 | + } |
|
545 | + $icon_html .= $count > 1 ? '</span>' : ''; |
|
546 | + } |
|
547 | + $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | + $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
549 | + return $button; |
|
550 | + } |
|
551 | + |
|
552 | + |
|
553 | + /** |
|
554 | + * This returns a generated link that will load the related help tab on admin pages. |
|
555 | + * |
|
556 | + * @param string $help_tab_id the id for the connected help tab |
|
557 | + * @param bool|string $page The page identifier for the page the help tab is on |
|
558 | + * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
559 | + * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
560 | + * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
561 | + * @return string generated link |
|
562 | + */ |
|
563 | + public static function get_help_tab_link( |
|
564 | + $help_tab_id, |
|
565 | + $page = false, |
|
566 | + $action = false, |
|
567 | + $icon_style = false, |
|
568 | + $help_text = false |
|
569 | + ) { |
|
570 | + |
|
571 | + if ( ! $page) { |
|
572 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
573 | + } |
|
574 | + |
|
575 | + if ( ! $action) { |
|
576 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
577 | + } |
|
578 | + |
|
579 | + $action = empty($action) ? 'default' : $action; |
|
580 | + |
|
581 | + |
|
582 | + $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
583 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
584 | + $help_text = ! $help_text ? '' : $help_text; |
|
585 | + return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | + 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + /** |
|
591 | + * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
592 | + * |
|
593 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
594 | + * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
595 | + * @param EE_Help_Tour |
|
596 | + * @return string html |
|
597 | + */ |
|
598 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
599 | + { |
|
600 | + $id = $tour->get_slug(); |
|
601 | + $stops = $tour->get_stops(); |
|
602 | + |
|
603 | + $content = '<ol style="display:none" id="' . $id . '">'; |
|
604 | + |
|
605 | + foreach ($stops as $stop) { |
|
606 | + $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
608 | + |
|
609 | + //if container is set to modal then let's make sure we set the options accordingly |
|
610 | + if (empty($data_id) && empty($data_class)) { |
|
611 | + $stop['options']['modal'] = true; |
|
612 | + $stop['options']['expose'] = true; |
|
613 | + } |
|
614 | + |
|
615 | + $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | + $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
617 | + $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
618 | + |
|
619 | + //options |
|
620 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
621 | + $options = ' data-options="'; |
|
622 | + foreach ($stop['options'] as $option => $value) { |
|
623 | + $options .= $option . ':' . $value . ';'; |
|
624 | + } |
|
625 | + $options .= '"'; |
|
626 | + } else { |
|
627 | + $options = ''; |
|
628 | + } |
|
629 | + |
|
630 | + //let's put all together |
|
631 | + $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
632 | + } |
|
633 | + |
|
634 | + $content .= '</ol>'; |
|
635 | + return $content; |
|
636 | + } |
|
637 | + |
|
638 | + |
|
639 | + /** |
|
640 | + * This is a helper method to generate a status legend for a given status array. |
|
641 | + * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
642 | + * status_array. |
|
643 | + * |
|
644 | + * @param array $status_array array of statuses that will make up the legend. In format: |
|
645 | + * array( |
|
646 | + * 'status_item' => 'status_name' |
|
647 | + * ) |
|
648 | + * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
649 | + * the legend. |
|
650 | + * @throws EE_Error |
|
651 | + * @return string html structure for status. |
|
652 | + */ |
|
653 | + public static function status_legend($status_array, $active_status = '') |
|
654 | + { |
|
655 | + if ( ! is_array($status_array)) { |
|
656 | + throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
657 | + 'event_espresso')); |
|
658 | + } |
|
659 | + |
|
660 | + $setup_array = array(); |
|
661 | + foreach ($status_array as $item => $status) { |
|
662 | + $setup_array[$item] = array( |
|
663 | + 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
664 | + 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
665 | + 'status' => $status, |
|
666 | + ); |
|
667 | + } |
|
668 | + |
|
669 | + $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | + $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | + $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
672 | + foreach ($setup_array as $item => $details) { |
|
673 | + $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
674 | + $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | + $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | + $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | + $content .= '</dt>' . "\n"; |
|
678 | + } |
|
679 | + $content .= '</dl>' . "\n"; |
|
680 | + $content .= '</div>' . "\n"; |
|
681 | + return $content; |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + /** |
|
686 | + * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
687 | + * that's nice for presenting in the wp admin |
|
688 | + * |
|
689 | + * @param mixed $data |
|
690 | + * @return string |
|
691 | + */ |
|
692 | + public static function layout_array_as_table($data) |
|
693 | + { |
|
694 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
695 | + $data = (array)$data; |
|
696 | + } |
|
697 | + ob_start(); |
|
698 | + if (is_array($data)) { |
|
699 | + if (EEH_Array::is_associative_array($data)) { |
|
700 | + ?> |
|
701 | 701 | <table class="widefat"> |
702 | 702 | <tbody> |
703 | 703 | <?php |
704 | - foreach ($data as $data_key => $data_values) { |
|
705 | - ?> |
|
704 | + foreach ($data as $data_key => $data_values) { |
|
705 | + ?> |
|
706 | 706 | <tr> |
707 | 707 | <td> |
708 | 708 | <?php echo $data_key; ?> |
@@ -712,248 +712,248 @@ discard block |
||
712 | 712 | </td> |
713 | 713 | </tr> |
714 | 714 | <?php |
715 | - } ?> |
|
715 | + } ?> |
|
716 | 716 | </tbody> |
717 | 717 | </table> |
718 | 718 | <?php |
719 | - } else { |
|
720 | - ?> |
|
719 | + } else { |
|
720 | + ?> |
|
721 | 721 | <ul> |
722 | 722 | <?php |
723 | - foreach ($data as $datum) { |
|
724 | - echo "<li>"; |
|
725 | - echo self::layout_array_as_table($datum); |
|
726 | - echo "</li>"; |
|
727 | - } ?> |
|
723 | + foreach ($data as $datum) { |
|
724 | + echo "<li>"; |
|
725 | + echo self::layout_array_as_table($datum); |
|
726 | + echo "</li>"; |
|
727 | + } ?> |
|
728 | 728 | </ul> |
729 | 729 | <?php |
730 | - } |
|
731 | - } else { |
|
732 | - //simple value |
|
733 | - echo esc_html($data); |
|
734 | - } |
|
735 | - return ob_get_clean(); |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
741 | - * |
|
742 | - * @since 4.4.0 |
|
743 | - * @see self:get_paging_html() for argument docs. |
|
744 | - * @param $total_items |
|
745 | - * @param $current |
|
746 | - * @param $per_page |
|
747 | - * @param $url |
|
748 | - * @param bool $show_num_field |
|
749 | - * @param string $paged_arg_name |
|
750 | - * @param array $items_label |
|
751 | - * @return string |
|
752 | - */ |
|
753 | - public static function paging_html( |
|
754 | - $total_items, |
|
755 | - $current, |
|
756 | - $per_page, |
|
757 | - $url, |
|
758 | - $show_num_field = true, |
|
759 | - $paged_arg_name = 'paged', |
|
760 | - $items_label = array() |
|
761 | - ) { |
|
762 | - echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
763 | - $items_label); |
|
764 | - } |
|
765 | - |
|
766 | - |
|
767 | - /** |
|
768 | - * A method for generating paging similar to WP_List_Table |
|
769 | - * |
|
770 | - * @since 4.4.0 |
|
771 | - * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
772 | - * @param integer $total_items How many total items there are to page. |
|
773 | - * @param integer $current What the current page is. |
|
774 | - * @param integer $per_page How many items per page. |
|
775 | - * @param string $url What the base url for page links is. |
|
776 | - * @param boolean $show_num_field Whether to show the input for changing page number. |
|
777 | - * @param string $paged_arg_name The name of the key for the paged query argument. |
|
778 | - * @param array $items_label An array of singular/plural values for the items label: |
|
779 | - * array( |
|
780 | - * 'single' => 'item', |
|
781 | - * 'plural' => 'items' |
|
782 | - * ) |
|
783 | - * @return string |
|
784 | - */ |
|
785 | - public static function get_paging_html( |
|
786 | - $total_items, |
|
787 | - $current, |
|
788 | - $per_page, |
|
789 | - $url, |
|
790 | - $show_num_field = true, |
|
791 | - $paged_arg_name = 'paged', |
|
792 | - $items_label = array() |
|
793 | - ) { |
|
794 | - $page_links = array(); |
|
795 | - $disable_first = $disable_last = ''; |
|
796 | - $total_items = (int)$total_items; |
|
797 | - $per_page = (int)$per_page; |
|
798 | - $current = (int)$current; |
|
799 | - $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
800 | - |
|
801 | - //filter items_label |
|
802 | - $items_label = apply_filters( |
|
803 | - 'FHEE__EEH_Template__get_paging_html__items_label', |
|
804 | - $items_label |
|
805 | - ); |
|
806 | - |
|
807 | - if (empty($items_label) |
|
808 | - || ! is_array($items_label) |
|
809 | - || ! isset($items_label['single']) |
|
810 | - || ! isset($items_label['plural']) |
|
811 | - ) { |
|
812 | - $items_label = array( |
|
813 | - 'single' => __('1 item', 'event_espresso'), |
|
814 | - 'plural' => __('%s items', 'event_espresso'), |
|
815 | - ); |
|
816 | - } else { |
|
817 | - $items_label = array( |
|
818 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
820 | - ); |
|
821 | - } |
|
822 | - |
|
823 | - $total_pages = ceil($total_items / $per_page); |
|
824 | - |
|
825 | - if ($total_pages <= 1) { |
|
826 | - return ''; |
|
827 | - } |
|
828 | - |
|
829 | - $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
830 | - |
|
831 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
832 | - |
|
833 | - if ($current === 1) { |
|
834 | - $disable_first = ' disabled'; |
|
835 | - } |
|
836 | - if ($current == $total_pages) { |
|
837 | - $disable_last = ' disabled'; |
|
838 | - } |
|
839 | - |
|
840 | - $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
841 | - 'first-page' . $disable_first, |
|
842 | - esc_attr__('Go to the first page'), |
|
843 | - esc_url(remove_query_arg($paged_arg_name, $url)), |
|
844 | - '«' |
|
845 | - ); |
|
846 | - |
|
847 | - $page_links[] = sprintf( |
|
848 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
849 | - 'prev-page' . $disable_first, |
|
850 | - esc_attr__('Go to the previous page'), |
|
851 | - esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
852 | - '‹' |
|
853 | - ); |
|
854 | - |
|
855 | - if ( ! $show_num_field) { |
|
856 | - $html_current_page = $current; |
|
857 | - } else { |
|
858 | - $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
859 | - esc_attr__('Current page'), |
|
860 | - $current, |
|
861 | - strlen($total_pages) |
|
862 | - ); |
|
863 | - } |
|
864 | - |
|
865 | - $html_total_pages = sprintf( |
|
866 | - '<span class="total-pages">%s</span>', |
|
867 | - number_format_i18n($total_pages) |
|
868 | - ); |
|
869 | - $page_links[] = sprintf( |
|
870 | - _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
871 | - $html_current_page, |
|
872 | - $html_total_pages, |
|
873 | - '<span class="paging-input">', |
|
874 | - '</span>' |
|
875 | - ); |
|
876 | - |
|
877 | - $page_links[] = sprintf( |
|
878 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
879 | - 'next-page' . $disable_last, |
|
880 | - esc_attr__('Go to the next page'), |
|
881 | - esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
882 | - '›' |
|
883 | - ); |
|
884 | - |
|
885 | - $page_links[] = sprintf( |
|
886 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
887 | - 'last-page' . $disable_last, |
|
888 | - esc_attr__('Go to the last page'), |
|
889 | - esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
890 | - '»' |
|
891 | - ); |
|
892 | - |
|
893 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
894 | - // set page class |
|
895 | - if ($total_pages) { |
|
896 | - $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
897 | - } else { |
|
898 | - $page_class = ' no-pages'; |
|
899 | - } |
|
900 | - |
|
901 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
902 | - } |
|
903 | - |
|
904 | - |
|
905 | - /** |
|
906 | - * @param string $wrap_class |
|
907 | - * @param string $wrap_id |
|
908 | - * @return string |
|
909 | - */ |
|
910 | - public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
911 | - { |
|
912 | - $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
913 | - if ( |
|
914 | - ! $admin && |
|
915 | - ! apply_filters( |
|
916 | - 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
917 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
918 | - ) |
|
919 | - ) { |
|
920 | - return ''; |
|
921 | - } |
|
922 | - $tag = $admin ? 'span' : 'div'; |
|
923 | - $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
924 | - $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
925 | - $attributes .= ! empty($wrap_class) |
|
926 | - ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
927 | - : ' class="powered-by-event-espresso-credit"'; |
|
928 | - $query_args = array_merge( |
|
929 | - array( |
|
930 | - 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
931 | - 'utm_source' => 'powered_by_event_espresso', |
|
932 | - 'utm_medium' => 'link', |
|
933 | - 'utm_campaign' => 'powered_by', |
|
934 | - ), |
|
935 | - $query_args |
|
936 | - ); |
|
937 | - $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
938 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | - $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
940 | - $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
941 | - return (string)apply_filters( |
|
942 | - 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
943 | - sprintf( |
|
944 | - esc_html_x( |
|
945 | - '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
946 | - 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
947 | - 'event_espresso' |
|
948 | - ), |
|
949 | - "<{$tag}{$attributes}>", |
|
950 | - "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
951 | - $admin ? '' : '<br />' |
|
952 | - ), |
|
953 | - $wrap_class, |
|
954 | - $wrap_id |
|
955 | - ); |
|
956 | - } |
|
730 | + } |
|
731 | + } else { |
|
732 | + //simple value |
|
733 | + echo esc_html($data); |
|
734 | + } |
|
735 | + return ob_get_clean(); |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
741 | + * |
|
742 | + * @since 4.4.0 |
|
743 | + * @see self:get_paging_html() for argument docs. |
|
744 | + * @param $total_items |
|
745 | + * @param $current |
|
746 | + * @param $per_page |
|
747 | + * @param $url |
|
748 | + * @param bool $show_num_field |
|
749 | + * @param string $paged_arg_name |
|
750 | + * @param array $items_label |
|
751 | + * @return string |
|
752 | + */ |
|
753 | + public static function paging_html( |
|
754 | + $total_items, |
|
755 | + $current, |
|
756 | + $per_page, |
|
757 | + $url, |
|
758 | + $show_num_field = true, |
|
759 | + $paged_arg_name = 'paged', |
|
760 | + $items_label = array() |
|
761 | + ) { |
|
762 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
763 | + $items_label); |
|
764 | + } |
|
765 | + |
|
766 | + |
|
767 | + /** |
|
768 | + * A method for generating paging similar to WP_List_Table |
|
769 | + * |
|
770 | + * @since 4.4.0 |
|
771 | + * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
772 | + * @param integer $total_items How many total items there are to page. |
|
773 | + * @param integer $current What the current page is. |
|
774 | + * @param integer $per_page How many items per page. |
|
775 | + * @param string $url What the base url for page links is. |
|
776 | + * @param boolean $show_num_field Whether to show the input for changing page number. |
|
777 | + * @param string $paged_arg_name The name of the key for the paged query argument. |
|
778 | + * @param array $items_label An array of singular/plural values for the items label: |
|
779 | + * array( |
|
780 | + * 'single' => 'item', |
|
781 | + * 'plural' => 'items' |
|
782 | + * ) |
|
783 | + * @return string |
|
784 | + */ |
|
785 | + public static function get_paging_html( |
|
786 | + $total_items, |
|
787 | + $current, |
|
788 | + $per_page, |
|
789 | + $url, |
|
790 | + $show_num_field = true, |
|
791 | + $paged_arg_name = 'paged', |
|
792 | + $items_label = array() |
|
793 | + ) { |
|
794 | + $page_links = array(); |
|
795 | + $disable_first = $disable_last = ''; |
|
796 | + $total_items = (int)$total_items; |
|
797 | + $per_page = (int)$per_page; |
|
798 | + $current = (int)$current; |
|
799 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
800 | + |
|
801 | + //filter items_label |
|
802 | + $items_label = apply_filters( |
|
803 | + 'FHEE__EEH_Template__get_paging_html__items_label', |
|
804 | + $items_label |
|
805 | + ); |
|
806 | + |
|
807 | + if (empty($items_label) |
|
808 | + || ! is_array($items_label) |
|
809 | + || ! isset($items_label['single']) |
|
810 | + || ! isset($items_label['plural']) |
|
811 | + ) { |
|
812 | + $items_label = array( |
|
813 | + 'single' => __('1 item', 'event_espresso'), |
|
814 | + 'plural' => __('%s items', 'event_espresso'), |
|
815 | + ); |
|
816 | + } else { |
|
817 | + $items_label = array( |
|
818 | + 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | + 'plural' => '%s ' . esc_html($items_label['plural']), |
|
820 | + ); |
|
821 | + } |
|
822 | + |
|
823 | + $total_pages = ceil($total_items / $per_page); |
|
824 | + |
|
825 | + if ($total_pages <= 1) { |
|
826 | + return ''; |
|
827 | + } |
|
828 | + |
|
829 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
830 | + |
|
831 | + $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
832 | + |
|
833 | + if ($current === 1) { |
|
834 | + $disable_first = ' disabled'; |
|
835 | + } |
|
836 | + if ($current == $total_pages) { |
|
837 | + $disable_last = ' disabled'; |
|
838 | + } |
|
839 | + |
|
840 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
841 | + 'first-page' . $disable_first, |
|
842 | + esc_attr__('Go to the first page'), |
|
843 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
844 | + '«' |
|
845 | + ); |
|
846 | + |
|
847 | + $page_links[] = sprintf( |
|
848 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
849 | + 'prev-page' . $disable_first, |
|
850 | + esc_attr__('Go to the previous page'), |
|
851 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
852 | + '‹' |
|
853 | + ); |
|
854 | + |
|
855 | + if ( ! $show_num_field) { |
|
856 | + $html_current_page = $current; |
|
857 | + } else { |
|
858 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
859 | + esc_attr__('Current page'), |
|
860 | + $current, |
|
861 | + strlen($total_pages) |
|
862 | + ); |
|
863 | + } |
|
864 | + |
|
865 | + $html_total_pages = sprintf( |
|
866 | + '<span class="total-pages">%s</span>', |
|
867 | + number_format_i18n($total_pages) |
|
868 | + ); |
|
869 | + $page_links[] = sprintf( |
|
870 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
871 | + $html_current_page, |
|
872 | + $html_total_pages, |
|
873 | + '<span class="paging-input">', |
|
874 | + '</span>' |
|
875 | + ); |
|
876 | + |
|
877 | + $page_links[] = sprintf( |
|
878 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
879 | + 'next-page' . $disable_last, |
|
880 | + esc_attr__('Go to the next page'), |
|
881 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
882 | + '›' |
|
883 | + ); |
|
884 | + |
|
885 | + $page_links[] = sprintf( |
|
886 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
887 | + 'last-page' . $disable_last, |
|
888 | + esc_attr__('Go to the last page'), |
|
889 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
890 | + '»' |
|
891 | + ); |
|
892 | + |
|
893 | + $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
894 | + // set page class |
|
895 | + if ($total_pages) { |
|
896 | + $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
897 | + } else { |
|
898 | + $page_class = ' no-pages'; |
|
899 | + } |
|
900 | + |
|
901 | + return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
902 | + } |
|
903 | + |
|
904 | + |
|
905 | + /** |
|
906 | + * @param string $wrap_class |
|
907 | + * @param string $wrap_id |
|
908 | + * @return string |
|
909 | + */ |
|
910 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
911 | + { |
|
912 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
913 | + if ( |
|
914 | + ! $admin && |
|
915 | + ! apply_filters( |
|
916 | + 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
917 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
918 | + ) |
|
919 | + ) { |
|
920 | + return ''; |
|
921 | + } |
|
922 | + $tag = $admin ? 'span' : 'div'; |
|
923 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
924 | + $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
925 | + $attributes .= ! empty($wrap_class) |
|
926 | + ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
927 | + : ' class="powered-by-event-espresso-credit"'; |
|
928 | + $query_args = array_merge( |
|
929 | + array( |
|
930 | + 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
931 | + 'utm_source' => 'powered_by_event_espresso', |
|
932 | + 'utm_medium' => 'link', |
|
933 | + 'utm_campaign' => 'powered_by', |
|
934 | + ), |
|
935 | + $query_args |
|
936 | + ); |
|
937 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
938 | + $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | + $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
940 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
941 | + return (string)apply_filters( |
|
942 | + 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
943 | + sprintf( |
|
944 | + esc_html_x( |
|
945 | + '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
946 | + 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
947 | + 'event_espresso' |
|
948 | + ), |
|
949 | + "<{$tag}{$attributes}>", |
|
950 | + "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
951 | + $admin ? '' : '<br />' |
|
952 | + ), |
|
953 | + $wrap_class, |
|
954 | + $wrap_id |
|
955 | + ); |
|
956 | + } |
|
957 | 957 | |
958 | 958 | |
959 | 959 | } //end EEH_Template class |
@@ -962,33 +962,33 @@ discard block |
||
962 | 962 | |
963 | 963 | |
964 | 964 | if ( ! function_exists('espresso_pagination')) { |
965 | - /** |
|
966 | - * espresso_pagination |
|
967 | - * |
|
968 | - * @access public |
|
969 | - * @return void |
|
970 | - */ |
|
971 | - function espresso_pagination() |
|
972 | - { |
|
973 | - global $wp_query; |
|
974 | - $big = 999999999; // need an unlikely integer |
|
975 | - $pagination = paginate_links( |
|
976 | - array( |
|
977 | - 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
978 | - 'format' => '?paged=%#%', |
|
979 | - 'current' => max(1, get_query_var('paged')), |
|
980 | - 'total' => $wp_query->max_num_pages, |
|
981 | - 'show_all' => true, |
|
982 | - 'end_size' => 10, |
|
983 | - 'mid_size' => 6, |
|
984 | - 'prev_next' => true, |
|
985 | - 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
986 | - 'next_text' => __('NEXT ›', 'event_espresso'), |
|
987 | - 'type' => 'plain', |
|
988 | - 'add_args' => false, |
|
989 | - 'add_fragment' => '', |
|
990 | - ) |
|
991 | - ); |
|
992 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
993 | - } |
|
965 | + /** |
|
966 | + * espresso_pagination |
|
967 | + * |
|
968 | + * @access public |
|
969 | + * @return void |
|
970 | + */ |
|
971 | + function espresso_pagination() |
|
972 | + { |
|
973 | + global $wp_query; |
|
974 | + $big = 999999999; // need an unlikely integer |
|
975 | + $pagination = paginate_links( |
|
976 | + array( |
|
977 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
978 | + 'format' => '?paged=%#%', |
|
979 | + 'current' => max(1, get_query_var('paged')), |
|
980 | + 'total' => $wp_query->max_num_pages, |
|
981 | + 'show_all' => true, |
|
982 | + 'end_size' => 10, |
|
983 | + 'mid_size' => 6, |
|
984 | + 'prev_next' => true, |
|
985 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
986 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
987 | + 'type' => 'plain', |
|
988 | + 'add_args' => false, |
|
989 | + 'add_fragment' => '', |
|
990 | + ) |
|
991 | + ); |
|
992 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
993 | + } |
|
994 | 994 | } |
995 | 995 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | public static function load_espresso_theme_functions() |
82 | 82 | { |
83 | 83 | if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
84 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
84 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
85 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public static function get_espresso_themes() |
97 | 97 | { |
98 | 98 | if (empty(EEH_Template::$_espresso_themes)) { |
99 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
99 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
100 | 100 | if (empty($espresso_themes)) { |
101 | 101 | return array(); |
102 | 102 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ) { |
133 | 133 | do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
134 | 134 | $templates = array(); |
135 | - $name = (string)$name; |
|
135 | + $name = (string) $name; |
|
136 | 136 | if ($name != '') { |
137 | 137 | $templates[] = "{$slug}-{$name}.php"; |
138 | 138 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | if (isset($EE_CPTs[$post_type])) { |
212 | 212 | $archive_or_single = is_archive() ? 'archive' : ''; |
213 | 213 | $archive_or_single = is_single() ? 'single' : $archive_or_single; |
214 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
214 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | // currently active EE template theme |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | // array of paths to folders that may contain templates |
221 | 221 | $template_folder_paths = array( |
222 | 222 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
223 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
223 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
224 | 224 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
225 | 225 | EVENT_ESPRESSO_TEMPLATE_DIR, |
226 | 226 | ); |
227 | 227 | |
228 | 228 | //add core plugin folders for checking only if we're not $check_if_custom |
229 | 229 | if ( ! $check_if_custom) { |
230 | - $core_paths = array( |
|
230 | + $core_paths = array( |
|
231 | 231 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
232 | - EE_PUBLIC . $current_theme, |
|
232 | + EE_PUBLIC.$current_theme, |
|
233 | 233 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
234 | - EE_TEMPLATES . $current_theme, |
|
234 | + EE_TEMPLATES.$current_theme, |
|
235 | 235 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
236 | 236 | EE_PLUGIN_DIR_PATH, |
237 | 237 | ); |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | ); |
263 | 263 | if ($common_base_path !== '') { |
264 | 264 | // both paths have a common base, so just tack the filename onto our search path |
265 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
265 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
266 | 266 | } else { |
267 | 267 | // no common base path, so let's just concatenate |
268 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
268 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
269 | 269 | } |
270 | 270 | // build up our template locations array by adding our resolved paths |
271 | 271 | $full_template_paths[] = $resolved_path; |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
274 | 274 | array_unshift($full_template_paths, $template); |
275 | 275 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
276 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
276 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
277 | 277 | } |
278 | 278 | // filter final array of full template paths |
279 | 279 | $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
280 | 280 | $full_template_paths, $file_name); |
281 | 281 | // now loop through our final array of template location paths and check each location |
282 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
282 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
283 | 283 | if (is_readable($full_template_path)) { |
284 | 284 | $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
285 | 285 | break; |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | if ( ! is_array($template_args) && ! is_object($template_args)) { |
367 | 367 | $template_args = array($template_args); |
368 | 368 | } |
369 | - extract( $template_args, EXTR_SKIP ); |
|
369 | + extract($template_args, EXTR_SKIP); |
|
370 | 370 | // ignore whether template is accessible ? |
371 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
371 | + if ($throw_exceptions && ! is_readable($template_path)) { |
|
372 | 372 | throw new \DomainException( |
373 | 373 | esc_html__( |
374 | 374 | 'Invalid, unreadable, or missing file.', |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
402 | 402 | { |
403 | 403 | // in the beginning... |
404 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
404 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
405 | 405 | // da muddle |
406 | 406 | $class = ''; |
407 | 407 | // the end |
408 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
408 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
409 | 409 | // is the passed object an EE object ? |
410 | 410 | if ($object instanceof EE_Base_Class) { |
411 | 411 | // grab the exact type of object |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | // no specifics just yet... |
416 | 416 | default : |
417 | 417 | $class = strtolower(str_replace('_', '-', $obj_class)); |
418 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
418 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | } |
422 | - return $prefix . $class . $suffix; |
|
422 | + return $prefix.$class.$suffix; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | return ''; |
452 | 452 | } |
453 | 453 | //ensure amount is float |
454 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
454 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
455 | 455 | $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
456 | 456 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
457 | 457 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
@@ -473,20 +473,20 @@ discard block |
||
473 | 473 | // add currency sign |
474 | 474 | if ($mny->sign_b4) { |
475 | 475 | if ($amount >= 0) { |
476 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
476 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
477 | 477 | } else { |
478 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
478 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | } else { |
482 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
482 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | // filter to allow global setting of display_code |
486 | 486 | $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
487 | 487 | |
488 | 488 | // add currency code ? |
489 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
489 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
490 | 490 | } |
491 | 491 | // filter results |
492 | 492 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
@@ -540,12 +540,12 @@ discard block |
||
540 | 540 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
541 | 541 | foreach ($dashicons as $dashicon) { |
542 | 542 | $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
543 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
543 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
544 | 544 | } |
545 | 545 | $icon_html .= $count > 1 ? '</span>' : ''; |
546 | 546 | } |
547 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
547 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
548 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
549 | 549 | return $button; |
550 | 550 | } |
551 | 551 | |
@@ -579,11 +579,11 @@ discard block |
||
579 | 579 | $action = empty($action) ? 'default' : $action; |
580 | 580 | |
581 | 581 | |
582 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
582 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
583 | 583 | $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
584 | 584 | $help_text = ! $help_text ? '' : $help_text; |
585 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
585 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | + 'event_espresso').'" > '.$help_text.' </a>'; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | $id = $tour->get_slug(); |
601 | 601 | $stops = $tour->get_stops(); |
602 | 602 | |
603 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
603 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
604 | 604 | |
605 | 605 | foreach ($stops as $stop) { |
606 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
606 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
607 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
608 | 608 | |
609 | 609 | //if container is set to modal then let's make sure we set the options accordingly |
610 | 610 | if (empty($data_id) && empty($data_class)) { |
@@ -612,15 +612,15 @@ discard block |
||
612 | 612 | $stop['options']['expose'] = true; |
613 | 613 | } |
614 | 614 | |
615 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
615 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
616 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
617 | 617 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
618 | 618 | |
619 | 619 | //options |
620 | 620 | if (isset($stop['options']) && is_array($stop['options'])) { |
621 | 621 | $options = ' data-options="'; |
622 | 622 | foreach ($stop['options'] as $option => $value) { |
623 | - $options .= $option . ':' . $value . ';'; |
|
623 | + $options .= $option.':'.$value.';'; |
|
624 | 624 | } |
625 | 625 | $options .= '"'; |
626 | 626 | } else { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | //let's put all together |
631 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
631 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | $content .= '</ol>'; |
@@ -660,24 +660,24 @@ discard block |
||
660 | 660 | $setup_array = array(); |
661 | 661 | foreach ($status_array as $item => $status) { |
662 | 662 | $setup_array[$item] = array( |
663 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
663 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
664 | 664 | 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
665 | 665 | 'status' => $status, |
666 | 666 | ); |
667 | 667 | } |
668 | 668 | |
669 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
669 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
670 | + $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
671 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
672 | 672 | foreach ($setup_array as $item => $details) { |
673 | 673 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
674 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | - $content .= '</dt>' . "\n"; |
|
674 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
675 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
676 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
677 | + $content .= '</dt>'."\n"; |
|
678 | 678 | } |
679 | - $content .= '</dl>' . "\n"; |
|
680 | - $content .= '</div>' . "\n"; |
|
679 | + $content .= '</dl>'."\n"; |
|
680 | + $content .= '</div>'."\n"; |
|
681 | 681 | return $content; |
682 | 682 | } |
683 | 683 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | public static function layout_array_as_table($data) |
693 | 693 | { |
694 | 694 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
695 | - $data = (array)$data; |
|
695 | + $data = (array) $data; |
|
696 | 696 | } |
697 | 697 | ob_start(); |
698 | 698 | if (is_array($data)) { |
@@ -793,9 +793,9 @@ discard block |
||
793 | 793 | ) { |
794 | 794 | $page_links = array(); |
795 | 795 | $disable_first = $disable_last = ''; |
796 | - $total_items = (int)$total_items; |
|
797 | - $per_page = (int)$per_page; |
|
798 | - $current = (int)$current; |
|
796 | + $total_items = (int) $total_items; |
|
797 | + $per_page = (int) $per_page; |
|
798 | + $current = (int) $current; |
|
799 | 799 | $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
800 | 800 | |
801 | 801 | //filter items_label |
@@ -815,8 +815,8 @@ discard block |
||
815 | 815 | ); |
816 | 816 | } else { |
817 | 817 | $items_label = array( |
818 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
818 | + 'single' => '1 '.esc_html($items_label['single']), |
|
819 | + 'plural' => '%s '.esc_html($items_label['plural']), |
|
820 | 820 | ); |
821 | 821 | } |
822 | 822 | |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | |
829 | 829 | $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
830 | 830 | |
831 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
831 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
832 | 832 | |
833 | 833 | if ($current === 1) { |
834 | 834 | $disable_first = ' disabled'; |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } |
839 | 839 | |
840 | 840 | $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
841 | - 'first-page' . $disable_first, |
|
841 | + 'first-page'.$disable_first, |
|
842 | 842 | esc_attr__('Go to the first page'), |
843 | 843 | esc_url(remove_query_arg($paged_arg_name, $url)), |
844 | 844 | '«' |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | |
847 | 847 | $page_links[] = sprintf( |
848 | 848 | '<a class="%s" title="%s" href="%s">%s</a>', |
849 | - 'prev-page' . $disable_first, |
|
849 | + 'prev-page'.$disable_first, |
|
850 | 850 | esc_attr__('Go to the previous page'), |
851 | 851 | esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
852 | 852 | '‹' |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | '<span class="total-pages">%s</span>', |
867 | 867 | number_format_i18n($total_pages) |
868 | 868 | ); |
869 | - $page_links[] = sprintf( |
|
869 | + $page_links[] = sprintf( |
|
870 | 870 | _x('%3$s%1$s of %2$s%4$s', 'paging'), |
871 | 871 | $html_current_page, |
872 | 872 | $html_total_pages, |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | |
877 | 877 | $page_links[] = sprintf( |
878 | 878 | '<a class="%s" title="%s" href="%s">%s</a>', |
879 | - 'next-page' . $disable_last, |
|
879 | + 'next-page'.$disable_last, |
|
880 | 880 | esc_attr__('Go to the next page'), |
881 | 881 | esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
882 | 882 | '›' |
@@ -884,13 +884,13 @@ discard block |
||
884 | 884 | |
885 | 885 | $page_links[] = sprintf( |
886 | 886 | '<a class="%s" title="%s" href="%s">%s</a>', |
887 | - 'last-page' . $disable_last, |
|
887 | + 'last-page'.$disable_last, |
|
888 | 888 | esc_attr__('Go to the last page'), |
889 | 889 | esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
890 | 890 | '»' |
891 | 891 | ); |
892 | 892 | |
893 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
893 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
894 | 894 | // set page class |
895 | 895 | if ($total_pages) { |
896 | 896 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | $page_class = ' no-pages'; |
899 | 899 | } |
900 | 900 | |
901 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
901 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | |
@@ -935,10 +935,10 @@ discard block |
||
935 | 935 | $query_args |
936 | 936 | ); |
937 | 937 | $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
938 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
938 | + $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | 939 | $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
940 | 940 | $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
941 | - return (string)apply_filters( |
|
941 | + return (string) apply_filters( |
|
942 | 942 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
943 | 943 | sprintf( |
944 | 944 | esc_html_x( |
@@ -989,6 +989,6 @@ discard block |
||
989 | 989 | 'add_fragment' => '', |
990 | 990 | ) |
991 | 991 | ); |
992 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
992 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
993 | 993 | } |
994 | 994 | } |
995 | 995 | \ No newline at end of file |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[$matches[1]] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | - // echo "$version_string can be migrated from"; |
|
66 | - return true; |
|
67 | - } elseif ( ! $version_string) { |
|
68 | - // echo "no version string provided: $version_string"; |
|
69 | - //no version string provided... this must be pre 4.3 |
|
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
72 | - // echo "$version_string doesnt apply"; |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | + // echo "$version_string can be migrated from"; |
|
66 | + return true; |
|
67 | + } elseif ( ! $version_string) { |
|
68 | + // echo "no version string provided: $version_string"; |
|
69 | + //no version string provided... this must be pre 4.3 |
|
70 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | + // echo "$version_string doesnt apply"; |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $now_in_mysql = current_time('mysql', true); |
|
86 | - $table_name = 'esp_answer'; |
|
87 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $now_in_mysql = current_time('mysql', true); |
|
86 | + $table_name = 'esp_answer'; |
|
87 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | REG_ID int(10) unsigned NOT NULL, |
89 | 89 | QST_ID int(10) unsigned NOT NULL, |
90 | 90 | ANS_value text NOT NULL, |
91 | 91 | PRIMARY KEY (ANS_ID), |
92 | 92 | KEY REG_ID (REG_ID), |
93 | 93 | KEY QST_ID (QST_ID)"; |
94 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - $table_name = 'esp_currency_payment_method'; |
|
153 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + $table_name = 'esp_currency_payment_method'; |
|
153 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
154 | 154 | CUR_code varchar(6) NOT NULL, |
155 | 155 | PMD_ID int(11) NOT NULL, |
156 | 156 | PRIMARY KEY (CPM_ID), |
157 | 157 | KEY PMD_ID (PMD_ID)"; |
158 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
159 | - $table_name = 'esp_datetime'; |
|
160 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
158 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
159 | + $table_name = 'esp_datetime'; |
|
160 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
161 | 161 | EVT_ID bigint(20) unsigned NOT NULL, |
162 | 162 | DTT_name varchar(255) NOT NULL DEFAULT '', |
163 | 163 | DTT_description text NOT NULL, |
@@ -174,25 +174,25 @@ discard block |
||
174 | 174 | KEY DTT_EVT_start (DTT_EVT_start), |
175 | 175 | KEY EVT_ID (EVT_ID), |
176 | 176 | KEY DTT_is_primary (DTT_is_primary)"; |
177 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | - $table_name = "esp_datetime_ticket"; |
|
179 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
177 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | + $table_name = "esp_datetime_ticket"; |
|
179 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
180 | 180 | DTT_ID int(10) unsigned NOT NULL, |
181 | 181 | TKT_ID int(10) unsigned NOT NULL, |
182 | 182 | PRIMARY KEY (DTK_ID), |
183 | 183 | KEY DTT_ID (DTT_ID), |
184 | 184 | KEY TKT_ID (TKT_ID)"; |
185 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | - $table_name = 'esp_event_message_template'; |
|
187 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
185 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $table_name = 'esp_event_message_template'; |
|
187 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | 188 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
189 | 189 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
190 | 190 | PRIMARY KEY (EMT_ID), |
191 | 191 | KEY EVT_ID (EVT_ID), |
192 | 192 | KEY GRP_ID (GRP_ID)"; |
193 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | - $table_name = 'esp_event_meta'; |
|
195 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
193 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | + $table_name = 'esp_event_meta'; |
|
195 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
196 | 196 | EVT_ID bigint(20) unsigned NOT NULL, |
197 | 197 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
198 | 198 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -207,34 +207,34 @@ discard block |
||
207 | 207 | EVT_donations tinyint(1) NULL, |
208 | 208 | PRIMARY KEY (EVTM_ID), |
209 | 209 | KEY EVT_ID (EVT_ID)"; |
210 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | - $table_name = 'esp_event_question_group'; |
|
212 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
210 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | + $table_name = 'esp_event_question_group'; |
|
212 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
213 | 213 | EVT_ID bigint(20) unsigned NOT NULL, |
214 | 214 | QSG_ID int(10) unsigned NOT NULL, |
215 | 215 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
216 | 216 | PRIMARY KEY (EQG_ID), |
217 | 217 | KEY EVT_ID (EVT_ID), |
218 | 218 | KEY QSG_ID (QSG_ID)"; |
219 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | - $table_name = 'esp_event_venue'; |
|
221 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
219 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $table_name = 'esp_event_venue'; |
|
221 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
222 | 222 | EVT_ID bigint(20) unsigned NOT NULL, |
223 | 223 | VNU_ID bigint(20) unsigned NOT NULL, |
224 | 224 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
225 | 225 | PRIMARY KEY (EVV_ID)"; |
226 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | - $table_name = 'esp_extra_meta'; |
|
228 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
226 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | + $table_name = 'esp_extra_meta'; |
|
228 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
229 | 229 | OBJ_ID int(11) DEFAULT NULL, |
230 | 230 | EXM_type varchar(45) DEFAULT NULL, |
231 | 231 | EXM_key varchar(45) DEFAULT NULL, |
232 | 232 | EXM_value text, |
233 | 233 | PRIMARY KEY (EXM_ID), |
234 | 234 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
235 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
236 | - $table_name = 'esp_extra_join'; |
|
237 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
235 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
236 | + $table_name = 'esp_extra_join'; |
|
237 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
238 | 238 | EXJ_first_model_id varchar(6) NOT NULL, |
239 | 239 | EXJ_first_model_name varchar(20) NOT NULL, |
240 | 240 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | PRIMARY KEY (EXJ_ID), |
243 | 243 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
244 | 244 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
245 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
246 | - $table_name = 'esp_line_item'; |
|
247 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
245 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
246 | + $table_name = 'esp_line_item'; |
|
247 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
248 | 248 | LIN_code varchar(245) NOT NULL DEFAULT '', |
249 | 249 | TXN_ID int(11) DEFAULT NULL, |
250 | 250 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | PRIMARY KEY (LIN_ID), |
264 | 264 | KEY LIN_code (LIN_code(191)), |
265 | 265 | KEY TXN_ID (TXN_ID)"; |
266 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
267 | - $table_name = 'esp_log'; |
|
268 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
266 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
267 | + $table_name = 'esp_log'; |
|
268 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
269 | 269 | LOG_time datetime DEFAULT NULL, |
270 | 270 | OBJ_ID varchar(45) DEFAULT NULL, |
271 | 271 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | KEY LOG_time (LOG_time), |
277 | 277 | KEY OBJ (OBJ_type,OBJ_ID), |
278 | 278 | KEY LOG_type (LOG_type)"; |
279 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
280 | - $table_name = 'esp_message'; |
|
281 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
282 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
283 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
284 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
279 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
280 | + $table_name = 'esp_message'; |
|
281 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
282 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
283 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
284 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
285 | 285 | GRP_ID int(10) unsigned NULL, |
286 | 286 | MSG_token varchar(255) NULL, |
287 | 287 | TXN_ID int(10) unsigned NULL, |
@@ -313,18 +313,18 @@ discard block |
||
313 | 313 | KEY STS_ID (STS_ID), |
314 | 314 | KEY MSG_created (MSG_created), |
315 | 315 | KEY MSG_modified (MSG_modified)"; |
316 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
317 | - $table_name = 'esp_message_template'; |
|
318 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
316 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
317 | + $table_name = 'esp_message_template'; |
|
318 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
319 | 319 | GRP_ID int(10) unsigned NOT NULL, |
320 | 320 | MTP_context varchar(50) NOT NULL, |
321 | 321 | MTP_template_field varchar(30) NOT NULL, |
322 | 322 | MTP_content text NOT NULL, |
323 | 323 | PRIMARY KEY (MTP_ID), |
324 | 324 | KEY GRP_ID (GRP_ID)"; |
325 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | - $table_name = 'esp_message_template_group'; |
|
327 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
325 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | + $table_name = 'esp_message_template_group'; |
|
327 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
328 | 328 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
329 | 329 | MTP_name varchar(245) NOT NULL DEFAULT '', |
330 | 330 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
337 | 337 | PRIMARY KEY (GRP_ID), |
338 | 338 | KEY MTP_user_id (MTP_user_id)"; |
339 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
340 | - $table_name = 'esp_payment'; |
|
341 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
339 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
340 | + $table_name = 'esp_payment'; |
|
341 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
342 | 342 | TXN_ID int(10) unsigned DEFAULT NULL, |
343 | 343 | STS_ID varchar(3) DEFAULT NULL, |
344 | 344 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | PRIMARY KEY (PAY_ID), |
356 | 356 | KEY PAY_timestamp (PAY_timestamp), |
357 | 357 | KEY TXN_ID (TXN_ID)"; |
358 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
359 | - $table_name = 'esp_payment_method'; |
|
360 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
358 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
359 | + $table_name = 'esp_payment_method'; |
|
360 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
361 | 361 | PMD_type varchar(124) DEFAULT NULL, |
362 | 362 | PMD_name varchar(255) DEFAULT NULL, |
363 | 363 | PMD_desc text, |
@@ -373,24 +373,24 @@ discard block |
||
373 | 373 | PRIMARY KEY (PMD_ID), |
374 | 374 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
375 | 375 | KEY PMD_type (PMD_type)"; |
376 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
377 | - $table_name = "esp_ticket_price"; |
|
378 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
376 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
377 | + $table_name = "esp_ticket_price"; |
|
378 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
379 | 379 | TKT_ID int(10) unsigned NOT NULL, |
380 | 380 | PRC_ID int(10) unsigned NOT NULL, |
381 | 381 | PRIMARY KEY (TKP_ID), |
382 | 382 | KEY TKT_ID (TKT_ID), |
383 | 383 | KEY PRC_ID (PRC_ID)"; |
384 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | - $table_name = "esp_ticket_template"; |
|
386 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
384 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | + $table_name = "esp_ticket_template"; |
|
386 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | 387 | TTM_name varchar(45) NOT NULL, |
388 | 388 | TTM_description text, |
389 | 389 | TTM_file varchar(45), |
390 | 390 | PRIMARY KEY (TTM_ID)"; |
391 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | - $table_name = 'esp_question'; |
|
393 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | + $table_name = 'esp_question'; |
|
393 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
394 | 394 | QST_display_text text NOT NULL, |
395 | 395 | QST_admin_label varchar(255) NOT NULL, |
396 | 396 | QST_system varchar(25) DEFAULT NULL, |
@@ -404,18 +404,18 @@ discard block |
||
404 | 404 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
405 | 405 | PRIMARY KEY (QST_ID), |
406 | 406 | KEY QST_order (QST_order)'; |
407 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
408 | - $table_name = 'esp_question_group_question'; |
|
409 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
407 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
408 | + $table_name = 'esp_question_group_question'; |
|
409 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
410 | 410 | QSG_ID int(10) unsigned NOT NULL, |
411 | 411 | QST_ID int(10) unsigned NOT NULL, |
412 | 412 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
413 | 413 | PRIMARY KEY (QGQ_ID), |
414 | 414 | KEY QST_ID (QST_ID), |
415 | 415 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
416 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | - $table_name = 'esp_question_option'; |
|
418 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | + $table_name = 'esp_question_option'; |
|
418 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
419 | 419 | QSO_value varchar(255) NOT NULL, |
420 | 420 | QSO_desc text NOT NULL, |
421 | 421 | QST_ID int(10) unsigned NOT NULL, |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | PRIMARY KEY (QSO_ID), |
426 | 426 | KEY QST_ID (QST_ID), |
427 | 427 | KEY QSO_order (QSO_order)"; |
428 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
429 | - $table_name = 'esp_registration'; |
|
430 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
428 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
429 | + $table_name = 'esp_registration'; |
|
430 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
431 | 431 | EVT_ID bigint(20) unsigned NOT NULL, |
432 | 432 | ATT_ID bigint(20) unsigned NOT NULL, |
433 | 433 | TXN_ID int(10) unsigned NOT NULL, |
@@ -451,18 +451,18 @@ discard block |
||
451 | 451 | KEY TKT_ID (TKT_ID), |
452 | 452 | KEY EVT_ID (EVT_ID), |
453 | 453 | KEY STS_ID (STS_ID)"; |
454 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
455 | - $table_name = 'esp_registration_payment'; |
|
456 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
454 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
455 | + $table_name = 'esp_registration_payment'; |
|
456 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
457 | 457 | REG_ID int(10) unsigned NOT NULL, |
458 | 458 | PAY_ID int(10) unsigned NULL, |
459 | 459 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
460 | 460 | PRIMARY KEY (RPY_ID), |
461 | 461 | KEY REG_ID (REG_ID), |
462 | 462 | KEY PAY_ID (PAY_ID)"; |
463 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
464 | - $table_name = 'esp_state'; |
|
465 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
463 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
464 | + $table_name = 'esp_state'; |
|
465 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
466 | 466 | CNT_ISO varchar(2) NOT NULL, |
467 | 467 | STA_abbrev varchar(24) NOT NULL, |
468 | 468 | STA_name varchar(100) NOT NULL, |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | PRIMARY KEY (STA_ID), |
471 | 471 | KEY STA_abbrev (STA_abbrev), |
472 | 472 | KEY CNT_ISO (CNT_ISO)"; |
473 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
474 | - $table_name = 'esp_status'; |
|
475 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
473 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
474 | + $table_name = 'esp_status'; |
|
475 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
476 | 476 | STS_code varchar(45) NOT NULL, |
477 | 477 | STS_type varchar(45) NOT NULL, |
478 | 478 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
481 | 481 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
482 | 482 | KEY STS_type (STS_type)"; |
483 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
484 | - $table_name = 'esp_transaction'; |
|
485 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
483 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
484 | + $table_name = 'esp_transaction'; |
|
485 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
486 | 486 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
487 | 487 | TXN_total decimal(10,3) DEFAULT '0.00', |
488 | 488 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | PRIMARY KEY (TXN_ID), |
495 | 495 | KEY TXN_timestamp (TXN_timestamp), |
496 | 496 | KEY STS_ID (STS_ID)"; |
497 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
498 | - $table_name = 'esp_venue_meta'; |
|
499 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
497 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
498 | + $table_name = 'esp_venue_meta'; |
|
499 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
500 | 500 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
501 | 501 | VNU_address varchar(255) DEFAULT NULL, |
502 | 502 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -515,10 +515,10 @@ discard block |
||
515 | 515 | KEY VNU_ID (VNU_ID), |
516 | 516 | KEY STA_ID (STA_ID), |
517 | 517 | KEY CNT_ISO (CNT_ISO)"; |
518 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
519 | - //modified tables |
|
520 | - $table_name = "esp_price"; |
|
521 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
518 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
519 | + //modified tables |
|
520 | + $table_name = "esp_price"; |
|
521 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
522 | 522 | PRT_ID tinyint(3) unsigned NOT NULL, |
523 | 523 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
524 | 524 | PRC_name varchar(245) NOT NULL, |
@@ -531,9 +531,9 @@ discard block |
||
531 | 531 | PRC_parent int(10) unsigned DEFAULT 0, |
532 | 532 | PRIMARY KEY (PRC_ID), |
533 | 533 | KEY PRT_ID (PRT_ID)"; |
534 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
535 | - $table_name = "esp_price_type"; |
|
536 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
534 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
535 | + $table_name = "esp_price_type"; |
|
536 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
537 | 537 | PRT_name varchar(45) NOT NULL, |
538 | 538 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
539 | 539 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -542,9 +542,9 @@ discard block |
||
542 | 542 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
543 | 543 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
544 | 544 | PRIMARY KEY (PRT_ID)"; |
545 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
546 | - $table_name = "esp_ticket"; |
|
547 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
545 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
546 | + $table_name = "esp_ticket"; |
|
547 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
548 | 548 | TTM_ID int(10) unsigned NOT NULL, |
549 | 549 | TKT_name varchar(245) NOT NULL DEFAULT '', |
550 | 550 | TKT_description text NOT NULL, |
@@ -567,9 +567,9 @@ discard block |
||
567 | 567 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
568 | 568 | PRIMARY KEY (TKT_ID), |
569 | 569 | KEY TKT_start_date (TKT_start_date)"; |
570 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
571 | - $table_name = 'esp_question_group'; |
|
572 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
570 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
571 | + $table_name = 'esp_question_group'; |
|
572 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
573 | 573 | QSG_name varchar(255) NOT NULL, |
574 | 574 | QSG_identifier varchar(100) NOT NULL, |
575 | 575 | QSG_desc text NULL, |
@@ -582,138 +582,138 @@ discard block |
||
582 | 582 | PRIMARY KEY (QSG_ID), |
583 | 583 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
584 | 584 | KEY QSG_order (QSG_order)'; |
585 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
586 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
587 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
588 | - //(because many need to convert old string states to foreign keys into the states table) |
|
589 | - $script_4_1_defaults->insert_default_states(); |
|
590 | - $script_4_1_defaults->insert_default_countries(); |
|
591 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
592 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
593 | - $script_4_5_defaults->insert_default_price_types(); |
|
594 | - $script_4_5_defaults->insert_default_prices(); |
|
595 | - $script_4_5_defaults->insert_default_tickets(); |
|
596 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
597 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
598 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
599 | - $script_4_6_defaults->insert_default_currencies(); |
|
600 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
601 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
602 | - $script_4_8_defaults->verify_new_countries(); |
|
603 | - $script_4_8_defaults->verify_new_currencies(); |
|
604 | - $this->verify_db_collations(); |
|
605 | - $this->verify_db_collations_again(); |
|
606 | - return true; |
|
607 | - } |
|
585 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
586 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
587 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
588 | + //(because many need to convert old string states to foreign keys into the states table) |
|
589 | + $script_4_1_defaults->insert_default_states(); |
|
590 | + $script_4_1_defaults->insert_default_countries(); |
|
591 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
592 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
593 | + $script_4_5_defaults->insert_default_price_types(); |
|
594 | + $script_4_5_defaults->insert_default_prices(); |
|
595 | + $script_4_5_defaults->insert_default_tickets(); |
|
596 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
597 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
598 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
599 | + $script_4_6_defaults->insert_default_currencies(); |
|
600 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
601 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
602 | + $script_4_8_defaults->verify_new_countries(); |
|
603 | + $script_4_8_defaults->verify_new_currencies(); |
|
604 | + $this->verify_db_collations(); |
|
605 | + $this->verify_db_collations_again(); |
|
606 | + return true; |
|
607 | + } |
|
608 | 608 | |
609 | 609 | |
610 | 610 | |
611 | - /** |
|
612 | - * @return boolean |
|
613 | - */ |
|
614 | - public function schema_changes_after_migration() |
|
615 | - { |
|
616 | - return true; |
|
617 | - } |
|
611 | + /** |
|
612 | + * @return boolean |
|
613 | + */ |
|
614 | + public function schema_changes_after_migration() |
|
615 | + { |
|
616 | + return true; |
|
617 | + } |
|
618 | 618 | |
619 | 619 | |
620 | 620 | |
621 | - public function migration_page_hooks() |
|
622 | - { |
|
623 | - } |
|
621 | + public function migration_page_hooks() |
|
622 | + { |
|
623 | + } |
|
624 | 624 | |
625 | 625 | |
626 | 626 | |
627 | - /** |
|
628 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
629 | - * |
|
630 | - * @return void |
|
631 | - */ |
|
632 | - public function verify_db_collations() |
|
633 | - { |
|
634 | - if (get_option('ee_verified_db_collations', false)) { |
|
635 | - return; |
|
636 | - } |
|
637 | - // grab tables from each model |
|
638 | - $tables_to_check = array(); |
|
639 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
640 | - if (method_exists($model_name, 'instance')) { |
|
641 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
642 | - if ($model_obj instanceof EEM_Base) { |
|
643 | - foreach ($model_obj->get_tables() as $table) { |
|
644 | - if ( |
|
645 | - strpos($table->get_table_name(), 'esp_') |
|
646 | - && (is_main_site()//for main tables, verify global tables |
|
647 | - || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
648 | - ) |
|
649 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
650 | - ) { |
|
651 | - $tables_to_check[] = $table->get_table_name(); |
|
652 | - } |
|
653 | - } |
|
654 | - } |
|
655 | - } |
|
656 | - } |
|
657 | - //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
658 | - //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
659 | - //of hard-coding this |
|
660 | - $addon_tables = array( |
|
661 | - //mailchimp |
|
662 | - 'esp_event_mailchimp_list_group', |
|
663 | - 'esp_event_question_mailchimp_field', |
|
664 | - //multisite |
|
665 | - 'esp_blog_meta', |
|
666 | - //people |
|
667 | - 'esp_people_to_post', |
|
668 | - //promotions |
|
669 | - 'esp_promotion', |
|
670 | - 'esp_promotion_object', |
|
671 | - ); |
|
672 | - foreach ($addon_tables as $table_name) { |
|
673 | - $tables_to_check[] = $table_name; |
|
674 | - } |
|
675 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
676 | - //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
677 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
678 | - //seeing how this ran with the fix from 10435, no need to check again |
|
679 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
680 | - } |
|
627 | + /** |
|
628 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
629 | + * |
|
630 | + * @return void |
|
631 | + */ |
|
632 | + public function verify_db_collations() |
|
633 | + { |
|
634 | + if (get_option('ee_verified_db_collations', false)) { |
|
635 | + return; |
|
636 | + } |
|
637 | + // grab tables from each model |
|
638 | + $tables_to_check = array(); |
|
639 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
640 | + if (method_exists($model_name, 'instance')) { |
|
641 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
642 | + if ($model_obj instanceof EEM_Base) { |
|
643 | + foreach ($model_obj->get_tables() as $table) { |
|
644 | + if ( |
|
645 | + strpos($table->get_table_name(), 'esp_') |
|
646 | + && (is_main_site()//for main tables, verify global tables |
|
647 | + || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
648 | + ) |
|
649 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
650 | + ) { |
|
651 | + $tables_to_check[] = $table->get_table_name(); |
|
652 | + } |
|
653 | + } |
|
654 | + } |
|
655 | + } |
|
656 | + } |
|
657 | + //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
658 | + //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
659 | + //of hard-coding this |
|
660 | + $addon_tables = array( |
|
661 | + //mailchimp |
|
662 | + 'esp_event_mailchimp_list_group', |
|
663 | + 'esp_event_question_mailchimp_field', |
|
664 | + //multisite |
|
665 | + 'esp_blog_meta', |
|
666 | + //people |
|
667 | + 'esp_people_to_post', |
|
668 | + //promotions |
|
669 | + 'esp_promotion', |
|
670 | + 'esp_promotion_object', |
|
671 | + ); |
|
672 | + foreach ($addon_tables as $table_name) { |
|
673 | + $tables_to_check[] = $table_name; |
|
674 | + } |
|
675 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
676 | + //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
677 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
678 | + //seeing how this ran with the fix from 10435, no need to check again |
|
679 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
680 | + } |
|
681 | 681 | |
682 | 682 | |
683 | 683 | |
684 | - /** |
|
685 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
686 | - * which meant some DB collations might not have been updated |
|
687 | - * @return void |
|
688 | - */ |
|
689 | - public function verify_db_collations_again(){ |
|
690 | - if (get_option('ee_verified_db_collations_again', false)) { |
|
691 | - return; |
|
692 | - } |
|
693 | - $tables_to_check = array( |
|
694 | - 'esp_attendee_meta', |
|
695 | - 'esp_message' |
|
696 | - ); |
|
697 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
698 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
699 | - } |
|
684 | + /** |
|
685 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
686 | + * which meant some DB collations might not have been updated |
|
687 | + * @return void |
|
688 | + */ |
|
689 | + public function verify_db_collations_again(){ |
|
690 | + if (get_option('ee_verified_db_collations_again', false)) { |
|
691 | + return; |
|
692 | + } |
|
693 | + $tables_to_check = array( |
|
694 | + 'esp_attendee_meta', |
|
695 | + 'esp_message' |
|
696 | + ); |
|
697 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
698 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
699 | + } |
|
700 | 700 | |
701 | 701 | |
702 | 702 | |
703 | - /** |
|
704 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
705 | - * @param $tables_to_check |
|
706 | - * @return boolean true if logic ran, false if it didn't |
|
707 | - */ |
|
708 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
709 | - { |
|
710 | - foreach ($tables_to_check as $table_name) { |
|
711 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
712 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
713 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
714 | - ) { |
|
715 | - maybe_convert_table_to_utf8mb4($table_name); |
|
716 | - } |
|
717 | - } |
|
718 | - } |
|
703 | + /** |
|
704 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
705 | + * @param $tables_to_check |
|
706 | + * @return boolean true if logic ran, false if it didn't |
|
707 | + */ |
|
708 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
709 | + { |
|
710 | + foreach ($tables_to_check as $table_name) { |
|
711 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
712 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
713 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
714 | + ) { |
|
715 | + maybe_convert_table_to_utf8mb4($table_name); |
|
716 | + } |
|
717 | + } |
|
718 | + } |
|
719 | 719 | } |
720 | 720 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | //unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | //instead of construction, because it only gets constructed on first page load |
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
|
12 | +$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
|
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | 15 | $matches = array(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } elseif ( ! $version_string) { |
68 | 68 | // echo "no version string provided: $version_string"; |
69 | 69 | //no version string provided... this must be pre 4.3 |
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | 71 | } else { |
72 | 72 | // echo "$version_string doesnt apply"; |
73 | 73 | return false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function schema_changes_before_migration() |
83 | 83 | { |
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
84 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
85 | 85 | $now_in_mysql = current_time('mysql', true); |
86 | 86 | $table_name = 'esp_answer'; |
87 | 87 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | //ok and now let's remember this was done (without needing to check the db schemas all over again) |
677 | 677 | add_option('ee_verified_db_collations', true, null, 'no'); |
678 | 678 | //seeing how this ran with the fix from 10435, no need to check again |
679 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
679 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | * which meant some DB collations might not have been updated |
687 | 687 | * @return void |
688 | 688 | */ |
689 | - public function verify_db_collations_again(){ |
|
689 | + public function verify_db_collations_again() { |
|
690 | 690 | if (get_option('ee_verified_db_collations_again', false)) { |
691 | 691 | return; |
692 | 692 | } |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | 'esp_message' |
696 | 696 | ); |
697 | 697 | $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
698 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
698 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | { |
710 | 710 | foreach ($tables_to_check as $table_name) { |
711 | 711 | $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
712 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
712 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
713 | 713 | && $this->_get_table_analysis()->tableExists($table_name) |
714 | 714 | ) { |
715 | 715 | maybe_convert_table_to_utf8mb4($table_name); |
@@ -17,252 +17,250 @@ |
||
17 | 17 | class TableManager extends \EE_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var TableAnalysis $table_analysis |
|
22 | - */ |
|
23 | - private $table_analysis; |
|
24 | - |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * TableManager constructor. |
|
29 | - * |
|
30 | - * @param TableAnalysis $TableAnalysis |
|
31 | - */ |
|
32 | - public function __construct(TableAnalysis $TableAnalysis) |
|
33 | - { |
|
34 | - $this->table_analysis = $TableAnalysis; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Gets the injected table analyzer, or throws an exception |
|
41 | - * |
|
42 | - * @return TableAnalysis |
|
43 | - * @throws \EE_Error |
|
44 | - */ |
|
45 | - protected function getTableAnalysis() |
|
46 | - { |
|
47 | - if ($this->table_analysis instanceof TableAnalysis) { |
|
48 | - return $this->table_analysis; |
|
49 | - } else { |
|
50 | - throw new \EE_Error( |
|
51 | - sprintf( |
|
52 | - __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
53 | - get_class($this) |
|
54 | - ) |
|
55 | - ); |
|
56 | - } |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
63 | - * @param string $column_name |
|
64 | - * @param string $column_info |
|
65 | - * @return bool|false|int |
|
66 | - */ |
|
67 | - public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
68 | - { |
|
69 | - if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
70 | - return false; |
|
71 | - } |
|
72 | - global $wpdb; |
|
73 | - $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
74 | - $columns = $this->getTableColumns($table_name); |
|
75 | - if ( ! in_array($column_name, $columns)) { |
|
76 | - $alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}"; |
|
77 | - return $wpdb->query($alter_query); |
|
78 | - } |
|
79 | - return true; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * Gets the name of all columns on the table. $table_name can |
|
86 | - * optionally start with $wpdb->prefix or not |
|
87 | - * |
|
88 | - * @global \wpdb $wpdb |
|
89 | - * @param string $table_name |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public function getTableColumns($table_name) |
|
93 | - { |
|
94 | - global $wpdb; |
|
95 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
96 | - $field_array = array(); |
|
97 | - if ( ! empty($table_name)) { |
|
98 | - $columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} "); |
|
99 | - if ($columns !== false) { |
|
100 | - foreach ($columns as $column) { |
|
101 | - $field_array[] = $column->Field; |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - return $field_array; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Drops the specified table from the database. $table_name can |
|
112 | - * optionally start with $wpdb->prefix or not |
|
113 | - * |
|
114 | - * @global \wpdb $wpdb |
|
115 | - * @param string $table_name |
|
116 | - * @return int |
|
117 | - */ |
|
118 | - public function dropTable($table_name) |
|
119 | - { |
|
120 | - global $wpdb; |
|
121 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
122 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
123 | - return $wpdb->query("DROP TABLE IF EXISTS {$table_name}"); |
|
124 | - } |
|
125 | - return 0; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
132 | - * each table name provided has a wpdb prefix attached, and that it exists. |
|
133 | - * Returns the list actually deleted |
|
134 | - * |
|
135 | - * @global WPDB $wpdb |
|
136 | - * @param array $table_names |
|
137 | - * @return array of table names which we deleted |
|
138 | - */ |
|
139 | - public function dropTables($table_names) |
|
140 | - { |
|
141 | - $tables_to_delete = array(); |
|
142 | - foreach ($table_names as $table_name) { |
|
143 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
144 | - if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
145 | - $tables_to_delete[] = $table_name; |
|
146 | - } |
|
147 | - } |
|
148 | - if( ! empty( $tables_to_delete ) ) { |
|
149 | - global $wpdb; |
|
150 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
151 | - } |
|
152 | - return $tables_to_delete; |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * Drops the specified index from the specified table. $table_name can |
|
159 | - * optionally start with $wpdb->prefix or not |
|
160 | - |
|
161 | - * |
|
20 | + /** |
|
21 | + * @var TableAnalysis $table_analysis |
|
22 | + */ |
|
23 | + private $table_analysis; |
|
24 | + |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * TableManager constructor. |
|
29 | + * |
|
30 | + * @param TableAnalysis $TableAnalysis |
|
31 | + */ |
|
32 | + public function __construct(TableAnalysis $TableAnalysis) |
|
33 | + { |
|
34 | + $this->table_analysis = $TableAnalysis; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Gets the injected table analyzer, or throws an exception |
|
41 | + * |
|
42 | + * @return TableAnalysis |
|
43 | + * @throws \EE_Error |
|
44 | + */ |
|
45 | + protected function getTableAnalysis() |
|
46 | + { |
|
47 | + if ($this->table_analysis instanceof TableAnalysis) { |
|
48 | + return $this->table_analysis; |
|
49 | + } else { |
|
50 | + throw new \EE_Error( |
|
51 | + sprintf( |
|
52 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
53 | + get_class($this) |
|
54 | + ) |
|
55 | + ); |
|
56 | + } |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
63 | + * @param string $column_name |
|
64 | + * @param string $column_info |
|
65 | + * @return bool|false|int |
|
66 | + */ |
|
67 | + public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
68 | + { |
|
69 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', false)) { |
|
70 | + return false; |
|
71 | + } |
|
72 | + global $wpdb; |
|
73 | + $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
74 | + $columns = $this->getTableColumns($table_name); |
|
75 | + if ( ! in_array($column_name, $columns)) { |
|
76 | + $alter_query = "ALTER TABLE {$full_table_name} ADD {$column_name} {$column_info}"; |
|
77 | + return $wpdb->query($alter_query); |
|
78 | + } |
|
79 | + return true; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * Gets the name of all columns on the table. $table_name can |
|
86 | + * optionally start with $wpdb->prefix or not |
|
87 | + * |
|
88 | + * @global \wpdb $wpdb |
|
89 | + * @param string $table_name |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public function getTableColumns($table_name) |
|
93 | + { |
|
94 | + global $wpdb; |
|
95 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
96 | + $field_array = array(); |
|
97 | + if ( ! empty($table_name)) { |
|
98 | + $columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name} "); |
|
99 | + if ($columns !== false) { |
|
100 | + foreach ($columns as $column) { |
|
101 | + $field_array[] = $column->Field; |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + return $field_array; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Drops the specified table from the database. $table_name can |
|
112 | + * optionally start with $wpdb->prefix or not |
|
113 | + * |
|
114 | + * @global \wpdb $wpdb |
|
115 | + * @param string $table_name |
|
116 | + * @return int |
|
117 | + */ |
|
118 | + public function dropTable($table_name) |
|
119 | + { |
|
120 | + global $wpdb; |
|
121 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
122 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
123 | + return $wpdb->query("DROP TABLE IF EXISTS {$table_name}"); |
|
124 | + } |
|
125 | + return 0; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
132 | + * each table name provided has a wpdb prefix attached, and that it exists. |
|
133 | + * Returns the list actually deleted |
|
134 | + * |
|
135 | + * @global WPDB $wpdb |
|
136 | + * @param array $table_names |
|
137 | + * @return array of table names which we deleted |
|
138 | + */ |
|
139 | + public function dropTables($table_names) |
|
140 | + { |
|
141 | + $tables_to_delete = array(); |
|
142 | + foreach ($table_names as $table_name) { |
|
143 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
144 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
145 | + $tables_to_delete[] = $table_name; |
|
146 | + } |
|
147 | + } |
|
148 | + if( ! empty( $tables_to_delete ) ) { |
|
149 | + global $wpdb; |
|
150 | + $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
151 | + } |
|
152 | + return $tables_to_delete; |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * Drops the specified index from the specified table. $table_name can |
|
159 | + * optionally start with $wpdb->prefix or not |
|
160 | + * |
|
162 | 161 | *@global \wpdb $wpdb |
163 | - * @param string $table_name |
|
164 | - * @param string $index_name |
|
165 | - * @return int the number of indexes dropped. False if there was a datbase error |
|
166 | - */ |
|
167 | - public function dropIndex($table_name, $index_name) |
|
168 | - { |
|
169 | - if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
170 | - return 0; |
|
171 | - } |
|
172 | - global $wpdb; |
|
173 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
174 | - $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'"; |
|
175 | - if ( |
|
176 | - $this->getTableAnalysis()->tableExists($table_name) |
|
177 | - && $wpdb->get_var($index_exists_query) |
|
178 | - === $table_name //using get_var with the $index_exists_query returns the table's name |
|
179 | - ) { |
|
180 | - return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}"); |
|
181 | - } |
|
182 | - return 0; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Just creates the requested table. $table_name can |
|
189 | - * optionally start with $wpdb->prefix or not |
|
190 | - |
|
191 | - * |
|
162 | + * @param string $table_name |
|
163 | + * @param string $index_name |
|
164 | + * @return int the number of indexes dropped. False if there was a datbase error |
|
165 | + */ |
|
166 | + public function dropIndex($table_name, $index_name) |
|
167 | + { |
|
168 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', false)) { |
|
169 | + return 0; |
|
170 | + } |
|
171 | + global $wpdb; |
|
172 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
173 | + $index_exists_query = "SHOW INDEX FROM {$table_name} WHERE key_name = '{$index_name}'"; |
|
174 | + if ( |
|
175 | + $this->getTableAnalysis()->tableExists($table_name) |
|
176 | + && $wpdb->get_var($index_exists_query) |
|
177 | + === $table_name //using get_var with the $index_exists_query returns the table's name |
|
178 | + ) { |
|
179 | + return $wpdb->query("ALTER TABLE {$table_name} DROP INDEX {$index_name}"); |
|
180 | + } |
|
181 | + return 0; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Just creates the requested table. $table_name can |
|
188 | + * optionally start with $wpdb->prefix or not |
|
189 | + * |
|
192 | 190 | *@param string $table_name |
193 | - * @param string $create_sql defining the table's columns and indexes |
|
194 | - * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
195 | - * @return void |
|
196 | - * @throws \EE_Error |
|
197 | - */ |
|
198 | - public function createTable($table_name, $create_sql, $engine = 'MyISAM') |
|
199 | - { |
|
200 | - // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
201 | - if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) { |
|
202 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
203 | - /** @var \wpdb $wpdb */ |
|
204 | - global $wpdb; |
|
205 | - $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate(); |
|
206 | - |
|
207 | - //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
208 | - //happened. And then we can choose to tell the end user |
|
209 | - $old_show_errors_policy = $wpdb->show_errors(true); |
|
210 | - $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
211 | - ob_start(); |
|
212 | - dbDelta($SQL); |
|
213 | - $output = ob_get_contents(); |
|
214 | - ob_end_clean(); |
|
215 | - $wpdb->show_errors($old_show_errors_policy); |
|
216 | - $wpdb->suppress_errors($old_error_suppression_policy); |
|
217 | - if ( ! empty($output)) { |
|
218 | - throw new \EE_Error($output); |
|
219 | - } |
|
220 | - } else { |
|
221 | - throw new \EE_Error( |
|
222 | - sprintf( |
|
223 | - __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
224 | - 'event_espresso'), |
|
225 | - '<br />', |
|
226 | - $create_sql |
|
227 | - ) |
|
228 | - ); |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * Drops the specified index if it's size differs from $desired_index_size. |
|
236 | - * WordPress' dbdelta method doesn't automatically change index sizes, so this |
|
237 | - * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal. |
|
238 | - * If the table doesn't exist, or it exists but the index does not, or returns false |
|
239 | - * |
|
240 | - * @param string $table_name |
|
241 | - * @param string $index_name |
|
242 | - * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE) |
|
243 | - * @param string|int $desired_index_size defaults to TableAnalysis::index_col_size, the max for utf8mb4. |
|
244 | - * @return bool whether an index was dropped or not |
|
245 | - * @throws /EE_Error if table analysis object isn't defined |
|
246 | - */ |
|
247 | - public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = TableAnalysis::INDEX_COLUMN_SIZE) |
|
248 | - { |
|
249 | - if($column_name === null){ |
|
250 | - $column_name = $index_name; |
|
251 | - } |
|
252 | - if(!$this->getTableAnalysis()->tableExists($table_name)){ |
|
253 | - return false; |
|
254 | - } |
|
255 | - $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name); |
|
256 | - if(empty($index_entries)){ |
|
257 | - return false; |
|
258 | - } |
|
259 | - foreach($index_entries as $index_entry){ |
|
260 | - if( $column_name === $index_entry->Column_name |
|
261 | - && (string)$desired_index_size !== $index_entry->Sub_part){ |
|
262 | - return $this->dropIndex($table_name,$index_name); |
|
263 | - } |
|
264 | - } |
|
265 | - return false; |
|
266 | - } |
|
191 | + * @param string $create_sql defining the table's columns and indexes |
|
192 | + * @param string $engine (no need to specify "ENGINE=", that's implied) |
|
193 | + * @return void |
|
194 | + * @throws \EE_Error |
|
195 | + */ |
|
196 | + public function createTable($table_name, $create_sql, $engine = 'MyISAM') |
|
197 | + { |
|
198 | + // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
|
199 | + if (preg_match('((((.*?))(,\s))+)', $create_sql, $valid_column_data)) { |
|
200 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
201 | + /** @var \wpdb $wpdb */ |
|
202 | + global $wpdb; |
|
203 | + $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate(); |
|
204 | + |
|
205 | + //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
|
206 | + //happened. And then we can choose to tell the end user |
|
207 | + $old_show_errors_policy = $wpdb->show_errors(true); |
|
208 | + $old_error_suppression_policy = $wpdb->suppress_errors(false); |
|
209 | + ob_start(); |
|
210 | + dbDelta($SQL); |
|
211 | + $output = ob_get_contents(); |
|
212 | + ob_end_clean(); |
|
213 | + $wpdb->show_errors($old_show_errors_policy); |
|
214 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
215 | + if ( ! empty($output)) { |
|
216 | + throw new \EE_Error($output); |
|
217 | + } |
|
218 | + } else { |
|
219 | + throw new \EE_Error( |
|
220 | + sprintf( |
|
221 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', |
|
222 | + 'event_espresso'), |
|
223 | + '<br />', |
|
224 | + $create_sql |
|
225 | + ) |
|
226 | + ); |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * Drops the specified index if it's size differs from $desired_index_size. |
|
234 | + * WordPress' dbdelta method doesn't automatically change index sizes, so this |
|
235 | + * method can be used to only drop the index if needed, and afterwards dbdelta can be used as normal. |
|
236 | + * If the table doesn't exist, or it exists but the index does not, or returns false |
|
237 | + * |
|
238 | + * @param string $table_name |
|
239 | + * @param string $index_name |
|
240 | + * @param string $column_name if none is provided, we assume the column name matches the index (often true in EE) |
|
241 | + * @param string|int $desired_index_size defaults to TableAnalysis::index_col_size, the max for utf8mb4. |
|
242 | + * @return bool whether an index was dropped or not |
|
243 | + * @throws /EE_Error if table analysis object isn't defined |
|
244 | + */ |
|
245 | + public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = TableAnalysis::INDEX_COLUMN_SIZE) |
|
246 | + { |
|
247 | + if($column_name === null){ |
|
248 | + $column_name = $index_name; |
|
249 | + } |
|
250 | + if(!$this->getTableAnalysis()->tableExists($table_name)){ |
|
251 | + return false; |
|
252 | + } |
|
253 | + $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name); |
|
254 | + if(empty($index_entries)){ |
|
255 | + return false; |
|
256 | + } |
|
257 | + foreach($index_entries as $index_entry){ |
|
258 | + if( $column_name === $index_entry->Column_name |
|
259 | + && (string)$desired_index_size !== $index_entry->Sub_part){ |
|
260 | + return $this->dropIndex($table_name,$index_name); |
|
261 | + } |
|
262 | + } |
|
263 | + return false; |
|
264 | + } |
|
267 | 265 | |
268 | 266 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | $tables_to_delete[] = $table_name; |
146 | 146 | } |
147 | 147 | } |
148 | - if( ! empty( $tables_to_delete ) ) { |
|
148 | + if ( ! empty($tables_to_delete)) { |
|
149 | 149 | global $wpdb; |
150 | - $wpdb->query('DROP TABLE ' . implode(', ', $tables_to_delete)); |
|
150 | + $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete)); |
|
151 | 151 | } |
152 | 152 | return $tables_to_delete; |
153 | 153 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
203 | 203 | /** @var \wpdb $wpdb */ |
204 | 204 | global $wpdb; |
205 | - $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} " . $wpdb->get_charset_collate(); |
|
205 | + $SQL = "CREATE TABLE {$table_name} ( {$create_sql} ) ENGINE={$engine} ".$wpdb->get_charset_collate(); |
|
206 | 206 | |
207 | 207 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
208 | 208 | //happened. And then we can choose to tell the end user |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function dropIndexIfSizeNot($table_name, $index_name, $column_name = null, $desired_index_size = TableAnalysis::INDEX_COLUMN_SIZE) |
248 | 248 | { |
249 | - if($column_name === null){ |
|
249 | + if ($column_name === null) { |
|
250 | 250 | $column_name = $index_name; |
251 | 251 | } |
252 | - if(!$this->getTableAnalysis()->tableExists($table_name)){ |
|
252 | + if ( ! $this->getTableAnalysis()->tableExists($table_name)) { |
|
253 | 253 | return false; |
254 | 254 | } |
255 | - $index_entries = $this->getTableAnalysis()->showIndexes($table_name,$index_name); |
|
256 | - if(empty($index_entries)){ |
|
255 | + $index_entries = $this->getTableAnalysis()->showIndexes($table_name, $index_name); |
|
256 | + if (empty($index_entries)) { |
|
257 | 257 | return false; |
258 | 258 | } |
259 | - foreach($index_entries as $index_entry){ |
|
260 | - if( $column_name === $index_entry->Column_name |
|
261 | - && (string)$desired_index_size !== $index_entry->Sub_part){ |
|
262 | - return $this->dropIndex($table_name,$index_name); |
|
259 | + foreach ($index_entries as $index_entry) { |
|
260 | + if ($column_name === $index_entry->Column_name |
|
261 | + && (string) $desired_index_size !== $index_entry->Sub_part) { |
|
262 | + return $this->dropIndex($table_name, $index_name); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | return false; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return EED_Event_Single |
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | - return parent::get_instance( __CLASS__ ); |
|
43 | + return parent::get_instance(__CLASS__); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @return void |
53 | 53 | */ |
54 | 54 | public static function set_hooks() { |
55 | - add_filter( 'FHEE_run_EE_wp', '__return_true' ); |
|
56 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
57 | - EE_Config::register_route( __( 'event', 'event_espresso' ), 'Event_Single', 'run' ); |
|
55 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
56 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
57 | + EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return void |
65 | 65 | */ |
66 | 66 | public static function set_hooks_admin() { |
67 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
67 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @return void |
79 | 79 | */ |
80 | 80 | public static function set_definitions() { |
81 | - define( 'EVENT_SINGLE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
82 | - define( 'EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
81 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
82 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @void |
91 | 91 | */ |
92 | - protected function set_config(){ |
|
93 | - $this->set_config_section( 'template_settings' ); |
|
94 | - $this->set_config_class( 'EE_Event_Single_Config' ); |
|
95 | - $this->set_config_name( 'EED_Event_Single' ); |
|
92 | + protected function set_config() { |
|
93 | + $this->set_config_section('template_settings'); |
|
94 | + $this->set_config_class('EE_Event_Single_Config'); |
|
95 | + $this->set_config_name('EED_Event_Single'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -105,35 +105,35 @@ discard block |
||
105 | 105 | * @param \EE_Event_Single_Config $config |
106 | 106 | * @return \EE_Template_Part_Manager |
107 | 107 | */ |
108 | - public function initialize_template_parts( EE_Event_Single_Config $config = null ) { |
|
108 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) { |
|
109 | 109 | $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
110 | 110 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
111 | 111 | $template_parts = new EE_Template_Part_Manager(); |
112 | 112 | $template_parts->add_template_part( |
113 | 113 | 'tickets', |
114 | - __( 'Ticket Selector', 'event_espresso' ), |
|
114 | + __('Ticket Selector', 'event_espresso'), |
|
115 | 115 | 'content-espresso_events-tickets.php', |
116 | 116 | $config->display_order_tickets |
117 | 117 | ); |
118 | 118 | $template_parts->add_template_part( |
119 | 119 | 'datetimes', |
120 | - __( 'Dates and Times', 'event_espresso' ), |
|
120 | + __('Dates and Times', 'event_espresso'), |
|
121 | 121 | 'content-espresso_events-datetimes.php', |
122 | 122 | $config->display_order_datetimes |
123 | 123 | ); |
124 | 124 | $template_parts->add_template_part( |
125 | 125 | 'event', |
126 | - __( 'Event Description', 'event_espresso' ), |
|
126 | + __('Event Description', 'event_espresso'), |
|
127 | 127 | 'content-espresso_events-details.php', |
128 | 128 | $config->display_order_event |
129 | 129 | ); |
130 | 130 | $template_parts->add_template_part( |
131 | 131 | 'venue', |
132 | - __( 'Venue Information', 'event_espresso' ), |
|
132 | + __('Venue Information', 'event_espresso'), |
|
133 | 133 | 'content-espresso_events-venues.php', |
134 | 134 | $config->display_order_venue |
135 | 135 | ); |
136 | - do_action( 'AHEE__EED_Event_Single__initialize_template_parts', $template_parts ); |
|
136 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
137 | 137 | return $template_parts; |
138 | 138 | } |
139 | 139 | |
@@ -147,14 +147,14 @@ discard block |
||
147 | 147 | * @param WP $WP |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function run( $WP ) { |
|
150 | + public function run($WP) { |
|
151 | 151 | // ensure valid EE_Events_Single_Config() object exists |
152 | 152 | $this->set_config(); |
153 | 153 | // check what template is loaded |
154 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
155 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
154 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
155 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
156 | 156 | // load css |
157 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
157 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -166,27 +166,27 @@ discard block |
||
166 | 166 | * @param string $template |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public function template_include( $template ) { |
|
169 | + public function template_include($template) { |
|
170 | 170 | global $post; |
171 | 171 | /** @type EE_Event_Single_Config $config */ |
172 | 172 | $config = $this->config(); |
173 | - if ( $config->display_status_banner_single ) { |
|
174 | - add_filter( 'the_title', array( 'EED_Event_Single', 'the_title' ), 100, 2 ); |
|
173 | + if ($config->display_status_banner_single) { |
|
174 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
175 | 175 | } |
176 | 176 | // not a custom template? |
177 | 177 | if ( |
178 | - EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'single-espresso_events.php' |
|
179 | - || apply_filters( 'FHEE__EED_Event_Single__template_include__allow_custom_selected_template', FALSE ) |
|
180 | - && ! post_password_required( $post ) |
|
178 | + EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'single-espresso_events.php' |
|
179 | + || apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', FALSE) |
|
180 | + && ! post_password_required($post) |
|
181 | 181 | ) { |
182 | 182 | EEH_Template::load_espresso_theme_functions(); |
183 | 183 | // then add extra event data via hooks |
184 | - add_action( 'loop_start', array( 'EED_Event_Single', 'loop_start' )); |
|
185 | - add_filter( 'get_the_excerpt', array( 'EED_Event_Single', 'get_the_excerpt' ), 1, 1 ); |
|
186 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
187 | - add_action( 'loop_end', array( 'EED_Event_Single', 'loop_end' )); |
|
184 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
185 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
186 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
187 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
188 | 188 | // don't display entry meta because the existing theme will take car of that |
189 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
189 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
190 | 190 | } |
191 | 191 | return $template; |
192 | 192 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * @param array $wp_query_array an array containing the WP_Query object |
201 | 201 | * @return void |
202 | 202 | */ |
203 | - public static function loop_start( $wp_query_array ) { |
|
203 | + public static function loop_start($wp_query_array) { |
|
204 | 204 | global $post; |
205 | - do_action( 'AHEE_event_details_before_post', $post, $wp_query_array ); |
|
205 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * @param int $id |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public static function the_title( $title = '', $id = 0 ) { |
|
218 | + public static function the_title($title = '', $id = 0) { |
|
219 | 219 | global $post; |
220 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
220 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | * @param string $excerpt |
230 | 230 | * @return string |
231 | 231 | */ |
232 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
232 | + public static function get_the_excerpt($excerpt = '') { |
|
233 | 233 | EED_Event_Single::$using_get_the_excerpt = true; |
234 | - add_filter( 'wp_trim_excerpt', array( 'EED_Event_Single', 'end_get_the_excerpt' ), 999, 1 ); |
|
234 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
235 | 235 | return $excerpt; |
236 | 236 | } |
237 | 237 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param string $text |
245 | 245 | * @return string |
246 | 246 | */ |
247 | - public static function end_get_the_excerpt( $text = '' ) { |
|
247 | + public static function end_get_the_excerpt($text = '') { |
|
248 | 248 | EED_Event_Single::$using_get_the_excerpt = false; |
249 | 249 | return $text; |
250 | 250 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param string $content |
259 | 259 | * @return string |
260 | 260 | */ |
261 | - public static function event_details( $content ) { |
|
261 | + public static function event_details($content) { |
|
262 | 262 | global $post; |
263 | 263 | static $current_post_ID = 0; |
264 | 264 | if ( |
@@ -273,15 +273,15 @@ discard block |
||
273 | 273 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
274 | 274 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
275 | 275 | // so the following allows this filter to be applied multiple times, but only once for real |
276 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
277 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order ) { |
|
276 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
277 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
278 | 278 | // we need to first remove this callback from being applied to the_content() |
279 | 279 | // (otherwise it will recurse and blow up the interweb) |
280 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
280 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
281 | 281 | EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
282 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
283 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters( $content ); |
|
284 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
282 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
283 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
284 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
285 | 285 | } else { |
286 | 286 | $content = EED_Event_Single::use_filterable_display_order(); |
287 | 287 | } |
@@ -302,20 +302,20 @@ discard block |
||
302 | 302 | // it uses the_content() for displaying the $post->post_content |
303 | 303 | // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
304 | 304 | // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
305 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
305 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
306 | 306 | //now add additional content |
307 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110, 1 ); |
|
308 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120, 1 ); |
|
309 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130, 1 ); |
|
310 | - do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters' ); |
|
307 | + add_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 110, 1); |
|
308 | + add_filter('the_content', array('EED_Event_Single', 'event_tickets'), 120, 1); |
|
309 | + add_filter('the_content', array('EED_Event_Single', 'event_venues'), 130, 1); |
|
310 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
311 | 311 | // now load our template |
312 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
312 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
313 | 313 | //now add our filter back in, plus some others |
314 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
315 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110 ); |
|
316 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120 ); |
|
317 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130 ); |
|
318 | - do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters' ); |
|
314 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
315 | + remove_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 110); |
|
316 | + remove_filter('the_content', array('EED_Event_Single', 'event_tickets'), 120); |
|
317 | + remove_filter('the_content', array('EED_Event_Single', 'event_venues'), 130); |
|
318 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
319 | 319 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
320 | 320 | return $content; |
321 | 321 | } |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | * @param string $content |
330 | 330 | * @return string |
331 | 331 | */ |
332 | - public static function event_datetimes( $content ) { |
|
333 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
332 | + public static function event_datetimes($content) { |
|
333 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param string $content |
343 | 343 | * @return string |
344 | 344 | */ |
345 | - public static function event_tickets( $content ) { |
|
346 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
345 | + public static function event_tickets($content) { |
|
346 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string $content |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public static function event_venue( $content ) { |
|
359 | - return EED_Event_Single::event_venues( $content ); |
|
358 | + public static function event_venue($content) { |
|
359 | + return EED_Event_Single::event_venues($content); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @param string $content |
369 | 369 | * @return string |
370 | 370 | */ |
371 | - public static function event_venues( $content ) { |
|
372 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
371 | + public static function event_venues($content) { |
|
372 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | * @param array $wp_query_array an array containing the WP_Query object |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - public static function loop_end( $wp_query_array ) { |
|
384 | + public static function loop_end($wp_query_array) { |
|
385 | 385 | global $post; |
386 | - do_action( 'AHEE_event_details_after_post', $post, $wp_query_array ); |
|
386 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -396,16 +396,16 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function wp_enqueue_scripts() { |
398 | 398 | // get some style |
399 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && apply_filters( 'FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE )) { |
|
399 | + if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)) { |
|
400 | 400 | // first check uploads folder |
401 | - if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
402 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
401 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
402 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
403 | 403 | } else { |
404 | - wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
404 | + wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
405 | 405 | } |
406 | - wp_enqueue_script( $this->theme ); |
|
407 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
408 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
406 | + wp_enqueue_script($this->theme); |
|
407 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
408 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | } |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | public static function display_venue() { |
427 | 427 | /** @type EE_Event_Single_Config $config */ |
428 | 428 | $config = EED_Event_Single::instance()->config(); |
429 | - $display_venue= isset( $config->display_venue ) ? $config->display_venue : TRUE; |
|
429 | + $display_venue = isset($config->display_venue) ? $config->display_venue : TRUE; |
|
430 | 430 | $venue_name = EEH_Venue_View::venue_name(); |
431 | - return $display_venue && ! empty( $venue_name ) ? TRUE : FALSE; |
|
431 | + return $display_venue && ! empty($venue_name) ? TRUE : FALSE; |
|
432 | 432 | } |
433 | 433 | |
434 | 434 |