Completed
Branch FET-Wait-List (44abc2)
by
unknown
98:41 queued 88:15
created

DisplayTicketSelector::isIframe()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace EventEspresso\modules\ticket_selector;
3
4
use EE_Datetime;
5
use EE_Error;
6
use EE_Event;
7
use EE_Registry;
8
use EE_System;
9
use EE_Ticket_Selector_Config;
10
use EED_Events_Archive;
11
use EEH_Event_View;
12
use EEH_HTML;
13
use EEH_Template;
14
use EEH_URL;
15
use EEM_Event;
16
use EEM_Ticket;
17
use WP_Post;
18
19
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
20
    exit( 'No direct script access allowed' );
21
}
22
23
24
25
/**
26
 * Class DisplayTicketSelector
27
 * Description
28
 *
29
 * @package       Event Espresso
30
 * @subpackage    core
31
 * @author        Brent Christensen
32
 * @since         $VID:$
33
 */
34
class DisplayTicketSelector
35
{
36
37
    /**
38
     * event that ticket selector is being generated for
39
     *
40
     * @access protected
41
     * @var EE_Event $event
42
     */
43
    protected $event;
44
45
    /**
46
     * Used to flag when the ticket selector is being called from an external iframe.
47
     *
48
     * @var bool $iframe
49
     */
50
    protected $iframe = false;
51
52
    /**
53
     * max attendees that can register for event at one time
54
     *
55
     * @var int $max_attendees
56
     */
57
    private $max_attendees = EE_INF;
58
59
    /**
60
     *@var string $date_format
61
     */
62
    private $date_format;
63
64
    /**
65
     *@var string $time_format
66
     */
67
    private $time_format;
68
69
    /**
70
     *@var boolean $display_full_ui
71
     */
72
    private $display_full_ui;
73
74
75
76
    /**
77
     * DisplayTicketSelector constructor.
78
     */
79
    public function __construct()
80
    {
81
        $this->date_format = apply_filters(
82
            'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
83
            get_option('date_format')
84
        );
85
        $this->time_format = apply_filters(
86
            'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
87
            get_option('time_format')
88
        );
89
    }
90
91
92
    /**
93
     * @return bool
94
     */
95
    public function isIframe()
96
    {
97
        return $this->iframe;
98
    }
99
100
101
102
    /**
103
     * @param boolean $iframe
104
     */
105
    public function setIframe( $iframe = true )
106
    {
107
        $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
108
    }
109
110
111
    /**
112
     * finds and sets the \EE_Event object for use throughout class
113
     *
114
     * @param mixed $event
115
     * @return bool
116
     * @throws EE_Error
117
     */
118
    protected function setEvent( $event = null )
119
    {
120
        if ( $event === null ) {
121
            global $post;
122
            $event = $post;
123
        }
124
        if ( $event instanceof EE_Event ) {
125
            $this->event = $event;
126
        } elseif ( $event instanceof WP_Post ) {
0 ignored issues
show
Bug introduced by
The class WP_Post does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
127
            if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
128
                $this->event = $event->EE_Event;
129
            } elseif ( $event->post_type === 'espresso_events' ) {
130
                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
131
                $this->event = $event->EE_Event;
132
            }
133 View Code Duplication
        } else {
134
            $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
135
            $dev_msg = $user_msg . __(
136
                    '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.',
137
                    'event_espresso'
138
                );
139
            EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
140
            return false;
141
        }
142
        return true;
143
    }
144
145
146
147
    /**
148
     * @return int
149
     */
150
    public function getMaxAttendees()
151
    {
152
        return $this->max_attendees;
153
    }
154
155
156
157
    /**
158
     * @param int $max_attendees
159
     */
160
    public function setMaxAttendees($max_attendees)
161
    {
162
        $this->max_attendees = absint(
163
            apply_filters(
164
                'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
165
                $max_attendees
166
            )
167
        );
168
    }
169
170
171
172
    /**
173
     * Returns whether or not the full ticket selector should be shown or not.
174
     * Currently, it displays on the frontend (including ajax requests) but not the backend
175
     * @return bool
176
     */
177
    private function display_full_ui()
178
    {
179
        if ($this->display_full_ui === null) {
180
            $this->display_full_ui = ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX);
181
        }
182
        return $this->display_full_ui;
183
    }
184
185
186
    /**
187
     * creates buttons for selecting number of attendees for an event
188
     *
189
     * @param WP_Post|int $event
190
     * @param bool         $view_details
191
     * @return string
192
     * @throws EE_Error
193
     */
194
    public function display( $event = null, $view_details = false )
195
    {
196
        // reset filter for displaying submit button
197
        remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
198
        // poke and prod incoming event till it tells us what it is
199
        if ( ! $this->setEvent( $event ) ) {
200
            return false;
201
        }
202
        // begin gathering template arguments by getting event status
203
        $template_args = array( 'event_status' => $this->event->get_active_status() );
204
        if (
205
            $this->activeEventAndShowTicketSelector(
206
                $event,
207
                $template_args['event_status'],
208
                $view_details
209
            )
210
        ) {
211
            return ! is_single() ? $this->displayViewDetailsButton() : '';
212
        }
213
        // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
214
        $this->setMaxAttendees($this->event->additional_limit());
215
        if ($this->getMaxAttendees() < 1) {
216
            return $this->ticketSalesClosedMessage();
217
        }
218
        // is the event expired ?
219
        $template_args['event_is_expired'] = $this->event->is_expired();
220
        if ( $template_args[ 'event_is_expired' ] ) {
221
            return $this->expiredEventMessage();
222
        }
223
        // get all tickets for this event ordered by the datetime
224
        $tickets = $this->getTickets();
225
        if (count($tickets) < 1) {
226
            return $this->noTicketAvailableMessage();
227
        }
228
        if (EED_Events_Archive::is_iframe()){
229
            $this->setIframe();
230
        }
231
        // redirecting to another site for registration ??
232
        $external_url = (string) $this->event->external_url();
233
        // if redirecting to another site for registration, then we don't load the TS
234
        $ticket_selector = $external_url
235
            ? $this->externalEventRegistration()
236
            : $this->loadTicketSelector($tickets,$template_args);
237
        // now set up the form (but not for the admin)
238
        $ticket_selector = $this->display_full_ui()
239
            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
240
            : $ticket_selector;
241
        // submit button and form close tag
242
        $ticket_selector .= $this->display_full_ui() ? $this->displaySubmitButton($external_url) : '';
243
        return $ticket_selector;
244
    }
245
246
247
248
    /**
249
     * displayTicketSelector
250
     * examines the event properties and determines whether a Ticket Selector should be displayed
251
     *
252
     * @param WP_Post|int $event
253
     * @param string       $_event_active_status
254
     * @param bool         $view_details
255
     * @return bool
256
     * @throws EE_Error
257
     */
258
    protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
259
    {
260
        $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
261
        return $this->display_full_ui()
262
               && (
263
                   ! $this->event->display_ticket_selector()
264
                   || $view_details
265
                   || post_password_required($event_post)
266
                   || (
267
                       $_event_active_status !== EE_Datetime::active
268
                       && $_event_active_status !== EE_Datetime::upcoming
269
                       && $_event_active_status !== EE_Datetime::sold_out
270
                       && ! (
271
                           $_event_active_status === EE_Datetime::inactive
272
                           && is_user_logged_in()
273
                       )
274
                   )
275
               );
276
    }
277
278
279
280
    /**
281
     * noTicketAvailableMessage
282
     * notice displayed if event is expired
283
     *
284
     * @return string
285
     * @throws EE_Error
286
     */
287
    protected function expiredEventMessage()
288
    {
289
        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
290
            'We\'re sorry, but all tickets sales have ended because the event is expired.',
291
            'event_espresso'
292
        ) . '</span></div><!-- .ee-event-expired-notice -->';
293
    }
294
295
296
297
    /**
298
     * noTicketAvailableMessage
299
     * notice displayed if event has no more tickets available
300
     *
301
     * @return string
302
     * @throws EE_Error
303
     */
304 View Code Duplication
    protected function noTicketAvailableMessage()
305
    {
306
        $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
307
        if (current_user_can('edit_post', $this->event->ID())) {
308
            $no_ticket_available_msg .= sprintf(
309
                esc_html__(
310
                    '%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',
311
                    'event_espresso'
312
                ),
313
                '<div class="ee-attention" style="text-align: left;"><b>',
314
                '</b><br />',
315
                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
316
                '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
317
            );
318
        }
319
        return '
320
            <div class="ee-event-expired-notice">
321
                <span class="important-notice">' . $no_ticket_available_msg . '</span>
322
            </div><!-- .ee-event-expired-notice -->';
323
    }
324
325
326
327
    /**
328
     * ticketSalesClosed
329
     * notice displayed if event ticket sales are turned off
330
     *
331
     * @return string
332
     * @throws EE_Error
333
     */
334 View Code Duplication
    protected function ticketSalesClosedMessage()
335
    {
336
        $sales_closed_msg = esc_html__(
337
            'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
338
            'event_espresso'
339
        );
340
        if (current_user_can('edit_post', $this->event->ID())) {
341
            $sales_closed_msg .= sprintf(
342
                esc_html__(
343
                    '%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',
344
                    'event_espresso'
345
                ),
346
                '<div class="ee-attention" style="text-align: left;"><b>',
347
                '</b><br />',
348
                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
349
                '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
350
            );
351
        }
352
        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
353
    }
354
355
356
357
    /**
358
     * getTickets
359
     *
360
     * @return \EE_Base_Class[]|\EE_Ticket[]
361
     * @throws EE_Error
362
     */
363
    protected function getTickets()
364
    {
365
        $ticket_query_args = array(
366
            array('Datetime.EVT_ID' => $this->event->ID()),
367
            'order_by' => array(
368
                'TKT_order'              => 'ASC',
369
                'TKT_required'           => 'DESC',
370
                'TKT_start_date'         => 'ASC',
371
                'TKT_end_date'           => 'ASC',
372
                'Datetime.DTT_EVT_start' => 'DESC',
373
            ),
374
        );
375
        if (
376
            ! (
377
                EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
378
                && EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets
379
            )
380
        ) {
381
            //use the correct applicable time query depending on what version of core is being run.
382
            $current_time = method_exists('EEM_Datetime', 'current_time_for_query')
383
                ? time()
384
                : current_time('timestamp');
385
            $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
386
        }
387
        return EEM_Ticket::instance()->get_all($ticket_query_args);
388
    }
389
390
391
392
    /**
393
     * loadTicketSelector
394
     * begins to assemble template arguments
395
     * and decides whether to load a "simple" ticket selector, or the standard
396
     *
397
     * @param \EE_Ticket[] $tickets
398
     * @param array $template_args
399
     * @return string
400
     * @throws EE_Error
401
     */
402
    protected function loadTicketSelector(array $tickets, array $template_args)
403
    {
404
        $template_args['event'] = $this->event;
405
        $template_args['EVT_ID'] = $this->event->ID();
406
        $template_args['event_is_expired'] = $this->event->is_expired();
407
        $template_args['max_atndz'] = $this->getMaxAttendees();
408
        $template_args['date_format'] = $this->date_format;
409
        $template_args['time_format'] = $this->time_format;
410
        /**
411
         * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
412
         *
413
         * @since 4.9.13
414
         * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
415
         * @param int $EVT_ID The Event ID
416
         */
417
        $template_args['anchor_id'] = apply_filters(
418
            'FHEE__EE_Ticket_Selector__redirect_anchor_id',
419
            '#tkt-slctr-tbl-' . $this->event->ID(),
420
            $this->event->ID()
421
        );
422
        $template_args['tickets'] = $tickets;
423
        $template_args['ticket_count'] = count($tickets);
424
        $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
425
        return $ticket_selector instanceof TicketSelectorSimple
426
            ? $ticket_selector
427
            : new TicketSelectorStandard(
428
                $this->event,
429
                $tickets,
430
                $this->getMaxAttendees(),
431
                $template_args,
432
                $this->date_format,
433
                $this->time_format
434
            );
435
    }
436
437
438
439
    /**
440
     * simpleTicketSelector
441
     * there's one ticket, and max attendees is set to one,
442
     * so if the event is free, then this is a "simple" ticket selector
443
     * a.k.a. "Dude Where's my Ticket Selector?"
444
     *
445
     * @param \EE_Ticket[] $tickets
446
     * @param array  $template_args
447
     * @return string
448
     * @throws EE_Error
449
     */
450
    protected function simpleTicketSelector($tickets, array $template_args)
451
    {
452
        // if there is only ONE ticket with a max qty of ONE
453
        if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
454
            return '';
455
        }
456
        /** @var \EE_Ticket $ticket */
457
        $ticket = reset($tickets);
458
        // if the ticket is free... then not much need for the ticket selector
459
        if (
460
            apply_filters(
461
                'FHEE__ticket_selector_chart_template__hide_ticket_selector',
462
                $ticket->is_free(),
463
                $this->event->ID()
464
            )
465
        ) {
466
            return new TicketSelectorSimple(
467
                $this->event,
468
                $ticket,
469
                $this->getMaxAttendees(),
470
                $template_args
471
            );
472
        }
473
        return '';
474
    }
475
476
477
478
    /**
479
     * externalEventRegistration
480
     *
481
     * @return string
482
     */
483
    public function externalEventRegistration()
484
    {
485
        // if not we still need to trigger the display of the submit button
486
        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
487
        //display notice to admin that registration is external
488
        return $this->display_full_ui()
489
            ? esc_html__(
490
                'Registration is at an external URL for this event.',
491
                'event_espresso'
492
            )
493
            : '';
494
    }
495
496
497
498
    /**
499
     * formOpen
500
     *
501
     * @param        int    $ID
502
     * @param        string $external_url
503
     * @return        string
504
     */
505
    public function formOpen( $ID = 0, $external_url = '' )
506
    {
507
        // if redirecting, we don't need any anything else
508
        if ( $external_url ) {
509
            $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
510
            // open link in new window ?
511
            $html .= apply_filters(
512
                'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
513
                EED_Events_Archive::is_iframe()
514
            )
515
                ? ' target="_blank"'
516
                : '';
517
            $html .= '>';
518
            $query_args = EEH_URL::get_query_string( $external_url );
519
            foreach ( (array)$query_args as $query_arg => $value ) {
520
                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
521
            }
522
            return $html;
523
        }
524
        // if there is no submit button, then don't start building a form
525
        // because the "View Details" button will build its own form
526
        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
527
            return '';
528
        }
529
        $checkout_url = EEH_Event_View::event_link_url( $ID );
530
        if ( ! $checkout_url ) {
531
            EE_Error::add_error(
532
                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
533
                __FILE__,
534
                __FUNCTION__,
535
                __LINE__
536
            );
537
        }
538
        // set no cache headers and constants
539
        EE_System::do_not_cache();
540
        $extra_params = $this->iframe ? ' target="_blank"' : '';
541
        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
542
        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
543
        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
544
        return $html;
545
    }
546
547
548
549
    /**
550
     * displaySubmitButton
551
     *
552
     * @param  string $external_url
553
     * @return string
554
     * @throws EE_Error
555
     */
556
    public function displaySubmitButton($external_url = '')
557
    {
558
        $html = '';
559
        if ($this->display_full_ui()) {
560
            // standard TS displayed with submit button, ie: "Register Now"
561
            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
562
                $html .= $this->displayRegisterNowButton();
563
                $html .= empty($external_url)
564
                    ? $this->ticketSelectorEndDiv()
565
                    : $this->clearTicketSelector();
566
                $html .= '<br/>' . $this->formClose();
567
            } elseif ($this->getMaxAttendees() === 1) {
568
                // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
569
                if ($this->event->is_sold_out()) {
570
                    // then instead of a View Details or Submit button, just display a "Sold Out" message
571
                    $html .= apply_filters(
572
                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
573
                        sprintf(
574
                            __(
575
                                '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
576
                                'event_espresso'
577
                            ),
578
                            '<p class="no-ticket-selector-msg clear-float">',
579
                            $this->event->name(),
580
                            '</p>',
581
                            '<br />'
582
                        ),
583
                        $this->event
584
                    );
585
                    if (
586
                        apply_filters(
587
                            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
588
                            false,
589
                            $this->event
590
                        )
591
                    ) {
592
                        $html .= $this->displayRegisterNowButton();
593
                    }
594
                    // sold out DWMTS event, no TS, no submit or view details button, but has additional content
595
                    $html .=  $this->ticketSelectorEndDiv();
596
                } elseif (
597
                    apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
598
                    && ! is_single()
599
                ) {
600
                    // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
601
                    // but no tickets are available, so display event's "View Details" button.
602
                    // it is being viewed via somewhere other than a single post
603
                    $html .= $this->displayViewDetailsButton(true);
604
                } else {
605
                    $html .= $this->ticketSelectorEndDiv();
606
                }
607
            } elseif (is_archive()) {
608
                // event list, no tickets available so display event's "View Details" button
609
                $html .= $this->ticketSelectorEndDiv();
610
                $html .= $this->displayViewDetailsButton();
611
            } else {
612
                if (
613
                    apply_filters(
614
                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
615
                        false,
616
                        $this->event
617
                    )
618
                ) {
619
                    $html .= $this->displayRegisterNowButton();
620
                }
621
                // no submit or view details button, and no additional content
622
                $html .= $this->ticketSelectorEndDiv();
623
            }
624
            if ( ! $this->iframe && ! is_archive()) {
625
                $html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
626
            }
627
        }
628
	    return apply_filters(
629
		    'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displaySubmitButton__html',
630
		    $html,
631
		    $this->event,
632
            $this
633
	    );
634
    }
635
636
637
638
    /**
639
     * @return string
640
     * @throws EE_Error
641
     */
642
    public function displayRegisterNowButton()
643
    {
644
        $btn_text = apply_filters(
645
            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
646
            __('Register Now', 'event_espresso'),
647
            $this->event
648
        );
649
        $external_url = $this->event->external_url();
650
        $html = EEH_HTML::div(
651
            '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
652
        );
653
        $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
654
        $html .= ' class="ticket-selector-submit-btn ';
655
        $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
656
        $html .= ' type="submit" value="' . $btn_text . '" />';
657
        $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
658
        $html .= apply_filters(
659
            'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
660
            '',
661
            $this->event
662
        );
663
        return $html;
664
    }
665
666
667
    /**
668
     * displayViewDetailsButton
669
     *
670
     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
671
     *                    (ie: $_max_atndz === 1) where there are no available tickets,
672
     *                    either because they are sold out, expired, or not yet on sale.
673
     *                    In this case, we need to close the form BEFORE adding any closing divs
674
     * @return string
675
     * @throws EE_Error
676
     */
677
    public function displayViewDetailsButton( $DWMTS = false )
678
    {
679
        if ( ! $this->event->get_permalink() ) {
680
            EE_Error::add_error(
681
                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
682
                __FILE__, __FUNCTION__, __LINE__
683
            );
684
        }
685
        $view_details_btn = '<form method="POST" action="';
686
        $view_details_btn .= apply_filters(
687
            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
688
            $this->event->get_permalink(),
689
            $this->event
690
        );
691
        $view_details_btn .= '"';
692
        // open link in new window ?
693
        $view_details_btn .= apply_filters(
694
            'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
695
            EED_Events_Archive::is_iframe()
696
        )
697
            ? ' target="_blank"'
698
            : '';
699
        $view_details_btn .='>';
700
        $btn_text = apply_filters(
701
            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
702
            esc_html__('View Details', 'event_espresso'),
703
            $this->event
704
        );
705
        $view_details_btn .= '<input id="ticket-selector-submit-'
706
                             . $this->event->ID()
707
                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
708
                             . $btn_text
709
                             . '" />';
710
        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
711
        if ($DWMTS) {
712
            $view_details_btn .= $this->formClose();
713
            $view_details_btn .= $this->ticketSelectorEndDiv();
714
            $view_details_btn .= '<br/>';
715
        } else {
716
            $view_details_btn .= $this->clearTicketSelector();
717
            $view_details_btn .= '<br/>';
718
            $view_details_btn .= $this->formClose();
719
        }
720
        return $view_details_btn;
721
    }
722
723
724
725
    /**
726
     * @return string
727
     */
728
    public function ticketSelectorEndDiv()
729
    {
730
        return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
731
    }
732
733
734
735
    /**
736
     * @return string
737
     */
738
    public function clearTicketSelector()
739
    {
740
        // standard TS displayed, appears after a "Register Now" or "view Details" button
741
        return '<div class="clear"></div><!-- clearTicketSelector -->';
742
    }
743
744
745
746
    /**
747
     * @access        public
748
     * @return        string
749
     */
750
    public function formClose()
751
    {
752
        return '</form>';
753
    }
754
755
756
757
}
758
// End of file DisplayTicketSelector.php
759
// Location: /DisplayTicketSelector.php
760