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