@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | } |
156 | 156 | } else { |
157 | 157 | $user_msg = esc_html__('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
158 | - $dev_msg = $user_msg . esc_html__( |
|
158 | + $dev_msg = $user_msg.esc_html__( |
|
159 | 159 | 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
160 | 160 | 'event_espresso' |
161 | 161 | ); |
162 | - EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
162 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
163 | 163 | return false; |
164 | 164 | } |
165 | 165 | return true; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | // reset filter for displaying submit button |
223 | 223 | remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
224 | 224 | // poke and prod incoming event till it tells us what it is |
225 | - if (! $this->setEvent($event)) { |
|
225 | + if ( ! $this->setEvent($event)) { |
|
226 | 226 | return $this->handleMissingEvent(); |
227 | 227 | } |
228 | 228 | // is the event expired ? |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | : $this->loadTicketSelector($tickets, $template_args); |
266 | 266 | // now set up the form (but not for the admin) |
267 | 267 | $ticket_selector = $this->display_full_ui() |
268 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
268 | + ? $this->formOpen($this->event->ID(), $external_url).$ticket_selector |
|
269 | 269 | : $ticket_selector; |
270 | 270 | // submit button and form close tag |
271 | 271 | $ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : ''; |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | */ |
314 | 314 | protected function expiredEventMessage() |
315 | 315 | { |
316 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
316 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.esc_html__( |
|
317 | 317 | 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
318 | 318 | 'event_espresso' |
319 | - ) . '</span></div><!-- .ee-event-expired-notice -->'; |
|
319 | + ).'</span></div><!-- .ee-event-expired-notice -->'; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | } |
348 | 348 | return ' |
349 | 349 | <div class="ee-event-expired-notice"> |
350 | - <span class="important-notice">' . $no_ticket_available_msg . '</span> |
|
350 | + <span class="important-notice">' . $no_ticket_available_msg.'</span> |
|
351 | 351 | </div><!-- .ee-event-expired-notice -->'; |
352 | 352 | } |
353 | 353 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->' |
381 | 381 | ); |
382 | 382 | } |
383 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
383 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'Datetime.DTT_EVT_start' => 'DESC', |
409 | 409 | ], |
410 | 410 | ]; |
411 | - if (! $show_expired_tickets) { |
|
411 | + if ( ! $show_expired_tickets) { |
|
412 | 412 | // use the correct applicable time query depending on what version of core is being run. |
413 | 413 | $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
414 | 414 | ? time() |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | * @param int $EVT_ID The Event ID |
446 | 446 | * @since 4.9.13 |
447 | 447 | */ |
448 | - $template_args['anchor_id'] = apply_filters( |
|
448 | + $template_args['anchor_id'] = apply_filters( |
|
449 | 449 | 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
450 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
450 | + '#tkt-slctr-tbl-'.$this->event->ID(), |
|
451 | 451 | $this->event->ID() |
452 | 452 | ); |
453 | 453 | $template_args['tickets'] = $tickets; |
@@ -539,30 +539,30 @@ discard block |
||
539 | 539 | // if redirecting, we don't need any anything else |
540 | 540 | if ($external_url) { |
541 | 541 | $html = '<form method="GET" '; |
542 | - $html .= 'action="' . EEH_URL::refactor_url($external_url) . '" '; |
|
543 | - $html .= 'name="ticket-selector-form-' . $ID . '"'; |
|
542 | + $html .= 'action="'.EEH_URL::refactor_url($external_url).'" '; |
|
543 | + $html .= 'name="ticket-selector-form-'.$ID.'"'; |
|
544 | 544 | // open link in new window ? |
545 | - $html .= apply_filters( |
|
545 | + $html .= apply_filters( |
|
546 | 546 | 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
547 | 547 | $this->isIframe(), |
548 | 548 | $this |
549 | 549 | ) |
550 | 550 | ? ' target="_blank"' |
551 | 551 | : ''; |
552 | - $html .= '>'; |
|
552 | + $html .= '>'; |
|
553 | 553 | $query_args = EEH_URL::get_query_string($external_url); |
554 | 554 | foreach ((array) $query_args as $query_arg => $value) { |
555 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
555 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
556 | 556 | } |
557 | 557 | return $html; |
558 | 558 | } |
559 | 559 | // if there is no submit button, then don't start building a form |
560 | 560 | // because the "View Details" button will build its own form |
561 | - if (! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
561 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
562 | 562 | return ''; |
563 | 563 | } |
564 | 564 | $checkout_url = EEH_Event_View::event_link_url($ID); |
565 | - if (! $checkout_url) { |
|
565 | + if ( ! $checkout_url) { |
|
566 | 566 | EE_Error::add_error( |
567 | 567 | esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
568 | 568 | __FILE__, |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | // set no cache headers and constants |
574 | 574 | EE_System::do_not_cache(); |
575 | 575 | $html = '<form method="POST" '; |
576 | - $html .= 'action="' . $checkout_url . '" '; |
|
577 | - $html .= 'name="ticket-selector-form-' . $ID . '"'; |
|
576 | + $html .= 'action="'.$checkout_url.'" '; |
|
577 | + $html .= 'name="ticket-selector-form-'.$ID.'"'; |
|
578 | 578 | $html .= $this->iframe ? ' target="_blank"' : ''; |
579 | 579 | $html .= '>'; |
580 | 580 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | $html .= empty($external_url) |
601 | 601 | ? $this->ticketSelectorEndDiv() |
602 | 602 | : $this->clearTicketSelector(); |
603 | - $html .= '<br/>' . $this->formClose(); |
|
603 | + $html .= '<br/>'.$this->formClose(); |
|
604 | 604 | } elseif ($this->getMaxAttendees() === 1) { |
605 | 605 | // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
606 | 606 | if ($this->event->is_sold_out()) { |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | // no submit or view details button, and no additional content |
659 | 659 | $html .= $this->ticketSelectorEndDiv(); |
660 | 660 | } |
661 | - if (! $this->iframe && ! is_archive()) { |
|
661 | + if ( ! $this->iframe && ! is_archive()) { |
|
662 | 662 | $html .= EEH_Template::powered_by_event_espresso('', '', ['utm_content' => 'ticket_selector']); |
663 | 663 | } |
664 | 664 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | */ |
679 | 679 | public function displayRegisterNowButton() |
680 | 680 | { |
681 | - $btn_text = apply_filters( |
|
681 | + $btn_text = apply_filters( |
|
682 | 682 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
683 | 683 | esc_html__('Register Now', 'event_espresso'), |
684 | 684 | $this->event |
@@ -687,16 +687,16 @@ discard block |
||
687 | 687 | && $this->event->external_url() !== get_the_permalink() |
688 | 688 | ? $this->event->external_url() |
689 | 689 | : ''; |
690 | - $html = EEH_HTML::div( |
|
690 | + $html = EEH_HTML::div( |
|
691 | 691 | '', |
692 | - 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', |
|
692 | + 'ticket-selector-submit-'.$this->event->ID().'-btn-wrap', |
|
693 | 693 | 'ticket-selector-submit-btn-wrap' |
694 | 694 | ); |
695 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
695 | + $html .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"'; |
|
696 | 696 | $html .= ' class="ticket-selector-submit-btn '; |
697 | 697 | $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
698 | - $html .= ' type="submit" value="' . $btn_text . '" data-ee-disable-after-recaptcha="true" />'; |
|
699 | - $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->'; |
|
698 | + $html .= ' type="submit" value="'.$btn_text.'" data-ee-disable-after-recaptcha="true" />'; |
|
699 | + $html .= EEH_HTML::divx().'<!-- .ticket-selector-submit-btn-wrap -->'; |
|
700 | 700 | $html .= apply_filters( |
701 | 701 | 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
702 | 702 | '', |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | */ |
721 | 721 | public function displayViewDetailsButton($DWMTS = false) |
722 | 722 | { |
723 | - if (! $this->event->get_permalink()) { |
|
723 | + if ( ! $this->event->get_permalink()) { |
|
724 | 724 | EE_Error::add_error( |
725 | 725 | esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
726 | 726 | __FILE__, |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | ? ' target="_blank"' |
745 | 745 | : ''; |
746 | 746 | $view_details_btn .= '>'; |
747 | - $btn_text = apply_filters( |
|
747 | + $btn_text = apply_filters( |
|
748 | 748 | 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
749 | 749 | esc_html__('View Details', 'event_espresso'), |
750 | 750 | $this->event |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public function ticketSelectorEndDiv() |
775 | 775 | { |
776 | - return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->'; |
|
776 | + return $this->clearTicketSelector().'</div><!-- ticketSelectorEndDiv -->'; |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | protected function handleMissingEvent() |
810 | 810 | { |
811 | 811 | // If this is not an iFrame request, simply return false. |
812 | - if (! $this->isIframe()) { |
|
812 | + if ( ! $this->isIframe()) { |
|
813 | 813 | return ''; |
814 | 814 | } |
815 | 815 | // This is an iFrame so return an error. |
@@ -39,817 +39,817 @@ |
||
39 | 39 | */ |
40 | 40 | class DisplayTicketSelector |
41 | 41 | { |
42 | - /** |
|
43 | - * @var RequestInterface |
|
44 | - */ |
|
45 | - protected $request; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Ticket_Selector_Config |
|
49 | - */ |
|
50 | - protected $config; |
|
51 | - |
|
52 | - /** |
|
53 | - * event that ticket selector is being generated for |
|
54 | - * |
|
55 | - * @access protected |
|
56 | - * @var EE_Event $event |
|
57 | - */ |
|
58 | - protected $event; |
|
59 | - |
|
60 | - /** |
|
61 | - * Used to flag when the ticket selector is being called from an external iframe. |
|
62 | - * |
|
63 | - * @var bool $iframe |
|
64 | - */ |
|
65 | - protected $iframe = false; |
|
66 | - |
|
67 | - /** |
|
68 | - * max attendees that can register for event at one time |
|
69 | - * |
|
70 | - * @var int $max_attendees |
|
71 | - */ |
|
72 | - private $max_attendees = EE_INF; |
|
73 | - |
|
74 | - /** |
|
75 | - * @var string $date_format |
|
76 | - */ |
|
77 | - private $date_format; |
|
78 | - |
|
79 | - /** |
|
80 | - * @var string $time_format |
|
81 | - */ |
|
82 | - private $time_format; |
|
83 | - |
|
84 | - /** |
|
85 | - * @var boolean $display_full_ui |
|
86 | - */ |
|
87 | - private $display_full_ui; |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * DisplayTicketSelector constructor. |
|
92 | - * |
|
93 | - * @param RequestInterface $request |
|
94 | - * @param EE_Ticket_Selector_Config $config |
|
95 | - * @param bool $iframe |
|
96 | - */ |
|
97 | - public function __construct(RequestInterface $request, EE_Ticket_Selector_Config $config, $iframe = false) |
|
98 | - { |
|
99 | - $this->request = $request; |
|
100 | - $this->config = $config; |
|
101 | - $this->iframe = $iframe; |
|
102 | - $this->date_format = apply_filters( |
|
103 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
104 | - get_option('date_format') |
|
105 | - ); |
|
106 | - $this->time_format = apply_filters( |
|
107 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
108 | - get_option('time_format') |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @return bool |
|
115 | - */ |
|
116 | - public function isIframe() |
|
117 | - { |
|
118 | - return $this->iframe; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @param boolean $iframe |
|
124 | - */ |
|
125 | - public function setIframe($iframe = true) |
|
126 | - { |
|
127 | - $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * finds and sets the \EE_Event object for use throughout class |
|
133 | - * |
|
134 | - * @param mixed $event |
|
135 | - * @return bool |
|
136 | - * @throws EE_Error |
|
137 | - * @throws InvalidDataTypeException |
|
138 | - * @throws InvalidInterfaceException |
|
139 | - * @throws InvalidArgumentException |
|
140 | - */ |
|
141 | - protected function setEvent($event = null) |
|
142 | - { |
|
143 | - if ($event === null) { |
|
144 | - global $post; |
|
145 | - $event = $post; |
|
146 | - } |
|
147 | - if ($event instanceof EE_Event) { |
|
148 | - $this->event = $event; |
|
149 | - } elseif ($event instanceof WP_Post) { |
|
150 | - if (isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
151 | - $this->event = $event->EE_Event; |
|
152 | - } elseif ($event->post_type === 'espresso_events') { |
|
153 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
154 | - $this->event = $event->EE_Event; |
|
155 | - } |
|
156 | - } else { |
|
157 | - $user_msg = esc_html__('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
158 | - $dev_msg = $user_msg . esc_html__( |
|
159 | - 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
160 | - 'event_espresso' |
|
161 | - ); |
|
162 | - EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
163 | - return false; |
|
164 | - } |
|
165 | - return true; |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @return int |
|
171 | - */ |
|
172 | - public function getMaxAttendees() |
|
173 | - { |
|
174 | - return $this->max_attendees; |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * @param int $max_attendees |
|
180 | - */ |
|
181 | - public function setMaxAttendees($max_attendees) |
|
182 | - { |
|
183 | - $this->max_attendees = absint( |
|
184 | - apply_filters( |
|
185 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
186 | - $max_attendees |
|
187 | - ) |
|
188 | - ); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * Returns whether or not the full ticket selector should be shown or not. |
|
194 | - * Currently, it displays on the frontend (including ajax requests) but not the backend |
|
195 | - * |
|
196 | - * @return bool |
|
197 | - */ |
|
198 | - private function display_full_ui() |
|
199 | - { |
|
200 | - if ($this->display_full_ui === null) { |
|
201 | - $this->display_full_ui = ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX); |
|
202 | - } |
|
203 | - return $this->display_full_ui; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * creates buttons for selecting number of attendees for an event |
|
209 | - * |
|
210 | - * @param WP_Post|int $event |
|
211 | - * @param bool $view_details |
|
212 | - * @return string |
|
213 | - * @throws EE_Error |
|
214 | - * @throws InvalidArgumentException |
|
215 | - * @throws InvalidDataTypeException |
|
216 | - * @throws InvalidInterfaceException |
|
217 | - * @throws ReflectionException |
|
218 | - * @throws Exception |
|
219 | - */ |
|
220 | - public function display($event = null, $view_details = false) |
|
221 | - { |
|
222 | - // reset filter for displaying submit button |
|
223 | - remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
224 | - // poke and prod incoming event till it tells us what it is |
|
225 | - if (! $this->setEvent($event)) { |
|
226 | - return $this->handleMissingEvent(); |
|
227 | - } |
|
228 | - // is the event expired ? |
|
229 | - $template_args['event_is_expired'] = ! is_admin() && $this->event->is_expired(); |
|
230 | - if ($template_args['event_is_expired']) { |
|
231 | - return is_single() |
|
232 | - ? $this->expiredEventMessage() |
|
233 | - : $this->expiredEventMessage() |
|
234 | - . $this->displayViewDetailsButton(); |
|
235 | - } |
|
236 | - // begin gathering template arguments by getting event status |
|
237 | - $template_args = ['event_status' => $this->event->get_active_status()]; |
|
238 | - if ( |
|
239 | - $this->activeEventAndShowTicketSelector( |
|
240 | - $event, |
|
241 | - $template_args['event_status'], |
|
242 | - $view_details |
|
243 | - ) |
|
244 | - ) { |
|
245 | - return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
246 | - } |
|
247 | - // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
248 | - $this->setMaxAttendees($this->event->additional_limit()); |
|
249 | - if ($this->getMaxAttendees() < 1) { |
|
250 | - return $this->ticketSalesClosedMessage(); |
|
251 | - } |
|
252 | - // get all tickets for this event ordered by the datetime |
|
253 | - $tickets = $this->getTickets(); |
|
254 | - if (count($tickets) < 1) { |
|
255 | - return $this->noTicketAvailableMessage(); |
|
256 | - } |
|
257 | - // redirecting to another site for registration ?? |
|
258 | - $external_url = (string) $this->event->external_url() |
|
259 | - && $this->event->external_url() !== get_the_permalink() |
|
260 | - ? $this->event->external_url() |
|
261 | - : ''; |
|
262 | - // if redirecting to another site for registration, then we don't load the TS |
|
263 | - $ticket_selector = $external_url |
|
264 | - ? $this->externalEventRegistration() |
|
265 | - : $this->loadTicketSelector($tickets, $template_args); |
|
266 | - // now set up the form (but not for the admin) |
|
267 | - $ticket_selector = $this->display_full_ui() |
|
268 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
269 | - : $ticket_selector; |
|
270 | - // submit button and form close tag |
|
271 | - $ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : ''; |
|
272 | - return $ticket_selector; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * displayTicketSelector |
|
278 | - * examines the event properties and determines whether a Ticket Selector should be displayed |
|
279 | - * |
|
280 | - * @param WP_Post|int $event |
|
281 | - * @param string $_event_active_status |
|
282 | - * @param bool $view_details |
|
283 | - * @return bool |
|
284 | - * @throws EE_Error |
|
285 | - * @throws ReflectionException |
|
286 | - */ |
|
287 | - protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
288 | - { |
|
289 | - $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event; |
|
290 | - return $this->display_full_ui() |
|
291 | - && ( |
|
292 | - ! $this->event->display_ticket_selector() |
|
293 | - || $view_details |
|
294 | - || post_password_required($event_post) |
|
295 | - || ( |
|
296 | - $_event_active_status !== EE_Datetime::active |
|
297 | - && $_event_active_status !== EE_Datetime::upcoming |
|
298 | - && $_event_active_status !== EE_Datetime::sold_out |
|
299 | - && ! ( |
|
300 | - $_event_active_status === EE_Datetime::inactive |
|
301 | - && is_user_logged_in() |
|
302 | - ) |
|
303 | - ) |
|
304 | - ); |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * noTicketAvailableMessage |
|
310 | - * notice displayed if event is expired |
|
311 | - * |
|
312 | - * @return string |
|
313 | - */ |
|
314 | - protected function expiredEventMessage() |
|
315 | - { |
|
316 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
317 | - 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
318 | - 'event_espresso' |
|
319 | - ) . '</span></div><!-- .ee-event-expired-notice -->'; |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * noTicketAvailableMessage |
|
325 | - * notice displayed if event has no more tickets available |
|
326 | - * |
|
327 | - * @return string |
|
328 | - * @throws EE_Error |
|
329 | - * @throws ReflectionException |
|
330 | - */ |
|
331 | - protected function noTicketAvailableMessage() |
|
332 | - { |
|
333 | - $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso'); |
|
334 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
335 | - $no_ticket_available_msg .= sprintf( |
|
336 | - esc_html__( |
|
337 | - '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
338 | - 'event_espresso' |
|
339 | - ), |
|
340 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
341 | - '</b><br />', |
|
342 | - '<span class="edit-link"><a class="post-edit-link" href="' |
|
343 | - . get_edit_post_link($this->event->ID()) |
|
344 | - . '">', |
|
345 | - '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->' |
|
346 | - ); |
|
347 | - } |
|
348 | - return ' |
|
42 | + /** |
|
43 | + * @var RequestInterface |
|
44 | + */ |
|
45 | + protected $request; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Ticket_Selector_Config |
|
49 | + */ |
|
50 | + protected $config; |
|
51 | + |
|
52 | + /** |
|
53 | + * event that ticket selector is being generated for |
|
54 | + * |
|
55 | + * @access protected |
|
56 | + * @var EE_Event $event |
|
57 | + */ |
|
58 | + protected $event; |
|
59 | + |
|
60 | + /** |
|
61 | + * Used to flag when the ticket selector is being called from an external iframe. |
|
62 | + * |
|
63 | + * @var bool $iframe |
|
64 | + */ |
|
65 | + protected $iframe = false; |
|
66 | + |
|
67 | + /** |
|
68 | + * max attendees that can register for event at one time |
|
69 | + * |
|
70 | + * @var int $max_attendees |
|
71 | + */ |
|
72 | + private $max_attendees = EE_INF; |
|
73 | + |
|
74 | + /** |
|
75 | + * @var string $date_format |
|
76 | + */ |
|
77 | + private $date_format; |
|
78 | + |
|
79 | + /** |
|
80 | + * @var string $time_format |
|
81 | + */ |
|
82 | + private $time_format; |
|
83 | + |
|
84 | + /** |
|
85 | + * @var boolean $display_full_ui |
|
86 | + */ |
|
87 | + private $display_full_ui; |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * DisplayTicketSelector constructor. |
|
92 | + * |
|
93 | + * @param RequestInterface $request |
|
94 | + * @param EE_Ticket_Selector_Config $config |
|
95 | + * @param bool $iframe |
|
96 | + */ |
|
97 | + public function __construct(RequestInterface $request, EE_Ticket_Selector_Config $config, $iframe = false) |
|
98 | + { |
|
99 | + $this->request = $request; |
|
100 | + $this->config = $config; |
|
101 | + $this->iframe = $iframe; |
|
102 | + $this->date_format = apply_filters( |
|
103 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
104 | + get_option('date_format') |
|
105 | + ); |
|
106 | + $this->time_format = apply_filters( |
|
107 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
108 | + get_option('time_format') |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @return bool |
|
115 | + */ |
|
116 | + public function isIframe() |
|
117 | + { |
|
118 | + return $this->iframe; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @param boolean $iframe |
|
124 | + */ |
|
125 | + public function setIframe($iframe = true) |
|
126 | + { |
|
127 | + $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * finds and sets the \EE_Event object for use throughout class |
|
133 | + * |
|
134 | + * @param mixed $event |
|
135 | + * @return bool |
|
136 | + * @throws EE_Error |
|
137 | + * @throws InvalidDataTypeException |
|
138 | + * @throws InvalidInterfaceException |
|
139 | + * @throws InvalidArgumentException |
|
140 | + */ |
|
141 | + protected function setEvent($event = null) |
|
142 | + { |
|
143 | + if ($event === null) { |
|
144 | + global $post; |
|
145 | + $event = $post; |
|
146 | + } |
|
147 | + if ($event instanceof EE_Event) { |
|
148 | + $this->event = $event; |
|
149 | + } elseif ($event instanceof WP_Post) { |
|
150 | + if (isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
151 | + $this->event = $event->EE_Event; |
|
152 | + } elseif ($event->post_type === 'espresso_events') { |
|
153 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
154 | + $this->event = $event->EE_Event; |
|
155 | + } |
|
156 | + } else { |
|
157 | + $user_msg = esc_html__('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
158 | + $dev_msg = $user_msg . esc_html__( |
|
159 | + 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
160 | + 'event_espresso' |
|
161 | + ); |
|
162 | + EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
163 | + return false; |
|
164 | + } |
|
165 | + return true; |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @return int |
|
171 | + */ |
|
172 | + public function getMaxAttendees() |
|
173 | + { |
|
174 | + return $this->max_attendees; |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * @param int $max_attendees |
|
180 | + */ |
|
181 | + public function setMaxAttendees($max_attendees) |
|
182 | + { |
|
183 | + $this->max_attendees = absint( |
|
184 | + apply_filters( |
|
185 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
186 | + $max_attendees |
|
187 | + ) |
|
188 | + ); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * Returns whether or not the full ticket selector should be shown or not. |
|
194 | + * Currently, it displays on the frontend (including ajax requests) but not the backend |
|
195 | + * |
|
196 | + * @return bool |
|
197 | + */ |
|
198 | + private function display_full_ui() |
|
199 | + { |
|
200 | + if ($this->display_full_ui === null) { |
|
201 | + $this->display_full_ui = ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX); |
|
202 | + } |
|
203 | + return $this->display_full_ui; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * creates buttons for selecting number of attendees for an event |
|
209 | + * |
|
210 | + * @param WP_Post|int $event |
|
211 | + * @param bool $view_details |
|
212 | + * @return string |
|
213 | + * @throws EE_Error |
|
214 | + * @throws InvalidArgumentException |
|
215 | + * @throws InvalidDataTypeException |
|
216 | + * @throws InvalidInterfaceException |
|
217 | + * @throws ReflectionException |
|
218 | + * @throws Exception |
|
219 | + */ |
|
220 | + public function display($event = null, $view_details = false) |
|
221 | + { |
|
222 | + // reset filter for displaying submit button |
|
223 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
224 | + // poke and prod incoming event till it tells us what it is |
|
225 | + if (! $this->setEvent($event)) { |
|
226 | + return $this->handleMissingEvent(); |
|
227 | + } |
|
228 | + // is the event expired ? |
|
229 | + $template_args['event_is_expired'] = ! is_admin() && $this->event->is_expired(); |
|
230 | + if ($template_args['event_is_expired']) { |
|
231 | + return is_single() |
|
232 | + ? $this->expiredEventMessage() |
|
233 | + : $this->expiredEventMessage() |
|
234 | + . $this->displayViewDetailsButton(); |
|
235 | + } |
|
236 | + // begin gathering template arguments by getting event status |
|
237 | + $template_args = ['event_status' => $this->event->get_active_status()]; |
|
238 | + if ( |
|
239 | + $this->activeEventAndShowTicketSelector( |
|
240 | + $event, |
|
241 | + $template_args['event_status'], |
|
242 | + $view_details |
|
243 | + ) |
|
244 | + ) { |
|
245 | + return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
246 | + } |
|
247 | + // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
248 | + $this->setMaxAttendees($this->event->additional_limit()); |
|
249 | + if ($this->getMaxAttendees() < 1) { |
|
250 | + return $this->ticketSalesClosedMessage(); |
|
251 | + } |
|
252 | + // get all tickets for this event ordered by the datetime |
|
253 | + $tickets = $this->getTickets(); |
|
254 | + if (count($tickets) < 1) { |
|
255 | + return $this->noTicketAvailableMessage(); |
|
256 | + } |
|
257 | + // redirecting to another site for registration ?? |
|
258 | + $external_url = (string) $this->event->external_url() |
|
259 | + && $this->event->external_url() !== get_the_permalink() |
|
260 | + ? $this->event->external_url() |
|
261 | + : ''; |
|
262 | + // if redirecting to another site for registration, then we don't load the TS |
|
263 | + $ticket_selector = $external_url |
|
264 | + ? $this->externalEventRegistration() |
|
265 | + : $this->loadTicketSelector($tickets, $template_args); |
|
266 | + // now set up the form (but not for the admin) |
|
267 | + $ticket_selector = $this->display_full_ui() |
|
268 | + ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
269 | + : $ticket_selector; |
|
270 | + // submit button and form close tag |
|
271 | + $ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : ''; |
|
272 | + return $ticket_selector; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * displayTicketSelector |
|
278 | + * examines the event properties and determines whether a Ticket Selector should be displayed |
|
279 | + * |
|
280 | + * @param WP_Post|int $event |
|
281 | + * @param string $_event_active_status |
|
282 | + * @param bool $view_details |
|
283 | + * @return bool |
|
284 | + * @throws EE_Error |
|
285 | + * @throws ReflectionException |
|
286 | + */ |
|
287 | + protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
288 | + { |
|
289 | + $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event; |
|
290 | + return $this->display_full_ui() |
|
291 | + && ( |
|
292 | + ! $this->event->display_ticket_selector() |
|
293 | + || $view_details |
|
294 | + || post_password_required($event_post) |
|
295 | + || ( |
|
296 | + $_event_active_status !== EE_Datetime::active |
|
297 | + && $_event_active_status !== EE_Datetime::upcoming |
|
298 | + && $_event_active_status !== EE_Datetime::sold_out |
|
299 | + && ! ( |
|
300 | + $_event_active_status === EE_Datetime::inactive |
|
301 | + && is_user_logged_in() |
|
302 | + ) |
|
303 | + ) |
|
304 | + ); |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * noTicketAvailableMessage |
|
310 | + * notice displayed if event is expired |
|
311 | + * |
|
312 | + * @return string |
|
313 | + */ |
|
314 | + protected function expiredEventMessage() |
|
315 | + { |
|
316 | + return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
317 | + 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
318 | + 'event_espresso' |
|
319 | + ) . '</span></div><!-- .ee-event-expired-notice -->'; |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * noTicketAvailableMessage |
|
325 | + * notice displayed if event has no more tickets available |
|
326 | + * |
|
327 | + * @return string |
|
328 | + * @throws EE_Error |
|
329 | + * @throws ReflectionException |
|
330 | + */ |
|
331 | + protected function noTicketAvailableMessage() |
|
332 | + { |
|
333 | + $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso'); |
|
334 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
335 | + $no_ticket_available_msg .= sprintf( |
|
336 | + esc_html__( |
|
337 | + '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
338 | + 'event_espresso' |
|
339 | + ), |
|
340 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
341 | + '</b><br />', |
|
342 | + '<span class="edit-link"><a class="post-edit-link" href="' |
|
343 | + . get_edit_post_link($this->event->ID()) |
|
344 | + . '">', |
|
345 | + '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->' |
|
346 | + ); |
|
347 | + } |
|
348 | + return ' |
|
349 | 349 | <div class="ee-event-expired-notice"> |
350 | 350 | <span class="important-notice">' . $no_ticket_available_msg . '</span> |
351 | 351 | </div><!-- .ee-event-expired-notice -->'; |
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * ticketSalesClosed |
|
357 | - * notice displayed if event ticket sales are turned off |
|
358 | - * |
|
359 | - * @return string |
|
360 | - * @throws EE_Error |
|
361 | - * @throws ReflectionException |
|
362 | - */ |
|
363 | - protected function ticketSalesClosedMessage() |
|
364 | - { |
|
365 | - $sales_closed_msg = esc_html__( |
|
366 | - 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
367 | - 'event_espresso' |
|
368 | - ); |
|
369 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
370 | - $sales_closed_msg .= sprintf( |
|
371 | - esc_html__( |
|
372 | - '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
373 | - 'event_espresso' |
|
374 | - ), |
|
375 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
376 | - '</b><br />', |
|
377 | - '<span class="edit-link"><a class="post-edit-link" href="' |
|
378 | - . get_edit_post_link($this->event->ID()) |
|
379 | - . '">', |
|
380 | - '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->' |
|
381 | - ); |
|
382 | - } |
|
383 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * getTickets |
|
389 | - * |
|
390 | - * @return EE_Base_Class[]|EE_Ticket[] |
|
391 | - * @throws EE_Error |
|
392 | - * @throws InvalidDataTypeException |
|
393 | - * @throws InvalidInterfaceException |
|
394 | - * @throws InvalidArgumentException |
|
395 | - * @throws ReflectionException |
|
396 | - */ |
|
397 | - protected function getTickets() |
|
398 | - { |
|
399 | - $show_expired_tickets = is_admin() || $this->config->show_expired_tickets; |
|
400 | - |
|
401 | - $ticket_query_args = [ |
|
402 | - ['Datetime.EVT_ID' => $this->event->ID()], |
|
403 | - 'order_by' => [ |
|
404 | - 'TKT_order' => 'ASC', |
|
405 | - 'TKT_required' => 'DESC', |
|
406 | - 'TKT_start_date' => 'ASC', |
|
407 | - 'TKT_end_date' => 'ASC', |
|
408 | - 'Datetime.DTT_EVT_start' => 'DESC', |
|
409 | - ], |
|
410 | - ]; |
|
411 | - if (! $show_expired_tickets) { |
|
412 | - // use the correct applicable time query depending on what version of core is being run. |
|
413 | - $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
414 | - ? time() |
|
415 | - : current_time('timestamp'); |
|
416 | - $ticket_query_args[0]['TKT_end_date'] = ['>', $current_time]; |
|
417 | - } |
|
418 | - return EEM_Ticket::instance()->get_all($ticket_query_args); |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * loadTicketSelector |
|
424 | - * begins to assemble template arguments |
|
425 | - * and decides whether to load a "simple" ticket selector, or the standard |
|
426 | - * |
|
427 | - * @param EE_Ticket[] $tickets |
|
428 | - * @param array $template_args |
|
429 | - * @return TicketSelectorSimple|TicketSelectorStandard |
|
430 | - * @throws EE_Error |
|
431 | - * @throws ReflectionException |
|
432 | - */ |
|
433 | - protected function loadTicketSelector(array $tickets, array $template_args) |
|
434 | - { |
|
435 | - $template_args['event'] = $this->event; |
|
436 | - $template_args['EVT_ID'] = $this->event->ID(); |
|
437 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
438 | - $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
439 | - $template_args['date_format'] = $this->date_format; |
|
440 | - $template_args['time_format'] = $this->time_format; |
|
441 | - /** |
|
442 | - * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
443 | - * |
|
444 | - * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
445 | - * @param int $EVT_ID The Event ID |
|
446 | - * @since 4.9.13 |
|
447 | - */ |
|
448 | - $template_args['anchor_id'] = apply_filters( |
|
449 | - 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
450 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
451 | - $this->event->ID() |
|
452 | - ); |
|
453 | - $template_args['tickets'] = $tickets; |
|
454 | - $template_args['ticket_count'] = count($tickets); |
|
455 | - $ticket_selector = $this->simpleTicketSelector($tickets, $template_args); |
|
456 | - if ($ticket_selector instanceof TicketSelectorSimple) { |
|
457 | - return $ticket_selector; |
|
458 | - } |
|
459 | - return new TicketSelectorStandard( |
|
460 | - $this->config, |
|
461 | - $this->getTaxConfig(), |
|
462 | - $this->event, |
|
463 | - $tickets, |
|
464 | - $this->getMaxAttendees(), |
|
465 | - $template_args, |
|
466 | - $this->date_format, |
|
467 | - $this->time_format |
|
468 | - ); |
|
469 | - } |
|
470 | - |
|
471 | - |
|
472 | - /** |
|
473 | - * simpleTicketSelector |
|
474 | - * there's one ticket, and max attendees is set to one, |
|
475 | - * so if the event is free, then this is a "simple" ticket selector |
|
476 | - * a.k.a. "Dude Where's my Ticket Selector?" |
|
477 | - * |
|
478 | - * @param EE_Ticket[] $tickets |
|
479 | - * @param array $template_args |
|
480 | - * @return string |
|
481 | - * @throws EE_Error |
|
482 | - * @throws ReflectionException |
|
483 | - */ |
|
484 | - protected function simpleTicketSelector($tickets, array $template_args) |
|
485 | - { |
|
486 | - // if there is only ONE ticket with a max qty of ONE |
|
487 | - if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
488 | - return ''; |
|
489 | - } |
|
490 | - /** @var EE_Ticket $ticket */ |
|
491 | - $ticket = reset($tickets); |
|
492 | - // if the ticket is free... then not much need for the ticket selector |
|
493 | - if ( |
|
494 | - apply_filters( |
|
495 | - 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
496 | - $ticket->is_free(), |
|
497 | - $this->event->ID() |
|
498 | - ) |
|
499 | - ) { |
|
500 | - return new TicketSelectorSimple( |
|
501 | - $this->event, |
|
502 | - $ticket, |
|
503 | - $this->getMaxAttendees(), |
|
504 | - $template_args |
|
505 | - ); |
|
506 | - } |
|
507 | - return ''; |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * externalEventRegistration |
|
513 | - * |
|
514 | - * @return string |
|
515 | - */ |
|
516 | - public function externalEventRegistration() |
|
517 | - { |
|
518 | - // if not we still need to trigger the display of the submit button |
|
519 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
520 | - // display notice to admin that registration is external |
|
521 | - return $this->display_full_ui() |
|
522 | - ? esc_html__( |
|
523 | - 'Registration is at an external URL for this event.', |
|
524 | - 'event_espresso' |
|
525 | - ) |
|
526 | - : ''; |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * formOpen |
|
532 | - * |
|
533 | - * @param int $ID |
|
534 | - * @param string $external_url |
|
535 | - * @return string |
|
536 | - */ |
|
537 | - public function formOpen($ID = 0, $external_url = '') |
|
538 | - { |
|
539 | - // if redirecting, we don't need any anything else |
|
540 | - if ($external_url) { |
|
541 | - $html = '<form method="GET" '; |
|
542 | - $html .= 'action="' . EEH_URL::refactor_url($external_url) . '" '; |
|
543 | - $html .= 'name="ticket-selector-form-' . $ID . '"'; |
|
544 | - // open link in new window ? |
|
545 | - $html .= apply_filters( |
|
546 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
547 | - $this->isIframe(), |
|
548 | - $this |
|
549 | - ) |
|
550 | - ? ' target="_blank"' |
|
551 | - : ''; |
|
552 | - $html .= '>'; |
|
553 | - $query_args = EEH_URL::get_query_string($external_url); |
|
554 | - foreach ((array) $query_args as $query_arg => $value) { |
|
555 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
556 | - } |
|
557 | - return $html; |
|
558 | - } |
|
559 | - // if there is no submit button, then don't start building a form |
|
560 | - // because the "View Details" button will build its own form |
|
561 | - if (! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
562 | - return ''; |
|
563 | - } |
|
564 | - $checkout_url = EEH_Event_View::event_link_url($ID); |
|
565 | - if (! $checkout_url) { |
|
566 | - EE_Error::add_error( |
|
567 | - esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
568 | - __FILE__, |
|
569 | - __FUNCTION__, |
|
570 | - __LINE__ |
|
571 | - ); |
|
572 | - } |
|
573 | - // set no cache headers and constants |
|
574 | - EE_System::do_not_cache(); |
|
575 | - $html = '<form method="POST" '; |
|
576 | - $html .= 'action="' . $checkout_url . '" '; |
|
577 | - $html .= 'name="ticket-selector-form-' . $ID . '"'; |
|
578 | - $html .= $this->iframe ? ' target="_blank"' : ''; |
|
579 | - $html .= '>'; |
|
580 | - $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
581 | - return apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event); |
|
582 | - } |
|
583 | - |
|
584 | - |
|
585 | - /** |
|
586 | - * displaySubmitButton |
|
587 | - * |
|
588 | - * @param string $external_url |
|
589 | - * @return string |
|
590 | - * @throws EE_Error |
|
591 | - * @throws ReflectionException |
|
592 | - */ |
|
593 | - public function displaySubmitButton($external_url = '') |
|
594 | - { |
|
595 | - $html = ''; |
|
596 | - if ($this->display_full_ui()) { |
|
597 | - // standard TS displayed with submit button, ie: "Register Now" |
|
598 | - if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
599 | - $html .= $this->displayRegisterNowButton(); |
|
600 | - $html .= empty($external_url) |
|
601 | - ? $this->ticketSelectorEndDiv() |
|
602 | - : $this->clearTicketSelector(); |
|
603 | - $html .= '<br/>' . $this->formClose(); |
|
604 | - } elseif ($this->getMaxAttendees() === 1) { |
|
605 | - // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
606 | - if ($this->event->is_sold_out()) { |
|
607 | - // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
608 | - $html .= apply_filters( |
|
609 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
610 | - sprintf( |
|
611 | - esc_html__( |
|
612 | - '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
613 | - 'event_espresso' |
|
614 | - ), |
|
615 | - '<p class="no-ticket-selector-msg clear-float">', |
|
616 | - $this->event->name(), |
|
617 | - '</p>', |
|
618 | - '<br />' |
|
619 | - ), |
|
620 | - $this->event |
|
621 | - ); |
|
622 | - if ( |
|
623 | - apply_filters( |
|
624 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
625 | - false, |
|
626 | - $this->event |
|
627 | - ) |
|
628 | - ) { |
|
629 | - $html .= $this->displayRegisterNowButton(); |
|
630 | - } |
|
631 | - // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
632 | - $html .= $this->ticketSelectorEndDiv(); |
|
633 | - } elseif ( |
|
634 | - apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
635 | - && ! is_single() |
|
636 | - ) { |
|
637 | - // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
638 | - // but no tickets are available, so display event's "View Details" button. |
|
639 | - // it is being viewed via somewhere other than a single post |
|
640 | - $html .= $this->displayViewDetailsButton(true); |
|
641 | - } else { |
|
642 | - $html .= $this->ticketSelectorEndDiv(); |
|
643 | - } |
|
644 | - } elseif (is_archive()) { |
|
645 | - // event list, no tickets available so display event's "View Details" button |
|
646 | - $html .= $this->ticketSelectorEndDiv(); |
|
647 | - $html .= $this->displayViewDetailsButton(); |
|
648 | - } else { |
|
649 | - if ( |
|
650 | - apply_filters( |
|
651 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
652 | - false, |
|
653 | - $this->event |
|
654 | - ) |
|
655 | - ) { |
|
656 | - $html .= $this->displayRegisterNowButton(); |
|
657 | - } |
|
658 | - // no submit or view details button, and no additional content |
|
659 | - $html .= $this->ticketSelectorEndDiv(); |
|
660 | - } |
|
661 | - if (! $this->iframe && ! is_archive()) { |
|
662 | - $html .= EEH_Template::powered_by_event_espresso('', '', ['utm_content' => 'ticket_selector']); |
|
663 | - } |
|
664 | - } |
|
665 | - return apply_filters( |
|
666 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html', |
|
667 | - $html, |
|
668 | - $this->event, |
|
669 | - $this |
|
670 | - ); |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - /** |
|
675 | - * @return string |
|
676 | - * @throws EE_Error |
|
677 | - * @throws ReflectionException |
|
678 | - */ |
|
679 | - public function displayRegisterNowButton() |
|
680 | - { |
|
681 | - $btn_text = apply_filters( |
|
682 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
683 | - esc_html__('Register Now', 'event_espresso'), |
|
684 | - $this->event |
|
685 | - ); |
|
686 | - $external_url = (string) $this->event->external_url() |
|
687 | - && $this->event->external_url() !== get_the_permalink() |
|
688 | - ? $this->event->external_url() |
|
689 | - : ''; |
|
690 | - $html = EEH_HTML::div( |
|
691 | - '', |
|
692 | - 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', |
|
693 | - 'ticket-selector-submit-btn-wrap' |
|
694 | - ); |
|
695 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
696 | - $html .= ' class="ticket-selector-submit-btn '; |
|
697 | - $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
698 | - $html .= ' type="submit" value="' . $btn_text . '" data-ee-disable-after-recaptcha="true" />'; |
|
699 | - $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->'; |
|
700 | - $html .= apply_filters( |
|
701 | - 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
702 | - '', |
|
703 | - $this->event, |
|
704 | - $this->iframe |
|
705 | - ); |
|
706 | - return $html; |
|
707 | - } |
|
708 | - |
|
709 | - |
|
710 | - /** |
|
711 | - * displayViewDetailsButton |
|
712 | - * |
|
713 | - * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
714 | - * (ie: $_max_atndz === 1) where there are no available tickets, |
|
715 | - * either because they are sold out, expired, or not yet on sale. |
|
716 | - * In this case, we need to close the form BEFORE adding any closing divs |
|
717 | - * @return string |
|
718 | - * @throws EE_Error |
|
719 | - * @throws ReflectionException |
|
720 | - */ |
|
721 | - public function displayViewDetailsButton($DWMTS = false) |
|
722 | - { |
|
723 | - if (! $this->event->get_permalink()) { |
|
724 | - EE_Error::add_error( |
|
725 | - esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
726 | - __FILE__, |
|
727 | - __FUNCTION__, |
|
728 | - __LINE__ |
|
729 | - ); |
|
730 | - } |
|
731 | - $view_details_btn = '<form method="GET" action="'; |
|
732 | - $view_details_btn .= apply_filters( |
|
733 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
734 | - $this->event->get_permalink(), |
|
735 | - $this->event |
|
736 | - ); |
|
737 | - $view_details_btn .= '"'; |
|
738 | - // open link in new window ? |
|
739 | - $view_details_btn .= apply_filters( |
|
740 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
741 | - $this->isIframe(), |
|
742 | - $this |
|
743 | - ) |
|
744 | - ? ' target="_blank"' |
|
745 | - : ''; |
|
746 | - $view_details_btn .= '>'; |
|
747 | - $btn_text = apply_filters( |
|
748 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
749 | - esc_html__('View Details', 'event_espresso'), |
|
750 | - $this->event |
|
751 | - ); |
|
752 | - $view_details_btn .= '<input id="ticket-selector-submit-' |
|
753 | - . $this->event->ID() |
|
754 | - . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
755 | - . $btn_text |
|
756 | - . '" />'; |
|
757 | - $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event); |
|
758 | - if ($DWMTS) { |
|
759 | - $view_details_btn .= $this->formClose(); |
|
760 | - $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
761 | - $view_details_btn .= '<br/>'; |
|
762 | - } else { |
|
763 | - $view_details_btn .= $this->clearTicketSelector(); |
|
764 | - $view_details_btn .= '<br/>'; |
|
765 | - $view_details_btn .= $this->formClose(); |
|
766 | - } |
|
767 | - return $view_details_btn; |
|
768 | - } |
|
769 | - |
|
770 | - |
|
771 | - /** |
|
772 | - * @return string |
|
773 | - */ |
|
774 | - public function ticketSelectorEndDiv() |
|
775 | - { |
|
776 | - return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->'; |
|
777 | - } |
|
778 | - |
|
779 | - |
|
780 | - /** |
|
781 | - * @return string |
|
782 | - */ |
|
783 | - public function clearTicketSelector() |
|
784 | - { |
|
785 | - // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
786 | - return '<div class="clear"></div><!-- clearTicketSelector -->'; |
|
787 | - } |
|
788 | - |
|
789 | - |
|
790 | - /** |
|
791 | - * @access public |
|
792 | - * @return string |
|
793 | - */ |
|
794 | - public function formClose() |
|
795 | - { |
|
796 | - return '</form>'; |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - /** |
|
801 | - * handleMissingEvent |
|
802 | - * Returns either false or an error to display when no valid event is passed. |
|
803 | - * |
|
804 | - * @return string |
|
805 | - * @throws ExceptionStackTraceDisplay |
|
806 | - * @throws InvalidInterfaceException |
|
807 | - * @throws Exception |
|
808 | - */ |
|
809 | - protected function handleMissingEvent() |
|
810 | - { |
|
811 | - // If this is not an iFrame request, simply return false. |
|
812 | - if (! $this->isIframe()) { |
|
813 | - return ''; |
|
814 | - } |
|
815 | - // This is an iFrame so return an error. |
|
816 | - // Display stack trace if WP_DEBUG is enabled. |
|
817 | - if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
818 | - $event_id = $this->request->getRequestParam('event', 0, 'int'); |
|
819 | - new ExceptionStackTraceDisplay( |
|
820 | - new InvalidArgumentException( |
|
821 | - sprintf( |
|
822 | - esc_html__( |
|
823 | - 'A valid Event ID is required to display the ticket selector.%3$sAn Event with an ID of "%1$s" could not be found.%3$sPlease verify that the embed code added to this post\'s content includes an "%2$s" argument and that its value corresponds to a valid Event ID.', |
|
824 | - 'event_espresso' |
|
825 | - ), |
|
826 | - $event_id, |
|
827 | - 'event', |
|
828 | - '<br />' |
|
829 | - ) |
|
830 | - ) |
|
831 | - ); |
|
832 | - return ''; |
|
833 | - } |
|
834 | - // If WP_DEBUG is not enabled, display a message stating the event could not be found. |
|
835 | - return EEH_HTML::p( |
|
836 | - esc_html__( |
|
837 | - 'A valid Event could not be found. Please contact the event administrator for assistance.', |
|
838 | - 'event_espresso' |
|
839 | - ) |
|
840 | - ); |
|
841 | - } |
|
842 | - |
|
843 | - |
|
844 | - /** |
|
845 | - * @return EE_Tax_Config |
|
846 | - * @since 4.10.14.p |
|
847 | - */ |
|
848 | - protected function getTaxConfig() |
|
849 | - { |
|
850 | - return isset(EE_Registry::instance()->CFG->tax_settings) |
|
851 | - && EE_Registry::instance()->CFG->tax_settings instanceof EE_Tax_Config |
|
852 | - ? EE_Registry::instance()->CFG->tax_settings |
|
853 | - : new EE_Tax_Config(); |
|
854 | - } |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * ticketSalesClosed |
|
357 | + * notice displayed if event ticket sales are turned off |
|
358 | + * |
|
359 | + * @return string |
|
360 | + * @throws EE_Error |
|
361 | + * @throws ReflectionException |
|
362 | + */ |
|
363 | + protected function ticketSalesClosedMessage() |
|
364 | + { |
|
365 | + $sales_closed_msg = esc_html__( |
|
366 | + 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
367 | + 'event_espresso' |
|
368 | + ); |
|
369 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
370 | + $sales_closed_msg .= sprintf( |
|
371 | + esc_html__( |
|
372 | + '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
373 | + 'event_espresso' |
|
374 | + ), |
|
375 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
376 | + '</b><br />', |
|
377 | + '<span class="edit-link"><a class="post-edit-link" href="' |
|
378 | + . get_edit_post_link($this->event->ID()) |
|
379 | + . '">', |
|
380 | + '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->' |
|
381 | + ); |
|
382 | + } |
|
383 | + return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * getTickets |
|
389 | + * |
|
390 | + * @return EE_Base_Class[]|EE_Ticket[] |
|
391 | + * @throws EE_Error |
|
392 | + * @throws InvalidDataTypeException |
|
393 | + * @throws InvalidInterfaceException |
|
394 | + * @throws InvalidArgumentException |
|
395 | + * @throws ReflectionException |
|
396 | + */ |
|
397 | + protected function getTickets() |
|
398 | + { |
|
399 | + $show_expired_tickets = is_admin() || $this->config->show_expired_tickets; |
|
400 | + |
|
401 | + $ticket_query_args = [ |
|
402 | + ['Datetime.EVT_ID' => $this->event->ID()], |
|
403 | + 'order_by' => [ |
|
404 | + 'TKT_order' => 'ASC', |
|
405 | + 'TKT_required' => 'DESC', |
|
406 | + 'TKT_start_date' => 'ASC', |
|
407 | + 'TKT_end_date' => 'ASC', |
|
408 | + 'Datetime.DTT_EVT_start' => 'DESC', |
|
409 | + ], |
|
410 | + ]; |
|
411 | + if (! $show_expired_tickets) { |
|
412 | + // use the correct applicable time query depending on what version of core is being run. |
|
413 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
414 | + ? time() |
|
415 | + : current_time('timestamp'); |
|
416 | + $ticket_query_args[0]['TKT_end_date'] = ['>', $current_time]; |
|
417 | + } |
|
418 | + return EEM_Ticket::instance()->get_all($ticket_query_args); |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * loadTicketSelector |
|
424 | + * begins to assemble template arguments |
|
425 | + * and decides whether to load a "simple" ticket selector, or the standard |
|
426 | + * |
|
427 | + * @param EE_Ticket[] $tickets |
|
428 | + * @param array $template_args |
|
429 | + * @return TicketSelectorSimple|TicketSelectorStandard |
|
430 | + * @throws EE_Error |
|
431 | + * @throws ReflectionException |
|
432 | + */ |
|
433 | + protected function loadTicketSelector(array $tickets, array $template_args) |
|
434 | + { |
|
435 | + $template_args['event'] = $this->event; |
|
436 | + $template_args['EVT_ID'] = $this->event->ID(); |
|
437 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
438 | + $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
439 | + $template_args['date_format'] = $this->date_format; |
|
440 | + $template_args['time_format'] = $this->time_format; |
|
441 | + /** |
|
442 | + * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
443 | + * |
|
444 | + * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
445 | + * @param int $EVT_ID The Event ID |
|
446 | + * @since 4.9.13 |
|
447 | + */ |
|
448 | + $template_args['anchor_id'] = apply_filters( |
|
449 | + 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
450 | + '#tkt-slctr-tbl-' . $this->event->ID(), |
|
451 | + $this->event->ID() |
|
452 | + ); |
|
453 | + $template_args['tickets'] = $tickets; |
|
454 | + $template_args['ticket_count'] = count($tickets); |
|
455 | + $ticket_selector = $this->simpleTicketSelector($tickets, $template_args); |
|
456 | + if ($ticket_selector instanceof TicketSelectorSimple) { |
|
457 | + return $ticket_selector; |
|
458 | + } |
|
459 | + return new TicketSelectorStandard( |
|
460 | + $this->config, |
|
461 | + $this->getTaxConfig(), |
|
462 | + $this->event, |
|
463 | + $tickets, |
|
464 | + $this->getMaxAttendees(), |
|
465 | + $template_args, |
|
466 | + $this->date_format, |
|
467 | + $this->time_format |
|
468 | + ); |
|
469 | + } |
|
470 | + |
|
471 | + |
|
472 | + /** |
|
473 | + * simpleTicketSelector |
|
474 | + * there's one ticket, and max attendees is set to one, |
|
475 | + * so if the event is free, then this is a "simple" ticket selector |
|
476 | + * a.k.a. "Dude Where's my Ticket Selector?" |
|
477 | + * |
|
478 | + * @param EE_Ticket[] $tickets |
|
479 | + * @param array $template_args |
|
480 | + * @return string |
|
481 | + * @throws EE_Error |
|
482 | + * @throws ReflectionException |
|
483 | + */ |
|
484 | + protected function simpleTicketSelector($tickets, array $template_args) |
|
485 | + { |
|
486 | + // if there is only ONE ticket with a max qty of ONE |
|
487 | + if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
488 | + return ''; |
|
489 | + } |
|
490 | + /** @var EE_Ticket $ticket */ |
|
491 | + $ticket = reset($tickets); |
|
492 | + // if the ticket is free... then not much need for the ticket selector |
|
493 | + if ( |
|
494 | + apply_filters( |
|
495 | + 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
496 | + $ticket->is_free(), |
|
497 | + $this->event->ID() |
|
498 | + ) |
|
499 | + ) { |
|
500 | + return new TicketSelectorSimple( |
|
501 | + $this->event, |
|
502 | + $ticket, |
|
503 | + $this->getMaxAttendees(), |
|
504 | + $template_args |
|
505 | + ); |
|
506 | + } |
|
507 | + return ''; |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * externalEventRegistration |
|
513 | + * |
|
514 | + * @return string |
|
515 | + */ |
|
516 | + public function externalEventRegistration() |
|
517 | + { |
|
518 | + // if not we still need to trigger the display of the submit button |
|
519 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
520 | + // display notice to admin that registration is external |
|
521 | + return $this->display_full_ui() |
|
522 | + ? esc_html__( |
|
523 | + 'Registration is at an external URL for this event.', |
|
524 | + 'event_espresso' |
|
525 | + ) |
|
526 | + : ''; |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * formOpen |
|
532 | + * |
|
533 | + * @param int $ID |
|
534 | + * @param string $external_url |
|
535 | + * @return string |
|
536 | + */ |
|
537 | + public function formOpen($ID = 0, $external_url = '') |
|
538 | + { |
|
539 | + // if redirecting, we don't need any anything else |
|
540 | + if ($external_url) { |
|
541 | + $html = '<form method="GET" '; |
|
542 | + $html .= 'action="' . EEH_URL::refactor_url($external_url) . '" '; |
|
543 | + $html .= 'name="ticket-selector-form-' . $ID . '"'; |
|
544 | + // open link in new window ? |
|
545 | + $html .= apply_filters( |
|
546 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
547 | + $this->isIframe(), |
|
548 | + $this |
|
549 | + ) |
|
550 | + ? ' target="_blank"' |
|
551 | + : ''; |
|
552 | + $html .= '>'; |
|
553 | + $query_args = EEH_URL::get_query_string($external_url); |
|
554 | + foreach ((array) $query_args as $query_arg => $value) { |
|
555 | + $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
556 | + } |
|
557 | + return $html; |
|
558 | + } |
|
559 | + // if there is no submit button, then don't start building a form |
|
560 | + // because the "View Details" button will build its own form |
|
561 | + if (! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
562 | + return ''; |
|
563 | + } |
|
564 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
565 | + if (! $checkout_url) { |
|
566 | + EE_Error::add_error( |
|
567 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
568 | + __FILE__, |
|
569 | + __FUNCTION__, |
|
570 | + __LINE__ |
|
571 | + ); |
|
572 | + } |
|
573 | + // set no cache headers and constants |
|
574 | + EE_System::do_not_cache(); |
|
575 | + $html = '<form method="POST" '; |
|
576 | + $html .= 'action="' . $checkout_url . '" '; |
|
577 | + $html .= 'name="ticket-selector-form-' . $ID . '"'; |
|
578 | + $html .= $this->iframe ? ' target="_blank"' : ''; |
|
579 | + $html .= '>'; |
|
580 | + $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
581 | + return apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event); |
|
582 | + } |
|
583 | + |
|
584 | + |
|
585 | + /** |
|
586 | + * displaySubmitButton |
|
587 | + * |
|
588 | + * @param string $external_url |
|
589 | + * @return string |
|
590 | + * @throws EE_Error |
|
591 | + * @throws ReflectionException |
|
592 | + */ |
|
593 | + public function displaySubmitButton($external_url = '') |
|
594 | + { |
|
595 | + $html = ''; |
|
596 | + if ($this->display_full_ui()) { |
|
597 | + // standard TS displayed with submit button, ie: "Register Now" |
|
598 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
599 | + $html .= $this->displayRegisterNowButton(); |
|
600 | + $html .= empty($external_url) |
|
601 | + ? $this->ticketSelectorEndDiv() |
|
602 | + : $this->clearTicketSelector(); |
|
603 | + $html .= '<br/>' . $this->formClose(); |
|
604 | + } elseif ($this->getMaxAttendees() === 1) { |
|
605 | + // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
606 | + if ($this->event->is_sold_out()) { |
|
607 | + // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
608 | + $html .= apply_filters( |
|
609 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
610 | + sprintf( |
|
611 | + esc_html__( |
|
612 | + '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
613 | + 'event_espresso' |
|
614 | + ), |
|
615 | + '<p class="no-ticket-selector-msg clear-float">', |
|
616 | + $this->event->name(), |
|
617 | + '</p>', |
|
618 | + '<br />' |
|
619 | + ), |
|
620 | + $this->event |
|
621 | + ); |
|
622 | + if ( |
|
623 | + apply_filters( |
|
624 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
625 | + false, |
|
626 | + $this->event |
|
627 | + ) |
|
628 | + ) { |
|
629 | + $html .= $this->displayRegisterNowButton(); |
|
630 | + } |
|
631 | + // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
632 | + $html .= $this->ticketSelectorEndDiv(); |
|
633 | + } elseif ( |
|
634 | + apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
635 | + && ! is_single() |
|
636 | + ) { |
|
637 | + // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
638 | + // but no tickets are available, so display event's "View Details" button. |
|
639 | + // it is being viewed via somewhere other than a single post |
|
640 | + $html .= $this->displayViewDetailsButton(true); |
|
641 | + } else { |
|
642 | + $html .= $this->ticketSelectorEndDiv(); |
|
643 | + } |
|
644 | + } elseif (is_archive()) { |
|
645 | + // event list, no tickets available so display event's "View Details" button |
|
646 | + $html .= $this->ticketSelectorEndDiv(); |
|
647 | + $html .= $this->displayViewDetailsButton(); |
|
648 | + } else { |
|
649 | + if ( |
|
650 | + apply_filters( |
|
651 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
652 | + false, |
|
653 | + $this->event |
|
654 | + ) |
|
655 | + ) { |
|
656 | + $html .= $this->displayRegisterNowButton(); |
|
657 | + } |
|
658 | + // no submit or view details button, and no additional content |
|
659 | + $html .= $this->ticketSelectorEndDiv(); |
|
660 | + } |
|
661 | + if (! $this->iframe && ! is_archive()) { |
|
662 | + $html .= EEH_Template::powered_by_event_espresso('', '', ['utm_content' => 'ticket_selector']); |
|
663 | + } |
|
664 | + } |
|
665 | + return apply_filters( |
|
666 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html', |
|
667 | + $html, |
|
668 | + $this->event, |
|
669 | + $this |
|
670 | + ); |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + /** |
|
675 | + * @return string |
|
676 | + * @throws EE_Error |
|
677 | + * @throws ReflectionException |
|
678 | + */ |
|
679 | + public function displayRegisterNowButton() |
|
680 | + { |
|
681 | + $btn_text = apply_filters( |
|
682 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
683 | + esc_html__('Register Now', 'event_espresso'), |
|
684 | + $this->event |
|
685 | + ); |
|
686 | + $external_url = (string) $this->event->external_url() |
|
687 | + && $this->event->external_url() !== get_the_permalink() |
|
688 | + ? $this->event->external_url() |
|
689 | + : ''; |
|
690 | + $html = EEH_HTML::div( |
|
691 | + '', |
|
692 | + 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', |
|
693 | + 'ticket-selector-submit-btn-wrap' |
|
694 | + ); |
|
695 | + $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
696 | + $html .= ' class="ticket-selector-submit-btn '; |
|
697 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
698 | + $html .= ' type="submit" value="' . $btn_text . '" data-ee-disable-after-recaptcha="true" />'; |
|
699 | + $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->'; |
|
700 | + $html .= apply_filters( |
|
701 | + 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
702 | + '', |
|
703 | + $this->event, |
|
704 | + $this->iframe |
|
705 | + ); |
|
706 | + return $html; |
|
707 | + } |
|
708 | + |
|
709 | + |
|
710 | + /** |
|
711 | + * displayViewDetailsButton |
|
712 | + * |
|
713 | + * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
714 | + * (ie: $_max_atndz === 1) where there are no available tickets, |
|
715 | + * either because they are sold out, expired, or not yet on sale. |
|
716 | + * In this case, we need to close the form BEFORE adding any closing divs |
|
717 | + * @return string |
|
718 | + * @throws EE_Error |
|
719 | + * @throws ReflectionException |
|
720 | + */ |
|
721 | + public function displayViewDetailsButton($DWMTS = false) |
|
722 | + { |
|
723 | + if (! $this->event->get_permalink()) { |
|
724 | + EE_Error::add_error( |
|
725 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
726 | + __FILE__, |
|
727 | + __FUNCTION__, |
|
728 | + __LINE__ |
|
729 | + ); |
|
730 | + } |
|
731 | + $view_details_btn = '<form method="GET" action="'; |
|
732 | + $view_details_btn .= apply_filters( |
|
733 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
734 | + $this->event->get_permalink(), |
|
735 | + $this->event |
|
736 | + ); |
|
737 | + $view_details_btn .= '"'; |
|
738 | + // open link in new window ? |
|
739 | + $view_details_btn .= apply_filters( |
|
740 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
741 | + $this->isIframe(), |
|
742 | + $this |
|
743 | + ) |
|
744 | + ? ' target="_blank"' |
|
745 | + : ''; |
|
746 | + $view_details_btn .= '>'; |
|
747 | + $btn_text = apply_filters( |
|
748 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
749 | + esc_html__('View Details', 'event_espresso'), |
|
750 | + $this->event |
|
751 | + ); |
|
752 | + $view_details_btn .= '<input id="ticket-selector-submit-' |
|
753 | + . $this->event->ID() |
|
754 | + . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
755 | + . $btn_text |
|
756 | + . '" />'; |
|
757 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event); |
|
758 | + if ($DWMTS) { |
|
759 | + $view_details_btn .= $this->formClose(); |
|
760 | + $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
761 | + $view_details_btn .= '<br/>'; |
|
762 | + } else { |
|
763 | + $view_details_btn .= $this->clearTicketSelector(); |
|
764 | + $view_details_btn .= '<br/>'; |
|
765 | + $view_details_btn .= $this->formClose(); |
|
766 | + } |
|
767 | + return $view_details_btn; |
|
768 | + } |
|
769 | + |
|
770 | + |
|
771 | + /** |
|
772 | + * @return string |
|
773 | + */ |
|
774 | + public function ticketSelectorEndDiv() |
|
775 | + { |
|
776 | + return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->'; |
|
777 | + } |
|
778 | + |
|
779 | + |
|
780 | + /** |
|
781 | + * @return string |
|
782 | + */ |
|
783 | + public function clearTicketSelector() |
|
784 | + { |
|
785 | + // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
786 | + return '<div class="clear"></div><!-- clearTicketSelector -->'; |
|
787 | + } |
|
788 | + |
|
789 | + |
|
790 | + /** |
|
791 | + * @access public |
|
792 | + * @return string |
|
793 | + */ |
|
794 | + public function formClose() |
|
795 | + { |
|
796 | + return '</form>'; |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + /** |
|
801 | + * handleMissingEvent |
|
802 | + * Returns either false or an error to display when no valid event is passed. |
|
803 | + * |
|
804 | + * @return string |
|
805 | + * @throws ExceptionStackTraceDisplay |
|
806 | + * @throws InvalidInterfaceException |
|
807 | + * @throws Exception |
|
808 | + */ |
|
809 | + protected function handleMissingEvent() |
|
810 | + { |
|
811 | + // If this is not an iFrame request, simply return false. |
|
812 | + if (! $this->isIframe()) { |
|
813 | + return ''; |
|
814 | + } |
|
815 | + // This is an iFrame so return an error. |
|
816 | + // Display stack trace if WP_DEBUG is enabled. |
|
817 | + if (WP_DEBUG === true && current_user_can('edit_pages')) { |
|
818 | + $event_id = $this->request->getRequestParam('event', 0, 'int'); |
|
819 | + new ExceptionStackTraceDisplay( |
|
820 | + new InvalidArgumentException( |
|
821 | + sprintf( |
|
822 | + esc_html__( |
|
823 | + 'A valid Event ID is required to display the ticket selector.%3$sAn Event with an ID of "%1$s" could not be found.%3$sPlease verify that the embed code added to this post\'s content includes an "%2$s" argument and that its value corresponds to a valid Event ID.', |
|
824 | + 'event_espresso' |
|
825 | + ), |
|
826 | + $event_id, |
|
827 | + 'event', |
|
828 | + '<br />' |
|
829 | + ) |
|
830 | + ) |
|
831 | + ); |
|
832 | + return ''; |
|
833 | + } |
|
834 | + // If WP_DEBUG is not enabled, display a message stating the event could not be found. |
|
835 | + return EEH_HTML::p( |
|
836 | + esc_html__( |
|
837 | + 'A valid Event could not be found. Please contact the event administrator for assistance.', |
|
838 | + 'event_espresso' |
|
839 | + ) |
|
840 | + ); |
|
841 | + } |
|
842 | + |
|
843 | + |
|
844 | + /** |
|
845 | + * @return EE_Tax_Config |
|
846 | + * @since 4.10.14.p |
|
847 | + */ |
|
848 | + protected function getTaxConfig() |
|
849 | + { |
|
850 | + return isset(EE_Registry::instance()->CFG->tax_settings) |
|
851 | + && EE_Registry::instance()->CFG->tax_settings instanceof EE_Tax_Config |
|
852 | + ? EE_Registry::instance()->CFG->tax_settings |
|
853 | + : new EE_Tax_Config(); |
|
854 | + } |
|
855 | 855 | } |
@@ -15,186 +15,186 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * @var \EE_Ticket $ticket |
|
20 | - */ |
|
21 | - protected $ticket; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var \EE_Ticket_Selector_Config $template_settings |
|
25 | - */ |
|
26 | - protected $template_settings; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string $date_format |
|
30 | - */ |
|
31 | - protected $date_format; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string $time_format |
|
35 | - */ |
|
36 | - protected $time_format; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var boolean $event_is_expired |
|
40 | - */ |
|
41 | - protected $event_is_expired; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * TicketDetails constructor. |
|
46 | - * |
|
47 | - * @param \EE_Ticket $ticket |
|
48 | - * @param \EE_Ticket_Selector_Config $template_settings |
|
49 | - * @param array $template_args |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - \EE_Ticket $ticket, |
|
53 | - \EE_Ticket_Selector_Config $template_settings, |
|
54 | - array $template_args |
|
55 | - ) { |
|
56 | - $this->ticket = $ticket; |
|
57 | - $this->template_settings = $template_settings; |
|
58 | - $this->date_format = $template_args['date_format']; |
|
59 | - $this->time_format = $template_args['time_format']; |
|
60 | - $this->event_is_expired = $template_args['event_is_expired']; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * @return \EE_Ticket |
|
66 | - */ |
|
67 | - public function getTicket() |
|
68 | - { |
|
69 | - return $this->ticket; |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function showTicketDetails() |
|
77 | - { |
|
78 | - return $this->template_settings->show_ticket_details; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @return \EE_Ticket_Selector_Config |
|
84 | - */ |
|
85 | - public function getTemplateSettings() |
|
86 | - { |
|
87 | - return $this->template_settings; |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function getDateFormat() |
|
95 | - { |
|
96 | - return $this->date_format; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getTimeFormat() |
|
104 | - { |
|
105 | - return $this->time_format; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getShowHideLinks() |
|
113 | - { |
|
114 | - if (! $this->showTicketDetails()) { |
|
115 | - return ''; |
|
116 | - } |
|
117 | - return \EEH_HTML::link( |
|
118 | - '', |
|
119 | - sprintf(esc_html__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
120 | - esc_attr( |
|
121 | - apply_filters( |
|
122 | - 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
123 | - esc_html__('click to show additional ticket details', 'event_espresso') |
|
124 | - ) |
|
125 | - ), |
|
126 | - "display-{$this->cssId()}", |
|
127 | - 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
128 | - '', |
|
129 | - 'rel="' . $this->cssId() . '"' |
|
130 | - ) . \EEH_HTML::link( |
|
131 | - '', |
|
132 | - sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
133 | - esc_attr( |
|
134 | - apply_filters( |
|
135 | - 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
136 | - esc_html__('click to hide additional ticket details', 'event_espresso') |
|
137 | - ) |
|
138 | - ), |
|
139 | - "hide-{$this->cssId()}", |
|
140 | - 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
141 | - 'display:none;', |
|
142 | - 'rel="' . $this->cssId() . '"' |
|
143 | - ); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - public function cssId() |
|
151 | - { |
|
152 | - return apply_filters( |
|
153 | - 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
154 | - "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * @param float $ticket_price |
|
161 | - * @param int $remaining |
|
162 | - * @param int $cols |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function display( |
|
166 | - $ticket_price = 0.00, |
|
167 | - $remaining, |
|
168 | - $cols = 2 |
|
169 | - ) { |
|
170 | - $template_args = array(); |
|
171 | - $template_args['ticket'] = $this->ticket; |
|
172 | - $template_args['ticket_price'] = $ticket_price; |
|
173 | - $template_args['remaining'] = $remaining; |
|
174 | - $template_args['cols'] = $cols; |
|
175 | - $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
176 | - $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
177 | - $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
178 | - $template_args['ticket_details_css_id'] = $this->cssId(); |
|
179 | - $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
180 | - 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
181 | - true |
|
182 | - ); |
|
183 | - $template_args['price_breakdown_heading'] = apply_filters( |
|
184 | - 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
185 | - esc_html__('Price', 'event_espresso') |
|
186 | - ); |
|
187 | - $template_args['date_format'] = $this->date_format; |
|
188 | - $template_args['time_format'] = $this->time_format; |
|
189 | - $template_args['event_is_expired'] = $this->event_is_expired; |
|
190 | - |
|
191 | - return \EEH_Template::locate_template( |
|
192 | - apply_filters( |
|
193 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
194 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
195 | - $this->ticket |
|
196 | - ), |
|
197 | - $template_args |
|
198 | - ); |
|
199 | - } |
|
18 | + /** |
|
19 | + * @var \EE_Ticket $ticket |
|
20 | + */ |
|
21 | + protected $ticket; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var \EE_Ticket_Selector_Config $template_settings |
|
25 | + */ |
|
26 | + protected $template_settings; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string $date_format |
|
30 | + */ |
|
31 | + protected $date_format; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string $time_format |
|
35 | + */ |
|
36 | + protected $time_format; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var boolean $event_is_expired |
|
40 | + */ |
|
41 | + protected $event_is_expired; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * TicketDetails constructor. |
|
46 | + * |
|
47 | + * @param \EE_Ticket $ticket |
|
48 | + * @param \EE_Ticket_Selector_Config $template_settings |
|
49 | + * @param array $template_args |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + \EE_Ticket $ticket, |
|
53 | + \EE_Ticket_Selector_Config $template_settings, |
|
54 | + array $template_args |
|
55 | + ) { |
|
56 | + $this->ticket = $ticket; |
|
57 | + $this->template_settings = $template_settings; |
|
58 | + $this->date_format = $template_args['date_format']; |
|
59 | + $this->time_format = $template_args['time_format']; |
|
60 | + $this->event_is_expired = $template_args['event_is_expired']; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * @return \EE_Ticket |
|
66 | + */ |
|
67 | + public function getTicket() |
|
68 | + { |
|
69 | + return $this->ticket; |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function showTicketDetails() |
|
77 | + { |
|
78 | + return $this->template_settings->show_ticket_details; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @return \EE_Ticket_Selector_Config |
|
84 | + */ |
|
85 | + public function getTemplateSettings() |
|
86 | + { |
|
87 | + return $this->template_settings; |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function getDateFormat() |
|
95 | + { |
|
96 | + return $this->date_format; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function getTimeFormat() |
|
104 | + { |
|
105 | + return $this->time_format; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getShowHideLinks() |
|
113 | + { |
|
114 | + if (! $this->showTicketDetails()) { |
|
115 | + return ''; |
|
116 | + } |
|
117 | + return \EEH_HTML::link( |
|
118 | + '', |
|
119 | + sprintf(esc_html__('show%1$sdetails%1$s+', 'event_espresso'), ' '), |
|
120 | + esc_attr( |
|
121 | + apply_filters( |
|
122 | + 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', |
|
123 | + esc_html__('click to show additional ticket details', 'event_espresso') |
|
124 | + ) |
|
125 | + ), |
|
126 | + "display-{$this->cssId()}", |
|
127 | + 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
|
128 | + '', |
|
129 | + 'rel="' . $this->cssId() . '"' |
|
130 | + ) . \EEH_HTML::link( |
|
131 | + '', |
|
132 | + sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
|
133 | + esc_attr( |
|
134 | + apply_filters( |
|
135 | + 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', |
|
136 | + esc_html__('click to hide additional ticket details', 'event_espresso') |
|
137 | + ) |
|
138 | + ), |
|
139 | + "hide-{$this->cssId()}", |
|
140 | + 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
|
141 | + 'display:none;', |
|
142 | + 'rel="' . $this->cssId() . '"' |
|
143 | + ); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + public function cssId() |
|
151 | + { |
|
152 | + return apply_filters( |
|
153 | + 'FHEE__ticket_selector_chart_template__ticket_details_css_id', |
|
154 | + "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}" |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * @param float $ticket_price |
|
161 | + * @param int $remaining |
|
162 | + * @param int $cols |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function display( |
|
166 | + $ticket_price = 0.00, |
|
167 | + $remaining, |
|
168 | + $cols = 2 |
|
169 | + ) { |
|
170 | + $template_args = array(); |
|
171 | + $template_args['ticket'] = $this->ticket; |
|
172 | + $template_args['ticket_price'] = $ticket_price; |
|
173 | + $template_args['remaining'] = $remaining; |
|
174 | + $template_args['cols'] = $cols; |
|
175 | + $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details; |
|
176 | + $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns; |
|
177 | + $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details'); |
|
178 | + $template_args['ticket_details_css_id'] = $this->cssId(); |
|
179 | + $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters( |
|
180 | + 'FHEE__ticket_selector_chart_template__display_ticket_price_details', |
|
181 | + true |
|
182 | + ); |
|
183 | + $template_args['price_breakdown_heading'] = apply_filters( |
|
184 | + 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
185 | + esc_html__('Price', 'event_espresso') |
|
186 | + ); |
|
187 | + $template_args['date_format'] = $this->date_format; |
|
188 | + $template_args['time_format'] = $this->time_format; |
|
189 | + $template_args['event_is_expired'] = $this->event_is_expired; |
|
190 | + |
|
191 | + return \EEH_Template::locate_template( |
|
192 | + apply_filters( |
|
193 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
|
194 | + TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
195 | + $this->ticket |
|
196 | + ), |
|
197 | + $template_args |
|
198 | + ); |
|
199 | + } |
|
200 | 200 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getShowHideLinks() |
113 | 113 | { |
114 | - if (! $this->showTicketDetails()) { |
|
114 | + if ( ! $this->showTicketDetails()) { |
|
115 | 115 | return ''; |
116 | 116 | } |
117 | 117 | return \EEH_HTML::link( |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | "display-{$this->cssId()}", |
127 | 127 | 'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js', |
128 | 128 | '', |
129 | - 'rel="' . $this->cssId() . '"' |
|
130 | - ) . \EEH_HTML::link( |
|
129 | + 'rel="'.$this->cssId().'"' |
|
130 | + ).\EEH_HTML::link( |
|
131 | 131 | '', |
132 | 132 | sprintf(esc_html__('hide%1$sdetails%1$s-', 'event_espresso'), ' '), |
133 | 133 | esc_attr( |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | "hide-{$this->cssId()}", |
140 | 140 | 'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js', |
141 | 141 | 'display:none;', |
142 | - 'rel="' . $this->cssId() . '"' |
|
142 | + 'rel="'.$this->cssId().'"' |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | return \EEH_Template::locate_template( |
192 | 192 | apply_filters( |
193 | 193 | 'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path', |
194 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php', |
|
194 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_details.template.php', |
|
195 | 195 | $this->ticket |
196 | 196 | ), |
197 | 197 | $template_args |
@@ -18,373 +18,373 @@ |
||
18 | 18 | abstract class TicketSelectorRow |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EE_Ticket $ticket |
|
23 | - */ |
|
24 | - protected $ticket; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var int $total_tickets |
|
28 | - */ |
|
29 | - protected $total_tickets; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var int $max_attendees |
|
33 | - */ |
|
34 | - protected $max_attendees; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string $date_format |
|
38 | - */ |
|
39 | - protected $date_format; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var int $EVT_ID |
|
43 | - */ |
|
44 | - protected $EVT_ID; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string $event_status |
|
48 | - */ |
|
49 | - protected $event_status; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var boolean $required_ticket_sold_out |
|
53 | - */ |
|
54 | - protected $required_ticket_sold_out; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var string $ticket_status_display |
|
58 | - */ |
|
59 | - protected $ticket_status_display; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var int $max |
|
63 | - */ |
|
64 | - protected $max = 0; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var int $min |
|
68 | - */ |
|
69 | - protected $min = 0; |
|
70 | - |
|
71 | - /** |
|
72 | - * @var float $ticket_price |
|
73 | - */ |
|
74 | - protected $ticket_price = 0.00; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var bool $ticket_bundle |
|
78 | - */ |
|
79 | - protected $ticket_bundle = false; |
|
80 | - |
|
81 | - /** |
|
82 | - * @var string $ticket_status_id |
|
83 | - */ |
|
84 | - protected $ticket_status_id = EE_Ticket::sold_out; |
|
85 | - |
|
86 | - /** |
|
87 | - * @var string $ticket_status_html |
|
88 | - */ |
|
89 | - protected $ticket_status_html = 'ticket-sales-sold-out'; |
|
90 | - |
|
91 | - /** |
|
92 | - * @var string $status_class |
|
93 | - */ |
|
94 | - protected $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @param EE_Ticket $ticket |
|
99 | - * @param int $max_attendees |
|
100 | - * @param string $date_format |
|
101 | - * @param string $event_status |
|
102 | - * @param bool $required_ticket_sold_out |
|
103 | - * @param int $total_tickets |
|
104 | - * @throws EE_Error |
|
105 | - * @throws UnexpectedEntityException |
|
106 | - */ |
|
107 | - public function __construct( |
|
108 | - EE_Ticket $ticket, |
|
109 | - $max_attendees, |
|
110 | - $date_format, |
|
111 | - $event_status, |
|
112 | - $required_ticket_sold_out = false, |
|
113 | - $total_tickets = 1 |
|
114 | - ) { |
|
115 | - $this->ticket = $ticket; |
|
116 | - $this->max_attendees = $max_attendees; |
|
117 | - $this->date_format = $date_format; |
|
118 | - $this->EVT_ID = $this->ticket->get_event_ID(); |
|
119 | - $this->event_status = $event_status; |
|
120 | - $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
121 | - $this->total_tickets = $total_tickets; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * getTicketStatusClasses |
|
127 | - * |
|
128 | - * @param int $remaining |
|
129 | - * @return void |
|
130 | - * @throws EE_Error |
|
131 | - */ |
|
132 | - protected function setTicketStatusClasses($remaining = 0) |
|
133 | - { |
|
134 | - // if a previous required ticket with the same sale start date is sold out, |
|
135 | - // then mark this ticket as sold out as well. |
|
136 | - // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
137 | - $this->ticket_status_id = $this->required_ticket_sold_out !== false |
|
138 | - && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
139 | - ? EE_Ticket::sold_out |
|
140 | - : $this->ticket->ticket_status(); |
|
141 | - $this->ticket_status_id = $this->event_status === EE_Datetime::sold_out |
|
142 | - ? EE_Ticket::sold_out |
|
143 | - : $this->ticket_status_id; |
|
144 | - // If at admin area, display expired tickets as on sale. |
|
145 | - $this->ticket_status_id = is_admin() && $this->ticket_status_id === EE_Ticket::expired |
|
146 | - ? EE_Ticket::onsale |
|
147 | - : $this->ticket_status_id; |
|
148 | - // check ticket status |
|
149 | - switch ($this->ticket_status_id) { |
|
150 | - // sold_out |
|
151 | - case EE_Ticket::sold_out: |
|
152 | - $ticket_status_class = 'ticket-sales-sold-out'; |
|
153 | - $this->status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
154 | - break; |
|
155 | - // expired |
|
156 | - case EE_Ticket::expired: |
|
157 | - $ticket_status_class = 'ticket-sales-expired'; |
|
158 | - $this->status_class = 'ticket-sales-expired lt-grey-text'; |
|
159 | - break; |
|
160 | - // archived |
|
161 | - case EE_Ticket::archived: |
|
162 | - $ticket_status_class = 'archived-ticket'; |
|
163 | - $this->status_class = 'archived-ticket hidden'; |
|
164 | - break; |
|
165 | - // pending |
|
166 | - case EE_Ticket::pending: |
|
167 | - $ticket_status_class = 'ticket-pending'; |
|
168 | - $this->status_class = 'ticket-pending'; |
|
169 | - break; |
|
170 | - // on sale |
|
171 | - case EE_Ticket::onsale: |
|
172 | - default: |
|
173 | - $ticket_status_class = 'ticket-on-sale'; |
|
174 | - $this->status_class = 'ticket-on-sale'; |
|
175 | - break; |
|
176 | - } |
|
177 | - $this->ticket_status_html = EEH_HTML::span( |
|
178 | - $this->ticket->ticket_status(true, ($remaining > 0)), |
|
179 | - "{$ticket_status_class}-{$this->ticket->ID()}", |
|
180 | - $ticket_status_class |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - public function getTicketStatusDisplay() |
|
189 | - { |
|
190 | - return $this->ticket_status_display; |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * setTicketStatusDisplay |
|
196 | - * |
|
197 | - * @param int $remaining |
|
198 | - * @throws EE_Error |
|
199 | - */ |
|
200 | - protected function setTicketStatusDisplay($remaining) |
|
201 | - { |
|
202 | - $this->ticket_status_display = ''; |
|
203 | - |
|
204 | - // now depending on the ticket and other circumstances... |
|
205 | - if ($this->max_attendees === 0) { |
|
206 | - // registration is CLOSED because admin set max attendees to ZERO |
|
207 | - $this->ticket_status_display = $this->registrationClosed(); |
|
208 | - } elseif ($this->ticket_status_id === EE_Ticket::sold_out || $remaining === 0) { |
|
209 | - // SOLD OUT - no tickets remaining |
|
210 | - $this->ticket_status_display = $this->ticketsSoldOut(); |
|
211 | - } elseif ($this->ticket_status_id === EE_Ticket::expired || $this->ticket_status_id === EE_Ticket::archived) { |
|
212 | - // expired or archived ticket |
|
213 | - $this->ticket_status_display = $this->ticket_status_html; |
|
214 | - } elseif ($this->ticket_status_id === EE_Ticket::pending) { |
|
215 | - // ticket not on sale yet |
|
216 | - $this->ticket_status_display = $this->ticketsSalesPending(); |
|
217 | - } elseif ($this->ticket->min() > $remaining) { |
|
218 | - // min qty purchasable is less than tickets available |
|
219 | - $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * registrationClosed |
|
226 | - */ |
|
227 | - protected function registrationClosed() |
|
228 | - { |
|
229 | - return EEH_HTML::span( |
|
230 | - apply_filters( |
|
231 | - 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
232 | - esc_html__('Closed', 'event_espresso') |
|
233 | - ), |
|
234 | - '', |
|
235 | - 'sold-out' |
|
236 | - ); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * ticketsSoldOut |
|
242 | - */ |
|
243 | - protected function ticketsSoldOut() |
|
244 | - { |
|
245 | - return EEH_HTML::span( |
|
246 | - apply_filters( |
|
247 | - 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
248 | - esc_html__('Sold Out', 'event_espresso') |
|
249 | - ), |
|
250 | - '', |
|
251 | - 'sold-out' |
|
252 | - ); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * ticketsSalesPending |
|
258 | - * |
|
259 | - * @throws EE_Error |
|
260 | - */ |
|
261 | - protected function ticketsSalesPending() |
|
262 | - { |
|
263 | - return EEH_HTML::span( |
|
264 | - EEH_HTML::span( |
|
265 | - apply_filters( |
|
266 | - 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
267 | - esc_html__('Goes On Sale', 'event_espresso') |
|
268 | - ), |
|
269 | - '', |
|
270 | - 'ticket-pending' |
|
271 | - ) |
|
272 | - . EEH_HTML::br() |
|
273 | - . EEH_HTML::span( |
|
274 | - $this->ticket->get_i18n_datetime( |
|
275 | - 'TKT_start_date', |
|
276 | - apply_filters( |
|
277 | - 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
278 | - $this->date_format |
|
279 | - ) |
|
280 | - ), |
|
281 | - '', |
|
282 | - 'small-text' |
|
283 | - ), |
|
284 | - '', |
|
285 | - 'ticket-pending-pg' |
|
286 | - ); |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * notEnoughTicketsAvailable |
|
292 | - */ |
|
293 | - protected function notEnoughTicketsAvailable() |
|
294 | - { |
|
295 | - return EEH_HTML::div( |
|
296 | - EEH_HTML::span( |
|
297 | - apply_filters( |
|
298 | - 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
299 | - esc_html__('Not Available', 'event_espresso') |
|
300 | - ), |
|
301 | - '', |
|
302 | - 'archived-ticket small-text' |
|
303 | - ) |
|
304 | - . EEH_HTML::br(), |
|
305 | - '', |
|
306 | - 'archived-ticket-pg' |
|
307 | - ); |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * setTicketMinAndMax |
|
313 | - * |
|
314 | - * @param int $remaining |
|
315 | - * @return void |
|
316 | - * @throws EE_Error |
|
317 | - */ |
|
318 | - protected function setTicketMinAndMax($remaining) |
|
319 | - { |
|
320 | - // offer the number of $tickets_remaining or $this->max_attendees, whichever is smaller |
|
321 | - $this->max = min($remaining, $this->max_attendees); |
|
322 | - // but... we also want to restrict the number of tickets by the ticket max setting, |
|
323 | - // however, the max still can't be higher than what was just set above |
|
324 | - $this->max = $this->ticket->max() > 0 |
|
325 | - ? min($this->ticket->max(), $this->max) |
|
326 | - : $this->max; |
|
327 | - // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
328 | - $this->min = $this->ticket->min() > 0 |
|
329 | - ? $this->ticket->min() |
|
330 | - : 0; |
|
331 | - // and if the ticket is required, then make sure that min qty is at least 1 |
|
332 | - $this->min = $this->ticket->required() |
|
333 | - ? max($this->min, 1) |
|
334 | - : $this->min; |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Allow plugins to hook in and abort the generation and display of this row to do |
|
340 | - * something elseif they want. |
|
341 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
342 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
343 | - * current row. |
|
344 | - * |
|
345 | - * @return string|bool |
|
346 | - */ |
|
347 | - protected function getFilteredRowHtml() |
|
348 | - { |
|
349 | - return apply_filters( |
|
350 | - 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
351 | - false, |
|
352 | - $this->ticket, |
|
353 | - $this->max, |
|
354 | - $this->min, |
|
355 | - $this->required_ticket_sold_out, |
|
356 | - $this->ticket_price, |
|
357 | - $this->ticket_bundle, |
|
358 | - $this->ticket_status_html, |
|
359 | - $this->status_class, |
|
360 | - $this |
|
361 | - ); |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * Allow plugins to hook in and abort the generation and display of the contents of this |
|
367 | - * row to do something elseif they want. |
|
368 | - * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
369 | - * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
370 | - * current row. |
|
371 | - * |
|
372 | - * @return string|bool |
|
373 | - */ |
|
374 | - protected function getFilteredRowContents() |
|
375 | - { |
|
376 | - return apply_filters( |
|
377 | - 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
378 | - false, |
|
379 | - $this->ticket, |
|
380 | - $this->max, |
|
381 | - $this->min, |
|
382 | - $this->required_ticket_sold_out, |
|
383 | - $this->ticket_price, |
|
384 | - $this->ticket_bundle, |
|
385 | - $this->ticket_status_html, |
|
386 | - $this->status_class, |
|
387 | - $this |
|
388 | - ); |
|
389 | - } |
|
21 | + /** |
|
22 | + * @var EE_Ticket $ticket |
|
23 | + */ |
|
24 | + protected $ticket; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var int $total_tickets |
|
28 | + */ |
|
29 | + protected $total_tickets; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var int $max_attendees |
|
33 | + */ |
|
34 | + protected $max_attendees; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string $date_format |
|
38 | + */ |
|
39 | + protected $date_format; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var int $EVT_ID |
|
43 | + */ |
|
44 | + protected $EVT_ID; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string $event_status |
|
48 | + */ |
|
49 | + protected $event_status; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var boolean $required_ticket_sold_out |
|
53 | + */ |
|
54 | + protected $required_ticket_sold_out; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var string $ticket_status_display |
|
58 | + */ |
|
59 | + protected $ticket_status_display; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var int $max |
|
63 | + */ |
|
64 | + protected $max = 0; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var int $min |
|
68 | + */ |
|
69 | + protected $min = 0; |
|
70 | + |
|
71 | + /** |
|
72 | + * @var float $ticket_price |
|
73 | + */ |
|
74 | + protected $ticket_price = 0.00; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var bool $ticket_bundle |
|
78 | + */ |
|
79 | + protected $ticket_bundle = false; |
|
80 | + |
|
81 | + /** |
|
82 | + * @var string $ticket_status_id |
|
83 | + */ |
|
84 | + protected $ticket_status_id = EE_Ticket::sold_out; |
|
85 | + |
|
86 | + /** |
|
87 | + * @var string $ticket_status_html |
|
88 | + */ |
|
89 | + protected $ticket_status_html = 'ticket-sales-sold-out'; |
|
90 | + |
|
91 | + /** |
|
92 | + * @var string $status_class |
|
93 | + */ |
|
94 | + protected $status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @param EE_Ticket $ticket |
|
99 | + * @param int $max_attendees |
|
100 | + * @param string $date_format |
|
101 | + * @param string $event_status |
|
102 | + * @param bool $required_ticket_sold_out |
|
103 | + * @param int $total_tickets |
|
104 | + * @throws EE_Error |
|
105 | + * @throws UnexpectedEntityException |
|
106 | + */ |
|
107 | + public function __construct( |
|
108 | + EE_Ticket $ticket, |
|
109 | + $max_attendees, |
|
110 | + $date_format, |
|
111 | + $event_status, |
|
112 | + $required_ticket_sold_out = false, |
|
113 | + $total_tickets = 1 |
|
114 | + ) { |
|
115 | + $this->ticket = $ticket; |
|
116 | + $this->max_attendees = $max_attendees; |
|
117 | + $this->date_format = $date_format; |
|
118 | + $this->EVT_ID = $this->ticket->get_event_ID(); |
|
119 | + $this->event_status = $event_status; |
|
120 | + $this->required_ticket_sold_out = $required_ticket_sold_out; |
|
121 | + $this->total_tickets = $total_tickets; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * getTicketStatusClasses |
|
127 | + * |
|
128 | + * @param int $remaining |
|
129 | + * @return void |
|
130 | + * @throws EE_Error |
|
131 | + */ |
|
132 | + protected function setTicketStatusClasses($remaining = 0) |
|
133 | + { |
|
134 | + // if a previous required ticket with the same sale start date is sold out, |
|
135 | + // then mark this ticket as sold out as well. |
|
136 | + // tickets that go on sale at a later date than the required ticket will NOT be affected |
|
137 | + $this->ticket_status_id = $this->required_ticket_sold_out !== false |
|
138 | + && $this->required_ticket_sold_out === $this->ticket->start_date() |
|
139 | + ? EE_Ticket::sold_out |
|
140 | + : $this->ticket->ticket_status(); |
|
141 | + $this->ticket_status_id = $this->event_status === EE_Datetime::sold_out |
|
142 | + ? EE_Ticket::sold_out |
|
143 | + : $this->ticket_status_id; |
|
144 | + // If at admin area, display expired tickets as on sale. |
|
145 | + $this->ticket_status_id = is_admin() && $this->ticket_status_id === EE_Ticket::expired |
|
146 | + ? EE_Ticket::onsale |
|
147 | + : $this->ticket_status_id; |
|
148 | + // check ticket status |
|
149 | + switch ($this->ticket_status_id) { |
|
150 | + // sold_out |
|
151 | + case EE_Ticket::sold_out: |
|
152 | + $ticket_status_class = 'ticket-sales-sold-out'; |
|
153 | + $this->status_class = 'ticket-sales-sold-out lt-grey-text'; |
|
154 | + break; |
|
155 | + // expired |
|
156 | + case EE_Ticket::expired: |
|
157 | + $ticket_status_class = 'ticket-sales-expired'; |
|
158 | + $this->status_class = 'ticket-sales-expired lt-grey-text'; |
|
159 | + break; |
|
160 | + // archived |
|
161 | + case EE_Ticket::archived: |
|
162 | + $ticket_status_class = 'archived-ticket'; |
|
163 | + $this->status_class = 'archived-ticket hidden'; |
|
164 | + break; |
|
165 | + // pending |
|
166 | + case EE_Ticket::pending: |
|
167 | + $ticket_status_class = 'ticket-pending'; |
|
168 | + $this->status_class = 'ticket-pending'; |
|
169 | + break; |
|
170 | + // on sale |
|
171 | + case EE_Ticket::onsale: |
|
172 | + default: |
|
173 | + $ticket_status_class = 'ticket-on-sale'; |
|
174 | + $this->status_class = 'ticket-on-sale'; |
|
175 | + break; |
|
176 | + } |
|
177 | + $this->ticket_status_html = EEH_HTML::span( |
|
178 | + $this->ticket->ticket_status(true, ($remaining > 0)), |
|
179 | + "{$ticket_status_class}-{$this->ticket->ID()}", |
|
180 | + $ticket_status_class |
|
181 | + ); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + public function getTicketStatusDisplay() |
|
189 | + { |
|
190 | + return $this->ticket_status_display; |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * setTicketStatusDisplay |
|
196 | + * |
|
197 | + * @param int $remaining |
|
198 | + * @throws EE_Error |
|
199 | + */ |
|
200 | + protected function setTicketStatusDisplay($remaining) |
|
201 | + { |
|
202 | + $this->ticket_status_display = ''; |
|
203 | + |
|
204 | + // now depending on the ticket and other circumstances... |
|
205 | + if ($this->max_attendees === 0) { |
|
206 | + // registration is CLOSED because admin set max attendees to ZERO |
|
207 | + $this->ticket_status_display = $this->registrationClosed(); |
|
208 | + } elseif ($this->ticket_status_id === EE_Ticket::sold_out || $remaining === 0) { |
|
209 | + // SOLD OUT - no tickets remaining |
|
210 | + $this->ticket_status_display = $this->ticketsSoldOut(); |
|
211 | + } elseif ($this->ticket_status_id === EE_Ticket::expired || $this->ticket_status_id === EE_Ticket::archived) { |
|
212 | + // expired or archived ticket |
|
213 | + $this->ticket_status_display = $this->ticket_status_html; |
|
214 | + } elseif ($this->ticket_status_id === EE_Ticket::pending) { |
|
215 | + // ticket not on sale yet |
|
216 | + $this->ticket_status_display = $this->ticketsSalesPending(); |
|
217 | + } elseif ($this->ticket->min() > $remaining) { |
|
218 | + // min qty purchasable is less than tickets available |
|
219 | + $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * registrationClosed |
|
226 | + */ |
|
227 | + protected function registrationClosed() |
|
228 | + { |
|
229 | + return EEH_HTML::span( |
|
230 | + apply_filters( |
|
231 | + 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
232 | + esc_html__('Closed', 'event_espresso') |
|
233 | + ), |
|
234 | + '', |
|
235 | + 'sold-out' |
|
236 | + ); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * ticketsSoldOut |
|
242 | + */ |
|
243 | + protected function ticketsSoldOut() |
|
244 | + { |
|
245 | + return EEH_HTML::span( |
|
246 | + apply_filters( |
|
247 | + 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
248 | + esc_html__('Sold Out', 'event_espresso') |
|
249 | + ), |
|
250 | + '', |
|
251 | + 'sold-out' |
|
252 | + ); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * ticketsSalesPending |
|
258 | + * |
|
259 | + * @throws EE_Error |
|
260 | + */ |
|
261 | + protected function ticketsSalesPending() |
|
262 | + { |
|
263 | + return EEH_HTML::span( |
|
264 | + EEH_HTML::span( |
|
265 | + apply_filters( |
|
266 | + 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
267 | + esc_html__('Goes On Sale', 'event_espresso') |
|
268 | + ), |
|
269 | + '', |
|
270 | + 'ticket-pending' |
|
271 | + ) |
|
272 | + . EEH_HTML::br() |
|
273 | + . EEH_HTML::span( |
|
274 | + $this->ticket->get_i18n_datetime( |
|
275 | + 'TKT_start_date', |
|
276 | + apply_filters( |
|
277 | + 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
278 | + $this->date_format |
|
279 | + ) |
|
280 | + ), |
|
281 | + '', |
|
282 | + 'small-text' |
|
283 | + ), |
|
284 | + '', |
|
285 | + 'ticket-pending-pg' |
|
286 | + ); |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * notEnoughTicketsAvailable |
|
292 | + */ |
|
293 | + protected function notEnoughTicketsAvailable() |
|
294 | + { |
|
295 | + return EEH_HTML::div( |
|
296 | + EEH_HTML::span( |
|
297 | + apply_filters( |
|
298 | + 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
299 | + esc_html__('Not Available', 'event_espresso') |
|
300 | + ), |
|
301 | + '', |
|
302 | + 'archived-ticket small-text' |
|
303 | + ) |
|
304 | + . EEH_HTML::br(), |
|
305 | + '', |
|
306 | + 'archived-ticket-pg' |
|
307 | + ); |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * setTicketMinAndMax |
|
313 | + * |
|
314 | + * @param int $remaining |
|
315 | + * @return void |
|
316 | + * @throws EE_Error |
|
317 | + */ |
|
318 | + protected function setTicketMinAndMax($remaining) |
|
319 | + { |
|
320 | + // offer the number of $tickets_remaining or $this->max_attendees, whichever is smaller |
|
321 | + $this->max = min($remaining, $this->max_attendees); |
|
322 | + // but... we also want to restrict the number of tickets by the ticket max setting, |
|
323 | + // however, the max still can't be higher than what was just set above |
|
324 | + $this->max = $this->ticket->max() > 0 |
|
325 | + ? min($this->ticket->max(), $this->max) |
|
326 | + : $this->max; |
|
327 | + // and we also want to restrict the minimum number of tickets by the ticket min setting |
|
328 | + $this->min = $this->ticket->min() > 0 |
|
329 | + ? $this->ticket->min() |
|
330 | + : 0; |
|
331 | + // and if the ticket is required, then make sure that min qty is at least 1 |
|
332 | + $this->min = $this->ticket->required() |
|
333 | + ? max($this->min, 1) |
|
334 | + : $this->min; |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Allow plugins to hook in and abort the generation and display of this row to do |
|
340 | + * something elseif they want. |
|
341 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
342 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
343 | + * current row. |
|
344 | + * |
|
345 | + * @return string|bool |
|
346 | + */ |
|
347 | + protected function getFilteredRowHtml() |
|
348 | + { |
|
349 | + return apply_filters( |
|
350 | + 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', |
|
351 | + false, |
|
352 | + $this->ticket, |
|
353 | + $this->max, |
|
354 | + $this->min, |
|
355 | + $this->required_ticket_sold_out, |
|
356 | + $this->ticket_price, |
|
357 | + $this->ticket_bundle, |
|
358 | + $this->ticket_status_html, |
|
359 | + $this->status_class, |
|
360 | + $this |
|
361 | + ); |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * Allow plugins to hook in and abort the generation and display of the contents of this |
|
367 | + * row to do something elseif they want. |
|
368 | + * For an addon to abort things, all they have to do is register a filter with this hook, and |
|
369 | + * return a value that is NOT false. Whatever is returned gets echoed instead of the |
|
370 | + * current row. |
|
371 | + * |
|
372 | + * @return string|bool |
|
373 | + */ |
|
374 | + protected function getFilteredRowContents() |
|
375 | + { |
|
376 | + return apply_filters( |
|
377 | + 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', |
|
378 | + false, |
|
379 | + $this->ticket, |
|
380 | + $this->max, |
|
381 | + $this->min, |
|
382 | + $this->required_ticket_sold_out, |
|
383 | + $this->ticket_price, |
|
384 | + $this->ticket_bundle, |
|
385 | + $this->ticket_status_html, |
|
386 | + $this->status_class, |
|
387 | + $this |
|
388 | + ); |
|
389 | + } |
|
390 | 390 | } |
@@ -20,198 +20,198 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper |
22 | 22 | { |
23 | - /** |
|
24 | - * |
|
25 | - * @var EE_Registration |
|
26 | - */ |
|
27 | - protected $_registration = null; |
|
23 | + /** |
|
24 | + * |
|
25 | + * @var EE_Registration |
|
26 | + */ |
|
27 | + protected $_registration = null; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * |
|
32 | - * @param EE_Registration $reg |
|
33 | - * @param array $options |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - public function __construct(EE_Registration $reg, $options = array()) |
|
38 | - { |
|
39 | - $this->_registration = $reg; |
|
40 | - if (! isset($options['layout_strategy'])) { |
|
41 | - $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
42 | - } |
|
43 | - if (! isset($options['html_id'])) { |
|
44 | - $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
45 | - } |
|
46 | - $this->build_form_from_registration(); |
|
47 | - parent::__construct($options); |
|
48 | - } |
|
30 | + /** |
|
31 | + * |
|
32 | + * @param EE_Registration $reg |
|
33 | + * @param array $options |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + public function __construct(EE_Registration $reg, $options = array()) |
|
38 | + { |
|
39 | + $this->_registration = $reg; |
|
40 | + if (! isset($options['layout_strategy'])) { |
|
41 | + $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
42 | + } |
|
43 | + if (! isset($options['html_id'])) { |
|
44 | + $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
45 | + } |
|
46 | + $this->build_form_from_registration(); |
|
47 | + parent::__construct($options); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * Gets the registration object this form is about |
|
53 | - * @return EE_Registration |
|
54 | - */ |
|
55 | - public function get_registration() |
|
56 | - { |
|
57 | - return $this->_registration; |
|
58 | - } |
|
51 | + /** |
|
52 | + * Gets the registration object this form is about |
|
53 | + * @return EE_Registration |
|
54 | + */ |
|
55 | + public function get_registration() |
|
56 | + { |
|
57 | + return $this->_registration; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @since 4.10.0.p |
|
62 | - * @throws EE_Error |
|
63 | - * @throws InvalidArgumentException |
|
64 | - * @throws ReflectionException |
|
65 | - * @throws InvalidDataTypeException |
|
66 | - * @throws InvalidInterfaceException |
|
67 | - */ |
|
68 | - public function build_form_from_registration() |
|
69 | - { |
|
70 | - $reg = $this->get_registration(); |
|
71 | - if (! $reg instanceof EE_Registration) { |
|
72 | - throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
73 | - } |
|
74 | - // we want to get all their question groups |
|
75 | - $question_groups = EEM_Question_Group::instance()->get_all( |
|
76 | - [ |
|
77 | - [ |
|
78 | - 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
79 | - 'OR' => [ |
|
80 | - 'Question.QST_system*blank' => '', |
|
81 | - 'Question.QST_system*null' => ['IS_NULL'] |
|
82 | - ], |
|
83 | - 'Event_Question_Group.' |
|
84 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
85 | - $reg->is_primary_registrant() |
|
86 | - ) => true |
|
87 | - ], |
|
88 | - 'order_by' => ['QSG_order' => 'ASC'] |
|
89 | - ] |
|
90 | - ); |
|
91 | - // get each question groups questions |
|
92 | - foreach ($question_groups as $question_group) { |
|
93 | - if ($question_group instanceof EE_Question_Group) { |
|
94 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
95 | - $question_group, |
|
96 | - $reg |
|
97 | - ); |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
60 | + /** |
|
61 | + * @since 4.10.0.p |
|
62 | + * @throws EE_Error |
|
63 | + * @throws InvalidArgumentException |
|
64 | + * @throws ReflectionException |
|
65 | + * @throws InvalidDataTypeException |
|
66 | + * @throws InvalidInterfaceException |
|
67 | + */ |
|
68 | + public function build_form_from_registration() |
|
69 | + { |
|
70 | + $reg = $this->get_registration(); |
|
71 | + if (! $reg instanceof EE_Registration) { |
|
72 | + throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
73 | + } |
|
74 | + // we want to get all their question groups |
|
75 | + $question_groups = EEM_Question_Group::instance()->get_all( |
|
76 | + [ |
|
77 | + [ |
|
78 | + 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
79 | + 'OR' => [ |
|
80 | + 'Question.QST_system*blank' => '', |
|
81 | + 'Question.QST_system*null' => ['IS_NULL'] |
|
82 | + ], |
|
83 | + 'Event_Question_Group.' |
|
84 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
85 | + $reg->is_primary_registrant() |
|
86 | + ) => true |
|
87 | + ], |
|
88 | + 'order_by' => ['QSG_order' => 'ASC'] |
|
89 | + ] |
|
90 | + ); |
|
91 | + // get each question groups questions |
|
92 | + foreach ($question_groups as $question_group) { |
|
93 | + if ($question_group instanceof EE_Question_Group) { |
|
94 | + $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
95 | + $question_group, |
|
96 | + $reg |
|
97 | + ); |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * |
|
105 | - * @param EE_Question_Group $question_group |
|
106 | - * @param EE_Registration $registration |
|
107 | - * @return EE_Form_Section_Proper |
|
108 | - * @throws EE_Error |
|
109 | - * @throws ReflectionException |
|
110 | - */ |
|
111 | - public function build_subform_from_question_group($question_group, $registration) |
|
112 | - { |
|
113 | - if ( |
|
114 | - ! $question_group instanceof EE_Question_Group || |
|
115 | - ! $registration instanceof EE_Registration |
|
116 | - ) { |
|
117 | - throw new EE_Error(esc_html__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
118 | - } |
|
119 | - $parts_of_subsection = array( |
|
120 | - 'title' => new EE_Form_Section_HTML( |
|
121 | - EEH_HTML::h5( |
|
122 | - $question_group->name(), |
|
123 | - $question_group->identifier(), |
|
124 | - 'espresso-question-group-title-h5 section-title' |
|
125 | - ) |
|
126 | - ) |
|
127 | - ); |
|
128 | - $questions = $question_group->questions( |
|
129 | - array( |
|
130 | - array( |
|
131 | - 'OR' => array( |
|
132 | - 'QST_system*blank' => '', |
|
133 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
134 | - ) |
|
135 | - ) |
|
136 | - ) |
|
137 | - ); |
|
138 | - foreach ($questions as $question) { |
|
139 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
140 | - } |
|
141 | - if ( |
|
142 | - EE_Registry::instance()->CAP->current_user_can( |
|
143 | - 'ee_edit_registration', |
|
144 | - 'edit-reg-questions-mbox', |
|
145 | - $this->_registration->ID() |
|
146 | - ) |
|
147 | - ) { |
|
148 | - $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
149 | - EEH_HTML::table( |
|
150 | - EEH_HTML::tr( |
|
151 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
103 | + /** |
|
104 | + * |
|
105 | + * @param EE_Question_Group $question_group |
|
106 | + * @param EE_Registration $registration |
|
107 | + * @return EE_Form_Section_Proper |
|
108 | + * @throws EE_Error |
|
109 | + * @throws ReflectionException |
|
110 | + */ |
|
111 | + public function build_subform_from_question_group($question_group, $registration) |
|
112 | + { |
|
113 | + if ( |
|
114 | + ! $question_group instanceof EE_Question_Group || |
|
115 | + ! $registration instanceof EE_Registration |
|
116 | + ) { |
|
117 | + throw new EE_Error(esc_html__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
118 | + } |
|
119 | + $parts_of_subsection = array( |
|
120 | + 'title' => new EE_Form_Section_HTML( |
|
121 | + EEH_HTML::h5( |
|
122 | + $question_group->name(), |
|
123 | + $question_group->identifier(), |
|
124 | + 'espresso-question-group-title-h5 section-title' |
|
125 | + ) |
|
126 | + ) |
|
127 | + ); |
|
128 | + $questions = $question_group->questions( |
|
129 | + array( |
|
130 | + array( |
|
131 | + 'OR' => array( |
|
132 | + 'QST_system*blank' => '', |
|
133 | + 'QST_system*null' => array( 'IS_NULL' ) |
|
134 | + ) |
|
135 | + ) |
|
136 | + ) |
|
137 | + ); |
|
138 | + foreach ($questions as $question) { |
|
139 | + $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
140 | + } |
|
141 | + if ( |
|
142 | + EE_Registry::instance()->CAP->current_user_can( |
|
143 | + 'ee_edit_registration', |
|
144 | + 'edit-reg-questions-mbox', |
|
145 | + $this->_registration->ID() |
|
146 | + ) |
|
147 | + ) { |
|
148 | + $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
149 | + EEH_HTML::table( |
|
150 | + EEH_HTML::tr( |
|
151 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
152 | 152 | <span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso') . '</span> |
153 | 153 | <div class="dashicons dashicons-edit"></div> |
154 | 154 | </a></td>' |
155 | - ) . |
|
156 | - EEH_HTML::no_row() |
|
157 | - ) |
|
158 | - ); |
|
159 | - } |
|
160 | - return new EE_Form_Section_Proper( |
|
161 | - array( |
|
162 | - 'subsections' => $parts_of_subsection, |
|
163 | - 'html_class' => 'question-group-questions', |
|
164 | - ) |
|
165 | - ); |
|
166 | - } |
|
155 | + ) . |
|
156 | + EEH_HTML::no_row() |
|
157 | + ) |
|
158 | + ); |
|
159 | + } |
|
160 | + return new EE_Form_Section_Proper( |
|
161 | + array( |
|
162 | + 'subsections' => $parts_of_subsection, |
|
163 | + 'html_class' => 'question-group-questions', |
|
164 | + ) |
|
165 | + ); |
|
166 | + } |
|
167 | 167 | |
168 | 168 | |
169 | - /** |
|
170 | - * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
171 | - * from the answers in the DB |
|
172 | - * |
|
173 | - * @param array $req_data like $_POST |
|
174 | - * @return void |
|
175 | - * @throws EE_Error |
|
176 | - */ |
|
177 | - protected function _normalize($req_data) |
|
178 | - { |
|
179 | - $this->_received_submission = true; |
|
180 | - $this->_validation_errors = array(); |
|
181 | - foreach ($this->get_validatable_subsections() as $subsection) { |
|
182 | - if ($subsection->form_data_present_in($req_data)) { |
|
183 | - try { |
|
184 | - $subsection->_normalize($req_data); |
|
185 | - } catch (EE_Validation_Error $e) { |
|
186 | - $subsection->add_validation_error($e); |
|
187 | - } |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
169 | + /** |
|
170 | + * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
171 | + * from the answers in the DB |
|
172 | + * |
|
173 | + * @param array $req_data like $_POST |
|
174 | + * @return void |
|
175 | + * @throws EE_Error |
|
176 | + */ |
|
177 | + protected function _normalize($req_data) |
|
178 | + { |
|
179 | + $this->_received_submission = true; |
|
180 | + $this->_validation_errors = array(); |
|
181 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
182 | + if ($subsection->form_data_present_in($req_data)) { |
|
183 | + try { |
|
184 | + $subsection->_normalize($req_data); |
|
185 | + } catch (EE_Validation_Error $e) { |
|
186 | + $subsection->add_validation_error($e); |
|
187 | + } |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | |
193 | - /** |
|
194 | - * Performs validation on this form section and its subsections. For each subsection, |
|
195 | - * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls |
|
196 | - * _validate on that subsection. If you need to perform validation on the form as a whole (considering multiple) |
|
197 | - * you would be best to override this _validate method, calling parent::_validate() first. |
|
198 | - * |
|
199 | - * @throws EE_Error |
|
200 | - */ |
|
201 | - protected function _validate() |
|
202 | - { |
|
203 | - /** @var RequestInterface $request */ |
|
204 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
205 | - $form_data = $request->requestParams(); |
|
206 | - foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
207 | - if ($subsection->form_data_present_in($form_data)) { |
|
208 | - if (method_exists($this, '_validate_' . $subsection_name)) { |
|
209 | - call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection)); |
|
210 | - } |
|
211 | - $subsection->_validate(); |
|
212 | - } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
213 | - $subsection->_received_submission = true; |
|
214 | - } |
|
215 | - } |
|
216 | - } |
|
193 | + /** |
|
194 | + * Performs validation on this form section and its subsections. For each subsection, |
|
195 | + * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls |
|
196 | + * _validate on that subsection. If you need to perform validation on the form as a whole (considering multiple) |
|
197 | + * you would be best to override this _validate method, calling parent::_validate() first. |
|
198 | + * |
|
199 | + * @throws EE_Error |
|
200 | + */ |
|
201 | + protected function _validate() |
|
202 | + { |
|
203 | + /** @var RequestInterface $request */ |
|
204 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
205 | + $form_data = $request->requestParams(); |
|
206 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
207 | + if ($subsection->form_data_present_in($form_data)) { |
|
208 | + if (method_exists($this, '_validate_' . $subsection_name)) { |
|
209 | + call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection)); |
|
210 | + } |
|
211 | + $subsection->_validate(); |
|
212 | + } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
213 | + $subsection->_received_submission = true; |
|
214 | + } |
|
215 | + } |
|
216 | + } |
|
217 | 217 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | public function __construct(EE_Registration $reg, $options = array()) |
38 | 38 | { |
39 | 39 | $this->_registration = $reg; |
40 | - if (! isset($options['layout_strategy'])) { |
|
40 | + if ( ! isset($options['layout_strategy'])) { |
|
41 | 41 | $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
42 | 42 | } |
43 | - if (! isset($options['html_id'])) { |
|
43 | + if ( ! isset($options['html_id'])) { |
|
44 | 44 | $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
45 | 45 | } |
46 | 46 | $this->build_form_from_registration(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function build_form_from_registration() |
69 | 69 | { |
70 | 70 | $reg = $this->get_registration(); |
71 | - if (! $reg instanceof EE_Registration) { |
|
71 | + if ( ! $reg instanceof EE_Registration) { |
|
72 | 72 | throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
73 | 73 | } |
74 | 74 | // we want to get all their question groups |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // get each question groups questions |
92 | 92 | foreach ($question_groups as $question_group) { |
93 | 93 | if ($question_group instanceof EE_Question_Group) { |
94 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
94 | + $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group( |
|
95 | 95 | $question_group, |
96 | 96 | $reg |
97 | 97 | ); |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | array( |
131 | 131 | 'OR' => array( |
132 | 132 | 'QST_system*blank' => '', |
133 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
133 | + 'QST_system*null' => array('IS_NULL') |
|
134 | 134 | ) |
135 | 135 | ) |
136 | 136 | ) |
137 | 137 | ); |
138 | 138 | foreach ($questions as $question) { |
139 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
139 | + $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration); |
|
140 | 140 | } |
141 | 141 | if ( |
142 | 142 | EE_Registry::instance()->CAP->current_user_can( |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
149 | 149 | EEH_HTML::table( |
150 | 150 | EEH_HTML::tr( |
151 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
152 | - <span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso') . '</span> |
|
151 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="'.esc_attr__('click to edit question', 'event_espresso').'"> |
|
152 | + <span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso').'</span> |
|
153 | 153 | <div class="dashicons dashicons-edit"></div> |
154 | 154 | </a></td>' |
155 | - ) . |
|
155 | + ). |
|
156 | 156 | EEH_HTML::no_row() |
157 | 157 | ) |
158 | 158 | ); |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $form_data = $request->requestParams(); |
206 | 206 | foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
207 | 207 | if ($subsection->form_data_present_in($form_data)) { |
208 | - if (method_exists($this, '_validate_' . $subsection_name)) { |
|
209 | - call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection)); |
|
208 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
209 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
210 | 210 | } |
211 | 211 | $subsection->_validate(); |
212 | 212 | } elseif ($subsection instanceof EE_Form_Section_Proper) { |
@@ -16,105 +16,105 @@ |
||
16 | 16 | class EE_PMT_Paypal_Standard extends EE_PMT_Base |
17 | 17 | { |
18 | 18 | |
19 | - const shipping_info_none = 1; |
|
19 | + const shipping_info_none = 1; |
|
20 | 20 | |
21 | - const shipping_info_optional = 0; |
|
21 | + const shipping_info_optional = 0; |
|
22 | 22 | |
23 | - const shipping_info_required = 2; |
|
23 | + const shipping_info_required = 2; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param null $pm_instance |
|
28 | - * @throws EE_Error |
|
29 | - */ |
|
30 | - public function __construct($pm_instance = null) |
|
31 | - { |
|
32 | - require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php'); |
|
33 | - $this->_gateway = new EEG_Paypal_Standard(); |
|
34 | - $this->_pretty_name = esc_html__("PayPal Standard", 'event_espresso'); |
|
35 | - $this->_default_description = sprintf( |
|
36 | - esc_html__( |
|
37 | - 'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - '<strong>', |
|
41 | - '</strong>' |
|
42 | - ); |
|
43 | - parent::__construct($pm_instance); |
|
44 | - $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png'; |
|
45 | - } |
|
26 | + /** |
|
27 | + * @param null $pm_instance |
|
28 | + * @throws EE_Error |
|
29 | + */ |
|
30 | + public function __construct($pm_instance = null) |
|
31 | + { |
|
32 | + require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php'); |
|
33 | + $this->_gateway = new EEG_Paypal_Standard(); |
|
34 | + $this->_pretty_name = esc_html__("PayPal Standard", 'event_espresso'); |
|
35 | + $this->_default_description = sprintf( |
|
36 | + esc_html__( |
|
37 | + 'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + '<strong>', |
|
41 | + '</strong>' |
|
42 | + ); |
|
43 | + parent::__construct($pm_instance); |
|
44 | + $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png'; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Creates the billing form for this payment method type |
|
50 | - * |
|
51 | - * @param EE_Transaction $transaction |
|
52 | - * @return NULL |
|
53 | - */ |
|
54 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
55 | - { |
|
56 | - return null; |
|
57 | - } |
|
48 | + /** |
|
49 | + * Creates the billing form for this payment method type |
|
50 | + * |
|
51 | + * @param EE_Transaction $transaction |
|
52 | + * @return NULL |
|
53 | + */ |
|
54 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
55 | + { |
|
56 | + return null; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Gets the form for all the settings related to this payment method type |
|
62 | - * |
|
63 | - * @return EE_Payment_Method_Form |
|
64 | - * @throws EE_Error |
|
65 | - */ |
|
66 | - public function generate_new_settings_form() |
|
67 | - { |
|
68 | - require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
69 | - $form = new EE_Paypal_Standard_Form($this); |
|
70 | - $form->get_input('PMD_debug_mode')->set_html_label_text( |
|
71 | - sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
|
72 | - ); |
|
73 | - $form->get_input('shipping_details')->set_html_label_text( |
|
74 | - sprintf(esc_html__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link()) |
|
75 | - ); |
|
76 | - return $form; |
|
77 | - } |
|
60 | + /** |
|
61 | + * Gets the form for all the settings related to this payment method type |
|
62 | + * |
|
63 | + * @return EE_Payment_Method_Form |
|
64 | + * @throws EE_Error |
|
65 | + */ |
|
66 | + public function generate_new_settings_form() |
|
67 | + { |
|
68 | + require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
69 | + $form = new EE_Paypal_Standard_Form($this); |
|
70 | + $form->get_input('PMD_debug_mode')->set_html_label_text( |
|
71 | + sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
|
72 | + ); |
|
73 | + $form->get_input('shipping_details')->set_html_label_text( |
|
74 | + sprintf(esc_html__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link()) |
|
75 | + ); |
|
76 | + return $form; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * Adds the help tab |
|
82 | - * |
|
83 | - * @return array |
|
84 | - * @see EE_PMT_Base::help_tabs_config() |
|
85 | - */ |
|
86 | - public function help_tabs_config() |
|
87 | - { |
|
88 | - return [ |
|
89 | - $this->get_help_tab_name() => [ |
|
90 | - 'title' => esc_html__("PayPal Standard Settings", 'event_espresso'), |
|
91 | - 'filename' => 'payment_methods_overview_paypalstandard', |
|
92 | - ], |
|
93 | - ]; |
|
94 | - } |
|
80 | + /** |
|
81 | + * Adds the help tab |
|
82 | + * |
|
83 | + * @return array |
|
84 | + * @see EE_PMT_Base::help_tabs_config() |
|
85 | + */ |
|
86 | + public function help_tabs_config() |
|
87 | + { |
|
88 | + return [ |
|
89 | + $this->get_help_tab_name() => [ |
|
90 | + 'title' => esc_html__("PayPal Standard Settings", 'event_espresso'), |
|
91 | + 'filename' => 'payment_methods_overview_paypalstandard', |
|
92 | + ], |
|
93 | + ]; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - /** |
|
98 | - * Logic to be accomplished when the payment attempt is complete. |
|
99 | - * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
100 | - * (Mijireh was an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
101 | - * Mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
102 | - * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
103 | - * |
|
104 | - * @param EE_Transaction $transaction |
|
105 | - * @return EE_Payment |
|
106 | - * @throws EE_Error |
|
107 | - */ |
|
108 | - public function finalize_payment_for($transaction) |
|
109 | - { |
|
110 | - /** @var RequestInterface $request */ |
|
111 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
112 | - // PayPal standard actually sends the IPN info along with the user when they return to our site |
|
113 | - // so in case the IPN is arriving later, let's try to process an IPN! |
|
114 | - if ($request->getServerParam('REQUEST_METHOD') === 'POST') { |
|
115 | - return $this->handle_ipn($request->postParams(), $transaction); |
|
116 | - } else { |
|
117 | - return parent::finalize_payment_for($transaction); |
|
118 | - } |
|
119 | - } |
|
97 | + /** |
|
98 | + * Logic to be accomplished when the payment attempt is complete. |
|
99 | + * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
100 | + * (Mijireh was an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
101 | + * Mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
102 | + * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
103 | + * |
|
104 | + * @param EE_Transaction $transaction |
|
105 | + * @return EE_Payment |
|
106 | + * @throws EE_Error |
|
107 | + */ |
|
108 | + public function finalize_payment_for($transaction) |
|
109 | + { |
|
110 | + /** @var RequestInterface $request */ |
|
111 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
112 | + // PayPal standard actually sends the IPN info along with the user when they return to our site |
|
113 | + // so in case the IPN is arriving later, let's try to process an IPN! |
|
114 | + if ($request->getServerParam('REQUEST_METHOD') === 'POST') { |
|
115 | + return $this->handle_ipn($request->postParams(), $transaction); |
|
116 | + } else { |
|
117 | + return parent::finalize_payment_for($transaction); |
|
118 | + } |
|
119 | + } |
|
120 | 120 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct($pm_instance = null) |
31 | 31 | { |
32 | - require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php'); |
|
32 | + require_once($this->file_folder().'EEG_Paypal_Standard.gateway.php'); |
|
33 | 33 | $this->_gateway = new EEG_Paypal_Standard(); |
34 | 34 | $this->_pretty_name = esc_html__("PayPal Standard", 'event_espresso'); |
35 | 35 | $this->_default_description = sprintf( |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | '</strong>' |
42 | 42 | ); |
43 | 43 | parent::__construct($pm_instance); |
44 | - $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png'; |
|
44 | + $this->_default_button_url = $this->file_url().'lib/paypal-logo.png'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function generate_new_settings_form() |
67 | 67 | { |
68 | - require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
68 | + require_once($this->file_folder().'EE_Paypal_Standard_Form.form.php'); |
|
69 | 69 | $form = new EE_Paypal_Standard_Form($this); |
70 | 70 | $form->get_input('PMD_debug_mode')->set_html_label_text( |
71 | 71 | sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
@@ -27,181 +27,181 @@ |
||
27 | 27 | class InvalidCheckoutAccess |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * key used for saving invalid checkout access data to the wp_options table |
|
32 | - */ |
|
33 | - const OPTION_KEY = 'ee_invalid_checkout_access'; |
|
30 | + /** |
|
31 | + * key used for saving invalid checkout access data to the wp_options table |
|
32 | + */ |
|
33 | + const OPTION_KEY = 'ee_invalid_checkout_access'; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * _block_bots |
|
38 | - * checks that the incoming request has either of the following set: |
|
39 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
40 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
41 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
42 | - * then where you coming from man? |
|
43 | - * |
|
44 | - * @param EE_Checkout $checkout |
|
45 | - * @return bool true if access to registration checkout appears to be invalid |
|
46 | - */ |
|
47 | - public function checkoutAccessIsInvalid(EE_Checkout $checkout) |
|
48 | - { |
|
49 | - if ( |
|
50 | - ! ($checkout->uts || $checkout->reg_url_link) |
|
51 | - && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
52 | - && EE_Config::instance()->registration->track_invalid_checkout_access() |
|
53 | - ) { |
|
54 | - /** @var RequestInterface $request */ |
|
55 | - $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
56 | - $ip_address = $request->ipAddress(); |
|
57 | - $ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY); |
|
58 | - if ($ee_bot_checkout === false) { |
|
59 | - $ee_bot_checkout = array(); |
|
60 | - add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false); |
|
61 | - } |
|
62 | - if (! isset($ee_bot_checkout[ $ip_address ])) { |
|
63 | - $ee_bot_checkout[ $ip_address ] = array(); |
|
64 | - } |
|
65 | - $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0)); |
|
66 | - if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) { |
|
67 | - $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0; |
|
68 | - } |
|
69 | - $ee_bot_checkout[ $ip_address ][ $http_referer ]++; |
|
70 | - update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout); |
|
71 | - if (WP_DEBUG) { |
|
72 | - EE_Error::add_error( |
|
73 | - esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'), |
|
74 | - __FILE__, |
|
75 | - __FUNCTION__, |
|
76 | - __LINE__ |
|
77 | - ); |
|
78 | - } |
|
79 | - return true; |
|
80 | - } |
|
81 | - return false; |
|
82 | - } |
|
36 | + /** |
|
37 | + * _block_bots |
|
38 | + * checks that the incoming request has either of the following set: |
|
39 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
40 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
41 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
42 | + * then where you coming from man? |
|
43 | + * |
|
44 | + * @param EE_Checkout $checkout |
|
45 | + * @return bool true if access to registration checkout appears to be invalid |
|
46 | + */ |
|
47 | + public function checkoutAccessIsInvalid(EE_Checkout $checkout) |
|
48 | + { |
|
49 | + if ( |
|
50 | + ! ($checkout->uts || $checkout->reg_url_link) |
|
51 | + && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
52 | + && EE_Config::instance()->registration->track_invalid_checkout_access() |
|
53 | + ) { |
|
54 | + /** @var RequestInterface $request */ |
|
55 | + $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
56 | + $ip_address = $request->ipAddress(); |
|
57 | + $ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY); |
|
58 | + if ($ee_bot_checkout === false) { |
|
59 | + $ee_bot_checkout = array(); |
|
60 | + add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false); |
|
61 | + } |
|
62 | + if (! isset($ee_bot_checkout[ $ip_address ])) { |
|
63 | + $ee_bot_checkout[ $ip_address ] = array(); |
|
64 | + } |
|
65 | + $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0)); |
|
66 | + if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) { |
|
67 | + $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0; |
|
68 | + } |
|
69 | + $ee_bot_checkout[ $ip_address ][ $http_referer ]++; |
|
70 | + update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout); |
|
71 | + if (WP_DEBUG) { |
|
72 | + EE_Error::add_error( |
|
73 | + esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'), |
|
74 | + __FILE__, |
|
75 | + __FUNCTION__, |
|
76 | + __LINE__ |
|
77 | + ); |
|
78 | + } |
|
79 | + return true; |
|
80 | + } |
|
81 | + return false; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * _invalid_checkout_access_form |
|
87 | - * |
|
88 | - * @return EE_Form_Section_Proper |
|
89 | - * @throws EE_Error |
|
90 | - */ |
|
91 | - public function getForm() |
|
92 | - { |
|
93 | - return new EE_Form_Section_Proper( |
|
94 | - array( |
|
95 | - 'name' => 'invalid_checkout_access', |
|
96 | - 'html_id' => 'invalid_checkout_access', |
|
97 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
98 | - 'subsections' => array( |
|
99 | - 'invalid_checkout_access_hdr' => new EE_Form_Section_HTML( |
|
100 | - EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso')) |
|
101 | - ), |
|
102 | - 'ee_bot_checkout_data' => new EE_Text_Area_Input( |
|
103 | - array( |
|
104 | - 'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'), |
|
105 | - 'default' => var_export( |
|
106 | - get_option(InvalidCheckoutAccess::OPTION_KEY, array()), |
|
107 | - true |
|
108 | - ), |
|
109 | - 'required' => false, |
|
110 | - 'html_help_text' => esc_html__( |
|
111 | - 'Event Espresso blocks any attempt to directly access the registration checkout page, that is NOT from a Ticket Selector or for a return visit for a valid transaction. These are not valid requests accessing your checkout page, so we track the IP addresses, what web page they just came from, and the number of times that they have attempted to access your registration page. This information may help you with protecting your site by other means, such as firewalls, etc, but please note that IP addresses are almost guaranteed to be spoofed by malicious agents.', |
|
112 | - 'event_espresso' |
|
113 | - ), |
|
114 | - ) |
|
115 | - ), |
|
116 | - 'track_invalid_checkout_access' => new EE_Yes_No_Input( |
|
117 | - array( |
|
118 | - 'html_label_text' => esc_html__('Track Invalid Checkout Access?', 'event_espresso'), |
|
119 | - 'html_help_text' => esc_html__( |
|
120 | - 'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.', |
|
121 | - 'event_espresso' |
|
122 | - ), |
|
123 | - 'default' => EE_Config::instance() |
|
124 | - ->registration |
|
125 | - ->track_invalid_checkout_access(), |
|
126 | - 'display_html_label_text' => false, |
|
127 | - ) |
|
128 | - ), |
|
129 | - 'delete_invalid_checkout_data' => new EE_Yes_No_Input( |
|
130 | - array( |
|
131 | - 'html_label_text' => esc_html__('Reset Invalid Checkout Data', 'event_espresso'), |
|
132 | - 'html_help_text' => esc_html__( |
|
133 | - 'Setting this to "Yes" will delete all existing invalid checkout access data.', |
|
134 | - 'event_espresso' |
|
135 | - ), |
|
136 | - 'default' => false, |
|
137 | - 'display_html_label_text' => false, |
|
138 | - ) |
|
139 | - ), |
|
140 | - ), |
|
141 | - ) |
|
142 | - ); |
|
143 | - } |
|
85 | + /** |
|
86 | + * _invalid_checkout_access_form |
|
87 | + * |
|
88 | + * @return EE_Form_Section_Proper |
|
89 | + * @throws EE_Error |
|
90 | + */ |
|
91 | + public function getForm() |
|
92 | + { |
|
93 | + return new EE_Form_Section_Proper( |
|
94 | + array( |
|
95 | + 'name' => 'invalid_checkout_access', |
|
96 | + 'html_id' => 'invalid_checkout_access', |
|
97 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
98 | + 'subsections' => array( |
|
99 | + 'invalid_checkout_access_hdr' => new EE_Form_Section_HTML( |
|
100 | + EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso')) |
|
101 | + ), |
|
102 | + 'ee_bot_checkout_data' => new EE_Text_Area_Input( |
|
103 | + array( |
|
104 | + 'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'), |
|
105 | + 'default' => var_export( |
|
106 | + get_option(InvalidCheckoutAccess::OPTION_KEY, array()), |
|
107 | + true |
|
108 | + ), |
|
109 | + 'required' => false, |
|
110 | + 'html_help_text' => esc_html__( |
|
111 | + 'Event Espresso blocks any attempt to directly access the registration checkout page, that is NOT from a Ticket Selector or for a return visit for a valid transaction. These are not valid requests accessing your checkout page, so we track the IP addresses, what web page they just came from, and the number of times that they have attempted to access your registration page. This information may help you with protecting your site by other means, such as firewalls, etc, but please note that IP addresses are almost guaranteed to be spoofed by malicious agents.', |
|
112 | + 'event_espresso' |
|
113 | + ), |
|
114 | + ) |
|
115 | + ), |
|
116 | + 'track_invalid_checkout_access' => new EE_Yes_No_Input( |
|
117 | + array( |
|
118 | + 'html_label_text' => esc_html__('Track Invalid Checkout Access?', 'event_espresso'), |
|
119 | + 'html_help_text' => esc_html__( |
|
120 | + 'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.', |
|
121 | + 'event_espresso' |
|
122 | + ), |
|
123 | + 'default' => EE_Config::instance() |
|
124 | + ->registration |
|
125 | + ->track_invalid_checkout_access(), |
|
126 | + 'display_html_label_text' => false, |
|
127 | + ) |
|
128 | + ), |
|
129 | + 'delete_invalid_checkout_data' => new EE_Yes_No_Input( |
|
130 | + array( |
|
131 | + 'html_label_text' => esc_html__('Reset Invalid Checkout Data', 'event_espresso'), |
|
132 | + 'html_help_text' => esc_html__( |
|
133 | + 'Setting this to "Yes" will delete all existing invalid checkout access data.', |
|
134 | + 'event_espresso' |
|
135 | + ), |
|
136 | + 'default' => false, |
|
137 | + 'display_html_label_text' => false, |
|
138 | + ) |
|
139 | + ), |
|
140 | + ), |
|
141 | + ) |
|
142 | + ); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - /** |
|
147 | - * update_invalid_checkout_access_form |
|
148 | - * |
|
149 | - * @param EE_Registration_Config $EE_Registration_Config |
|
150 | - * @return EE_Registration_Config |
|
151 | - * @throws EE_Error |
|
152 | - * @throws ReflectionException |
|
153 | - */ |
|
154 | - public function processForm(EE_Registration_Config $EE_Registration_Config) |
|
155 | - { |
|
156 | - try { |
|
157 | - $invalid_checkout_access_form = $this->getForm(); |
|
158 | - // if not displaying a form, then check for form submission |
|
159 | - if ($invalid_checkout_access_form->was_submitted()) { |
|
160 | - // capture form data |
|
161 | - $invalid_checkout_access_form->receive_form_submission(); |
|
162 | - // validate form data |
|
163 | - if ($invalid_checkout_access_form->is_valid()) { |
|
164 | - // grab validated data from form |
|
165 | - $valid_data = $invalid_checkout_access_form->valid_data(); |
|
166 | - // ensure form inputs we want are set |
|
167 | - if ( |
|
168 | - isset( |
|
169 | - $valid_data['track_invalid_checkout_access'], |
|
170 | - $valid_data['delete_invalid_checkout_data'] |
|
171 | - ) |
|
172 | - ) { |
|
173 | - $EE_Registration_Config->set_track_invalid_checkout_access( |
|
174 | - $valid_data['track_invalid_checkout_access'] |
|
175 | - ); |
|
176 | - // if deleting, then update option with empty array |
|
177 | - if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) { |
|
178 | - update_option(InvalidCheckoutAccess::OPTION_KEY, array()); |
|
179 | - } |
|
180 | - } else { |
|
181 | - EE_Error::add_error( |
|
182 | - esc_html__( |
|
183 | - 'Invalid or missing Invalid Checkout Access form data. Please refresh the form and try again.', |
|
184 | - 'event_espresso' |
|
185 | - ), |
|
186 | - __FILE__, |
|
187 | - __FUNCTION__, |
|
188 | - __LINE__ |
|
189 | - ); |
|
190 | - } |
|
191 | - } else { |
|
192 | - if ($invalid_checkout_access_form->submission_error_message() !== '') { |
|
193 | - EE_Error::add_error( |
|
194 | - $invalid_checkout_access_form->submission_error_message(), |
|
195 | - __FILE__, |
|
196 | - __FUNCTION__, |
|
197 | - __LINE__ |
|
198 | - ); |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - } catch (EE_Error $e) { |
|
203 | - $e->get_error(); |
|
204 | - } |
|
205 | - return $EE_Registration_Config; |
|
206 | - } |
|
146 | + /** |
|
147 | + * update_invalid_checkout_access_form |
|
148 | + * |
|
149 | + * @param EE_Registration_Config $EE_Registration_Config |
|
150 | + * @return EE_Registration_Config |
|
151 | + * @throws EE_Error |
|
152 | + * @throws ReflectionException |
|
153 | + */ |
|
154 | + public function processForm(EE_Registration_Config $EE_Registration_Config) |
|
155 | + { |
|
156 | + try { |
|
157 | + $invalid_checkout_access_form = $this->getForm(); |
|
158 | + // if not displaying a form, then check for form submission |
|
159 | + if ($invalid_checkout_access_form->was_submitted()) { |
|
160 | + // capture form data |
|
161 | + $invalid_checkout_access_form->receive_form_submission(); |
|
162 | + // validate form data |
|
163 | + if ($invalid_checkout_access_form->is_valid()) { |
|
164 | + // grab validated data from form |
|
165 | + $valid_data = $invalid_checkout_access_form->valid_data(); |
|
166 | + // ensure form inputs we want are set |
|
167 | + if ( |
|
168 | + isset( |
|
169 | + $valid_data['track_invalid_checkout_access'], |
|
170 | + $valid_data['delete_invalid_checkout_data'] |
|
171 | + ) |
|
172 | + ) { |
|
173 | + $EE_Registration_Config->set_track_invalid_checkout_access( |
|
174 | + $valid_data['track_invalid_checkout_access'] |
|
175 | + ); |
|
176 | + // if deleting, then update option with empty array |
|
177 | + if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) { |
|
178 | + update_option(InvalidCheckoutAccess::OPTION_KEY, array()); |
|
179 | + } |
|
180 | + } else { |
|
181 | + EE_Error::add_error( |
|
182 | + esc_html__( |
|
183 | + 'Invalid or missing Invalid Checkout Access form data. Please refresh the form and try again.', |
|
184 | + 'event_espresso' |
|
185 | + ), |
|
186 | + __FILE__, |
|
187 | + __FUNCTION__, |
|
188 | + __LINE__ |
|
189 | + ); |
|
190 | + } |
|
191 | + } else { |
|
192 | + if ($invalid_checkout_access_form->submission_error_message() !== '') { |
|
193 | + EE_Error::add_error( |
|
194 | + $invalid_checkout_access_form->submission_error_message(), |
|
195 | + __FILE__, |
|
196 | + __FUNCTION__, |
|
197 | + __LINE__ |
|
198 | + ); |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + } catch (EE_Error $e) { |
|
203 | + $e->get_error(); |
|
204 | + } |
|
205 | + return $EE_Registration_Config; |
|
206 | + } |
|
207 | 207 | } |
@@ -59,14 +59,14 @@ |
||
59 | 59 | $ee_bot_checkout = array(); |
60 | 60 | add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false); |
61 | 61 | } |
62 | - if (! isset($ee_bot_checkout[ $ip_address ])) { |
|
63 | - $ee_bot_checkout[ $ip_address ] = array(); |
|
62 | + if ( ! isset($ee_bot_checkout[$ip_address])) { |
|
63 | + $ee_bot_checkout[$ip_address] = array(); |
|
64 | 64 | } |
65 | 65 | $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0)); |
66 | - if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) { |
|
67 | - $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0; |
|
66 | + if ( ! isset($ee_bot_checkout[$ip_address][$http_referer])) { |
|
67 | + $ee_bot_checkout[$ip_address][$http_referer] = 0; |
|
68 | 68 | } |
69 | - $ee_bot_checkout[ $ip_address ][ $http_referer ]++; |
|
69 | + $ee_bot_checkout[$ip_address][$http_referer]++; |
|
70 | 70 | update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout); |
71 | 71 | if (WP_DEBUG) { |
72 | 72 | EE_Error::add_error( |
@@ -20,151 +20,151 @@ |
||
20 | 20 | abstract class EE_Form_Section_Validatable extends EE_Form_Section_Base |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
25 | - * Those are stored individually on each subsection. |
|
26 | - * |
|
27 | - * @var EE_Validation_Error[] |
|
28 | - */ |
|
29 | - protected $_validation_errors = array(); |
|
30 | - |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Errors on this form section. Note: EE_Form_Section_Proper |
|
35 | - * has another function for getting all errors in this form section and subsections |
|
36 | - * called get_validation_errors_accumulated |
|
37 | - * |
|
38 | - * @return EE_Validation_Error[] |
|
39 | - */ |
|
40 | - public function get_validation_errors() |
|
41 | - { |
|
42 | - return $this->_validation_errors; |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * returns a comma-separated list of all the validation errors in it. |
|
49 | - * If we want this to be customizable, we may decide to create a strategy for displaying it |
|
50 | - * |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function get_validation_error_string() |
|
54 | - { |
|
55 | - $validation_error_messages = array(); |
|
56 | - if ($this->get_validation_errors()) { |
|
57 | - foreach ($this->get_validation_errors() as $validation_error) { |
|
58 | - if ($validation_error instanceof EE_Validation_Error) { |
|
59 | - $validation_error_messages[] = $validation_error->getMessage(); |
|
60 | - } |
|
61 | - } |
|
62 | - } |
|
63 | - return implode(", ", $validation_error_messages); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
70 | - * |
|
71 | - * @return boolean of whether or not the form section is valid |
|
72 | - */ |
|
73 | - abstract protected function _validate(); |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Checks if this field has any validation errors |
|
79 | - * |
|
80 | - * @return boolean |
|
81 | - */ |
|
82 | - public function is_valid() |
|
83 | - { |
|
84 | - if (count($this->_validation_errors)) { |
|
85 | - return false; |
|
86 | - } else { |
|
87 | - return true; |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Sanitizes input for this form section |
|
95 | - * |
|
96 | - * @param array $req_data is the full request data |
|
97 | - * @return boolean of whether a normalization error occurred |
|
98 | - * @throws EE_Validation_Error |
|
99 | - */ |
|
100 | - abstract protected function _normalize($req_data); |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
106 | - * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
107 | - * adds it to the list of validation errors of errors |
|
108 | - * |
|
109 | - * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
110 | - * proper EE_Validation_Error object |
|
111 | - * @param string $error_code a short key which can be used to uniquely identify the error |
|
112 | - * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
113 | - * @return void |
|
114 | - */ |
|
115 | - public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
116 | - { |
|
117 | - if ($message_or_object instanceof EE_Validation_Error) { |
|
118 | - $validation_error = $message_or_object; |
|
119 | - $validation_error->set_form_section($this); |
|
120 | - } else { |
|
121 | - $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
122 | - } |
|
123 | - $this->_validation_errors[] = $validation_error; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * When generating the JS for the jquery validation rules like<br> |
|
130 | - * <code>$( "#myform" ).validate({ |
|
131 | - * rules: { |
|
132 | - * password: "required", |
|
133 | - * password_again: { |
|
134 | - * equalTo: "#password" |
|
135 | - * } |
|
136 | - * } |
|
137 | - * });</code> |
|
138 | - * gets the sections like |
|
139 | - * <br><code>password: "required", |
|
140 | - * password_again: { |
|
141 | - * equalTo: "#password" |
|
142 | - * }</code> |
|
143 | - * except we leave it as a PHP object, and leave wp_localize_script to |
|
144 | - * turn it into a JSON object which can be used by the js |
|
145 | - * |
|
146 | - * @return array |
|
147 | - */ |
|
148 | - abstract public function get_jquery_validation_rules(); |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Checks if this form section's data is present in the req data specified |
|
154 | - * |
|
155 | - * @param array $req_data usually post data, if null that's what's used |
|
156 | - * @return boolean |
|
157 | - */ |
|
158 | - abstract public function form_data_present_in($req_data = null); |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Removes teh sensitive data from this form section (usually done after |
|
164 | - * utilizing the data business function, but before saving it somewhere. Eg, |
|
165 | - * may remove a password from the form after verifying it was correct) |
|
166 | - * |
|
167 | - * @return void |
|
168 | - */ |
|
169 | - abstract public function clean_sensitive_data(); |
|
23 | + /** |
|
24 | + * Array of validation errors in this section. Does not contain validation errors in subsections, however. |
|
25 | + * Those are stored individually on each subsection. |
|
26 | + * |
|
27 | + * @var EE_Validation_Error[] |
|
28 | + */ |
|
29 | + protected $_validation_errors = array(); |
|
30 | + |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Errors on this form section. Note: EE_Form_Section_Proper |
|
35 | + * has another function for getting all errors in this form section and subsections |
|
36 | + * called get_validation_errors_accumulated |
|
37 | + * |
|
38 | + * @return EE_Validation_Error[] |
|
39 | + */ |
|
40 | + public function get_validation_errors() |
|
41 | + { |
|
42 | + return $this->_validation_errors; |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * returns a comma-separated list of all the validation errors in it. |
|
49 | + * If we want this to be customizable, we may decide to create a strategy for displaying it |
|
50 | + * |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function get_validation_error_string() |
|
54 | + { |
|
55 | + $validation_error_messages = array(); |
|
56 | + if ($this->get_validation_errors()) { |
|
57 | + foreach ($this->get_validation_errors() as $validation_error) { |
|
58 | + if ($validation_error instanceof EE_Validation_Error) { |
|
59 | + $validation_error_messages[] = $validation_error->getMessage(); |
|
60 | + } |
|
61 | + } |
|
62 | + } |
|
63 | + return implode(", ", $validation_error_messages); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Performs validation on this form section (and subsections). Should be called after _normalize() |
|
70 | + * |
|
71 | + * @return boolean of whether or not the form section is valid |
|
72 | + */ |
|
73 | + abstract protected function _validate(); |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Checks if this field has any validation errors |
|
79 | + * |
|
80 | + * @return boolean |
|
81 | + */ |
|
82 | + public function is_valid() |
|
83 | + { |
|
84 | + if (count($this->_validation_errors)) { |
|
85 | + return false; |
|
86 | + } else { |
|
87 | + return true; |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * Sanitizes input for this form section |
|
95 | + * |
|
96 | + * @param array $req_data is the full request data |
|
97 | + * @return boolean of whether a normalization error occurred |
|
98 | + * @throws EE_Validation_Error |
|
99 | + */ |
|
100 | + abstract protected function _normalize($req_data); |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Creates a validation error from the arguments provided, and adds it to the form section's list. |
|
106 | + * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and |
|
107 | + * adds it to the list of validation errors of errors |
|
108 | + * |
|
109 | + * @param mixed $message_or_object internationalized string describing the validation error; or it could be a |
|
110 | + * proper EE_Validation_Error object |
|
111 | + * @param string $error_code a short key which can be used to uniquely identify the error |
|
112 | + * @param Exception $previous_exception if there was an exception that caused the error, that exception |
|
113 | + * @return void |
|
114 | + */ |
|
115 | + public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null) |
|
116 | + { |
|
117 | + if ($message_or_object instanceof EE_Validation_Error) { |
|
118 | + $validation_error = $message_or_object; |
|
119 | + $validation_error->set_form_section($this); |
|
120 | + } else { |
|
121 | + $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception); |
|
122 | + } |
|
123 | + $this->_validation_errors[] = $validation_error; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * When generating the JS for the jquery validation rules like<br> |
|
130 | + * <code>$( "#myform" ).validate({ |
|
131 | + * rules: { |
|
132 | + * password: "required", |
|
133 | + * password_again: { |
|
134 | + * equalTo: "#password" |
|
135 | + * } |
|
136 | + * } |
|
137 | + * });</code> |
|
138 | + * gets the sections like |
|
139 | + * <br><code>password: "required", |
|
140 | + * password_again: { |
|
141 | + * equalTo: "#password" |
|
142 | + * }</code> |
|
143 | + * except we leave it as a PHP object, and leave wp_localize_script to |
|
144 | + * turn it into a JSON object which can be used by the js |
|
145 | + * |
|
146 | + * @return array |
|
147 | + */ |
|
148 | + abstract public function get_jquery_validation_rules(); |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Checks if this form section's data is present in the req data specified |
|
154 | + * |
|
155 | + * @param array $req_data usually post data, if null that's what's used |
|
156 | + * @return boolean |
|
157 | + */ |
|
158 | + abstract public function form_data_present_in($req_data = null); |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Removes teh sensitive data from this form section (usually done after |
|
164 | + * utilizing the data business function, but before saving it somewhere. Eg, |
|
165 | + * may remove a password from the form after verifying it was correct) |
|
166 | + * |
|
167 | + * @return void |
|
168 | + */ |
|
169 | + abstract public function clean_sensitive_data(); |
|
170 | 170 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <tr class="item"> |
9 | 9 | <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td> |
10 | 10 | <td colspan="2">[LINE_ITEM_DESCRIPTION] |
11 | - <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . esc_html__('any', 'event_espresso') . ']'); ?></p> |
|
11 | + <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.esc_html__('any', 'event_espresso').']'); ?></p> |
|
12 | 12 | </td> |
13 | 13 | <td class="item_c">[LINE_ITEM_QUANTITY]</td> |
14 | 14 | <td class="item_c">[LINE_ITEM_AMOUNT]</td> |
@@ -15,17 +15,17 @@ |
||
15 | 15 | class Extend_EE_Attendee_Contact_List_Table extends EE_Attendee_Contact_List_Table |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_properties() |
|
19 | - { |
|
20 | - parent::_set_properties(); |
|
21 | - $this->_bottom_buttons = array( |
|
22 | - 'contact_list_report' => array( |
|
23 | - 'route' => 'contact_list_report', |
|
24 | - 'extra_request' => |
|
25 | - array( |
|
26 | - 'return_url' => $this->getReturnUrl(), |
|
27 | - ), |
|
28 | - ), |
|
29 | - ); |
|
30 | - } |
|
18 | + protected function _set_properties() |
|
19 | + { |
|
20 | + parent::_set_properties(); |
|
21 | + $this->_bottom_buttons = array( |
|
22 | + 'contact_list_report' => array( |
|
23 | + 'route' => 'contact_list_report', |
|
24 | + 'extra_request' => |
|
25 | + array( |
|
26 | + 'return_url' => $this->getReturnUrl(), |
|
27 | + ), |
|
28 | + ), |
|
29 | + ); |
|
30 | + } |
|
31 | 31 | } |