Completed
Branch FET-8385-datetime-ticket-selec... (cac7e5)
by
unknown
67:23 queued 43:13
created
modules/ticket_selector/DisplayTicketSelector.php 2 patches
Indentation   +620 added lines, -620 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,628 +19,628 @@  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() : '';
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() : '';
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
-            );
377
-    }
378
-
379
-
380
-
381
-    /**
382
-     * simpleTicketSelector
383
-     * there's one ticket, and max attendees is set to one,
384
-     * so if the event is free, then this is a "simple" ticket selector
385
-     * a.k.a. "Dude Where's my Ticket Selector?"
386
-     *
387
-     * @param \EE_Ticket[] $tickets
388
-     * @param array  $template_args
389
-     * @return string
390
-     * @throws \EE_Error
391
-     */
392
-    protected function simpleTicketSelector($tickets, array $template_args)
393
-    {
394
-        // if there is only ONE ticket with a max qty of ONE
395
-        if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
396
-            return '';
397
-        }
398
-        /** @var \EE_Ticket $ticket */
399
-        $ticket = reset($tickets);
400
-        // if the ticket is free... then not much need for the ticket selector
401
-        if (
402
-            apply_filters(
403
-                'FHEE__ticket_selector_chart_template__hide_ticket_selector',
404
-                $ticket->is_free(),
405
-                $this->event->ID()
406
-            )
407
-        ) {
408
-            return new TicketSelectorSimple(
409
-                $this->event,
410
-                $ticket,
411
-                $this->getMaxAttendees(),
412
-                $template_args
413
-            );
414
-        }
415
-        return '';
416
-    }
417
-
418
-
419
-
420
-    /**
421
-     * externalEventRegistration
422
-     *
423
-     * @return string
424
-     */
425
-    public function externalEventRegistration()
426
-    {
427
-        // if not we still need to trigger the display of the submit button
428
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
429
-        //display notice to admin that registration is external
430
-        return is_admin()
431
-            ? esc_html__(
432
-                'Registration is at an external URL for this event.',
433
-                'event_espresso'
434
-            )
435
-            : '';
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * formOpen
442
-     *
443
-     * @param        int    $ID
444
-     * @param        string $external_url
445
-     * @return        string
446
-     */
447
-    public function formOpen( $ID = 0, $external_url = '' )
448
-    {
449
-        // if redirecting, we don't need any anything else
450
-        if ( $external_url ) {
451
-            $html = '<form method="GET" action="' . \EEH_URL::refactor_url( $external_url ) . '">';
452
-            $query_args = \EEH_URL::get_query_string( $external_url );
453
-            foreach ( (array)$query_args as $query_arg => $value ) {
454
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
455
-            }
456
-            return $html;
457
-        }
458
-        // if there is no submit button, then don't start building a form
459
-        // because the "View Details" button will build its own form
460
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
461
-            return '';
462
-        }
463
-        $checkout_url = \EEH_Event_View::event_link_url( $ID );
464
-        if ( ! $checkout_url ) {
465
-            \EE_Error::add_error(
466
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
467
-                __FILE__,
468
-                __FUNCTION__,
469
-                __LINE__
470
-            );
471
-        }
472
-        // set no cache headers and constants
473
-        \EE_System::do_not_cache();
474
-        $extra_params = $this->iframe ? ' target="_blank"' : '';
475
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
476
-        $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
477
-        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
478
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
479
-        return $html;
480
-    }
481
-
482
-
483
-
484
-    /**
485
-     * displaySubmitButton
486
-     *
487
-     * @access        public
488
-     * @return        string
489
-     * @throws \EE_Error
490
-     */
491
-    public function displaySubmitButton()
492
-    {
493
-        $html = '';
494
-        if ( ! is_admin() ) {
495
-            // standard TS displayed with submit button, ie: "Register Now"
496
-            if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
497
-                $btn_text = apply_filters(
498
-                    'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
499
-                    esc_html__( 'Register Now', 'event_espresso' ),
500
-                    $this->event
501
-                );
502
-                $external_url = $this->event->external_url();
503
-                $html .= \EEH_HTML::div(
504
-                	'', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
505
-                );
506
-	            $html .= \EEH_HTML::span(
507
-		            esc_html__( 'please select a datetime', 'event_espresso' ),
508
-		            '', 'ticket-selector-disabled-submit-btn-msg important-notice'
509
-	            );
510
-	            $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
511
-                $html .= ' class="ticket-selector-submit-btn ';
512
-                $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"';
513
-                $html .= ' type="submit" value="' . $btn_text . '" />';
514
-                $html .= \EEH_HTML::divx();
515
-                $html .= apply_filters(
516
-                    'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
517
-                    '',
518
-                    $this->event
519
-                );
520
-                $html .= $this->ticketSelectorEndDiv();
521
-                $html .= '<br/>' . $this->formClose();
522
-            } else if (
523
-                // a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
524
-                $this->getMaxAttendees() === 1
525
-                // and the event is sold out
526
-                && $this->event->is_sold_out()
527
-            ) {
528
-                // then instead of a View Details or Submit button, just display a "Sold Out" message
529
-                $html .= apply_filters(
530
-                    'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
531
-                    sprintf(
532
-                        esc_html__(
533
-                            '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
534
-                            'event_espresso'
535
-                        ),
536
-                        '<p class="no-ticket-selector-msg clear-float">',
537
-                        $this->event->name(),
538
-                        '</p>',
539
-                        '<br />'
540
-                    ),
541
-                    $this->event
542
-                );
543
-                // sold out DWMTS event, no TS, no submit or view details button, but has additional content
544
-                $html .= $this->ticketSelectorEndDiv();
545
-            } else if (
546
-                $this->getMaxAttendees() === 1
547
-                && apply_filters( 'FHEE__EE_Ticket_Selector__hide_ticket_selector', false )
548
-                && ! is_single()
549
-            ) {
550
-                // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
551
-                // but no tickets are available, so display event's "View Details" button.
552
-                // it is being viewed via somewhere other than a single post
553
-                $html .= $this->displayViewDetailsButton( true );
554
-            } else if ( is_archive() ) {
555
-                // event list, no tickets available so display event's "View Details" button
556
-                $html .= $this->ticketSelectorEndDiv();
557
-                $html .= $this->displayViewDetailsButton();
558
-            } else {
559
-                // no submit or view details button, and no additional content
560
-                $html .= $this->ticketSelectorEndDiv();
561
-            }
562
-            if ( ! $this->iframe && ! is_archive() ) {
563
-                $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
564
-            }
565
-        }
566
-        return $html;
567
-    }
568
-
569
-
570
-
571
-    /**
572
-     * displayViewDetailsButton
573
-     *
574
-     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
575
-     *                    (ie: $_max_atndz === 1) where there are no available tickets,
576
-     *                    either because they are sold out, expired, or not yet on sale.
577
-     *                    In this case, we need to close the form BEFORE adding any closing divs
578
-     * @return string
579
-     * @throws \EE_Error
580
-     */
581
-    public function displayViewDetailsButton( $DWMTS = false )
582
-    {
583
-        if ( ! $this->event->get_permalink() ) {
584
-            \EE_Error::add_error(
585
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
586
-                __FILE__, __FUNCTION__, __LINE__
587
-            );
588
-        }
589
-        $view_details_btn = '<form method="POST" action="' . $this->event->get_permalink() . '">';
590
-        $btn_text = apply_filters(
591
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
592
-            esc_html__( 'View Details', 'event_espresso' ),
593
-            $this->event
594
-        );
595
-        $view_details_btn .= '<input id="ticket-selector-submit-'
596
-                             . $this->event->ID()
597
-                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
598
-                             . $btn_text
599
-                             . '" />';
600
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
601
-        if ( $DWMTS ) {
602
-            $view_details_btn .= $this->formClose();
603
-            $view_details_btn .= $this->ticketSelectorEndDiv();
604
-            $view_details_btn .= '<br/>';
605
-        } else {
606
-            $view_details_btn .= $this->clearTicketSelector();
607
-            $view_details_btn .= '<br/>';
608
-            $view_details_btn .= $this->formClose();
609
-        }
610
-        return $view_details_btn;
611
-    }
612
-
613
-
614
-
615
-    /**
616
-     * @return string
617
-     */
618
-    public function ticketSelectorEndDiv()
619
-    {
620
-        return '<div class="clear"></div></div>';
621
-    }
622
-
623
-
624
-
625
-    /**
626
-     * @return string
627
-     */
628
-    public function clearTicketSelector()
629
-    {
630
-        // standard TS displayed, appears after a "Register Now" or "view Details" button
631
-        return '<div class="clear"></div>';
632
-    }
633
-
634
-
635
-
636
-    /**
637
-     * @access        public
638
-     * @return        string
639
-     */
640
-    public function formClose()
641
-    {
642
-        return '</form>';
643
-    }
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
+			);
377
+	}
378
+
379
+
380
+
381
+	/**
382
+	 * simpleTicketSelector
383
+	 * there's one ticket, and max attendees is set to one,
384
+	 * so if the event is free, then this is a "simple" ticket selector
385
+	 * a.k.a. "Dude Where's my Ticket Selector?"
386
+	 *
387
+	 * @param \EE_Ticket[] $tickets
388
+	 * @param array  $template_args
389
+	 * @return string
390
+	 * @throws \EE_Error
391
+	 */
392
+	protected function simpleTicketSelector($tickets, array $template_args)
393
+	{
394
+		// if there is only ONE ticket with a max qty of ONE
395
+		if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
396
+			return '';
397
+		}
398
+		/** @var \EE_Ticket $ticket */
399
+		$ticket = reset($tickets);
400
+		// if the ticket is free... then not much need for the ticket selector
401
+		if (
402
+			apply_filters(
403
+				'FHEE__ticket_selector_chart_template__hide_ticket_selector',
404
+				$ticket->is_free(),
405
+				$this->event->ID()
406
+			)
407
+		) {
408
+			return new TicketSelectorSimple(
409
+				$this->event,
410
+				$ticket,
411
+				$this->getMaxAttendees(),
412
+				$template_args
413
+			);
414
+		}
415
+		return '';
416
+	}
417
+
418
+
419
+
420
+	/**
421
+	 * externalEventRegistration
422
+	 *
423
+	 * @return string
424
+	 */
425
+	public function externalEventRegistration()
426
+	{
427
+		// if not we still need to trigger the display of the submit button
428
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
429
+		//display notice to admin that registration is external
430
+		return is_admin()
431
+			? esc_html__(
432
+				'Registration is at an external URL for this event.',
433
+				'event_espresso'
434
+			)
435
+			: '';
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * formOpen
442
+	 *
443
+	 * @param        int    $ID
444
+	 * @param        string $external_url
445
+	 * @return        string
446
+	 */
447
+	public function formOpen( $ID = 0, $external_url = '' )
448
+	{
449
+		// if redirecting, we don't need any anything else
450
+		if ( $external_url ) {
451
+			$html = '<form method="GET" action="' . \EEH_URL::refactor_url( $external_url ) . '">';
452
+			$query_args = \EEH_URL::get_query_string( $external_url );
453
+			foreach ( (array)$query_args as $query_arg => $value ) {
454
+				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
455
+			}
456
+			return $html;
457
+		}
458
+		// if there is no submit button, then don't start building a form
459
+		// because the "View Details" button will build its own form
460
+		if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
461
+			return '';
462
+		}
463
+		$checkout_url = \EEH_Event_View::event_link_url( $ID );
464
+		if ( ! $checkout_url ) {
465
+			\EE_Error::add_error(
466
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
467
+				__FILE__,
468
+				__FUNCTION__,
469
+				__LINE__
470
+			);
471
+		}
472
+		// set no cache headers and constants
473
+		\EE_System::do_not_cache();
474
+		$extra_params = $this->iframe ? ' target="_blank"' : '';
475
+		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
476
+		$html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
477
+		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
478
+		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
479
+		return $html;
480
+	}
481
+
482
+
483
+
484
+	/**
485
+	 * displaySubmitButton
486
+	 *
487
+	 * @access        public
488
+	 * @return        string
489
+	 * @throws \EE_Error
490
+	 */
491
+	public function displaySubmitButton()
492
+	{
493
+		$html = '';
494
+		if ( ! is_admin() ) {
495
+			// standard TS displayed with submit button, ie: "Register Now"
496
+			if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
497
+				$btn_text = apply_filters(
498
+					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
499
+					esc_html__( 'Register Now', 'event_espresso' ),
500
+					$this->event
501
+				);
502
+				$external_url = $this->event->external_url();
503
+				$html .= \EEH_HTML::div(
504
+					'', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
505
+				);
506
+				$html .= \EEH_HTML::span(
507
+					esc_html__( 'please select a datetime', 'event_espresso' ),
508
+					'', 'ticket-selector-disabled-submit-btn-msg important-notice'
509
+				);
510
+				$html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
511
+				$html .= ' class="ticket-selector-submit-btn ';
512
+				$html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"';
513
+				$html .= ' type="submit" value="' . $btn_text . '" />';
514
+				$html .= \EEH_HTML::divx();
515
+				$html .= apply_filters(
516
+					'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
517
+					'',
518
+					$this->event
519
+				);
520
+				$html .= $this->ticketSelectorEndDiv();
521
+				$html .= '<br/>' . $this->formClose();
522
+			} else if (
523
+				// a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
524
+				$this->getMaxAttendees() === 1
525
+				// and the event is sold out
526
+				&& $this->event->is_sold_out()
527
+			) {
528
+				// then instead of a View Details or Submit button, just display a "Sold Out" message
529
+				$html .= apply_filters(
530
+					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
531
+					sprintf(
532
+						esc_html__(
533
+							'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
534
+							'event_espresso'
535
+						),
536
+						'<p class="no-ticket-selector-msg clear-float">',
537
+						$this->event->name(),
538
+						'</p>',
539
+						'<br />'
540
+					),
541
+					$this->event
542
+				);
543
+				// sold out DWMTS event, no TS, no submit or view details button, but has additional content
544
+				$html .= $this->ticketSelectorEndDiv();
545
+			} else if (
546
+				$this->getMaxAttendees() === 1
547
+				&& apply_filters( 'FHEE__EE_Ticket_Selector__hide_ticket_selector', false )
548
+				&& ! is_single()
549
+			) {
550
+				// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
551
+				// but no tickets are available, so display event's "View Details" button.
552
+				// it is being viewed via somewhere other than a single post
553
+				$html .= $this->displayViewDetailsButton( true );
554
+			} else if ( is_archive() ) {
555
+				// event list, no tickets available so display event's "View Details" button
556
+				$html .= $this->ticketSelectorEndDiv();
557
+				$html .= $this->displayViewDetailsButton();
558
+			} else {
559
+				// no submit or view details button, and no additional content
560
+				$html .= $this->ticketSelectorEndDiv();
561
+			}
562
+			if ( ! $this->iframe && ! is_archive() ) {
563
+				$html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
564
+			}
565
+		}
566
+		return $html;
567
+	}
568
+
569
+
570
+
571
+	/**
572
+	 * displayViewDetailsButton
573
+	 *
574
+	 * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
575
+	 *                    (ie: $_max_atndz === 1) where there are no available tickets,
576
+	 *                    either because they are sold out, expired, or not yet on sale.
577
+	 *                    In this case, we need to close the form BEFORE adding any closing divs
578
+	 * @return string
579
+	 * @throws \EE_Error
580
+	 */
581
+	public function displayViewDetailsButton( $DWMTS = false )
582
+	{
583
+		if ( ! $this->event->get_permalink() ) {
584
+			\EE_Error::add_error(
585
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
586
+				__FILE__, __FUNCTION__, __LINE__
587
+			);
588
+		}
589
+		$view_details_btn = '<form method="POST" action="' . $this->event->get_permalink() . '">';
590
+		$btn_text = apply_filters(
591
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
592
+			esc_html__( 'View Details', 'event_espresso' ),
593
+			$this->event
594
+		);
595
+		$view_details_btn .= '<input id="ticket-selector-submit-'
596
+							 . $this->event->ID()
597
+							 . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
598
+							 . $btn_text
599
+							 . '" />';
600
+		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
601
+		if ( $DWMTS ) {
602
+			$view_details_btn .= $this->formClose();
603
+			$view_details_btn .= $this->ticketSelectorEndDiv();
604
+			$view_details_btn .= '<br/>';
605
+		} else {
606
+			$view_details_btn .= $this->clearTicketSelector();
607
+			$view_details_btn .= '<br/>';
608
+			$view_details_btn .= $this->formClose();
609
+		}
610
+		return $view_details_btn;
611
+	}
612
+
613
+
614
+
615
+	/**
616
+	 * @return string
617
+	 */
618
+	public function ticketSelectorEndDiv()
619
+	{
620
+		return '<div class="clear"></div></div>';
621
+	}
622
+
623
+
624
+
625
+	/**
626
+	 * @return string
627
+	 */
628
+	public function clearTicketSelector()
629
+	{
630
+		// standard TS displayed, appears after a "Register Now" or "view Details" button
631
+		return '<div class="clear"></div>';
632
+	}
633
+
634
+
635
+
636
+	/**
637
+	 * @access        public
638
+	 * @return        string
639
+	 */
640
+	public function formClose()
641
+	{
642
+		return '</form>';
643
+	}
644 644
 
645 645
 
646 646
 
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 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() : '';
@@ -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(
@@ -444,26 +444,26 @@  discard block
 block discarded – undo
444 444
      * @param        string $external_url
445 445
      * @return        string
446 446
      */
447
-    public function formOpen( $ID = 0, $external_url = '' )
447
+    public function formOpen($ID = 0, $external_url = '')
448 448
     {
449 449
         // if redirecting, we don't need any anything else
450
-        if ( $external_url ) {
451
-            $html = '<form method="GET" action="' . \EEH_URL::refactor_url( $external_url ) . '">';
452
-            $query_args = \EEH_URL::get_query_string( $external_url );
453
-            foreach ( (array)$query_args as $query_arg => $value ) {
454
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
450
+        if ($external_url) {
451
+            $html = '<form method="GET" action="'.\EEH_URL::refactor_url($external_url).'">';
452
+            $query_args = \EEH_URL::get_query_string($external_url);
453
+            foreach ((array) $query_args as $query_arg => $value) {
454
+                $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
455 455
             }
456 456
             return $html;
457 457
         }
458 458
         // if there is no submit button, then don't start building a form
459 459
         // because the "View Details" button will build its own form
460
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
460
+        if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
461 461
             return '';
462 462
         }
463
-        $checkout_url = \EEH_Event_View::event_link_url( $ID );
464
-        if ( ! $checkout_url ) {
463
+        $checkout_url = \EEH_Event_View::event_link_url($ID);
464
+        if ( ! $checkout_url) {
465 465
             \EE_Error::add_error(
466
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
466
+                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
467 467
                 __FILE__,
468 468
                 __FUNCTION__,
469 469
                 __LINE__
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
         // set no cache headers and constants
473 473
         \EE_System::do_not_cache();
474 474
         $extra_params = $this->iframe ? ' target="_blank"' : '';
475
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
476
-        $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
475
+        $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
476
+        $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, true, false);
477 477
         $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
478
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
478
+        $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event);
479 479
         return $html;
480 480
     }
481 481
 
@@ -491,26 +491,26 @@  discard block
 block discarded – undo
491 491
     public function displaySubmitButton()
492 492
     {
493 493
         $html = '';
494
-        if ( ! is_admin() ) {
494
+        if ( ! is_admin()) {
495 495
             // standard TS displayed with submit button, ie: "Register Now"
496
-            if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
496
+            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
497 497
                 $btn_text = apply_filters(
498 498
                     'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
499
-                    esc_html__( 'Register Now', 'event_espresso' ),
499
+                    esc_html__('Register Now', 'event_espresso'),
500 500
                     $this->event
501 501
                 );
502 502
                 $external_url = $this->event->external_url();
503 503
                 $html .= \EEH_HTML::div(
504
-                	'', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
504
+                	'', 'ticket-selector-submit-'.$this->event->ID().'-btn-wrap', 'ticket-selector-submit-btn-wrap'
505 505
                 );
506 506
 	            $html .= \EEH_HTML::span(
507
-		            esc_html__( 'please select a datetime', 'event_espresso' ),
507
+		            esc_html__('please select a datetime', 'event_espresso'),
508 508
 		            '', 'ticket-selector-disabled-submit-btn-msg important-notice'
509 509
 	            );
510
-	            $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
510
+	            $html .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"';
511 511
                 $html .= ' class="ticket-selector-submit-btn ';
512
-                $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"';
513
-                $html .= ' type="submit" value="' . $btn_text . '" />';
512
+                $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
513
+                $html .= ' type="submit" value="'.$btn_text.'" />';
514 514
                 $html .= \EEH_HTML::divx();
515 515
                 $html .= apply_filters(
516 516
                     'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
                     $this->event
519 519
                 );
520 520
                 $html .= $this->ticketSelectorEndDiv();
521
-                $html .= '<br/>' . $this->formClose();
521
+                $html .= '<br/>'.$this->formClose();
522 522
             } else if (
523 523
                 // a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
524 524
                 $this->getMaxAttendees() === 1
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
                 $html .= $this->ticketSelectorEndDiv();
545 545
             } else if (
546 546
                 $this->getMaxAttendees() === 1
547
-                && apply_filters( 'FHEE__EE_Ticket_Selector__hide_ticket_selector', false )
547
+                && apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
548 548
                 && ! is_single()
549 549
             ) {
550 550
                 // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
551 551
                 // but no tickets are available, so display event's "View Details" button.
552 552
                 // it is being viewed via somewhere other than a single post
553
-                $html .= $this->displayViewDetailsButton( true );
554
-            } else if ( is_archive() ) {
553
+                $html .= $this->displayViewDetailsButton(true);
554
+            } else if (is_archive()) {
555 555
                 // event list, no tickets available so display event's "View Details" button
556 556
                 $html .= $this->ticketSelectorEndDiv();
557 557
                 $html .= $this->displayViewDetailsButton();
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
                 // no submit or view details button, and no additional content
560 560
                 $html .= $this->ticketSelectorEndDiv();
561 561
             }
562
-            if ( ! $this->iframe && ! is_archive() ) {
562
+            if ( ! $this->iframe && ! is_archive()) {
563 563
                 $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
564 564
             }
565 565
         }
@@ -578,18 +578,18 @@  discard block
 block discarded – undo
578 578
      * @return string
579 579
      * @throws \EE_Error
580 580
      */
581
-    public function displayViewDetailsButton( $DWMTS = false )
581
+    public function displayViewDetailsButton($DWMTS = false)
582 582
     {
583
-        if ( ! $this->event->get_permalink() ) {
583
+        if ( ! $this->event->get_permalink()) {
584 584
             \EE_Error::add_error(
585
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
585
+                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
586 586
                 __FILE__, __FUNCTION__, __LINE__
587 587
             );
588 588
         }
589
-        $view_details_btn = '<form method="POST" action="' . $this->event->get_permalink() . '">';
589
+        $view_details_btn = '<form method="POST" action="'.$this->event->get_permalink().'">';
590 590
         $btn_text = apply_filters(
591 591
             'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
592
-            esc_html__( 'View Details', 'event_espresso' ),
592
+            esc_html__('View Details', 'event_espresso'),
593 593
             $this->event
594 594
         );
595 595
         $view_details_btn .= '<input id="ticket-selector-submit-'
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
                              . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
598 598
                              . $btn_text
599 599
                              . '" />';
600
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
601
-        if ( $DWMTS ) {
600
+        $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event);
601
+        if ($DWMTS) {
602 602
             $view_details_btn .= $this->formClose();
603 603
             $view_details_btn .= $this->ticketSelectorEndDiv();
604 604
             $view_details_btn .= '<br/>';
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorSimple.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -18,46 +18,46 @@
 block discarded – undo
18 18
 class TicketSelectorSimple extends TicketSelector
19 19
 {
20 20
 
21
-    /**
22
-     * @var \EE_Ticket $ticket
23
-     */
24
-    protected $ticket;
21
+	/**
22
+	 * @var \EE_Ticket $ticket
23
+	 */
24
+	protected $ticket;
25 25
 
26 26
 
27 27
 
28
-    /**
29
-     * TicketSelectorSimple constructor.
30
-     *
31
-     * @param \EE_Event  $event
32
-     * @param \EE_Ticket $ticket
33
-     * @param int        $max_attendees
34
-     * @param array      $template_args
35
-     */
36
-    public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args)
37
-    {
38
-        $this->ticket = $ticket;
39
-        parent::__construct($event, array($this->ticket), $max_attendees, $template_args);
40
-    }
28
+	/**
29
+	 * TicketSelectorSimple constructor.
30
+	 *
31
+	 * @param \EE_Event  $event
32
+	 * @param \EE_Ticket $ticket
33
+	 * @param int        $max_attendees
34
+	 * @param array      $template_args
35
+	 */
36
+	public function __construct(\EE_Event $event, \EE_Ticket $ticket, $max_attendees, array $template_args)
37
+	{
38
+		$this->ticket = $ticket;
39
+		parent::__construct($event, array($this->ticket), $max_attendees, $template_args);
40
+	}
41 41
 
42 42
 
43 43
 
44
-    /**
45
-     * sets any and all template args that are required for this Ticket Selector
46
-     *
47
-     * @return void
48
-     */
49
-    protected function addTemplateArgs()
50
-    {
51
-        unset($this->template_args['tickets']);
52
-        $this->template_args['ticket'] = $this->ticket;
53
-        $ticket_selector_row = new TicketSelectorRowSimple(
54
-            $this->ticket,
55
-            $this->max_attendees,
56
-            $this->template_args['date_format']
57
-        );
58
-        $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
59
-        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
60
-    }
44
+	/**
45
+	 * sets any and all template args that are required for this Ticket Selector
46
+	 *
47
+	 * @return void
48
+	 */
49
+	protected function addTemplateArgs()
50
+	{
51
+		unset($this->template_args['tickets']);
52
+		$this->template_args['ticket'] = $this->ticket;
53
+		$ticket_selector_row = new TicketSelectorRowSimple(
54
+			$this->ticket,
55
+			$this->max_attendees,
56
+			$this->template_args['date_format']
57
+		);
58
+		$this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
59
+		$this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
60
+	}
61 61
 
62 62
 
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
             $this->template_args['date_format']
57 57
         );
58 58
         $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
59
-        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
59
+        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php';
60 60
     }
61 61
 
62 62
 
Please login to merge, or discard this patch.
modules/ticket_selector/templates/standard_ticket_selector.template.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 			<tr>
28 28
 				<th scope="col" class="ee-ticket-selector-ticket-details-th">
29 29
 					<?php
30
-                    echo apply_filters(
31
-                        'FHEE__ticket_selector_chart_template__table_header_available_tickets',
32
-                        esc_html__(''),
33
-                        $EVT_ID
34
-                    );
35
-                    ?>
30
+					echo apply_filters(
31
+						'FHEE__ticket_selector_chart_template__table_header_available_tickets',
32
+						esc_html__(''),
33
+						$EVT_ID
34
+					);
35
+					?>
36 36
 				</th>
37 37
 				<?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?>
38 38
 				<th scope="col" class="ee-ticket-selector-ticket-price-th cntr">
@@ -46,28 +46,28 @@  discard block
 block discarded – undo
46 46
 						 * @param int $EVT_ID The Event ID
47 47
 						 */
48 48
 						echo apply_filters(
49
-                            'FHEE__ticket_selector_chart_template__table_header_price',
50
-                            esc_html__( 'Price', 'event_espresso' ),
51
-                            $EVT_ID
52
-                        );
49
+							'FHEE__ticket_selector_chart_template__table_header_price',
50
+							esc_html__( 'Price', 'event_espresso' ),
51
+							$EVT_ID
52
+						);
53 53
 					?>
54 54
 				</th>
55 55
 				<?php } ?>
56 56
 				<th scope="col" class="ee-ticket-selector-ticket-qty-th cntr">
57 57
 					<?php
58 58
 						/**
59
-						* Filters the text printed for the header of the quantity column in the ticket selector table
60
-						*
61
-						* @since 4.7.2
62
-						*
63
-						* @param string 'Qty*' The translatable text to display in the table header for the Quantity of tickets
64
-						* @param int $EVT_ID The Event ID
65
-						*/
59
+						 * Filters the text printed for the header of the quantity column in the ticket selector table
60
+						 *
61
+						 * @since 4.7.2
62
+						 *
63
+						 * @param string 'Qty*' The translatable text to display in the table header for the Quantity of tickets
64
+						 * @param int $EVT_ID The Event ID
65
+						 */
66 66
 						echo apply_filters(
67
-                            'FHEE__ticket_selector_chart_template__table_header_qty',
68
-                            esc_html__( 'Qty*', 'event_espresso' ),
69
-                            $EVT_ID
70
-                        );
67
+							'FHEE__ticket_selector_chart_template__table_header_qty',
68
+							esc_html__( 'Qty*', 'event_espresso' ),
69
+							$EVT_ID
70
+						);
71 71
 					?>
72 72
 				</th>
73 73
 			</tr>
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 if ( $max_atndz > 0 ) {
98 98
 	echo apply_filters(
99 99
 		'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote',
100
-        esc_html__('')
100
+		esc_html__('')
101 101
 	);
102 102
 }
103 103
 if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 ?>
20 20
 <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv">
21 21
 
22
-	<?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?>
22
+	<?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?>
23 23
 	<?php echo $datetime_selector; ?>
24 24
 
25 25
 	<table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl">
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                     );
35 35
                     ?>
36 36
 				</th>
37
-				<?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?>
37
+				<?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?>
38 38
 				<th scope="col" class="ee-ticket-selector-ticket-price-th cntr">
39 39
 					<?php
40 40
 						/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 						 */
48 48
 						echo apply_filters(
49 49
                             'FHEE__ticket_selector_chart_template__table_header_price',
50
-                            esc_html__( 'Price', 'event_espresso' ),
50
+                            esc_html__('Price', 'event_espresso'),
51 51
                             $EVT_ID
52 52
                         );
53 53
 					?>
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 						*/
66 66
 						echo apply_filters(
67 67
                             'FHEE__ticket_selector_chart_template__table_header_qty',
68
-                            esc_html__( 'Qty*', 'event_espresso' ),
68
+                            esc_html__('Qty*', 'event_espresso'),
69 69
                             $EVT_ID
70 70
                         );
71 71
 					?>
@@ -73,34 +73,34 @@  discard block
 block discarded – undo
73 73
 			</tr>
74 74
 		</thead>
75 75
 		<tbody>
76
-			<?php echo $ticket_row_html;?>
76
+			<?php echo $ticket_row_html; ?>
77 77
 		</tbody>
78 78
 	</table>
79 79
 	<?php
80
-	if ( $taxable_tickets && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', true ) ) {
81
-		if ( $prices_displayed_including_taxes ) {
82
-			$ticket_price_includes_taxes = esc_html__( '* price includes taxes', 'event_espresso' );
80
+	if ($taxable_tickets && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
81
+		if ($prices_displayed_including_taxes) {
82
+			$ticket_price_includes_taxes = esc_html__('* price includes taxes', 'event_espresso');
83 83
 		} else {
84
-			$ticket_price_includes_taxes = esc_html__( '* price does not include taxes', 'event_espresso' );
84
+			$ticket_price_includes_taxes = esc_html__('* price does not include taxes', 'event_espresso');
85 85
 		}
86
-		echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">' . $ticket_price_includes_taxes . '</p>';
86
+		echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">'.$ticket_price_includes_taxes.'</p>';
87 87
 	}
88 88
 	?>
89 89
 
90 90
 	<input type="hidden" name="noheader" value="true" />
91
-	<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url() . $anchor_id; ?>" />
91
+	<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url().$anchor_id; ?>" />
92 92
 	<input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>" />
93 93
 	<input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>" />
94 94
 	<input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>" />
95 95
 
96 96
 <?php
97
-if ( $max_atndz > 0 ) {
97
+if ($max_atndz > 0) {
98 98
 	echo apply_filters(
99 99
 		'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote',
100 100
         esc_html__('')
101 101
 	);
102 102
 }
103
-if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
104
-	add_filter( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true' );
103
+if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
104
+	add_filter('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true');
105 105
 }
106
-do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
107 106
\ No newline at end of file
107
+do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event);
108 108
\ No newline at end of file
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelector.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -16,90 +16,90 @@
 block discarded – undo
16 16
 abstract class TicketSelector
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 int max_attendees
31
-     */
32
-    protected $max_attendees;
33
-
34
-    /**
35
-     * @var array $template_args
36
-     */
37
-    protected $template_args;
38
-
39
-
40
-
41
-    /**
42
-     * TicketSelectorSimple constructor.
43
-     *
44
-     * @param \EE_Event    $event
45
-     * @param \EE_Ticket[] $tickets
46
-     * @param int          $max_attendees
47
-     * @param array        $template_args
48
-     */
49
-    public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args)
50
-    {
51
-        $this->event         = $event;
52
-        $this->tickets       = $tickets;
53
-        $this->max_attendees = $max_attendees;
54
-        $this->template_args = $template_args;
55
-        $this->addTemplateArgs();
56
-    }
57
-
58
-
59
-
60
-    /**
61
-     * sets any and all template args that are required for this Ticket Selector
62
-     *
63
-     * @return void
64
-     */
65
-    abstract protected function addTemplateArgs();
66
-
67
-
68
-
69
-    /**
70
-     * loadTicketSelectorTemplate
71
-     *
72
-     * @return string
73
-     */
74
-    protected function loadTicketSelectorTemplate()
75
-    {
76
-        try {
77
-            return \EEH_Template::locate_template(
78
-                apply_filters(
79
-                    'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path',
80
-                    $this->template_args['template_path'],
81
-                    $this->event
82
-                ),
83
-                $this->template_args
84
-            );
85
-        } catch (\Exception $e) {
86
-            \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
87
-        }
88
-        return '';
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * The __toString method allows a class to decide how it will react when it is converted to a string.
95
-     *
96
-     * @return string
97
-     * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
98
-     */
99
-    public function __toString()
100
-    {
101
-        return $this->loadTicketSelectorTemplate();
102
-    }
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 int max_attendees
31
+	 */
32
+	protected $max_attendees;
33
+
34
+	/**
35
+	 * @var array $template_args
36
+	 */
37
+	protected $template_args;
38
+
39
+
40
+
41
+	/**
42
+	 * TicketSelectorSimple constructor.
43
+	 *
44
+	 * @param \EE_Event    $event
45
+	 * @param \EE_Ticket[] $tickets
46
+	 * @param int          $max_attendees
47
+	 * @param array        $template_args
48
+	 */
49
+	public function __construct(\EE_Event $event, array $tickets, $max_attendees, array $template_args)
50
+	{
51
+		$this->event         = $event;
52
+		$this->tickets       = $tickets;
53
+		$this->max_attendees = $max_attendees;
54
+		$this->template_args = $template_args;
55
+		$this->addTemplateArgs();
56
+	}
57
+
58
+
59
+
60
+	/**
61
+	 * sets any and all template args that are required for this Ticket Selector
62
+	 *
63
+	 * @return void
64
+	 */
65
+	abstract protected function addTemplateArgs();
66
+
67
+
68
+
69
+	/**
70
+	 * loadTicketSelectorTemplate
71
+	 *
72
+	 * @return string
73
+	 */
74
+	protected function loadTicketSelectorTemplate()
75
+	{
76
+		try {
77
+			return \EEH_Template::locate_template(
78
+				apply_filters(
79
+					'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path',
80
+					$this->template_args['template_path'],
81
+					$this->event
82
+				),
83
+				$this->template_args
84
+			);
85
+		} catch (\Exception $e) {
86
+			\EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
87
+		}
88
+		return '';
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * The __toString method allows a class to decide how it will react when it is converted to a string.
95
+	 *
96
+	 * @return string
97
+	 * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring
98
+	 */
99
+	public function __toString()
100
+	{
101
+		return $this->loadTicketSelectorTemplate();
102
+	}
103 103
 
104 104
 
105 105
 
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorStandard.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -17,103 +17,103 @@
 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 \EE_Ticket_Selector_Config $ticket_selector_config
27
-     */
28
-    protected $ticket_selector_config;
29
-
30
-    /**
31
-     * @var \EE_Tax_Config $tax_config
32
-     */
33
-    protected $tax_config;
34
-
35
-
36
-
37
-    /**
38
-     * TicketSelectorSimple constructor.
39
-     *
40
-     * @param \EE_Event                  $event
41
-     * @param \EE_Ticket[]               $tickets
42
-     * @param int                        $max_attendees
43
-     * @param array                      $template_args
44
-     * @param string                     $date_format
45
-     * @param \EE_Ticket_Selector_Config $ticket_selector_config
46
-     * @param \EE_Tax_Config             $tax_config
47
-     */
48
-    public function __construct(
49
-        \EE_Event $event,
50
-        array $tickets,
51
-        $max_attendees,
52
-        array $template_args,
53
-        $date_format = 'Y-m-d',
54
-        \EE_Ticket_Selector_Config $ticket_selector_config = null,
55
-        \EE_Tax_Config $tax_config = null
56
-    ) {
57
-        // get EE_Ticket_Selector_Config and TicketDetails
58
-        $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
59
-            ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
60
-            : new \EE_Ticket_Selector_Config();
61
-        // $template_settings->setDatetimeSelectorThreshold(2);
62
-        // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__);
63
-        // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__);
64
-        $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings)
65
-            ? \EE_Registry::instance()->CFG->tax_settings
66
-            : new \EE_Tax_Config();
67
-        parent::__construct($event, $tickets, $max_attendees, $template_args);
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * sets any and all template args that are required for this Ticket Selector
74
-     *
75
-     * @return void
76
-     * @throws \EE_Error
77
-     */
78
-    protected function addTemplateArgs()
79
-    {
80
-        $row = 1;
81
-        $ticket_row_html = '';
82
-        $required_ticket_sold_out = false;
83
-        // flag to indicate that at least one taxable ticket has been encountered
84
-        $taxable_tickets = false;
85
-        $datetime_selector = new DatetimeSelector($this->event, $this->tickets, $this->ticket_selector_config);
86
-        // loop through tickets
87
-        foreach ($this->tickets as $TKT_ID => $ticket) {
88
-            if ($ticket instanceof \EE_Ticket) {
89
-                $cols = 2;
90
-                $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
91
-                $ticket_selector_row = new TicketSelectorRowStandard(
92
-                    $ticket,
93
-                    new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),
94
-                    $this->ticket_selector_config,
95
-                    $this->tax_config,
96
-                    $this->max_attendees,
97
-                    $row,
98
-                    $cols,
99
-                    $required_ticket_sold_out,
100
-                    $this->template_args['event_status'],
101
-                    $this->template_args['date_format'],
102
-                    $datetime_selector->getTicketDatetimeClasses($ticket)
103
-                );
104
-                $ticket_row_html .= $ticket_selector_row->getHtml();
105
-                $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();
106
-                $row++;
107
-            }
108
-        }
109
-        $this->template_args['row'] = $row;
110
-        $this->template_args['ticket_row_html'] = $ticket_row_html;
111
-        $this->template_args['taxable_tickets'] = $taxable_tickets;
112
-        $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector($this->date_format);
113
-        $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
114
-        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
115
-        remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
116
-    }
20
+	/**
21
+	 * @var string $date_format
22
+	 */
23
+	protected $date_format;
24
+
25
+	/**
26
+	 * @var \EE_Ticket_Selector_Config $ticket_selector_config
27
+	 */
28
+	protected $ticket_selector_config;
29
+
30
+	/**
31
+	 * @var \EE_Tax_Config $tax_config
32
+	 */
33
+	protected $tax_config;
34
+
35
+
36
+
37
+	/**
38
+	 * TicketSelectorSimple constructor.
39
+	 *
40
+	 * @param \EE_Event                  $event
41
+	 * @param \EE_Ticket[]               $tickets
42
+	 * @param int                        $max_attendees
43
+	 * @param array                      $template_args
44
+	 * @param string                     $date_format
45
+	 * @param \EE_Ticket_Selector_Config $ticket_selector_config
46
+	 * @param \EE_Tax_Config             $tax_config
47
+	 */
48
+	public function __construct(
49
+		\EE_Event $event,
50
+		array $tickets,
51
+		$max_attendees,
52
+		array $template_args,
53
+		$date_format = 'Y-m-d',
54
+		\EE_Ticket_Selector_Config $ticket_selector_config = null,
55
+		\EE_Tax_Config $tax_config = null
56
+	) {
57
+		// get EE_Ticket_Selector_Config and TicketDetails
58
+		$this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
59
+			? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
60
+			: new \EE_Ticket_Selector_Config();
61
+		// $template_settings->setDatetimeSelectorThreshold(2);
62
+		// \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__);
63
+		// \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__);
64
+		$this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings)
65
+			? \EE_Registry::instance()->CFG->tax_settings
66
+			: new \EE_Tax_Config();
67
+		parent::__construct($event, $tickets, $max_attendees, $template_args);
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * sets any and all template args that are required for this Ticket Selector
74
+	 *
75
+	 * @return void
76
+	 * @throws \EE_Error
77
+	 */
78
+	protected function addTemplateArgs()
79
+	{
80
+		$row = 1;
81
+		$ticket_row_html = '';
82
+		$required_ticket_sold_out = false;
83
+		// flag to indicate that at least one taxable ticket has been encountered
84
+		$taxable_tickets = false;
85
+		$datetime_selector = new DatetimeSelector($this->event, $this->tickets, $this->ticket_selector_config);
86
+		// loop through tickets
87
+		foreach ($this->tickets as $TKT_ID => $ticket) {
88
+			if ($ticket instanceof \EE_Ticket) {
89
+				$cols = 2;
90
+				$taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
91
+				$ticket_selector_row = new TicketSelectorRowStandard(
92
+					$ticket,
93
+					new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),
94
+					$this->ticket_selector_config,
95
+					$this->tax_config,
96
+					$this->max_attendees,
97
+					$row,
98
+					$cols,
99
+					$required_ticket_sold_out,
100
+					$this->template_args['event_status'],
101
+					$this->template_args['date_format'],
102
+					$datetime_selector->getTicketDatetimeClasses($ticket)
103
+				);
104
+				$ticket_row_html .= $ticket_selector_row->getHtml();
105
+				$required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();
106
+				$row++;
107
+			}
108
+		}
109
+		$this->template_args['row'] = $row;
110
+		$this->template_args['ticket_row_html'] = $ticket_row_html;
111
+		$this->template_args['taxable_tickets'] = $taxable_tickets;
112
+		$this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector($this->date_format);
113
+		$this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
114
+		$this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
115
+		remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
116
+	}
117 117
 
118 118
 
119 119
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
         $this->template_args['taxable_tickets'] = $taxable_tickets;
112 112
         $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector($this->date_format);
113 113
         $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
114
-        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
114
+        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php';
115 115
         remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
116 116
     }
117 117
 
Please login to merge, or discard this patch.