Completed
Branch BUG-10478-ticket-selector-radi... (7868f0)
by
unknown
65:35 queued 38:30
created
modules/ticket_selector/TicketSelectorRowStandard.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
      * setTicketMinAndMax
240 240
      *
241 241
      * @param int $remaining
242
-     * @return array
242
+     * @return integer[]
243 243
      * @throws \EE_Error
244 244
      */
245 245
     protected function setTicketMinAndMax($remaining)
Please login to merge, or discard this patch.
Indentation   +456 added lines, -456 removed lines patch added patch discarded remove patch
@@ -16,462 +16,462 @@
 block discarded – undo
16 16
 class TicketSelectorRowStandard extends TicketSelectorRow
17 17
 {
18 18
 
19
-    /**
20
-     * @var TicketDetails $ticket_details
21
-     */
22
-    protected $ticket_details;
23
-
24
-    /**
25
-     * @var \EE_Ticket_Selector_Config $template_settings
26
-     */
27
-    protected $template_settings;
28
-
29
-    /**
30
-     * @var \EE_Tax_Config $tax_settings
31
-     */
32
-    protected $tax_settings;
33
-
34
-    /**
35
-     * @var boolean $required_ticket_sold_out
36
-     */
37
-    protected $required_ticket_sold_out;
38
-
39
-    /**
40
-     * @var boolean $prices_displayed_including_taxes
41
-     */
42
-    protected $prices_displayed_including_taxes;
43
-
44
-    /**
45
-     * @var string $event_status
46
-     */
47
-    protected $event_status;
48
-
49
-    /**
50
-     * @var int $row
51
-     */
52
-    protected $row;
53
-
54
-    /**
55
-     * @var int $cols
56
-     */
57
-    protected $cols;
58
-
59
-    /**
60
-     * @var boolean $hidden_input_qty
61
-     */
62
-    protected $hidden_input_qty;
63
-
64
-    /**
65
-     * @var string $ticket_datetime_classes
66
-     */
67
-    protected $ticket_datetime_classes;
68
-
69
-
70
-
71
-    /**
72
-     * TicketDetails constructor.
73
-     *
74
-     * @param TicketDetails              $ticket_details
75
-     * @param \EE_Tax_Config             $tax_settings
76
-     * @param int                        $total_tickets
77
-     * @param int                        $max_atndz
78
-     * @param int                        $row
79
-     * @param int                        $cols
80
-     * @param boolean                    $required_ticket_sold_out
81
-     * @param string                     $event_status
82
-     * @param string                     $ticket_datetime_classes
83
-     */
84
-    public function __construct(
85
-        TicketDetails $ticket_details,
86
-        \EE_Tax_Config $tax_settings,
87
-        $total_tickets,
88
-        $max_atndz,
89
-        $row,
90
-        $cols,
91
-        $required_ticket_sold_out,
92
-        $event_status,
93
-        $ticket_datetime_classes
94
-    ) {
95
-        $this->ticket = $ticket_details->getTicket();
96
-        $this->ticket_details = $ticket_details;
97
-        $this->template_settings = $ticket_details->getTemplateSettings();
98
-        $this->tax_settings = $tax_settings;
99
-        $this->total_tickets = $total_tickets;
100
-        $this->max_atndz = $max_atndz;
101
-        $this->row = $row;
102
-        $this->cols = $cols;
103
-        $this->required_ticket_sold_out = $required_ticket_sold_out;
104
-        $this->event_status = $event_status;
105
-        $this->date_format = $ticket_details->getDateFormat();
106
-        $this->ticket_datetime_classes = $ticket_datetime_classes;
107
-        parent::__construct($this->ticket, $max_atndz, $this->date_format);
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * other ticket rows will need to know if a required ticket is sold out,
114
-     * so that they are not offered for sale
115
-     *
116
-     * @return boolean
117
-     */
118
-    public function getRequiredTicketSoldOut()
119
-    {
120
-        return $this->required_ticket_sold_out;
121
-    }
122
-
123
-
124
-
125
-    /**
126
-     * @return int
127
-     */
128
-    public function getCols()
129
-    {
130
-        return $this->cols;
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * getHtml
137
-     *
138
-     * @return string
139
-     * @throws \EE_Error
140
-     */
141
-    public function getHtml()
142
-    {
143
-        $min = 0;
144
-        $max = $this->ticket->max();
145
-        $remaining = $this->ticket->remaining();
146
-        if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
147
-            list($min, $max) = $this->setTicketMinAndMax($remaining);
148
-        } else {
149
-            // set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
150
-            $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
151
-                ? $this->ticket->start_date()
152
-                : $this->required_ticket_sold_out;
153
-        }
154
-        list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
155
-        list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
156
-        /**
157
-         * Allow plugins to hook in and abort the generation and display of this row to do
158
-         * something else if they want.
159
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
160
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
161
-         * current row.
162
-         *
163
-         * @var string|bool
164
-         */
165
-        $ticket_selector_row_html = apply_filters(
166
-            'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
167
-            false,
168
-            $this->ticket,
169
-            $max,
170
-            $min,
171
-            $this->required_ticket_sold_out,
172
-            $ticket_price,
173
-            $ticket_bundle,
174
-            $ticket_status,
175
-            $status_class
176
-        );
177
-        if ($ticket_selector_row_html !== false) {
178
-            return $ticket_selector_row_html;
179
-        }
180
-        $ticket_selector_row_html = \EEH_HTML::tr(
181
-            '', '',
182
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
183
-        );
184
-        /**
185
-         * Allow plugins to hook in and abort the generation and display of the contents of this
186
-         * row to do something else if they want.
187
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
188
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
189
-         * current row.
190
-         *
191
-         * @var string|bool
192
-         */
193
-        $new_row_cells_content = apply_filters(
194
-            'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
195
-            false,
196
-            $this->ticket,
197
-            $max,
198
-            $min,
199
-            $this->required_ticket_sold_out,
200
-            $ticket_price,
201
-            $ticket_bundle,
202
-            $ticket_status,
203
-            $status_class
204
-        );
205
-        if ($new_row_cells_content !== false) {
206
-            return $ticket_selector_row_html
207
-                   . $new_row_cells_content
208
-                   . $this->ticketQtyAndIdHiddenInputs()
209
-                   . \EEH_HTML::trx();
210
-        }
211
-        $this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
212
-
213
-        $ticket_selector_row_html .= $this->ticketNameTableCell();
214
-        $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
215
-        $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
216
-        $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
217
-        if (empty($this->ticket_status_display)) {
218
-            if ($this->max_atndz === 1) {
219
-                // only ONE attendee is allowed to register at a time
220
-                $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
221
-            } else if ($max > 0) {
222
-                $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
223
-            }
224
-        }
225
-        $ticket_selector_row_html .= $this->ticket_status_display;
226
-        $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
227
-        $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
228
-        $ticket_selector_row_html .= \EEH_HTML::tdx();
229
-        $ticket_selector_row_html .= \EEH_HTML::trx();
230
-
231
-
232
-        $this->row++;
233
-        return $ticket_selector_row_html;
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * setTicketMinAndMax
240
-     *
241
-     * @param int $remaining
242
-     * @return array
243
-     * @throws \EE_Error
244
-     */
245
-    protected function setTicketMinAndMax($remaining)
246
-    {
247
-        // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
248
-        $max = min($remaining, $this->max_atndz);
249
-        // but... we also want to restrict the number of tickets by the ticket max setting,
250
-        // however, the max still can't be higher than what was just set above
251
-        $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
252
-        // and we also want to restrict the minimum number of tickets by the ticket min setting
253
-        $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
254
-        // and if the ticket is required, then make sure that min qty is at least 1
255
-        $min = $this->ticket->required() ? max($min, 1) : $min;
256
-        return array($min, $max);
257
-    }
258
-
259
-
260
-
261
-    /**
262
-     * getTicketPriceDetails
263
-     *
264
-     * @return array
265
-     * @throws \EE_Error
266
-     */
267
-    protected function getTicketPriceDetails()
268
-    {
269
-        $ticket_price = $this->tax_settings->prices_displayed_including_taxes
270
-            ? $this->ticket->get_ticket_total_with_taxes()
271
-            : $this->ticket->get_ticket_subtotal();
272
-        $ticket_bundle = false;
273
-        $ticket_min = $this->ticket->min();
274
-        // for ticket bundles, set min and max qty the same
275
-        if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
276
-            $ticket_price *= $ticket_min;
277
-            $ticket_bundle = true;
278
-        }
279
-        $ticket_price = apply_filters(
280
-            'FHEE__ticket_selector_chart_template__ticket_price',
281
-            $ticket_price,
282
-            $this->ticket
283
-        );
284
-        return array($ticket_price, $ticket_bundle);
285
-    }
286
-
287
-
288
-
289
-    /**
290
-     * getTicketStatusClasses
291
-     *
292
-     * @param int $remaining
293
-     * @return array
294
-     * @throws \EE_Error
295
-     */
296
-    protected function getTicketStatusClasses($remaining = 0)
297
-    {
298
-        // if a previous required ticket with the same sale start date is sold out,
299
-        // then mark this ticket as sold out as well.
300
-        // tickets that go on sale at a later date than the required ticket  will NOT be affected
301
-        $tkt_status = $this->required_ticket_sold_out !== false
302
-                      && $this->required_ticket_sold_out === $this->ticket->start_date()
303
-            ? \EE_Ticket::sold_out
304
-            : $this->ticket->ticket_status();
305
-        $tkt_status = $this->event_status === \EE_Datetime::sold_out
306
-            ? \EE_Ticket::sold_out
307
-            : $tkt_status;
308
-        // check ticket status
309
-        switch ($tkt_status) {
310
-            // sold_out
311
-            case \EE_Ticket::sold_out :
312
-                $ticket_status = 'ticket-sales-sold-out';
313
-                $status_class = 'ticket-sales-sold-out lt-grey-text';
314
-                break;
315
-            // expired
316
-            case \EE_Ticket::expired :
317
-                $ticket_status = 'ticket-sales-expired';
318
-                $status_class = 'ticket-sales-expired lt-grey-text';
319
-                break;
320
-            // archived
321
-            case \EE_Ticket::archived :
322
-                $ticket_status = 'archived-ticket';
323
-                $status_class = 'archived-ticket hidden';
324
-                break;
325
-            // pending
326
-            case \EE_Ticket::pending :
327
-                $ticket_status = 'ticket-pending';
328
-                $status_class = 'ticket-pending';
329
-                break;
330
-            // onsale
331
-            case \EE_Ticket::onsale :
332
-            default :
333
-                $ticket_status = 'ticket-on-sale';
334
-                $status_class = 'ticket-on-sale';
335
-                break;
336
-        }
337
-        $ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status);
338
-        return array($tkt_status, $ticket_status, $status_class);
339
-    }
340
-
341
-
342
-
343
-    /**
344
-     * ticketNameTableCell
345
-     *
346
-     * @return string
347
-     * @throws \EE_Error
348
-     */
349
-    protected function ticketNameTableCell()
350
-    {
351
-        $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
352
-        $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
353
-        $html .= $this->ticket_details->getShowHideLinks();
354
-        if ($this->ticket->required()) {
355
-            $html .= \EEH_HTML::p(
356
-                    apply_filters(
357
-                            'FHEE__ticket_selector_chart_template__ticket_required_message',
358
-                            esc_html__('This ticket is required and must be purchased.', 'event_espresso')
359
-                    ),
360
-                    '', 'ticket-required-pg'
361
-            );
362
-        }
363
-        $html .= \EEH_HTML::tdx();
364
-        return $html;
365
-    }
366
-
367
-
368
-
369
-    /**
370
-     * ticketPriceTableCell
371
-     *
372
-     * @param float $ticket_price
373
-     * @param bool  $ticket_bundle
374
-     * @return string
375
-     * @throws \EE_Error
376
-     */
377
-    protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
378
-    {
379
-        $html = '';
380
-        if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
381
-            $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382
-            $html .= \EEH_Template::format_currency($ticket_price);
383
-            $html .= $this->ticket->taxable()
384
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
385
-                : '';
386
-            $html .= ' ';
387
-            $html .= \EEH_HTML::span(
388
-                $ticket_bundle
389
-                    ? apply_filters(
390
-                        'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
391
-                        __(' / bundle', 'event_espresso')
392
-                    )
393
-                    : apply_filters(
394
-                        'FHEE__ticket_selector_chart_template__per_ticket_text',
395
-                        __('', 'event_espresso')
396
-                    ),
397
-                '', 'smaller-text no-bold'
398
-            );
399
-            $html .= ' ';
400
-            $html .= \EEH_HTML::tdx();
401
-            $this->cols++;
402
-        }
403
-        return $html;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * onlyOneAttendeeCanRegister
410
-     *
411
-     * @return string
412
-     */
413
-    protected function onlyOneAttendeeCanRegister()
414
-    {
415
-        // display submit button since we have tickets available
416
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417
-        $this->hidden_input_qty = false;
418
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
421
-        $html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
422
-        $html .= ' title=""/>';
423
-        return $html;
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * ticketQuantitySelector
430
-     *
431
-     * @param int $min
432
-     * @param int $max
433
-     * @return string
434
-     * @throws \EE_Error
435
-     */
436
-    protected function ticketQuantitySelector($min = 0, $max = 0)
437
-    {
438
-        // display submit button since we have tickets available
439
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
440
-        $this->hidden_input_qty = false;
441
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
442
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
443
-        $html .= ' class="ticket-selector-tbl-qty-slct">';
444
-        // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
445
-        if ($min !== 0 && ! $this->ticket->required()) {
446
-            $html .= '<option value="0">&nbsp;0&nbsp;</option>';
447
-        }
448
-        // offer ticket quantities from the min to the max
449
-        for ($i = $min; $i <= $max; $i++) {
450
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
451
-        }
452
-        $html .= '</select>';
453
-        return $html;
454
-    }
455
-
456
-
457
-
458
-    /**
459
-     * getHiddenInputs
460
-     *
461
-     * @return string
462
-     * @throws \EE_Error
463
-     */
464
-    protected function ticketQtyAndIdHiddenInputs()
465
-    {
466
-        $html = '';
467
-        // depending on group reg we need to change the format for qty
468
-        if ($this->hidden_input_qty) {
469
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
470
-        }
471
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
472
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
473
-        return $html;
474
-    }
19
+	/**
20
+	 * @var TicketDetails $ticket_details
21
+	 */
22
+	protected $ticket_details;
23
+
24
+	/**
25
+	 * @var \EE_Ticket_Selector_Config $template_settings
26
+	 */
27
+	protected $template_settings;
28
+
29
+	/**
30
+	 * @var \EE_Tax_Config $tax_settings
31
+	 */
32
+	protected $tax_settings;
33
+
34
+	/**
35
+	 * @var boolean $required_ticket_sold_out
36
+	 */
37
+	protected $required_ticket_sold_out;
38
+
39
+	/**
40
+	 * @var boolean $prices_displayed_including_taxes
41
+	 */
42
+	protected $prices_displayed_including_taxes;
43
+
44
+	/**
45
+	 * @var string $event_status
46
+	 */
47
+	protected $event_status;
48
+
49
+	/**
50
+	 * @var int $row
51
+	 */
52
+	protected $row;
53
+
54
+	/**
55
+	 * @var int $cols
56
+	 */
57
+	protected $cols;
58
+
59
+	/**
60
+	 * @var boolean $hidden_input_qty
61
+	 */
62
+	protected $hidden_input_qty;
63
+
64
+	/**
65
+	 * @var string $ticket_datetime_classes
66
+	 */
67
+	protected $ticket_datetime_classes;
68
+
69
+
70
+
71
+	/**
72
+	 * TicketDetails constructor.
73
+	 *
74
+	 * @param TicketDetails              $ticket_details
75
+	 * @param \EE_Tax_Config             $tax_settings
76
+	 * @param int                        $total_tickets
77
+	 * @param int                        $max_atndz
78
+	 * @param int                        $row
79
+	 * @param int                        $cols
80
+	 * @param boolean                    $required_ticket_sold_out
81
+	 * @param string                     $event_status
82
+	 * @param string                     $ticket_datetime_classes
83
+	 */
84
+	public function __construct(
85
+		TicketDetails $ticket_details,
86
+		\EE_Tax_Config $tax_settings,
87
+		$total_tickets,
88
+		$max_atndz,
89
+		$row,
90
+		$cols,
91
+		$required_ticket_sold_out,
92
+		$event_status,
93
+		$ticket_datetime_classes
94
+	) {
95
+		$this->ticket = $ticket_details->getTicket();
96
+		$this->ticket_details = $ticket_details;
97
+		$this->template_settings = $ticket_details->getTemplateSettings();
98
+		$this->tax_settings = $tax_settings;
99
+		$this->total_tickets = $total_tickets;
100
+		$this->max_atndz = $max_atndz;
101
+		$this->row = $row;
102
+		$this->cols = $cols;
103
+		$this->required_ticket_sold_out = $required_ticket_sold_out;
104
+		$this->event_status = $event_status;
105
+		$this->date_format = $ticket_details->getDateFormat();
106
+		$this->ticket_datetime_classes = $ticket_datetime_classes;
107
+		parent::__construct($this->ticket, $max_atndz, $this->date_format);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * other ticket rows will need to know if a required ticket is sold out,
114
+	 * so that they are not offered for sale
115
+	 *
116
+	 * @return boolean
117
+	 */
118
+	public function getRequiredTicketSoldOut()
119
+	{
120
+		return $this->required_ticket_sold_out;
121
+	}
122
+
123
+
124
+
125
+	/**
126
+	 * @return int
127
+	 */
128
+	public function getCols()
129
+	{
130
+		return $this->cols;
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * getHtml
137
+	 *
138
+	 * @return string
139
+	 * @throws \EE_Error
140
+	 */
141
+	public function getHtml()
142
+	{
143
+		$min = 0;
144
+		$max = $this->ticket->max();
145
+		$remaining = $this->ticket->remaining();
146
+		if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
147
+			list($min, $max) = $this->setTicketMinAndMax($remaining);
148
+		} else {
149
+			// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
150
+			$this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
151
+				? $this->ticket->start_date()
152
+				: $this->required_ticket_sold_out;
153
+		}
154
+		list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
155
+		list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
156
+		/**
157
+		 * Allow plugins to hook in and abort the generation and display of this row to do
158
+		 * something else if they want.
159
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
160
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
161
+		 * current row.
162
+		 *
163
+		 * @var string|bool
164
+		 */
165
+		$ticket_selector_row_html = apply_filters(
166
+			'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
167
+			false,
168
+			$this->ticket,
169
+			$max,
170
+			$min,
171
+			$this->required_ticket_sold_out,
172
+			$ticket_price,
173
+			$ticket_bundle,
174
+			$ticket_status,
175
+			$status_class
176
+		);
177
+		if ($ticket_selector_row_html !== false) {
178
+			return $ticket_selector_row_html;
179
+		}
180
+		$ticket_selector_row_html = \EEH_HTML::tr(
181
+			'', '',
182
+			"tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
183
+		);
184
+		/**
185
+		 * Allow plugins to hook in and abort the generation and display of the contents of this
186
+		 * row to do something else if they want.
187
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
188
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
189
+		 * current row.
190
+		 *
191
+		 * @var string|bool
192
+		 */
193
+		$new_row_cells_content = apply_filters(
194
+			'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
195
+			false,
196
+			$this->ticket,
197
+			$max,
198
+			$min,
199
+			$this->required_ticket_sold_out,
200
+			$ticket_price,
201
+			$ticket_bundle,
202
+			$ticket_status,
203
+			$status_class
204
+		);
205
+		if ($new_row_cells_content !== false) {
206
+			return $ticket_selector_row_html
207
+				   . $new_row_cells_content
208
+				   . $this->ticketQtyAndIdHiddenInputs()
209
+				   . \EEH_HTML::trx();
210
+		}
211
+		$this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
212
+
213
+		$ticket_selector_row_html .= $this->ticketNameTableCell();
214
+		$ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
215
+		$ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
216
+		$this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
217
+		if (empty($this->ticket_status_display)) {
218
+			if ($this->max_atndz === 1) {
219
+				// only ONE attendee is allowed to register at a time
220
+				$ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
221
+			} else if ($max > 0) {
222
+				$ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
223
+			}
224
+		}
225
+		$ticket_selector_row_html .= $this->ticket_status_display;
226
+		$ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
227
+		$ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
228
+		$ticket_selector_row_html .= \EEH_HTML::tdx();
229
+		$ticket_selector_row_html .= \EEH_HTML::trx();
230
+
231
+
232
+		$this->row++;
233
+		return $ticket_selector_row_html;
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * setTicketMinAndMax
240
+	 *
241
+	 * @param int $remaining
242
+	 * @return array
243
+	 * @throws \EE_Error
244
+	 */
245
+	protected function setTicketMinAndMax($remaining)
246
+	{
247
+		// offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
248
+		$max = min($remaining, $this->max_atndz);
249
+		// but... we also want to restrict the number of tickets by the ticket max setting,
250
+		// however, the max still can't be higher than what was just set above
251
+		$max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
252
+		// and we also want to restrict the minimum number of tickets by the ticket min setting
253
+		$min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
254
+		// and if the ticket is required, then make sure that min qty is at least 1
255
+		$min = $this->ticket->required() ? max($min, 1) : $min;
256
+		return array($min, $max);
257
+	}
258
+
259
+
260
+
261
+	/**
262
+	 * getTicketPriceDetails
263
+	 *
264
+	 * @return array
265
+	 * @throws \EE_Error
266
+	 */
267
+	protected function getTicketPriceDetails()
268
+	{
269
+		$ticket_price = $this->tax_settings->prices_displayed_including_taxes
270
+			? $this->ticket->get_ticket_total_with_taxes()
271
+			: $this->ticket->get_ticket_subtotal();
272
+		$ticket_bundle = false;
273
+		$ticket_min = $this->ticket->min();
274
+		// for ticket bundles, set min and max qty the same
275
+		if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
276
+			$ticket_price *= $ticket_min;
277
+			$ticket_bundle = true;
278
+		}
279
+		$ticket_price = apply_filters(
280
+			'FHEE__ticket_selector_chart_template__ticket_price',
281
+			$ticket_price,
282
+			$this->ticket
283
+		);
284
+		return array($ticket_price, $ticket_bundle);
285
+	}
286
+
287
+
288
+
289
+	/**
290
+	 * getTicketStatusClasses
291
+	 *
292
+	 * @param int $remaining
293
+	 * @return array
294
+	 * @throws \EE_Error
295
+	 */
296
+	protected function getTicketStatusClasses($remaining = 0)
297
+	{
298
+		// if a previous required ticket with the same sale start date is sold out,
299
+		// then mark this ticket as sold out as well.
300
+		// tickets that go on sale at a later date than the required ticket  will NOT be affected
301
+		$tkt_status = $this->required_ticket_sold_out !== false
302
+					  && $this->required_ticket_sold_out === $this->ticket->start_date()
303
+			? \EE_Ticket::sold_out
304
+			: $this->ticket->ticket_status();
305
+		$tkt_status = $this->event_status === \EE_Datetime::sold_out
306
+			? \EE_Ticket::sold_out
307
+			: $tkt_status;
308
+		// check ticket status
309
+		switch ($tkt_status) {
310
+			// sold_out
311
+			case \EE_Ticket::sold_out :
312
+				$ticket_status = 'ticket-sales-sold-out';
313
+				$status_class = 'ticket-sales-sold-out lt-grey-text';
314
+				break;
315
+			// expired
316
+			case \EE_Ticket::expired :
317
+				$ticket_status = 'ticket-sales-expired';
318
+				$status_class = 'ticket-sales-expired lt-grey-text';
319
+				break;
320
+			// archived
321
+			case \EE_Ticket::archived :
322
+				$ticket_status = 'archived-ticket';
323
+				$status_class = 'archived-ticket hidden';
324
+				break;
325
+			// pending
326
+			case \EE_Ticket::pending :
327
+				$ticket_status = 'ticket-pending';
328
+				$status_class = 'ticket-pending';
329
+				break;
330
+			// onsale
331
+			case \EE_Ticket::onsale :
332
+			default :
333
+				$ticket_status = 'ticket-on-sale';
334
+				$status_class = 'ticket-on-sale';
335
+				break;
336
+		}
337
+		$ticket_status = \EEH_HTML::span($this->ticket->ticket_status(true, ($remaining > 0)), '', $ticket_status);
338
+		return array($tkt_status, $ticket_status, $status_class);
339
+	}
340
+
341
+
342
+
343
+	/**
344
+	 * ticketNameTableCell
345
+	 *
346
+	 * @return string
347
+	 * @throws \EE_Error
348
+	 */
349
+	protected function ticketNameTableCell()
350
+	{
351
+		$html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
352
+		$html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
353
+		$html .= $this->ticket_details->getShowHideLinks();
354
+		if ($this->ticket->required()) {
355
+			$html .= \EEH_HTML::p(
356
+					apply_filters(
357
+							'FHEE__ticket_selector_chart_template__ticket_required_message',
358
+							esc_html__('This ticket is required and must be purchased.', 'event_espresso')
359
+					),
360
+					'', 'ticket-required-pg'
361
+			);
362
+		}
363
+		$html .= \EEH_HTML::tdx();
364
+		return $html;
365
+	}
366
+
367
+
368
+
369
+	/**
370
+	 * ticketPriceTableCell
371
+	 *
372
+	 * @param float $ticket_price
373
+	 * @param bool  $ticket_bundle
374
+	 * @return string
375
+	 * @throws \EE_Error
376
+	 */
377
+	protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
378
+	{
379
+		$html = '';
380
+		if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
381
+			$html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382
+			$html .= \EEH_Template::format_currency($ticket_price);
383
+			$html .= $this->ticket->taxable()
384
+				? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
385
+				: '';
386
+			$html .= '&nbsp;';
387
+			$html .= \EEH_HTML::span(
388
+				$ticket_bundle
389
+					? apply_filters(
390
+						'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
391
+						__(' / bundle', 'event_espresso')
392
+					)
393
+					: apply_filters(
394
+						'FHEE__ticket_selector_chart_template__per_ticket_text',
395
+						__('', 'event_espresso')
396
+					),
397
+				'', 'smaller-text no-bold'
398
+			);
399
+			$html .= '&nbsp;';
400
+			$html .= \EEH_HTML::tdx();
401
+			$this->cols++;
402
+		}
403
+		return $html;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * onlyOneAttendeeCanRegister
410
+	 *
411
+	 * @return string
412
+	 */
413
+	protected function onlyOneAttendeeCanRegister()
414
+	{
415
+		// display submit button since we have tickets available
416
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417
+		$this->hidden_input_qty = false;
418
+		$html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
+		$html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
421
+		$html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
422
+		$html .= ' title=""/>';
423
+		return $html;
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * ticketQuantitySelector
430
+	 *
431
+	 * @param int $min
432
+	 * @param int $max
433
+	 * @return string
434
+	 * @throws \EE_Error
435
+	 */
436
+	protected function ticketQuantitySelector($min = 0, $max = 0)
437
+	{
438
+		// display submit button since we have tickets available
439
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
440
+		$this->hidden_input_qty = false;
441
+		$html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
442
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
443
+		$html .= ' class="ticket-selector-tbl-qty-slct">';
444
+		// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
445
+		if ($min !== 0 && ! $this->ticket->required()) {
446
+			$html .= '<option value="0">&nbsp;0&nbsp;</option>';
447
+		}
448
+		// offer ticket quantities from the min to the max
449
+		for ($i = $min; $i <= $max; $i++) {
450
+			$html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
451
+		}
452
+		$html .= '</select>';
453
+		return $html;
454
+	}
455
+
456
+
457
+
458
+	/**
459
+	 * getHiddenInputs
460
+	 *
461
+	 * @return string
462
+	 * @throws \EE_Error
463
+	 */
464
+	protected function ticketQtyAndIdHiddenInputs()
465
+	{
466
+		$html = '';
467
+		// depending on group reg we need to change the format for qty
468
+		if ($this->hidden_input_qty) {
469
+			$html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
470
+		}
471
+		$html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
472
+		$html .= ' value="' . $this->ticket->ID() . '"/>';
473
+		return $html;
474
+	}
475 475
 
476 476
 }
477 477
 // End of file TicketSelectorRowStandard.php
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         }
180 180
         $ticket_selector_row_html = \EEH_HTML::tr(
181 181
             '', '',
182
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
182
+            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} ".espresso_get_object_css_class($this->ticket)
183 183
         );
184 184
         /**
185 185
          * Allow plugins to hook in and abort the generation and display of the contents of this
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
382 382
             $html .= \EEH_Template::format_currency($ticket_price);
383 383
             $html .= $this->ticket->taxable()
384
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
384
+                ? \EEH_HTML::span('*', '', 'taxable-tickets-asterisk grey-text')
385 385
                 : '';
386 386
             $html .= '&nbsp;';
387 387
             $html .= \EEH_HTML::span(
@@ -415,9 +415,9 @@  discard block
 block discarded – undo
415 415
         // display submit button since we have tickets available
416 416
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
417 417
         $this->hidden_input_qty = false;
418
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
419
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
420
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
418
+        $html = '<input type="radio" name="tkt-slctr-qty-'.$this->EVT_ID.'"';
419
+        $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"';
420
+        $html .= ' class="ticket-selector-tbl-qty-slct" value="'.$this->row.'-1"';
421 421
         $html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
422 422
         $html .= ' title=""/>';
423 423
         return $html;
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
         // display submit button since we have tickets available
439 439
         add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
440 440
         $this->hidden_input_qty = false;
441
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
442
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
441
+        $html = '<select name="tkt-slctr-qty-'.$this->EVT_ID.'[]"';
442
+        $html .= ' id="ticket-selector-tbl-qty-slct-'.$this->EVT_ID.'-'.$this->row.'"';
443 443
         $html .= ' class="ticket-selector-tbl-qty-slct">';
444 444
         // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
445 445
         if ($min !== 0 && ! $this->ticket->required()) {
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
         }
448 448
         // offer ticket quantities from the min to the max
449 449
         for ($i = $min; $i <= $max; $i++) {
450
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
450
+            $html .= '<option value="'.$i.'">&nbsp;'.$i.'&nbsp;</option>';
451 451
         }
452 452
         $html .= '</select>';
453 453
         return $html;
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
         $html = '';
467 467
         // depending on group reg we need to change the format for qty
468 468
         if ($this->hidden_input_qty) {
469
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
469
+            $html .= '<input type="hidden" name="tkt-slctr-qty-'.$this->EVT_ID.'[]" value="0"/>';
470 470
         }
471
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
472
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
471
+        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-'.$this->EVT_ID.'[]"';
472
+        $html .= ' value="'.$this->ticket->ID().'"/>';
473 473
         return $html;
474 474
     }
475 475
 
Please login to merge, or discard this patch.
modules/ticket_selector/TicketDetails.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -17,198 +17,198 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @var \EE_Ticket $ticket
22
-     */
23
-    protected $ticket;
24
-
25
-    /**
26
-     * @var \EE_Ticket_Selector_Config $template_settings
27
-     */
28
-    protected $template_settings;
29
-
30
-    /**
31
-     * @var string $date_format
32
-     */
33
-    protected $date_format;
34
-
35
-    /**
36
-     * @var string $time_format
37
-     */
38
-    protected $time_format;
39
-
40
-    /**
41
-     * @var boolean $event_is_expired
42
-     */
43
-    protected $event_is_expired;
44
-
45
-
46
-
47
-    /**
48
-     * TicketDetails constructor.
49
-     *
50
-     * @param \EE_Ticket                 $ticket
51
-     * @param \EE_Ticket_Selector_Config $template_settings
52
-     * @param array                      $template_args
53
-     */
54
-    public function __construct(
55
-        \EE_Ticket $ticket,
56
-        \EE_Ticket_Selector_Config $template_settings,
57
-        array $template_args
58
-    )
59
-    {
60
-        $this->ticket            = $ticket;
61
-        $this->template_settings = $template_settings;
62
-        $this->date_format       = $template_args['date_format'];
63
-        $this->time_format       = $template_args['time_format'];
64
-        $this->event_is_expired  = $template_args['event_is_expired'];
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * @return \EE_Ticket
71
-     */
72
-    public function getTicket()
73
-    {
74
-        return $this->ticket;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @return bool
81
-     */
82
-    public function showTicketDetails()
83
-    {
84
-        return $this->template_settings->show_ticket_details;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * @return \EE_Ticket_Selector_Config
91
-     */
92
-    public function getTemplateSettings()
93
-    {
94
-        return $this->template_settings;
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * @return string
101
-     */
102
-    public function getDateFormat()
103
-    {
104
-        return $this->date_format;
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getTimeFormat()
113
-    {
114
-        return $this->time_format;
115
-    }
116
-
117
-
118
-
119
-    /**
120
-     * @return string
121
-     */
122
-    public function getShowHideLinks()
123
-    {
124
-        if ( ! $this->showTicketDetails()) {
125
-            return '';
126
-        }
127
-        return \EEH_HTML::link(
128
-            '',
129
-            sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), '&nbsp;'),
130
-            esc_attr(
131
-                apply_filters(
132
-                    'FHEE__ticket_selector_chart_template__show_ticket_details_link_title',
133
-                    __('click to show additional ticket details', 'event_espresso')
134
-                )
135
-            ),
136
-            "display-{$this->cssId()}",
137
-            'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
138
-            '',
139
-            'rel="' . $this->cssId() . '"'
140
-        ) . \EEH_HTML::link(
141
-            '',
142
-            sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'),
143
-            esc_attr(
144
-                apply_filters(
145
-                    'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title',
146
-                    __('click to hide additional ticket details', 'event_espresso')
147
-                )
148
-            ),
149
-            "hide-{$this->cssId()}",
150
-            'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
151
-            'display:none;',
152
-            'rel="' . $this->cssId() . '"'
153
-        );
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * @return string
160
-     */
161
-    public function cssId()
162
-    {
163
-        return apply_filters(
164
-            'FHEE__ticket_selector_chart_template__ticket_details_css_id',
165
-            "tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}"
166
-        );
167
-    }
168
-
169
-
170
-
171
-    /**
172
-     * @param float $ticket_price
173
-     * @param int   $remaining
174
-     * @param int   $cols
175
-     * @return string
176
-     */
177
-    public function display(
178
-        $ticket_price = 0.00,
179
-        $remaining,
180
-        $cols = 2
181
-    ) {
182
-        $template_args = array();
183
-        $template_args['ticket'] = $this->ticket;
184
-        $template_args['ticket_price'] = $ticket_price;
185
-        $template_args['remaining'] = $remaining;
186
-        $template_args['cols'] = $cols;
187
-        $template_args['show_ticket_details'] = $this->template_settings->show_ticket_details;
188
-        $template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns;
189
-        $template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details');
190
-        $template_args['ticket_details_css_id'] = $this->cssId();
191
-        $template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters(
192
-            'FHEE__ticket_selector_chart_template__display_ticket_price_details',
193
-            true
194
-        );
195
-        $template_args['price_breakdown_heading'] = apply_filters(
196
-            'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
197
-            esc_html__('Price', 'event_espresso')
198
-        );
199
-        $template_args['date_format'] = $this->date_format;
200
-        $template_args['time_format'] = $this->time_format;
201
-        $template_args['event_is_expired'] = $this->event_is_expired;
202
-
203
-        return \EEH_Template::locate_template(
204
-            apply_filters(
205
-                'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
206
-                TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
207
-                $this->ticket
208
-            ),
209
-            $template_args
210
-        );
211
-    }
20
+	/**
21
+	 * @var \EE_Ticket $ticket
22
+	 */
23
+	protected $ticket;
24
+
25
+	/**
26
+	 * @var \EE_Ticket_Selector_Config $template_settings
27
+	 */
28
+	protected $template_settings;
29
+
30
+	/**
31
+	 * @var string $date_format
32
+	 */
33
+	protected $date_format;
34
+
35
+	/**
36
+	 * @var string $time_format
37
+	 */
38
+	protected $time_format;
39
+
40
+	/**
41
+	 * @var boolean $event_is_expired
42
+	 */
43
+	protected $event_is_expired;
44
+
45
+
46
+
47
+	/**
48
+	 * TicketDetails constructor.
49
+	 *
50
+	 * @param \EE_Ticket                 $ticket
51
+	 * @param \EE_Ticket_Selector_Config $template_settings
52
+	 * @param array                      $template_args
53
+	 */
54
+	public function __construct(
55
+		\EE_Ticket $ticket,
56
+		\EE_Ticket_Selector_Config $template_settings,
57
+		array $template_args
58
+	)
59
+	{
60
+		$this->ticket            = $ticket;
61
+		$this->template_settings = $template_settings;
62
+		$this->date_format       = $template_args['date_format'];
63
+		$this->time_format       = $template_args['time_format'];
64
+		$this->event_is_expired  = $template_args['event_is_expired'];
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * @return \EE_Ticket
71
+	 */
72
+	public function getTicket()
73
+	{
74
+		return $this->ticket;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @return bool
81
+	 */
82
+	public function showTicketDetails()
83
+	{
84
+		return $this->template_settings->show_ticket_details;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * @return \EE_Ticket_Selector_Config
91
+	 */
92
+	public function getTemplateSettings()
93
+	{
94
+		return $this->template_settings;
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * @return string
101
+	 */
102
+	public function getDateFormat()
103
+	{
104
+		return $this->date_format;
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getTimeFormat()
113
+	{
114
+		return $this->time_format;
115
+	}
116
+
117
+
118
+
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function getShowHideLinks()
123
+	{
124
+		if ( ! $this->showTicketDetails()) {
125
+			return '';
126
+		}
127
+		return \EEH_HTML::link(
128
+			'',
129
+			sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), '&nbsp;'),
130
+			esc_attr(
131
+				apply_filters(
132
+					'FHEE__ticket_selector_chart_template__show_ticket_details_link_title',
133
+					__('click to show additional ticket details', 'event_espresso')
134
+				)
135
+			),
136
+			"display-{$this->cssId()}",
137
+			'display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js',
138
+			'',
139
+			'rel="' . $this->cssId() . '"'
140
+		) . \EEH_HTML::link(
141
+			'',
142
+			sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'),
143
+			esc_attr(
144
+				apply_filters(
145
+					'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title',
146
+					__('click to hide additional ticket details', 'event_espresso')
147
+				)
148
+			),
149
+			"hide-{$this->cssId()}",
150
+			'hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js',
151
+			'display:none;',
152
+			'rel="' . $this->cssId() . '"'
153
+		);
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * @return string
160
+	 */
161
+	public function cssId()
162
+	{
163
+		return apply_filters(
164
+			'FHEE__ticket_selector_chart_template__ticket_details_css_id',
165
+			"tckt-slctr-tkt-details-{$this->ticket->get_event_ID()}-{$this->ticket->ID()}"
166
+		);
167
+	}
168
+
169
+
170
+
171
+	/**
172
+	 * @param float $ticket_price
173
+	 * @param int   $remaining
174
+	 * @param int   $cols
175
+	 * @return string
176
+	 */
177
+	public function display(
178
+		$ticket_price = 0.00,
179
+		$remaining,
180
+		$cols = 2
181
+	) {
182
+		$template_args = array();
183
+		$template_args['ticket'] = $this->ticket;
184
+		$template_args['ticket_price'] = $ticket_price;
185
+		$template_args['remaining'] = $remaining;
186
+		$template_args['cols'] = $cols;
187
+		$template_args['show_ticket_details'] = $this->template_settings->show_ticket_details;
188
+		$template_args['show_ticket_sale_columns'] = $this->template_settings->show_ticket_sale_columns;
189
+		$template_args['ticket_details_row_class'] = espresso_get_object_css_class($this->ticket, '', 'details');
190
+		$template_args['ticket_details_css_id'] = $this->cssId();
191
+		$template_args['display_ticket_price'] = $ticket_price !== 0 && apply_filters(
192
+			'FHEE__ticket_selector_chart_template__display_ticket_price_details',
193
+			true
194
+		);
195
+		$template_args['price_breakdown_heading'] = apply_filters(
196
+			'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading',
197
+			esc_html__('Price', 'event_espresso')
198
+		);
199
+		$template_args['date_format'] = $this->date_format;
200
+		$template_args['time_format'] = $this->time_format;
201
+		$template_args['event_is_expired'] = $this->event_is_expired;
202
+
203
+		return \EEH_Template::locate_template(
204
+			apply_filters(
205
+				'FHEE__EventEspresso_modules_ticket_selector_TicketDetails__display__template_path',
206
+				TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_details.template.php',
207
+				$this->ticket
208
+			),
209
+			$template_args
210
+		);
211
+	}
212 212
 
213 213
 }
214 214
 // End of file TicketDetails.php
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorStandard.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -17,126 +17,126 @@
 block discarded – undo
17 17
 class TicketSelectorStandard extends TicketSelector
18 18
 {
19 19
 
20
-    /**
21
-     * @var string $date_format
22
-     */
23
-    protected $date_format;
24
-
25
-    /**
26
-     * @var string $time_format
27
-     */
28
-    protected $time_format;
29
-
30
-    /**
31
-     * @var \EE_Ticket_Selector_Config $ticket_selector_config
32
-     */
33
-    protected $ticket_selector_config;
34
-
35
-    /**
36
-     * @var \EE_Tax_Config $tax_config
37
-     */
38
-    protected $tax_config;
39
-
40
-
41
-
42
-    /**
43
-     * TicketSelectorSimple constructor.
44
-     *
45
-     * @param \EE_Event                  $event
46
-     * @param \EE_Ticket[]               $tickets
47
-     * @param int                        $max_attendees
48
-     * @param array                      $template_args
49
-     * @param string                     $date_format
50
-     * @param string                     $time_format
51
-     * @param \EE_Ticket_Selector_Config $ticket_selector_config
52
-     * @param \EE_Tax_Config             $tax_config
53
-     */
54
-    public function __construct(
55
-        \EE_Event $event,
56
-        array $tickets,
57
-        $max_attendees,
58
-        array $template_args,
59
-        $date_format = 'Y-m-d',
60
-        $time_format = 'g:i a',
61
-        \EE_Ticket_Selector_Config $ticket_selector_config = null,
62
-        \EE_Tax_Config $tax_config = null
63
-    ) {
64
-        $this->date_format = $date_format;
65
-        $this->time_format = $time_format;
66
-        // get EE_Ticket_Selector_Config and TicketDetails
67
-        $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
68
-            ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
69
-            : new \EE_Ticket_Selector_Config();
70
-        // $template_settings->setDatetimeSelectorThreshold(2);
71
-        // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__);
72
-        // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__);
73
-        $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings)
74
-            ? \EE_Registry::instance()->CFG->tax_settings
75
-            : new \EE_Tax_Config();
76
-        parent::__construct($event, $tickets, $max_attendees, $template_args);
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * sets any and all template args that are required for this Ticket Selector
83
-     *
84
-     * @return void
85
-     * @throws \EE_Error
86
-     */
87
-    protected function addTemplateArgs()
88
-    {
89
-        $row = 1;
90
-        $ticket_row_html = '';
91
-        $required_ticket_sold_out = false;
92
-        // flag to indicate that at least one taxable ticket has been encountered
93
-        $taxable_tickets = false;
94
-        $datetime_selector = null;
95
-        $this->template_args['datetime_selector'] = '';
96
-        if (
97
-            $this->ticket_selector_config->getShowDatetimeSelector()
98
-            !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
99
-        ) {
100
-            $datetime_selector = new DatetimeSelector(
101
-                $this->event,
102
-                $this->tickets,
103
-                $this->ticket_selector_config,
104
-                $this->date_format,
105
-                $this->time_format
106
-            );
107
-            $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector();
108
-        }
109
-        $total_tickets = count($this->tickets);
110
-        // loop through tickets
111
-        foreach ($this->tickets as $TKT_ID => $ticket) {
112
-            if ($ticket instanceof \EE_Ticket) {
113
-                $cols = 2;
114
-                $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
115
-                $ticket_selector_row = new TicketSelectorRowStandard(
116
-                    new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),
117
-                    $this->tax_config,
118
-                    $total_tickets,
119
-                    $this->max_attendees,
120
-                    $row,
121
-                    $cols,
122
-                    $required_ticket_sold_out,
123
-                    $this->template_args['event_status'],
124
-                    $datetime_selector instanceof DatetimeSelector
125
-                        ? $datetime_selector->getTicketDatetimeClasses($ticket)
126
-                        : ''
127
-                );
128
-                $ticket_row_html .= $ticket_selector_row->getHtml();
129
-                $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();
130
-                $row++;
131
-            }
132
-        }
133
-        $this->template_args['row'] = $row;
134
-        $this->template_args['ticket_row_html'] = $ticket_row_html;
135
-        $this->template_args['taxable_tickets'] = $taxable_tickets;
136
-        $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
137
-        $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
138
-        remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
139
-    }
20
+	/**
21
+	 * @var string $date_format
22
+	 */
23
+	protected $date_format;
24
+
25
+	/**
26
+	 * @var string $time_format
27
+	 */
28
+	protected $time_format;
29
+
30
+	/**
31
+	 * @var \EE_Ticket_Selector_Config $ticket_selector_config
32
+	 */
33
+	protected $ticket_selector_config;
34
+
35
+	/**
36
+	 * @var \EE_Tax_Config $tax_config
37
+	 */
38
+	protected $tax_config;
39
+
40
+
41
+
42
+	/**
43
+	 * TicketSelectorSimple constructor.
44
+	 *
45
+	 * @param \EE_Event                  $event
46
+	 * @param \EE_Ticket[]               $tickets
47
+	 * @param int                        $max_attendees
48
+	 * @param array                      $template_args
49
+	 * @param string                     $date_format
50
+	 * @param string                     $time_format
51
+	 * @param \EE_Ticket_Selector_Config $ticket_selector_config
52
+	 * @param \EE_Tax_Config             $tax_config
53
+	 */
54
+	public function __construct(
55
+		\EE_Event $event,
56
+		array $tickets,
57
+		$max_attendees,
58
+		array $template_args,
59
+		$date_format = 'Y-m-d',
60
+		$time_format = 'g:i a',
61
+		\EE_Ticket_Selector_Config $ticket_selector_config = null,
62
+		\EE_Tax_Config $tax_config = null
63
+	) {
64
+		$this->date_format = $date_format;
65
+		$this->time_format = $time_format;
66
+		// get EE_Ticket_Selector_Config and TicketDetails
67
+		$this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)
68
+			? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector
69
+			: new \EE_Ticket_Selector_Config();
70
+		// $template_settings->setDatetimeSelectorThreshold(2);
71
+		// \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__);
72
+		// \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__);
73
+		$this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings)
74
+			? \EE_Registry::instance()->CFG->tax_settings
75
+			: new \EE_Tax_Config();
76
+		parent::__construct($event, $tickets, $max_attendees, $template_args);
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * sets any and all template args that are required for this Ticket Selector
83
+	 *
84
+	 * @return void
85
+	 * @throws \EE_Error
86
+	 */
87
+	protected function addTemplateArgs()
88
+	{
89
+		$row = 1;
90
+		$ticket_row_html = '';
91
+		$required_ticket_sold_out = false;
92
+		// flag to indicate that at least one taxable ticket has been encountered
93
+		$taxable_tickets = false;
94
+		$datetime_selector = null;
95
+		$this->template_args['datetime_selector'] = '';
96
+		if (
97
+			$this->ticket_selector_config->getShowDatetimeSelector()
98
+			!== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
99
+		) {
100
+			$datetime_selector = new DatetimeSelector(
101
+				$this->event,
102
+				$this->tickets,
103
+				$this->ticket_selector_config,
104
+				$this->date_format,
105
+				$this->time_format
106
+			);
107
+			$this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector();
108
+		}
109
+		$total_tickets = count($this->tickets);
110
+		// loop through tickets
111
+		foreach ($this->tickets as $TKT_ID => $ticket) {
112
+			if ($ticket instanceof \EE_Ticket) {
113
+				$cols = 2;
114
+				$taxable_tickets = $ticket->taxable() ? true : $taxable_tickets;
115
+				$ticket_selector_row = new TicketSelectorRowStandard(
116
+					new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args),
117
+					$this->tax_config,
118
+					$total_tickets,
119
+					$this->max_attendees,
120
+					$row,
121
+					$cols,
122
+					$required_ticket_sold_out,
123
+					$this->template_args['event_status'],
124
+					$datetime_selector instanceof DatetimeSelector
125
+						? $datetime_selector->getTicketDatetimeClasses($ticket)
126
+						: ''
127
+				);
128
+				$ticket_row_html .= $ticket_selector_row->getHtml();
129
+				$required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut();
130
+				$row++;
131
+			}
132
+		}
133
+		$this->template_args['row'] = $row;
134
+		$this->template_args['ticket_row_html'] = $ticket_row_html;
135
+		$this->template_args['taxable_tickets'] = $taxable_tickets;
136
+		$this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes;
137
+		$this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php';
138
+		remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector');
139
+	}
140 140
 
141 141
 
142 142
 
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorRow.php 1 patch
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -16,201 +16,201 @@
 block discarded – undo
16 16
 abstract class TicketSelectorRow
17 17
 {
18 18
 
19
-    /**
20
-     * @var \EE_Ticket $ticket
21
-     */
22
-    protected $ticket;
23
-
24
-    /**
25
-     * @var int $total_tickets
26
-     */
27
-    protected $total_tickets;
28
-
29
-    /**
30
-     * @var int $max_atndz
31
-     */
32
-    protected $max_atndz;
33
-
34
-    /**
35
-     * @var string $date_format
36
-     */
37
-    protected $date_format;
38
-
39
-    /**
40
-     * @var int $EVT_ID
41
-     */
42
-    protected $EVT_ID;
43
-
44
-    /**
45
-     * @var string $ticket_status_display
46
-     */
47
-    protected $ticket_status_display;
48
-
49
-
50
-
51
-    /**
52
-     * TicketDetails constructor.
53
-     *
54
-     * @param \EE_Ticket                 $ticket
55
-     * @param int                        $max_atndz
56
-     * @param string                     $date_format
57
-     */
58
-    public function __construct(
59
-        \EE_Ticket $ticket,
60
-        $max_atndz,
61
-        $date_format
62
-    ) {
63
-        $this->ticket = $ticket;
64
-        $this->max_atndz = $max_atndz;
65
-        $this->date_format = $date_format;
66
-        $this->EVT_ID = $this->ticket->get_event_ID();
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     * @return string
73
-     */
74
-    public function getTicketStatusDisplay()
75
-    {
76
-        return $this->ticket_status_display;
77
-    }
78
-
79
-
80
-
81
-    /**
82
-     * setTicketStatusDisplay
83
-     *
84
-     * @param string $tkt_status
85
-     * @param string $ticket_status
86
-     * @param int    $remaining
87
-     * @throws \EE_Error
88
-     */
89
-    protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) {
90
-        $this->ticket_status_display = '';
91
-        // now depending on the ticket and other circumstances...
92
-        if ($this->max_atndz === 0) {
93
-            // registration is CLOSED because admin set max attendees to ZERO
94
-            $this->ticket_status_display = $this->registrationClosed();
95
-        } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) {
96
-            // SOLD OUT - no tickets remaining
97
-            $this->ticket_status_display = $this->ticketsSoldOut();
98
-        } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) {
99
-            // expired or archived ticket
100
-            $this->ticket_status_display = $ticket_status;
101
-        } else if ($tkt_status === \EE_Ticket::pending) {
102
-            // ticket not on sale yet
103
-            $this->ticket_status_display = $this->ticketsSalesPending();
104
-        } else if ($this->ticket->min() > $remaining) {
105
-            // min qty purchasable is less than tickets available
106
-            $this->ticket_status_display = $this->notEnoughTicketsAvailable();
107
-        }
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * registrationClosed
114
-     */
115
-    protected function registrationClosed()
116
-    {
117
-        return \EEH_HTML::span(
118
-            apply_filters(
119
-                'FHEE__ticket_selector_chart_template__ticket_closed_msg',
120
-                __('Closed', 'event_espresso')
121
-            ),
122
-            '', 'sold-out'
123
-        );
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * ticketsSoldOut
130
-     */
131
-    protected function ticketsSoldOut()
132
-    {
133
-        return \EEH_HTML::span(
134
-            apply_filters(
135
-                'FHEE__ticket_selector_chart_template__ticket_sold_out_msg',
136
-                __('Sold&nbsp;Out', 'event_espresso')
137
-            ),
138
-            '', 'sold-out'
139
-        );
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * ticketsSalesPending
146
-     *
147
-     * @throws \EE_Error
148
-     */
149
-    protected function ticketsSalesPending()
150
-    {
151
-        return \EEH_HTML::span(
152
-            \EEH_HTML::span(
153
-                apply_filters(
154
-                    'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg',
155
-                    __('Goes&nbsp;On&nbsp;Sale', 'event_espresso')
156
-                ),
157
-                '', 'ticket-pending'
158
-            )
159
-            . \EEH_HTML::br()
160
-            . \EEH_HTML::span(
161
-                $this->ticket->get_i18n_datetime(
162
-                    'TKT_start_date',
163
-                    apply_filters(
164
-                        'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format',
165
-                        $this->date_format
166
-                    )
167
-                ),
168
-                '', 'small-text'
169
-            ),
170
-            '', 'ticket-pending-pg'
171
-        );
172
-    }
173
-
174
-
175
-
176
-    /**
177
-     * notEnoughTicketsAvailable
178
-     */
179
-    protected function notEnoughTicketsAvailable()
180
-    {
181
-        return \EEH_HTML::div(
182
-            \EEH_HTML::span(
183
-                apply_filters(
184
-                    'FHEE__ticket_selector_chart_template__ticket_not_available_msg',
185
-                    __('Not Available', 'event_espresso')
186
-                ),
187
-                '', 'archived-ticket small-text'
188
-            )
189
-            . \EEH_HTML::br(),
190
-            '', 'archived-ticket-pg'
191
-        );
192
-    }
193
-
194
-
195
-
196
-    /**
197
-     * getHiddenInputs
198
-     *
199
-     * @param string $anchor_id
200
-     * @param int    $row
201
-     * @param int    $max_atndz
202
-     * @return string
203
-     */
204
-    protected function getHiddenInputs($anchor_id, $row, $max_atndz)
205
-    {
206
-        $html = '<input type="hidden" name="noheader" value="true"/>';
207
-        $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->EVT_ID . '"';
208
-        $html .= ' value="' . \EEH_URL::current_url() . $anchor_id . '"/>';
209
-        $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->EVT_ID . '" value="' . $row - 1 . '"/>';
210
-        $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->EVT_ID . '" value="' . $max_atndz . '"/>';
211
-        $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->EVT_ID . '"/>';
212
-        return $html;
213
-    }
19
+	/**
20
+	 * @var \EE_Ticket $ticket
21
+	 */
22
+	protected $ticket;
23
+
24
+	/**
25
+	 * @var int $total_tickets
26
+	 */
27
+	protected $total_tickets;
28
+
29
+	/**
30
+	 * @var int $max_atndz
31
+	 */
32
+	protected $max_atndz;
33
+
34
+	/**
35
+	 * @var string $date_format
36
+	 */
37
+	protected $date_format;
38
+
39
+	/**
40
+	 * @var int $EVT_ID
41
+	 */
42
+	protected $EVT_ID;
43
+
44
+	/**
45
+	 * @var string $ticket_status_display
46
+	 */
47
+	protected $ticket_status_display;
48
+
49
+
50
+
51
+	/**
52
+	 * TicketDetails constructor.
53
+	 *
54
+	 * @param \EE_Ticket                 $ticket
55
+	 * @param int                        $max_atndz
56
+	 * @param string                     $date_format
57
+	 */
58
+	public function __construct(
59
+		\EE_Ticket $ticket,
60
+		$max_atndz,
61
+		$date_format
62
+	) {
63
+		$this->ticket = $ticket;
64
+		$this->max_atndz = $max_atndz;
65
+		$this->date_format = $date_format;
66
+		$this->EVT_ID = $this->ticket->get_event_ID();
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 * @return string
73
+	 */
74
+	public function getTicketStatusDisplay()
75
+	{
76
+		return $this->ticket_status_display;
77
+	}
78
+
79
+
80
+
81
+	/**
82
+	 * setTicketStatusDisplay
83
+	 *
84
+	 * @param string $tkt_status
85
+	 * @param string $ticket_status
86
+	 * @param int    $remaining
87
+	 * @throws \EE_Error
88
+	 */
89
+	protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) {
90
+		$this->ticket_status_display = '';
91
+		// now depending on the ticket and other circumstances...
92
+		if ($this->max_atndz === 0) {
93
+			// registration is CLOSED because admin set max attendees to ZERO
94
+			$this->ticket_status_display = $this->registrationClosed();
95
+		} else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) {
96
+			// SOLD OUT - no tickets remaining
97
+			$this->ticket_status_display = $this->ticketsSoldOut();
98
+		} else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) {
99
+			// expired or archived ticket
100
+			$this->ticket_status_display = $ticket_status;
101
+		} else if ($tkt_status === \EE_Ticket::pending) {
102
+			// ticket not on sale yet
103
+			$this->ticket_status_display = $this->ticketsSalesPending();
104
+		} else if ($this->ticket->min() > $remaining) {
105
+			// min qty purchasable is less than tickets available
106
+			$this->ticket_status_display = $this->notEnoughTicketsAvailable();
107
+		}
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * registrationClosed
114
+	 */
115
+	protected function registrationClosed()
116
+	{
117
+		return \EEH_HTML::span(
118
+			apply_filters(
119
+				'FHEE__ticket_selector_chart_template__ticket_closed_msg',
120
+				__('Closed', 'event_espresso')
121
+			),
122
+			'', 'sold-out'
123
+		);
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * ticketsSoldOut
130
+	 */
131
+	protected function ticketsSoldOut()
132
+	{
133
+		return \EEH_HTML::span(
134
+			apply_filters(
135
+				'FHEE__ticket_selector_chart_template__ticket_sold_out_msg',
136
+				__('Sold&nbsp;Out', 'event_espresso')
137
+			),
138
+			'', 'sold-out'
139
+		);
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * ticketsSalesPending
146
+	 *
147
+	 * @throws \EE_Error
148
+	 */
149
+	protected function ticketsSalesPending()
150
+	{
151
+		return \EEH_HTML::span(
152
+			\EEH_HTML::span(
153
+				apply_filters(
154
+					'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg',
155
+					__('Goes&nbsp;On&nbsp;Sale', 'event_espresso')
156
+				),
157
+				'', 'ticket-pending'
158
+			)
159
+			. \EEH_HTML::br()
160
+			. \EEH_HTML::span(
161
+				$this->ticket->get_i18n_datetime(
162
+					'TKT_start_date',
163
+					apply_filters(
164
+						'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format',
165
+						$this->date_format
166
+					)
167
+				),
168
+				'', 'small-text'
169
+			),
170
+			'', 'ticket-pending-pg'
171
+		);
172
+	}
173
+
174
+
175
+
176
+	/**
177
+	 * notEnoughTicketsAvailable
178
+	 */
179
+	protected function notEnoughTicketsAvailable()
180
+	{
181
+		return \EEH_HTML::div(
182
+			\EEH_HTML::span(
183
+				apply_filters(
184
+					'FHEE__ticket_selector_chart_template__ticket_not_available_msg',
185
+					__('Not Available', 'event_espresso')
186
+				),
187
+				'', 'archived-ticket small-text'
188
+			)
189
+			. \EEH_HTML::br(),
190
+			'', 'archived-ticket-pg'
191
+		);
192
+	}
193
+
194
+
195
+
196
+	/**
197
+	 * getHiddenInputs
198
+	 *
199
+	 * @param string $anchor_id
200
+	 * @param int    $row
201
+	 * @param int    $max_atndz
202
+	 * @return string
203
+	 */
204
+	protected function getHiddenInputs($anchor_id, $row, $max_atndz)
205
+	{
206
+		$html = '<input type="hidden" name="noheader" value="true"/>';
207
+		$html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->EVT_ID . '"';
208
+		$html .= ' value="' . \EEH_URL::current_url() . $anchor_id . '"/>';
209
+		$html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->EVT_ID . '" value="' . $row - 1 . '"/>';
210
+		$html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->EVT_ID . '" value="' . $max_atndz . '"/>';
211
+		$html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->EVT_ID . '"/>';
212
+		return $html;
213
+	}
214 214
 
215 215
 
216 216
 
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.31.rc.001');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.31.rc.001');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
Please login to merge, or discard this patch.