Completed
Branch FET-10586-integer-input (b0e424)
by
unknown
13:52
created
modules/ticket_selector/TicketSelectorRowStandard.php 1 patch
Indentation   +398 added lines, -398 removed lines patch added patch discarded remove patch
@@ -19,404 +19,404 @@
 block discarded – undo
19 19
 class TicketSelectorRowStandard extends TicketSelectorRow
20 20
 {
21 21
 
22
-    /**
23
-     * @var TicketDetails $ticket_details
24
-     */
25
-    protected $ticket_details;
26
-
27
-    /**
28
-     * @var \EE_Ticket_Selector_Config $template_settings
29
-     */
30
-    protected $template_settings;
31
-
32
-    /**
33
-     * @var \EE_Tax_Config $tax_settings
34
-     */
35
-    protected $tax_settings;
36
-
37
-    /**
38
-     * @var boolean $prices_displayed_including_taxes
39
-     */
40
-    protected $prices_displayed_including_taxes;
41
-
42
-    /**
43
-     * @var int $row
44
-     */
45
-    protected $row;
46
-
47
-    /**
48
-     * @var int $cols
49
-     */
50
-    protected $cols;
51
-
52
-    /**
53
-     * @var boolean $hidden_input_qty
54
-     */
55
-    protected $hidden_input_qty;
56
-
57
-    /**
58
-     * @var string $ticket_datetime_classes
59
-     */
60
-    protected $ticket_datetime_classes;
61
-
62
-
63
-
64
-    /**
65
-     * TicketDetails constructor.
66
-     *
67
-     * @param TicketDetails  $ticket_details
68
-     * @param \EE_Tax_Config $tax_settings
69
-     * @param int            $total_tickets
70
-     * @param int            $max_atndz
71
-     * @param int            $row
72
-     * @param int            $cols
73
-     * @param boolean        $required_ticket_sold_out
74
-     * @param string         $event_status
75
-     * @param string         $ticket_datetime_classes
76
-     * @throws EE_Error
77
-     * @throws UnexpectedEntityException
78
-     */
79
-    public function __construct(
80
-        TicketDetails $ticket_details,
81
-        \EE_Tax_Config $tax_settings,
82
-        $total_tickets,
83
-        $max_atndz,
84
-        $row,
85
-        $cols,
86
-        $required_ticket_sold_out,
87
-        $event_status,
88
-        $ticket_datetime_classes
89
-    ) {
90
-        $this->ticket = $ticket_details->getTicket();
91
-        $this->ticket_details = $ticket_details;
92
-        $this->template_settings = $ticket_details->getTemplateSettings();
93
-        $this->tax_settings = $tax_settings;
94
-        $this->total_tickets = $total_tickets;
95
-        $this->max_atndz = $max_atndz;
96
-        $this->row = $row;
97
-        $this->cols = $cols;
98
-        $this->date_format = $ticket_details->getDateFormat();
99
-        $this->ticket_datetime_classes = $ticket_datetime_classes;
100
-        parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out);
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * other ticket rows will need to know if a required ticket is sold out,
107
-     * so that they are not offered for sale
108
-     *
109
-     * @return boolean
110
-     */
111
-    public function getRequiredTicketSoldOut()
112
-    {
113
-        return $this->required_ticket_sold_out;
114
-    }
115
-
116
-
117
-
118
-    /**
119
-     * @return int
120
-     */
121
-    public function getCols()
122
-    {
123
-        return $this->cols;
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * getHtml
130
-     *
131
-     * @return string
132
-     * @throws EE_Error
133
-     */
134
-    public function getHtml()
135
-    {
136
-        $min = 0;
137
-        $max = $this->ticket->max();
138
-        $remaining = $this->ticket->remaining();
139
-        if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
140
-            list($min, $max) = $this->setTicketMinAndMax($remaining);
141
-        } else {
142
-            // set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
143
-            $this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
144
-                ? $this->ticket->start_date()
145
-                : $this->required_ticket_sold_out;
146
-        }
147
-        list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
148
-        list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
149
-        /**
150
-         * Allow plugins to hook in and abort the generation and display of this row to do
151
-         * something else if they want.
152
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
153
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
154
-         * current row.
155
-         *
156
-         * @var string|bool
157
-         */
158
-        $ticket_selector_row_html = apply_filters(
159
-            'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
160
-            false,
161
-            $this->ticket,
162
-            $max,
163
-            $min,
164
-            $this->required_ticket_sold_out,
165
-            $ticket_price,
166
-            $ticket_bundle,
167
-            $ticket_status,
168
-            $status_class
169
-        );
170
-        if ($ticket_selector_row_html !== false) {
171
-            return $ticket_selector_row_html;
172
-        }
173
-        $ticket_selector_row_html = \EEH_HTML::tr(
174
-            '', '',
175
-            "tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
176
-        );
177
-        /**
178
-         * Allow plugins to hook in and abort the generation and display of the contents of this
179
-         * row to do something else if they want.
180
-         * For an addon to abort things, all they have to do is register a filter with this hook, and
181
-         * return a value that is NOT false.  Whatever is returned gets echoed instead of the
182
-         * current row.
183
-         *
184
-         * @var string|bool
185
-         */
186
-        $new_row_cells_content = apply_filters(
187
-            'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
188
-            false,
189
-            $this->ticket,
190
-            $max,
191
-            $min,
192
-            $this->required_ticket_sold_out,
193
-            $ticket_price,
194
-            $ticket_bundle,
195
-            $ticket_status,
196
-            $status_class
197
-        );
198
-        if ($new_row_cells_content !== false && $this->max_atndz === 1) {
199
-            return $ticket_selector_row_html
200
-                   . $new_row_cells_content
201
-                   . $this->ticketQtyAndIdHiddenInputs()
202
-                   . \EEH_HTML::trx();
203
-        }
204
-        if ($new_row_cells_content !== false) {
205
-            return $ticket_selector_row_html
206
-                   . $new_row_cells_content
207
-                   . \EEH_HTML::trx();
208
-        }
209
-        $this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
210
-
211
-        $ticket_selector_row_html .= $this->ticketNameTableCell();
212
-        $ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
213
-        $ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
214
-        $this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
215
-        if (empty($this->ticket_status_display)) {
216
-            if ($this->max_atndz === 1) {
217
-                // only ONE attendee is allowed to register at a time
218
-                $ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
219
-            } else if ($max > 0) {
220
-                $ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
221
-            }
222
-        }
223
-        $ticket_selector_row_html .= $this->ticket_status_display;
224
-        $ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
225
-        $ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
226
-        $ticket_selector_row_html .= \EEH_HTML::tdx();
227
-        $ticket_selector_row_html .= \EEH_HTML::trx();
228
-
229
-
230
-        $this->row++;
231
-        return $ticket_selector_row_html;
232
-    }
233
-
234
-
235
-
236
-    /**
237
-     * setTicketMinAndMax
238
-     *
239
-     * @param int $remaining
240
-     * @return array
241
-     * @throws EE_Error
242
-     */
243
-    protected function setTicketMinAndMax($remaining)
244
-    {
245
-        // offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
246
-        $max = min($remaining, $this->max_atndz);
247
-        // but... we also want to restrict the number of tickets by the ticket max setting,
248
-        // however, the max still can't be higher than what was just set above
249
-        $max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
250
-        // and we also want to restrict the minimum number of tickets by the ticket min setting
251
-        $min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
252
-        // and if the ticket is required, then make sure that min qty is at least 1
253
-        $min = $this->ticket->required() ? max($min, 1) : $min;
254
-        return array($min, $max);
255
-    }
256
-
257
-
258
-
259
-    /**
260
-     * getTicketPriceDetails
261
-     *
262
-     * @return array
263
-     * @throws EE_Error
264
-     */
265
-    protected function getTicketPriceDetails()
266
-    {
267
-        $ticket_price = $this->tax_settings->prices_displayed_including_taxes
268
-            ? $this->ticket->get_ticket_total_with_taxes()
269
-            : $this->ticket->get_ticket_subtotal();
270
-        $ticket_bundle = false;
271
-        $ticket_min = $this->ticket->min();
272
-        // for ticket bundles, set min and max qty the same
273
-        if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
274
-            $ticket_price *= $ticket_min;
275
-            $ticket_bundle = true;
276
-        }
277
-        $ticket_price = apply_filters(
278
-            'FHEE__ticket_selector_chart_template__ticket_price',
279
-            $ticket_price,
280
-            $this->ticket
281
-        );
282
-        return array($ticket_price, $ticket_bundle);
283
-    }
284
-
285
-
286
-
287
-
288
-    /**
289
-     * ticketNameTableCell
290
-     *
291
-     * @return string
292
-     * @throws EE_Error
293
-     */
294
-    protected function ticketNameTableCell()
295
-    {
296
-        $html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
297
-        $html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
298
-        $html .= $this->ticket_details->getShowHideLinks();
299
-        if ($this->ticket->required()) {
300
-            $html .= \EEH_HTML::p(
301
-                    apply_filters(
302
-                            'FHEE__ticket_selector_chart_template__ticket_required_message',
303
-                            esc_html__('This ticket is required and must be purchased.', 'event_espresso')
304
-                    ),
305
-                    '', 'ticket-required-pg'
306
-            );
307
-        }
308
-        $html .= \EEH_HTML::tdx();
309
-        return $html;
310
-    }
311
-
312
-
313
-
314
-    /**
315
-     * ticketPriceTableCell
316
-     *
317
-     * @param float $ticket_price
318
-     * @param bool  $ticket_bundle
319
-     * @return string
320
-     * @throws EE_Error
321
-     */
322
-    protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
323
-    {
324
-        $html = '';
325
-        if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
326
-            $html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
327
-            $html .= \EEH_Template::format_currency($ticket_price);
328
-            $html .= $this->ticket->taxable()
329
-                ? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
330
-                : '';
331
-            $html .= ' ';
332
-            $html .= \EEH_HTML::span(
333
-                $ticket_bundle
334
-                    ? apply_filters(
335
-                        'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
336
-                        __(' / bundle', 'event_espresso')
337
-                    )
338
-                    : apply_filters(
339
-                        'FHEE__ticket_selector_chart_template__per_ticket_text',
340
-                        __('', 'event_espresso')
341
-                    ),
342
-                '', 'smaller-text no-bold'
343
-            );
344
-            $html .= ' ';
345
-            $html .= \EEH_HTML::tdx();
346
-            $this->cols++;
347
-        }
348
-        return $html;
349
-    }
350
-
351
-
352
-
353
-    /**
354
-     * onlyOneAttendeeCanRegister
355
-     *
356
-     * @return string
357
-     */
358
-    protected function onlyOneAttendeeCanRegister()
359
-    {
360
-        // display submit button since we have tickets available
361
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
362
-        $this->hidden_input_qty = false;
363
-        $html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
364
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
365
-        $html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
366
-        $html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
367
-        $html .= ' title=""/>';
368
-        return $html;
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * ticketQuantitySelector
375
-     *
376
-     * @param int $min
377
-     * @param int $max
378
-     * @return string
379
-     * @throws EE_Error
380
-     */
381
-    protected function ticketQuantitySelector($min = 0, $max = 0)
382
-    {
383
-        // display submit button since we have tickets available
384
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
385
-        $this->hidden_input_qty = false;
386
-        $html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
387
-        $html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
388
-        $html .= ' class="ticket-selector-tbl-qty-slct">';
389
-        // this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
390
-        if ($min !== 0 && ! $this->ticket->required()) {
391
-            $html .= '<option value="0">&nbsp;0&nbsp;</option>';
392
-        }
393
-        // offer ticket quantities from the min to the max
394
-        for ($i = $min; $i <= $max; $i++) {
395
-            $html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
396
-        }
397
-        $html .= '</select>';
398
-        return $html;
399
-    }
400
-
401
-
402
-
403
-    /**
404
-     * getHiddenInputs
405
-     *
406
-     * @return string
407
-     * @throws EE_Error
408
-     */
409
-    protected function ticketQtyAndIdHiddenInputs()
410
-    {
411
-        $html = '';
412
-        // depending on group reg we need to change the format for qty
413
-        if ($this->hidden_input_qty) {
414
-            $html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
415
-        }
416
-        $html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
417
-        $html .= ' value="' . $this->ticket->ID() . '"/>';
418
-        return $html;
419
-    }
22
+	/**
23
+	 * @var TicketDetails $ticket_details
24
+	 */
25
+	protected $ticket_details;
26
+
27
+	/**
28
+	 * @var \EE_Ticket_Selector_Config $template_settings
29
+	 */
30
+	protected $template_settings;
31
+
32
+	/**
33
+	 * @var \EE_Tax_Config $tax_settings
34
+	 */
35
+	protected $tax_settings;
36
+
37
+	/**
38
+	 * @var boolean $prices_displayed_including_taxes
39
+	 */
40
+	protected $prices_displayed_including_taxes;
41
+
42
+	/**
43
+	 * @var int $row
44
+	 */
45
+	protected $row;
46
+
47
+	/**
48
+	 * @var int $cols
49
+	 */
50
+	protected $cols;
51
+
52
+	/**
53
+	 * @var boolean $hidden_input_qty
54
+	 */
55
+	protected $hidden_input_qty;
56
+
57
+	/**
58
+	 * @var string $ticket_datetime_classes
59
+	 */
60
+	protected $ticket_datetime_classes;
61
+
62
+
63
+
64
+	/**
65
+	 * TicketDetails constructor.
66
+	 *
67
+	 * @param TicketDetails  $ticket_details
68
+	 * @param \EE_Tax_Config $tax_settings
69
+	 * @param int            $total_tickets
70
+	 * @param int            $max_atndz
71
+	 * @param int            $row
72
+	 * @param int            $cols
73
+	 * @param boolean        $required_ticket_sold_out
74
+	 * @param string         $event_status
75
+	 * @param string         $ticket_datetime_classes
76
+	 * @throws EE_Error
77
+	 * @throws UnexpectedEntityException
78
+	 */
79
+	public function __construct(
80
+		TicketDetails $ticket_details,
81
+		\EE_Tax_Config $tax_settings,
82
+		$total_tickets,
83
+		$max_atndz,
84
+		$row,
85
+		$cols,
86
+		$required_ticket_sold_out,
87
+		$event_status,
88
+		$ticket_datetime_classes
89
+	) {
90
+		$this->ticket = $ticket_details->getTicket();
91
+		$this->ticket_details = $ticket_details;
92
+		$this->template_settings = $ticket_details->getTemplateSettings();
93
+		$this->tax_settings = $tax_settings;
94
+		$this->total_tickets = $total_tickets;
95
+		$this->max_atndz = $max_atndz;
96
+		$this->row = $row;
97
+		$this->cols = $cols;
98
+		$this->date_format = $ticket_details->getDateFormat();
99
+		$this->ticket_datetime_classes = $ticket_datetime_classes;
100
+		parent::__construct($this->ticket, $max_atndz, $this->date_format, $event_status, $required_ticket_sold_out);
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * other ticket rows will need to know if a required ticket is sold out,
107
+	 * so that they are not offered for sale
108
+	 *
109
+	 * @return boolean
110
+	 */
111
+	public function getRequiredTicketSoldOut()
112
+	{
113
+		return $this->required_ticket_sold_out;
114
+	}
115
+
116
+
117
+
118
+	/**
119
+	 * @return int
120
+	 */
121
+	public function getCols()
122
+	{
123
+		return $this->cols;
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * getHtml
130
+	 *
131
+	 * @return string
132
+	 * @throws EE_Error
133
+	 */
134
+	public function getHtml()
135
+	{
136
+		$min = 0;
137
+		$max = $this->ticket->max();
138
+		$remaining = $this->ticket->remaining();
139
+		if ($this->ticket->is_on_sale() && $this->ticket->is_remaining()) {
140
+			list($min, $max) = $this->setTicketMinAndMax($remaining);
141
+		} else {
142
+			// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
143
+			$this->required_ticket_sold_out = $this->ticket->required() && ! $remaining
144
+				? $this->ticket->start_date()
145
+				: $this->required_ticket_sold_out;
146
+		}
147
+		list($ticket_price, $ticket_bundle) = $this->getTicketPriceDetails();
148
+		list($tkt_status, $ticket_status, $status_class) = $this->getTicketStatusClasses($remaining);
149
+		/**
150
+		 * Allow plugins to hook in and abort the generation and display of this row to do
151
+		 * something else if they want.
152
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
153
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
154
+		 * current row.
155
+		 *
156
+		 * @var string|bool
157
+		 */
158
+		$ticket_selector_row_html = apply_filters(
159
+			'FHEE__ticket_selector_chart_template__do_ticket_entire_row',
160
+			false,
161
+			$this->ticket,
162
+			$max,
163
+			$min,
164
+			$this->required_ticket_sold_out,
165
+			$ticket_price,
166
+			$ticket_bundle,
167
+			$ticket_status,
168
+			$status_class
169
+		);
170
+		if ($ticket_selector_row_html !== false) {
171
+			return $ticket_selector_row_html;
172
+		}
173
+		$ticket_selector_row_html = \EEH_HTML::tr(
174
+			'', '',
175
+			"tckt-slctr-tbl-tr {$status_class}{$this->ticket_datetime_classes} " . espresso_get_object_css_class($this->ticket)
176
+		);
177
+		/**
178
+		 * Allow plugins to hook in and abort the generation and display of the contents of this
179
+		 * row to do something else if they want.
180
+		 * For an addon to abort things, all they have to do is register a filter with this hook, and
181
+		 * return a value that is NOT false.  Whatever is returned gets echoed instead of the
182
+		 * current row.
183
+		 *
184
+		 * @var string|bool
185
+		 */
186
+		$new_row_cells_content = apply_filters(
187
+			'FHEE__ticket_selector_chart_template__do_ticket_inside_row',
188
+			false,
189
+			$this->ticket,
190
+			$max,
191
+			$min,
192
+			$this->required_ticket_sold_out,
193
+			$ticket_price,
194
+			$ticket_bundle,
195
+			$ticket_status,
196
+			$status_class
197
+		);
198
+		if ($new_row_cells_content !== false && $this->max_atndz === 1) {
199
+			return $ticket_selector_row_html
200
+				   . $new_row_cells_content
201
+				   . $this->ticketQtyAndIdHiddenInputs()
202
+				   . \EEH_HTML::trx();
203
+		}
204
+		if ($new_row_cells_content !== false) {
205
+			return $ticket_selector_row_html
206
+				   . $new_row_cells_content
207
+				   . \EEH_HTML::trx();
208
+		}
209
+		$this->hidden_input_qty = $this->max_atndz > 1 ? true : false;
210
+
211
+		$ticket_selector_row_html .= $this->ticketNameTableCell();
212
+		$ticket_selector_row_html .= $this->ticketPriceTableCell($ticket_price, $ticket_bundle);
213
+		$ticket_selector_row_html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-qty cntr');
214
+		$this->setTicketStatusDisplay($tkt_status, $ticket_status, $remaining);
215
+		if (empty($this->ticket_status_display)) {
216
+			if ($this->max_atndz === 1) {
217
+				// only ONE attendee is allowed to register at a time
218
+				$ticket_selector_row_html .= $this->onlyOneAttendeeCanRegister();
219
+			} else if ($max > 0) {
220
+				$ticket_selector_row_html .= $this->ticketQuantitySelector($min, $max);
221
+			}
222
+		}
223
+		$ticket_selector_row_html .= $this->ticket_status_display;
224
+		$ticket_selector_row_html .= $this->ticketQtyAndIdHiddenInputs();
225
+		$ticket_selector_row_html .= $this->ticket_details->display($ticket_price, $remaining, $this->cols);
226
+		$ticket_selector_row_html .= \EEH_HTML::tdx();
227
+		$ticket_selector_row_html .= \EEH_HTML::trx();
228
+
229
+
230
+		$this->row++;
231
+		return $ticket_selector_row_html;
232
+	}
233
+
234
+
235
+
236
+	/**
237
+	 * setTicketMinAndMax
238
+	 *
239
+	 * @param int $remaining
240
+	 * @return array
241
+	 * @throws EE_Error
242
+	 */
243
+	protected function setTicketMinAndMax($remaining)
244
+	{
245
+		// offer the number of $tickets_remaining or $this->max_atndz, whichever is smaller
246
+		$max = min($remaining, $this->max_atndz);
247
+		// but... we also want to restrict the number of tickets by the ticket max setting,
248
+		// however, the max still can't be higher than what was just set above
249
+		$max = $this->ticket->max() > 0 ? min($this->ticket->max(), $max) : $max;
250
+		// and we also want to restrict the minimum number of tickets by the ticket min setting
251
+		$min = $this->ticket->min() > 0 ? $this->ticket->min() : 0;
252
+		// and if the ticket is required, then make sure that min qty is at least 1
253
+		$min = $this->ticket->required() ? max($min, 1) : $min;
254
+		return array($min, $max);
255
+	}
256
+
257
+
258
+
259
+	/**
260
+	 * getTicketPriceDetails
261
+	 *
262
+	 * @return array
263
+	 * @throws EE_Error
264
+	 */
265
+	protected function getTicketPriceDetails()
266
+	{
267
+		$ticket_price = $this->tax_settings->prices_displayed_including_taxes
268
+			? $this->ticket->get_ticket_total_with_taxes()
269
+			: $this->ticket->get_ticket_subtotal();
270
+		$ticket_bundle = false;
271
+		$ticket_min = $this->ticket->min();
272
+		// for ticket bundles, set min and max qty the same
273
+		if ($ticket_min !== 0 && $ticket_min === $this->ticket->max()) {
274
+			$ticket_price *= $ticket_min;
275
+			$ticket_bundle = true;
276
+		}
277
+		$ticket_price = apply_filters(
278
+			'FHEE__ticket_selector_chart_template__ticket_price',
279
+			$ticket_price,
280
+			$this->ticket
281
+		);
282
+		return array($ticket_price, $ticket_bundle);
283
+	}
284
+
285
+
286
+
287
+
288
+	/**
289
+	 * ticketNameTableCell
290
+	 *
291
+	 * @return string
292
+	 * @throws EE_Error
293
+	 */
294
+	protected function ticketNameTableCell()
295
+	{
296
+		$html = \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-name');
297
+		$html .= \EEH_HTML::strong($this->ticket->get_pretty('TKT_name'));
298
+		$html .= $this->ticket_details->getShowHideLinks();
299
+		if ($this->ticket->required()) {
300
+			$html .= \EEH_HTML::p(
301
+					apply_filters(
302
+							'FHEE__ticket_selector_chart_template__ticket_required_message',
303
+							esc_html__('This ticket is required and must be purchased.', 'event_espresso')
304
+					),
305
+					'', 'ticket-required-pg'
306
+			);
307
+		}
308
+		$html .= \EEH_HTML::tdx();
309
+		return $html;
310
+	}
311
+
312
+
313
+
314
+	/**
315
+	 * ticketPriceTableCell
316
+	 *
317
+	 * @param float $ticket_price
318
+	 * @param bool  $ticket_bundle
319
+	 * @return string
320
+	 * @throws EE_Error
321
+	 */
322
+	protected function ticketPriceTableCell($ticket_price, $ticket_bundle)
323
+	{
324
+		$html = '';
325
+		if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) {
326
+			$html .= \EEH_HTML::td('', '', 'tckt-slctr-tbl-td-price jst-rght');
327
+			$html .= \EEH_Template::format_currency($ticket_price);
328
+			$html .= $this->ticket->taxable()
329
+				? \EEH_HTML::span( '*', '', 'taxable-tickets-asterisk grey-text' )
330
+				: '';
331
+			$html .= '&nbsp;';
332
+			$html .= \EEH_HTML::span(
333
+				$ticket_bundle
334
+					? apply_filters(
335
+						'FHEE__ticket_selector_chart_template__per_ticket_bundle_text',
336
+						__(' / bundle', 'event_espresso')
337
+					)
338
+					: apply_filters(
339
+						'FHEE__ticket_selector_chart_template__per_ticket_text',
340
+						__('', 'event_espresso')
341
+					),
342
+				'', 'smaller-text no-bold'
343
+			);
344
+			$html .= '&nbsp;';
345
+			$html .= \EEH_HTML::tdx();
346
+			$this->cols++;
347
+		}
348
+		return $html;
349
+	}
350
+
351
+
352
+
353
+	/**
354
+	 * onlyOneAttendeeCanRegister
355
+	 *
356
+	 * @return string
357
+	 */
358
+	protected function onlyOneAttendeeCanRegister()
359
+	{
360
+		// display submit button since we have tickets available
361
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
362
+		$this->hidden_input_qty = false;
363
+		$html = '<input type="radio" name="tkt-slctr-qty-' . $this->EVT_ID . '"';
364
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
365
+		$html .= ' class="ticket-selector-tbl-qty-slct" value="' . $this->row . '-1"';
366
+		$html .= $this->total_tickets === 1 ? ' checked="checked"' : '';
367
+		$html .= ' title=""/>';
368
+		return $html;
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * ticketQuantitySelector
375
+	 *
376
+	 * @param int $min
377
+	 * @param int $max
378
+	 * @return string
379
+	 * @throws EE_Error
380
+	 */
381
+	protected function ticketQuantitySelector($min = 0, $max = 0)
382
+	{
383
+		// display submit button since we have tickets available
384
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
385
+		$this->hidden_input_qty = false;
386
+		$html = '<select name="tkt-slctr-qty-' . $this->EVT_ID . '[]"';
387
+		$html .= ' id="ticket-selector-tbl-qty-slct-' . $this->EVT_ID . '-' . $this->row . '"';
388
+		$html .= ' class="ticket-selector-tbl-qty-slct">';
389
+		// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
390
+		if ($min !== 0 && ! $this->ticket->required()) {
391
+			$html .= '<option value="0">&nbsp;0&nbsp;</option>';
392
+		}
393
+		// offer ticket quantities from the min to the max
394
+		for ($i = $min; $i <= $max; $i++) {
395
+			$html .= '<option value="' . $i . '">&nbsp;' . $i . '&nbsp;</option>';
396
+		}
397
+		$html .= '</select>';
398
+		return $html;
399
+	}
400
+
401
+
402
+
403
+	/**
404
+	 * getHiddenInputs
405
+	 *
406
+	 * @return string
407
+	 * @throws EE_Error
408
+	 */
409
+	protected function ticketQtyAndIdHiddenInputs()
410
+	{
411
+		$html = '';
412
+		// depending on group reg we need to change the format for qty
413
+		if ($this->hidden_input_qty) {
414
+			$html .= '<input type="hidden" name="tkt-slctr-qty-' . $this->EVT_ID . '[]" value="0"/>';
415
+		}
416
+		$html .= '<input type="hidden" name="tkt-slctr-ticket-id-' . $this->EVT_ID . '[]"';
417
+		$html .= ' value="' . $this->ticket->ID() . '"/>';
418
+		return $html;
419
+	}
420 420
 
421 421
 }
422 422
 // End of file TicketSelectorRowStandard.php
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/rpc/Checkin.php 2 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 use EventEspresso\core\libraries\rest_api\controllers\model\Read;
15 15
 
16 16
 if (! defined('EVENT_ESPRESSO_VERSION')) {
17
-    exit('No direct script access allowed');
17
+	exit('No direct script access allowed');
18 18
 }
19 19
 
20 20
 
@@ -31,116 +31,116 @@  discard block
 block discarded – undo
31 31
 class Checkin extends Base
32 32
 {
33 33
 
34
-    /**
35
-     * @param WP_REST_Request $request
36
-     * @return WP_Error|WP_REST_Response
37
-     */
38
-    public static function handle_request_toggle_checkin(WP_REST_Request $request)
39
-    {
40
-        $controller = new Checkin();
41
-        return $controller->_create_checkin_checkout_object($request);
42
-    }
34
+	/**
35
+	 * @param WP_REST_Request $request
36
+	 * @return WP_Error|WP_REST_Response
37
+	 */
38
+	public static function handle_request_toggle_checkin(WP_REST_Request $request)
39
+	{
40
+		$controller = new Checkin();
41
+		return $controller->_create_checkin_checkout_object($request);
42
+	}
43 43
 
44 44
 
45 45
 
46
-    /**
47
-     * Toggles whether the user is checked in or not.
48
-     *
49
-     * @param WP_REST_Request $request
50
-     * @return WP_Error|WP_REST_Response
51
-     */
52
-    protected function _create_checkin_checkout_object(WP_REST_Request $request)
53
-    {
54
-        $reg_id = $request->get_param('REG_ID');
55
-        $dtt_id = $request->get_param('DTT_ID');
56
-        $force = $request->get_param('force');
57
-        if ($force == 'true') {
58
-            $force = true;
59
-        } else {
60
-            $force = false;
61
-        }
62
-        $reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
63
-        if (! $reg instanceof EE_Registration) {
64
-            return $this->send_response(
65
-                new WP_Error(
66
-                    'rest_registration_toggle_checkin_invalid_id',
67
-                    sprintf(
68
-                        __('You cannot checkin registration with ID %1$s because it doesn\'t exist.',
69
-                            'event_espresso'),
70
-                        $reg_id
71
-                    ),
72
-                    array('status' => 422)
73
-                )
74
-            );
75
-        }
76
-        if (! EE_Capabilities::instance()
77
-                             ->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)
78
-        ) {
79
-            return $this->send_response(
80
-                new WP_Error(
81
-                    'rest_user_cannot_toggle_checkin',
82
-                    sprintf(
83
-                        __('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'),
84
-                        $reg_id
85
-                    ),
86
-                    array('status' => 403)
87
-                )
88
-            );
89
-        }
90
-        $success = $reg->toggle_checkin_status($dtt_id, ! $force);
91
-        if ($success === false) {
92
-            //check if we know they can't check in because they're not approved and we aren't forcing
93
-            if (! $reg->is_approved() && ! $force) {
94
-                //rely on EE_Error::add_error messages to have been added to give more data about why it failed
95
-                return $this->send_response(
96
-                    new WP_Error(
97
-                        'rest_toggle_checkin_failed',
98
-                        __('Registration check-in failed because the registration is not approved. You may attempt to force checking in though.',
99
-                            'event_espresso')
100
-                    )
101
-                );
102
-            }
103
-            return $this->send_response(
104
-                new WP_Error(
105
-                    'rest_toggle_checkin_failed_not_forceable',
106
-                    __('Registration checkin failed. Please see additional error data.', 'event_espresso')
107
-                )
108
-            );
109
-        }
110
-        $checkin = EEM_Checkin::instance()->get_one(
111
-            array(
112
-                array(
113
-                    'REG_ID' => $reg_id,
114
-                    'DTT_ID' => $dtt_id,
115
-                ),
116
-                'order_by' => array(
117
-                    'CHK_timestamp' => 'DESC',
118
-                ),
119
-            )
120
-        );
121
-        if (! $checkin instanceof EE_Checkin) {
122
-            return $this->send_response(
123
-                new WP_Error(
124
-                    'rest_toggle_checkin_error',
125
-                    sprintf(
126
-                        __('Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.',
127
-                            'event_espresso'),
128
-                        $reg_id,
129
-                        $dtt_id
130
-                    )
131
-                )
132
-            );
133
-        }
134
-        $requested_version = $this->get_requested_version($request->get_route());
135
-        $get_request = new WP_REST_Request(
136
-            'GET',
137
-            EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID()
138
-        );
139
-        $get_request->set_url_params(
140
-            array(
141
-                'id' => $checkin->ID(),
142
-            )
143
-        );
144
-        return Read::handle_request_get_one($get_request);
145
-    }
46
+	/**
47
+	 * Toggles whether the user is checked in or not.
48
+	 *
49
+	 * @param WP_REST_Request $request
50
+	 * @return WP_Error|WP_REST_Response
51
+	 */
52
+	protected function _create_checkin_checkout_object(WP_REST_Request $request)
53
+	{
54
+		$reg_id = $request->get_param('REG_ID');
55
+		$dtt_id = $request->get_param('DTT_ID');
56
+		$force = $request->get_param('force');
57
+		if ($force == 'true') {
58
+			$force = true;
59
+		} else {
60
+			$force = false;
61
+		}
62
+		$reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
63
+		if (! $reg instanceof EE_Registration) {
64
+			return $this->send_response(
65
+				new WP_Error(
66
+					'rest_registration_toggle_checkin_invalid_id',
67
+					sprintf(
68
+						__('You cannot checkin registration with ID %1$s because it doesn\'t exist.',
69
+							'event_espresso'),
70
+						$reg_id
71
+					),
72
+					array('status' => 422)
73
+				)
74
+			);
75
+		}
76
+		if (! EE_Capabilities::instance()
77
+							 ->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)
78
+		) {
79
+			return $this->send_response(
80
+				new WP_Error(
81
+					'rest_user_cannot_toggle_checkin',
82
+					sprintf(
83
+						__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'),
84
+						$reg_id
85
+					),
86
+					array('status' => 403)
87
+				)
88
+			);
89
+		}
90
+		$success = $reg->toggle_checkin_status($dtt_id, ! $force);
91
+		if ($success === false) {
92
+			//check if we know they can't check in because they're not approved and we aren't forcing
93
+			if (! $reg->is_approved() && ! $force) {
94
+				//rely on EE_Error::add_error messages to have been added to give more data about why it failed
95
+				return $this->send_response(
96
+					new WP_Error(
97
+						'rest_toggle_checkin_failed',
98
+						__('Registration check-in failed because the registration is not approved. You may attempt to force checking in though.',
99
+							'event_espresso')
100
+					)
101
+				);
102
+			}
103
+			return $this->send_response(
104
+				new WP_Error(
105
+					'rest_toggle_checkin_failed_not_forceable',
106
+					__('Registration checkin failed. Please see additional error data.', 'event_espresso')
107
+				)
108
+			);
109
+		}
110
+		$checkin = EEM_Checkin::instance()->get_one(
111
+			array(
112
+				array(
113
+					'REG_ID' => $reg_id,
114
+					'DTT_ID' => $dtt_id,
115
+				),
116
+				'order_by' => array(
117
+					'CHK_timestamp' => 'DESC',
118
+				),
119
+			)
120
+		);
121
+		if (! $checkin instanceof EE_Checkin) {
122
+			return $this->send_response(
123
+				new WP_Error(
124
+					'rest_toggle_checkin_error',
125
+					sprintf(
126
+						__('Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.',
127
+							'event_espresso'),
128
+						$reg_id,
129
+						$dtt_id
130
+					)
131
+				)
132
+			);
133
+		}
134
+		$requested_version = $this->get_requested_version($request->get_route());
135
+		$get_request = new WP_REST_Request(
136
+			'GET',
137
+			EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID()
138
+		);
139
+		$get_request->set_url_params(
140
+			array(
141
+				'id' => $checkin->ID(),
142
+			)
143
+		);
144
+		return Read::handle_request_get_one($get_request);
145
+	}
146 146
 }
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use EventEspresso\core\libraries\rest_api\controllers\Base as Base;
14 14
 use EventEspresso\core\libraries\rest_api\controllers\model\Read;
15 15
 
16
-if (! defined('EVENT_ESPRESSO_VERSION')) {
16
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
17 17
     exit('No direct script access allowed');
18 18
 }
19 19
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             $force = false;
61 61
         }
62 62
         $reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
63
-        if (! $reg instanceof EE_Registration) {
63
+        if ( ! $reg instanceof EE_Registration) {
64 64
             return $this->send_response(
65 65
                 new WP_Error(
66 66
                     'rest_registration_toggle_checkin_invalid_id',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                 )
74 74
             );
75 75
         }
76
-        if (! EE_Capabilities::instance()
76
+        if ( ! EE_Capabilities::instance()
77 77
                              ->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)
78 78
         ) {
79 79
             return $this->send_response(
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $success = $reg->toggle_checkin_status($dtt_id, ! $force);
91 91
         if ($success === false) {
92 92
             //check if we know they can't check in because they're not approved and we aren't forcing
93
-            if (! $reg->is_approved() && ! $force) {
93
+            if ( ! $reg->is_approved() && ! $force) {
94 94
                 //rely on EE_Error::add_error messages to have been added to give more data about why it failed
95 95
                 return $this->send_response(
96 96
                     new WP_Error(
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                 ),
119 119
             )
120 120
         );
121
-        if (! $checkin instanceof EE_Checkin) {
121
+        if ( ! $checkin instanceof EE_Checkin) {
122 122
             return $this->send_response(
123 123
                 new WP_Error(
124 124
                     'rest_toggle_checkin_error',
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $requested_version = $this->get_requested_version($request->get_route());
135 135
         $get_request = new WP_REST_Request(
136 136
             'GET',
137
-            EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID()
137
+            EED_Core_Rest_Api::ee_api_namespace.$requested_version.'/checkins/'.$checkin->ID()
138 138
         );
139 139
         $get_request->set_url_params(
140 140
             array(
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Transaction_Shortcodes.lib.php 2 patches
Indentation   +608 added lines, -608 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -28,616 +28,616 @@  discard block
 block discarded – undo
28 28
 class EE_Transaction_Shortcodes extends EE_Shortcodes
29 29
 {
30 30
 
31
-    /**
32
-     * @var EE_Payment_Method $_invoice_pm the invoiec payment method for use in invoices etc
33
-     */
34
-    protected $_invoice_pm;
35
-
36
-
37
-
38
-    /**
39
-     * EE_Transaction_Shortcodes constructor.
40
-     */
41
-    public function __construct()
42
-    {
43
-        parent::__construct();
44
-    }
45
-
46
-
47
-
48
-    protected function _init_props()
49
-    {
50
-        $this->label = esc_html__('Transaction Shortcodes', 'event_espresso');
51
-        $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso');
52
-        $this->_shortcodes = array(
53
-            '[TXN_ID]'                          => esc_html__('The transaction id for the purchase.', 'event_espresso'),
54
-            '[PAYMENT_URL]'                     => esc_html__('This is a link to make a payment for the event',
55
-                'event_espresso'),
56
-            '[PAYMENT_LINK_IF_NEEDED_*]'        => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:',
57
-                    'event_espresso')
58
-                                                   . '<ul>'
59
-                                                   . '<li>'
60
-                                                   . sprintf(esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").',
61
-                    'event_espresso'), '<strong>', '</strong>')
62
-                                                   . '</li>'
63
-                                                   . '<li>'
64
-                                                   . sprintf(esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)',
65
-                    'event_espresso'), '<strong>', '</strong>')
66
-                                                   . '</li>'
67
-                                                   . '<li>'
68
-                                                   . sprintf(esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").',
69
-                    'event_espresso'), '<strong>', '</strong>')
70
-                                                   . '</li>'
71
-                                                   . '</ul>',
72
-            '[PAYMENT_DUE_DATE_*]'              => esc_html__('This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:',
73
-                    'event_espresso')
74
-                                                   . '<ul>'
75
-                                                   . '<li>'
76
-                                                   . sprintf(esc_html__('%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.',
77
-                    'event_espresso'), '<strong>', '</strong>')
78
-                                                   . '</li>'
79
-                                                   . '<li>'
80
-                                                   . sprintf(esc_html__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.',
81
-                    'event_espresso'), '<strong>', '</strong>')
82
-                                                   . '</li>'
83
-                                                   . '<li>'
84
-                                                   . sprintf(esc_html__('%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"',
85
-                    'event_espresso'), '<strong>', '</strong>')
86
-                                                   . '</li>',
87
-            '[INVOICE_LINK]'                    => esc_html__('This is a full html link to the invoice',
88
-                'event_espresso'),
89
-            '[INVOICE_URL]'                     => esc_html__('This is just the url for the invoice', 'event_espresso'),
90
-            '[INVOICE_LOGO_URL]'                => esc_html__('This returns the url for the logo uploaded via the invoice settings page.',
91
-                'event_espresso'),
92
-            '[INVOICE_LOGO]'                    => esc_html__('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.',
93
-                'event_espresso'),
94
-            '[INVOICE_PAYEE_NAME]'              => esc_html__('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.',
95
-                'event_espresso'),
96
-            '[INVOICE_PAYEE_ADDRESS]'           => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.',
97
-                'event_espresso'),
98
-            '[INVOICE_PAYMENT_INSTRUCTIONS]'    => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page',
99
-                'event_espresso'),
100
-            '[INVOICE_PAYEE_EMAIL]'             => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.',
101
-                'event_espresso'),
102
-            '[INVOICE_PAYEE_TAX_NUMBER_*]'      => sprintf(esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.',
103
-                'event_espresso'), '<code>', '</code>'),
104
-            '[TOTAL_COST]'                      => esc_html__('The total cost for the transaction', 'event_espresso'),
105
-            '[TXN_STATUS]'                      => esc_html__('The transaction status for the transaction.',
106
-                'event_espresso'),
107
-            '[TXN_STATUS_ID]'                   => esc_html__('The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.',
108
-                'event_espresso'),
109
-            '[PAYMENT_STATUS]'                  => esc_html__('The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.',
110
-                'event_espresso'),
111
-            '[PAYMENT_GATEWAY]'                 => esc_html__('The payment gateway used for the transaction',
112
-                'event_espresso'),
113
-            '[AMOUNT_PAID]'                     => esc_html__('The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.',
114
-                'event_espresso'),
115
-            '[LAST_AMOUNT_PAID]'                => esc_html__('This is the last payment or refund made on the transaction related to the message being generated.',
116
-                'event_espresso'),
117
-            '[TOTAL_AMOUNT_PAID]'               => esc_html__('This parses to the total amount paid over all payments',
118
-                'event_espresso'),
119
-            '[TOTAL_OWING]'                     => esc_html__('The total owing on a transaction with no attributes.',
120
-                'event_espresso'),
121
-            '[TXN_SUBTOTAL]'                    => esc_html__('The subtotal for all txn line items.', 'event_espresso'),
122
-            '[TXN_TAX_SUBTOTAL]'                => esc_html__('The subtotal for all tax line items.', 'event_espresso'),
123
-            '[OWING_STATUS_MESSAGE_*]'          => esc_html__('A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:',
124
-                    'event_espresso')
125
-                                                   . '<p></ul>'
126
-                                                   .
127
-                                                   '<li><strong>still_owing</strong>:'
128
-                                                   . esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:',
129
-                    'event_espresso')
130
-                                                   . sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'),
131
-                    '<a href="[PAYMENT_URL]" class="noPrint">', '</a>')
132
-                                                   . '</li>'
133
-                                                   .
134
-                                                   '<li><strong>none_owing</strong>:'
135
-                                                   . esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.',
136
-                    'event_espresso')
137
-                                                   . '</li></ul></p>',
138
-            '[TXN_TOTAL_TICKETS]'               => esc_html__('The total number of all tickets purchased in a transaction',
139
-                'event_espresso'),
140
-            '[TKT_QTY_PURCHASED]'               => sprintf(esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s',
141
-                'event_espresso'), '<strong>', '</strong>'),
142
-            '[TRANSACTION_ADMIN_URL]'           => esc_html__('The url to the admin page for this transaction',
143
-                'event_espresso'),
144
-            '[RECEIPT_URL]'                     => esc_html__('This parses to the generated url for retrieving the receipt for the transaction',
145
-                'event_espresso'),
146
-            '[INVOICE_RECEIPT_SWITCHER_URL]'    => esc_html__('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.',
147
-                'event_espresso'),
148
-            '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(esc_html__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.',
149
-                'event_espresso'), '<code>', '</code>'),
150
-        );
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * @access protected
157
-     * @param  string $shortcode the shortcode to be parsed.
158
-     * @return string parsed shortcode
159
-     */
160
-    protected function _parser($shortcode)
161
-    {
162
-        //attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction.
163
-        $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
164
-        $transaction = ! $transaction instanceof EE_Transaction
165
-                       && is_array($this->_extra_data)
166
-                       && isset($this->_extra_data['data'])
167
-                       && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn
168
-            : $transaction;
169
-        //payment
170
-        $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
171
-        $payment = ! $payment instanceof EE_Payment
172
-                   && is_array($this->_extra_data)
173
-                   && isset($this->_extra_data['data'])
174
-                   && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
175
-            : $payment;
176
-        if (! $transaction instanceof EE_Transaction) {
177
-            return '';
178
-        }
179
-        switch ($shortcode) {
180
-            case '[TXN_ID]' :
181
-                return $transaction->ID();
182
-                break;
183
-            case '[PAYMENT_URL]' :
184
-                $payment_url = $transaction->payment_overview_url();
185
-                return empty($payment_url) ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso')
186
-                    : $payment_url;
187
-                break;
188
-            case '[INVOICE_LINK]' :
189
-                $invoice_url = $transaction->invoice_url();
190
-                $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
191
-                return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'),
192
-                    '<a href="' . $invoice_url . '">', '</a>');
193
-                break; /**/
194
-            case '[INVOICE_URL]' :
195
-                $invoice_url = $transaction->invoice_url();
196
-                return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
197
-                break;
198
-            case '[INVOICE_LOGO_URL]' :
199
-                return $this->_get_invoice_logo();
200
-                break;
201
-            case '[INVOICE_LOGO]' :
202
-                return $this->_get_invoice_logo(true);
203
-                break;
204
-            case '[INVOICE_PAYEE_NAME]' :
205
-                return $this->_get_invoice_payee_name();
206
-                break;
207
-            case '[INVOICE_PAYEE_ADDRESS]' :
208
-                return $this->_get_invoice_payee_address();
209
-                break;
210
-            case '[INVOICE_PAYMENT_INSTRUCTIONS]' :
211
-                return $this->_get_invoice_payment_instructions();
212
-                break;
213
-            case '[INVOICE_PAYEE_EMAIL]' :
214
-                return $this->_get_invoice_payee_email();
215
-                break;
216
-            case '[TOTAL_COST]' :
217
-                $total = $transaction->total();
218
-                return ! empty($total) ? EEH_Template::format_currency($total) : '';
219
-                break;
220
-            case '[PAYMENT_STATUS]' :
221
-                $status = $transaction->pretty_status();
222
-                return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
223
-                break; /**/
224
-            // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity.
225
-            case '[TXN_STATUS]':
226
-                $status = $transaction->pretty_status();
227
-                return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
228
-                break;
229
-            case '[TXN_STATUS_ID]' :
230
-                return $transaction->status_ID();
231
-                break;
232
-            case '[PAYMENT_GATEWAY]' :
233
-                return $this->_get_payment_gateway($transaction);
234
-                break;
235
-            case '[AMOUNT_PAID]' :
236
-                return $payment instanceof EE_Payment
237
-                    ? EEH_Template::format_currency($payment->amount())
238
-                    : EEH_Template::format_currency(0);
239
-                break;
240
-            case '[LAST_AMOUNT_PAID]' :
241
-                $last_payment = $transaction->last_payment();
242
-                return $last_payment instanceof EE_Payment
243
-                    ? EEH_Template::format_currency($last_payment->amount())
244
-                    : EEH_Template::format_currency(0);
245
-            case '[TOTAL_AMOUNT_PAID]' :
246
-                return EEH_Template::format_currency($transaction->paid());
247
-                break;
248
-            case '[TOTAL_OWING]' :
249
-                $total_owing = $transaction->remaining();
250
-                return EEH_Template::format_currency($total_owing);
251
-                break;
252
-            case '[TXN_SUBTOTAL]' :
253
-                return EEH_Template::format_currency($this->_get_subtotal());
254
-                break;
255
-            case '[TXN_TAX_SUBTOTAL]' :
256
-                return EEH_Template::format_currency($this->_get_subtotal(true));
257
-                break;
258
-            case '[TKT_QTY_PURCHASED]' :
259
-            case '[TXN_TOTAL_TICKETS]' :
260
-                return $this->_data->total_ticket_count;
261
-                break;
262
-            case '[TRANSACTION_ADMIN_URL]' :
263
-                require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
264
-                $query_args = array(
265
-                    'page'   => 'espresso_transactions',
266
-                    'action' => 'view_transaction',
267
-                    'TXN_ID' => $transaction->ID(),
268
-                );
269
-                $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
270
-                return $url;
271
-                break;
272
-            case '[RECEIPT_URL]' :
273
-                //get primary_registration
274
-                $reg = $this->_data->primary_reg_obj;
275
-                if (! $reg instanceof EE_Registration) {
276
-                    return '';
277
-                }
278
-                return $reg->receipt_url();
279
-                break;
280
-            case '[INVOICE_RECEIPT_SWITCHER_URL]' :
281
-                return $this->_get_invoice_receipt_switcher(false);
282
-                break;
283
-            case '[INVOICE_RECEIPT_SWITCHER_BUTTON]' :
284
-                return $this->_get_invoice_receipt_switcher();
285
-                break;
286
-        }
287
-        if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) {
288
-            return $this->_get_custom_total_owing($shortcode);
289
-        }
290
-        if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) {
291
-            return $this->_get_invoice_payee_tax_number($shortcode);
292
-        }
293
-        if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) {
294
-            return $this->_get_payment_link_if_needed($shortcode);
295
-        }
296
-        if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
297
-            return $this->_get_payment_due_date($shortcode, $transaction);
298
-        }
299
-        return '';
300
-    }
301
-
302
-
303
-
304
-    /**
305
-     * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode
306
-     *
307
-     * @since 4.5.0
308
-     * @param string $shortcode the incoming shortcode
309
-     * @return string parsed.
310
-     */
311
-    private function _get_custom_total_owing($shortcode)
312
-    {
313
-        $valid_shortcodes = array('transaction');
314
-        $attrs = $this->_get_shortcode_attrs($shortcode);
315
-        //ensure default is set.
316
-        $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
317
-        $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
318
-            ? $addressee->txn->remaining() : 0;
319
-        if ($total_owing > 0) {
320
-            $owing_content = ! empty($attrs['still_owing'])
321
-                ? $attrs['still_owing']
322
-                : sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'),
323
-                    '<a href="[PAYMENT_URL]" class="noPrint">', '</a>');
324
-            $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee,
325
-                $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
326
-        } else {
327
-            $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
328
-        }
329
-        return $owing_content;
330
-    }
331
-
332
-
333
-
334
-    /**
335
-     * @param EE_Transaction $transaction
336
-     * @return string
337
-     */
338
-    private function _get_payment_gateway($transaction)
339
-    {
340
-        if($transaction instanceof EE_Transaction){
341
-            $pm = $transaction->payment_method();
342
-        } else {
343
-            $pm = null;
344
-        }
345
-        return $pm instanceof EE_Payment_Method ? $pm->name() : '';
346
-    }
347
-
348
-
349
-
350
-    /**
351
-     * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page.  If its
352
-     * not present then the organization logo is used if its found (set on the organization settings page).
353
-     *
354
-     * @since 4.5.0
355
-     * @param bool $img_tags TRUE means to return with the img tag wrappers.  False just returns the url to the image.
356
-     * @return string url or html
357
-     */
358
-    private function _get_invoice_logo($img_tags = false)
359
-    {
360
-        //try to get the invoice payment method's logo for this transaction image first
361
-        $pm = $this->_get_invoice_payment_method();
362
-        if ($pm instanceof EE_Payment_Method) {
363
-            $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true);
364
-        } else {
365
-            $invoice_logo_url = null;
366
-        }
367
-        if (empty($invoice_logo_url)) {
368
-            $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
369
-        }
370
-        if (empty($invoice_logo_url)) {
371
-            return '';
372
-        }
373
-        if (! $img_tags) {
374
-            return $invoice_logo_url;
375
-        }
376
-        //image tags have been requested.
377
-        $image_size = getimagesize($invoice_logo_url);
378
-        //if image is wider than 300px, set the width to 300
379
-        if ($image_size[0] > 300) {
380
-            $image_width = 300;
381
-        } else {
382
-            $image_width = $image_size[0];
383
-        }
384
-        return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />';
385
-    }
386
-
387
-
388
-
389
-    /**
390
-     * Used to retrieve the appropriate content for the invoice payee name shortcode
391
-     *
392
-     * @since 4.5.0
393
-     * @return string
394
-     */
395
-    private function _get_invoice_payee_name()
396
-    {
397
-        $payee_name = null;
398
-        $pm = $this->_get_invoice_payment_method();
399
-        if ($pm instanceof EE_Payment_Method) {
400
-            $payee_name = $pm->get_extra_meta('pdf_payee_name', true);
401
-        }
402
-        $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
403
-        return $payee_name;
404
-    }
405
-
406
-
407
-
408
-    /**
409
-     * gets the default invoice payment method, but has a filter so it can be overridden
410
-     *
411
-     * @return \EE_Payment_Method|null
412
-     */
413
-    private function _get_invoice_payment_method()
414
-    {
415
-        if (! $this->_invoice_pm instanceof EE_Payment_Method) {
416
-            $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
417
-            $transaction = ! $transaction instanceof EE_Transaction
418
-                           && is_array($this->_extra_data)
419
-                           && isset($this->_extra_data['data'])
420
-                           && $this->_extra_data['data'] instanceof EE_Messages_Addressee
421
-                ? $this->_extra_data['data']->txn : $transaction;
422
-            //get the invoice payment method, and remember it for the next call too
423
-            $this->_invoice_pm = apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default',
424
-                EEM_Payment_Method::instance()->get_one_of_type('Invoice'), $transaction);
425
-        }
426
-        return $this->_invoice_pm;
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * Used to retrieve the appropriate content for the invoice payee email shortcode
433
-     *
434
-     * @since 4.5.0
435
-     * @return string
436
-     */
437
-    private function _get_invoice_payee_email()
438
-    {
439
-        $payee_email = null;
440
-        $pm = $this->_get_invoice_payment_method();
441
-        if ($pm instanceof EE_Payment_Method) {
442
-            $payee_email = $pm->get_extra_meta('pdf_payee_email', true);
443
-        }
444
-        $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email')
445
-            : $payee_email;
446
-        return $payee_email;
447
-    }
448
-
449
-
450
-
451
-    /**
452
-     * Used to retrieve the appropriate content for the invoice payee tax number shortcode
453
-     *
454
-     * @since 4.5.0
455
-     * @param string $shortcode
456
-     * @return string
457
-     */
458
-    private function _get_invoice_payee_tax_number($shortcode)
459
-    {
460
-        $payee_tax_number = null;
461
-        $pm = $this->_get_invoice_payment_method();
462
-        if ($pm instanceof EE_Payment_Method) {
463
-            $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
464
-        }
465
-        $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat
466
-            : $payee_tax_number;
467
-        if (empty($payee_tax_number)) {
468
-            return '';
469
-        }
470
-        //any attributes?
471
-        $attrs = $this->_get_shortcode_attrs($shortcode);
472
-        //prefix?
473
-        $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
474
-        return $prefix . $payee_tax_number;
475
-    }
476
-
477
-
478
-
479
-    /**
480
-     * Used to retrieve the appropriate content for the invoice payee address shortcode.
481
-     *
482
-     * @since 4.5.0
483
-     * @return string
484
-     */
485
-    private function _get_invoice_payee_address()
486
-    {
487
-        $payee_address = null;
488
-        $pm = $this->_get_invoice_payment_method();
489
-        if ($pm instanceof EE_Payment_Method) {
490
-            $payee_address = $pm->get_extra_meta('pdf_payee_address', true);
491
-        }
492
-        if (empty($payee_address)) {
493
-            $organization = EE_Registry::instance()->CFG->organization;
494
-            $payee_address = $organization->get_pretty('address_1') . '<br>';
495
-            $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2') . '<br>' : '';
496
-            $payee_address .= $organization->get_pretty('city') . '<br>';
497
-            //state
498
-            $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
499
-            $payee_address .= $state instanceof EE_State ? $state->name() : '';
500
-            //Country
501
-            $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
502
-            $payee_address .= ! empty($organization->zip) ? $organization->zip : '';
503
-        }
504
-        return $payee_address;
505
-    }
506
-
507
-
508
-
509
-    /**
510
-     * Used to retrieve the appropriate content for the invoice payment instructions shortcode.
511
-     *
512
-     * @since 4.5.0
513
-     * @return string
514
-     */
515
-    private function _get_invoice_payment_instructions()
516
-    {
517
-        $instructions = null;
518
-        $pm = $this->_get_invoice_payment_method();
519
-        return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
520
-    }
521
-
522
-
523
-
524
-    /**
525
-     * get invoice/receipt switch button or url.
526
-     *
527
-     * @param bool $button true (default) returns the html for a button, false just returns the url.
528
-     * @return string
529
-     */
530
-    protected function _get_invoice_receipt_switcher($button = true)
531
-    {
532
-        $reg = $this->_data->primary_reg_obj;
533
-        $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
534
-        if (! $reg instanceof EE_Registration || empty($message_type)) {
535
-            return '';
536
-        }
537
-        $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
538
-        $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type
539
-            ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
540
-        $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
541
-        $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
542
-        if (! $button) {
543
-            return $switch_to_url;
544
-        }
545
-        if (! empty($switch_to_url)) {
546
-            return '
31
+	/**
32
+	 * @var EE_Payment_Method $_invoice_pm the invoiec payment method for use in invoices etc
33
+	 */
34
+	protected $_invoice_pm;
35
+
36
+
37
+
38
+	/**
39
+	 * EE_Transaction_Shortcodes constructor.
40
+	 */
41
+	public function __construct()
42
+	{
43
+		parent::__construct();
44
+	}
45
+
46
+
47
+
48
+	protected function _init_props()
49
+	{
50
+		$this->label = esc_html__('Transaction Shortcodes', 'event_espresso');
51
+		$this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso');
52
+		$this->_shortcodes = array(
53
+			'[TXN_ID]'                          => esc_html__('The transaction id for the purchase.', 'event_espresso'),
54
+			'[PAYMENT_URL]'                     => esc_html__('This is a link to make a payment for the event',
55
+				'event_espresso'),
56
+			'[PAYMENT_LINK_IF_NEEDED_*]'        => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:',
57
+					'event_espresso')
58
+												   . '<ul>'
59
+												   . '<li>'
60
+												   . sprintf(esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").',
61
+					'event_espresso'), '<strong>', '</strong>')
62
+												   . '</li>'
63
+												   . '<li>'
64
+												   . sprintf(esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)',
65
+					'event_espresso'), '<strong>', '</strong>')
66
+												   . '</li>'
67
+												   . '<li>'
68
+												   . sprintf(esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").',
69
+					'event_espresso'), '<strong>', '</strong>')
70
+												   . '</li>'
71
+												   . '</ul>',
72
+			'[PAYMENT_DUE_DATE_*]'              => esc_html__('This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:',
73
+					'event_espresso')
74
+												   . '<ul>'
75
+												   . '<li>'
76
+												   . sprintf(esc_html__('%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.',
77
+					'event_espresso'), '<strong>', '</strong>')
78
+												   . '</li>'
79
+												   . '<li>'
80
+												   . sprintf(esc_html__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.',
81
+					'event_espresso'), '<strong>', '</strong>')
82
+												   . '</li>'
83
+												   . '<li>'
84
+												   . sprintf(esc_html__('%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"',
85
+					'event_espresso'), '<strong>', '</strong>')
86
+												   . '</li>',
87
+			'[INVOICE_LINK]'                    => esc_html__('This is a full html link to the invoice',
88
+				'event_espresso'),
89
+			'[INVOICE_URL]'                     => esc_html__('This is just the url for the invoice', 'event_espresso'),
90
+			'[INVOICE_LOGO_URL]'                => esc_html__('This returns the url for the logo uploaded via the invoice settings page.',
91
+				'event_espresso'),
92
+			'[INVOICE_LOGO]'                    => esc_html__('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.',
93
+				'event_espresso'),
94
+			'[INVOICE_PAYEE_NAME]'              => esc_html__('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.',
95
+				'event_espresso'),
96
+			'[INVOICE_PAYEE_ADDRESS]'           => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.',
97
+				'event_espresso'),
98
+			'[INVOICE_PAYMENT_INSTRUCTIONS]'    => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page',
99
+				'event_espresso'),
100
+			'[INVOICE_PAYEE_EMAIL]'             => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.',
101
+				'event_espresso'),
102
+			'[INVOICE_PAYEE_TAX_NUMBER_*]'      => sprintf(esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.',
103
+				'event_espresso'), '<code>', '</code>'),
104
+			'[TOTAL_COST]'                      => esc_html__('The total cost for the transaction', 'event_espresso'),
105
+			'[TXN_STATUS]'                      => esc_html__('The transaction status for the transaction.',
106
+				'event_espresso'),
107
+			'[TXN_STATUS_ID]'                   => esc_html__('The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.',
108
+				'event_espresso'),
109
+			'[PAYMENT_STATUS]'                  => esc_html__('The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.',
110
+				'event_espresso'),
111
+			'[PAYMENT_GATEWAY]'                 => esc_html__('The payment gateway used for the transaction',
112
+				'event_espresso'),
113
+			'[AMOUNT_PAID]'                     => esc_html__('The amount paid or refunded.  This will only have a value if there was a payment or refund at the time of generating the message.',
114
+				'event_espresso'),
115
+			'[LAST_AMOUNT_PAID]'                => esc_html__('This is the last payment or refund made on the transaction related to the message being generated.',
116
+				'event_espresso'),
117
+			'[TOTAL_AMOUNT_PAID]'               => esc_html__('This parses to the total amount paid over all payments',
118
+				'event_espresso'),
119
+			'[TOTAL_OWING]'                     => esc_html__('The total owing on a transaction with no attributes.',
120
+				'event_espresso'),
121
+			'[TXN_SUBTOTAL]'                    => esc_html__('The subtotal for all txn line items.', 'event_espresso'),
122
+			'[TXN_TAX_SUBTOTAL]'                => esc_html__('The subtotal for all tax line items.', 'event_espresso'),
123
+			'[OWING_STATUS_MESSAGE_*]'          => esc_html__('A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:',
124
+					'event_espresso')
125
+												   . '<p></ul>'
126
+												   .
127
+												   '<li><strong>still_owing</strong>:'
128
+												   . esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:',
129
+					'event_espresso')
130
+												   . sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'),
131
+					'<a href="[PAYMENT_URL]" class="noPrint">', '</a>')
132
+												   . '</li>'
133
+												   .
134
+												   '<li><strong>none_owing</strong>:'
135
+												   . esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total owing.',
136
+					'event_espresso')
137
+												   . '</li></ul></p>',
138
+			'[TXN_TOTAL_TICKETS]'               => esc_html__('The total number of all tickets purchased in a transaction',
139
+				'event_espresso'),
140
+			'[TKT_QTY_PURCHASED]'               => sprintf(esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s',
141
+				'event_espresso'), '<strong>', '</strong>'),
142
+			'[TRANSACTION_ADMIN_URL]'           => esc_html__('The url to the admin page for this transaction',
143
+				'event_espresso'),
144
+			'[RECEIPT_URL]'                     => esc_html__('This parses to the generated url for retrieving the receipt for the transaction',
145
+				'event_espresso'),
146
+			'[INVOICE_RECEIPT_SWITCHER_URL]'    => esc_html__('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.',
147
+				'event_espresso'),
148
+			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(esc_html__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.',
149
+				'event_espresso'), '<code>', '</code>'),
150
+		);
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * @access protected
157
+	 * @param  string $shortcode the shortcode to be parsed.
158
+	 * @return string parsed shortcode
159
+	 */
160
+	protected function _parser($shortcode)
161
+	{
162
+		//attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction.
163
+		$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
164
+		$transaction = ! $transaction instanceof EE_Transaction
165
+					   && is_array($this->_extra_data)
166
+					   && isset($this->_extra_data['data'])
167
+					   && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn
168
+			: $transaction;
169
+		//payment
170
+		$payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
171
+		$payment = ! $payment instanceof EE_Payment
172
+				   && is_array($this->_extra_data)
173
+				   && isset($this->_extra_data['data'])
174
+				   && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
175
+			: $payment;
176
+		if (! $transaction instanceof EE_Transaction) {
177
+			return '';
178
+		}
179
+		switch ($shortcode) {
180
+			case '[TXN_ID]' :
181
+				return $transaction->ID();
182
+				break;
183
+			case '[PAYMENT_URL]' :
184
+				$payment_url = $transaction->payment_overview_url();
185
+				return empty($payment_url) ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso')
186
+					: $payment_url;
187
+				break;
188
+			case '[INVOICE_LINK]' :
189
+				$invoice_url = $transaction->invoice_url();
190
+				$invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
191
+				return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'),
192
+					'<a href="' . $invoice_url . '">', '</a>');
193
+				break; /**/
194
+			case '[INVOICE_URL]' :
195
+				$invoice_url = $transaction->invoice_url();
196
+				return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
197
+				break;
198
+			case '[INVOICE_LOGO_URL]' :
199
+				return $this->_get_invoice_logo();
200
+				break;
201
+			case '[INVOICE_LOGO]' :
202
+				return $this->_get_invoice_logo(true);
203
+				break;
204
+			case '[INVOICE_PAYEE_NAME]' :
205
+				return $this->_get_invoice_payee_name();
206
+				break;
207
+			case '[INVOICE_PAYEE_ADDRESS]' :
208
+				return $this->_get_invoice_payee_address();
209
+				break;
210
+			case '[INVOICE_PAYMENT_INSTRUCTIONS]' :
211
+				return $this->_get_invoice_payment_instructions();
212
+				break;
213
+			case '[INVOICE_PAYEE_EMAIL]' :
214
+				return $this->_get_invoice_payee_email();
215
+				break;
216
+			case '[TOTAL_COST]' :
217
+				$total = $transaction->total();
218
+				return ! empty($total) ? EEH_Template::format_currency($total) : '';
219
+				break;
220
+			case '[PAYMENT_STATUS]' :
221
+				$status = $transaction->pretty_status();
222
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
223
+				break; /**/
224
+			// note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity.
225
+			case '[TXN_STATUS]':
226
+				$status = $transaction->pretty_status();
227
+				return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso');
228
+				break;
229
+			case '[TXN_STATUS_ID]' :
230
+				return $transaction->status_ID();
231
+				break;
232
+			case '[PAYMENT_GATEWAY]' :
233
+				return $this->_get_payment_gateway($transaction);
234
+				break;
235
+			case '[AMOUNT_PAID]' :
236
+				return $payment instanceof EE_Payment
237
+					? EEH_Template::format_currency($payment->amount())
238
+					: EEH_Template::format_currency(0);
239
+				break;
240
+			case '[LAST_AMOUNT_PAID]' :
241
+				$last_payment = $transaction->last_payment();
242
+				return $last_payment instanceof EE_Payment
243
+					? EEH_Template::format_currency($last_payment->amount())
244
+					: EEH_Template::format_currency(0);
245
+			case '[TOTAL_AMOUNT_PAID]' :
246
+				return EEH_Template::format_currency($transaction->paid());
247
+				break;
248
+			case '[TOTAL_OWING]' :
249
+				$total_owing = $transaction->remaining();
250
+				return EEH_Template::format_currency($total_owing);
251
+				break;
252
+			case '[TXN_SUBTOTAL]' :
253
+				return EEH_Template::format_currency($this->_get_subtotal());
254
+				break;
255
+			case '[TXN_TAX_SUBTOTAL]' :
256
+				return EEH_Template::format_currency($this->_get_subtotal(true));
257
+				break;
258
+			case '[TKT_QTY_PURCHASED]' :
259
+			case '[TXN_TOTAL_TICKETS]' :
260
+				return $this->_data->total_ticket_count;
261
+				break;
262
+			case '[TRANSACTION_ADMIN_URL]' :
263
+				require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
264
+				$query_args = array(
265
+					'page'   => 'espresso_transactions',
266
+					'action' => 'view_transaction',
267
+					'TXN_ID' => $transaction->ID(),
268
+				);
269
+				$url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
270
+				return $url;
271
+				break;
272
+			case '[RECEIPT_URL]' :
273
+				//get primary_registration
274
+				$reg = $this->_data->primary_reg_obj;
275
+				if (! $reg instanceof EE_Registration) {
276
+					return '';
277
+				}
278
+				return $reg->receipt_url();
279
+				break;
280
+			case '[INVOICE_RECEIPT_SWITCHER_URL]' :
281
+				return $this->_get_invoice_receipt_switcher(false);
282
+				break;
283
+			case '[INVOICE_RECEIPT_SWITCHER_BUTTON]' :
284
+				return $this->_get_invoice_receipt_switcher();
285
+				break;
286
+		}
287
+		if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) {
288
+			return $this->_get_custom_total_owing($shortcode);
289
+		}
290
+		if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) {
291
+			return $this->_get_invoice_payee_tax_number($shortcode);
292
+		}
293
+		if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) {
294
+			return $this->_get_payment_link_if_needed($shortcode);
295
+		}
296
+		if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
297
+			return $this->_get_payment_due_date($shortcode, $transaction);
298
+		}
299
+		return '';
300
+	}
301
+
302
+
303
+
304
+	/**
305
+	 * parser for the [OWING_STATUS_MESSAGE_*] attribute type shortcode
306
+	 *
307
+	 * @since 4.5.0
308
+	 * @param string $shortcode the incoming shortcode
309
+	 * @return string parsed.
310
+	 */
311
+	private function _get_custom_total_owing($shortcode)
312
+	{
313
+		$valid_shortcodes = array('transaction');
314
+		$attrs = $this->_get_shortcode_attrs($shortcode);
315
+		//ensure default is set.
316
+		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
317
+		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
318
+			? $addressee->txn->remaining() : 0;
319
+		if ($total_owing > 0) {
320
+			$owing_content = ! empty($attrs['still_owing'])
321
+				? $attrs['still_owing']
322
+				: sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'),
323
+					'<a href="[PAYMENT_URL]" class="noPrint">', '</a>');
324
+			$owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee,
325
+				$valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
326
+		} else {
327
+			$owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
328
+		}
329
+		return $owing_content;
330
+	}
331
+
332
+
333
+
334
+	/**
335
+	 * @param EE_Transaction $transaction
336
+	 * @return string
337
+	 */
338
+	private function _get_payment_gateway($transaction)
339
+	{
340
+		if($transaction instanceof EE_Transaction){
341
+			$pm = $transaction->payment_method();
342
+		} else {
343
+			$pm = null;
344
+		}
345
+		return $pm instanceof EE_Payment_Method ? $pm->name() : '';
346
+	}
347
+
348
+
349
+
350
+	/**
351
+	 * This retrieves a logo to be used for the invoice from whatever is set on the invoice logo settings page.  If its
352
+	 * not present then the organization logo is used if its found (set on the organization settings page).
353
+	 *
354
+	 * @since 4.5.0
355
+	 * @param bool $img_tags TRUE means to return with the img tag wrappers.  False just returns the url to the image.
356
+	 * @return string url or html
357
+	 */
358
+	private function _get_invoice_logo($img_tags = false)
359
+	{
360
+		//try to get the invoice payment method's logo for this transaction image first
361
+		$pm = $this->_get_invoice_payment_method();
362
+		if ($pm instanceof EE_Payment_Method) {
363
+			$invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true);
364
+		} else {
365
+			$invoice_logo_url = null;
366
+		}
367
+		if (empty($invoice_logo_url)) {
368
+			$invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
369
+		}
370
+		if (empty($invoice_logo_url)) {
371
+			return '';
372
+		}
373
+		if (! $img_tags) {
374
+			return $invoice_logo_url;
375
+		}
376
+		//image tags have been requested.
377
+		$image_size = getimagesize($invoice_logo_url);
378
+		//if image is wider than 300px, set the width to 300
379
+		if ($image_size[0] > 300) {
380
+			$image_width = 300;
381
+		} else {
382
+			$image_width = $image_size[0];
383
+		}
384
+		return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />';
385
+	}
386
+
387
+
388
+
389
+	/**
390
+	 * Used to retrieve the appropriate content for the invoice payee name shortcode
391
+	 *
392
+	 * @since 4.5.0
393
+	 * @return string
394
+	 */
395
+	private function _get_invoice_payee_name()
396
+	{
397
+		$payee_name = null;
398
+		$pm = $this->_get_invoice_payment_method();
399
+		if ($pm instanceof EE_Payment_Method) {
400
+			$payee_name = $pm->get_extra_meta('pdf_payee_name', true);
401
+		}
402
+		$payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
403
+		return $payee_name;
404
+	}
405
+
406
+
407
+
408
+	/**
409
+	 * gets the default invoice payment method, but has a filter so it can be overridden
410
+	 *
411
+	 * @return \EE_Payment_Method|null
412
+	 */
413
+	private function _get_invoice_payment_method()
414
+	{
415
+		if (! $this->_invoice_pm instanceof EE_Payment_Method) {
416
+			$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
417
+			$transaction = ! $transaction instanceof EE_Transaction
418
+						   && is_array($this->_extra_data)
419
+						   && isset($this->_extra_data['data'])
420
+						   && $this->_extra_data['data'] instanceof EE_Messages_Addressee
421
+				? $this->_extra_data['data']->txn : $transaction;
422
+			//get the invoice payment method, and remember it for the next call too
423
+			$this->_invoice_pm = apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default',
424
+				EEM_Payment_Method::instance()->get_one_of_type('Invoice'), $transaction);
425
+		}
426
+		return $this->_invoice_pm;
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * Used to retrieve the appropriate content for the invoice payee email shortcode
433
+	 *
434
+	 * @since 4.5.0
435
+	 * @return string
436
+	 */
437
+	private function _get_invoice_payee_email()
438
+	{
439
+		$payee_email = null;
440
+		$pm = $this->_get_invoice_payment_method();
441
+		if ($pm instanceof EE_Payment_Method) {
442
+			$payee_email = $pm->get_extra_meta('pdf_payee_email', true);
443
+		}
444
+		$payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email')
445
+			: $payee_email;
446
+		return $payee_email;
447
+	}
448
+
449
+
450
+
451
+	/**
452
+	 * Used to retrieve the appropriate content for the invoice payee tax number shortcode
453
+	 *
454
+	 * @since 4.5.0
455
+	 * @param string $shortcode
456
+	 * @return string
457
+	 */
458
+	private function _get_invoice_payee_tax_number($shortcode)
459
+	{
460
+		$payee_tax_number = null;
461
+		$pm = $this->_get_invoice_payment_method();
462
+		if ($pm instanceof EE_Payment_Method) {
463
+			$payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true);
464
+		}
465
+		$payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat
466
+			: $payee_tax_number;
467
+		if (empty($payee_tax_number)) {
468
+			return '';
469
+		}
470
+		//any attributes?
471
+		$attrs = $this->_get_shortcode_attrs($shortcode);
472
+		//prefix?
473
+		$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
474
+		return $prefix . $payee_tax_number;
475
+	}
476
+
477
+
478
+
479
+	/**
480
+	 * Used to retrieve the appropriate content for the invoice payee address shortcode.
481
+	 *
482
+	 * @since 4.5.0
483
+	 * @return string
484
+	 */
485
+	private function _get_invoice_payee_address()
486
+	{
487
+		$payee_address = null;
488
+		$pm = $this->_get_invoice_payment_method();
489
+		if ($pm instanceof EE_Payment_Method) {
490
+			$payee_address = $pm->get_extra_meta('pdf_payee_address', true);
491
+		}
492
+		if (empty($payee_address)) {
493
+			$organization = EE_Registry::instance()->CFG->organization;
494
+			$payee_address = $organization->get_pretty('address_1') . '<br>';
495
+			$payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2') . '<br>' : '';
496
+			$payee_address .= $organization->get_pretty('city') . '<br>';
497
+			//state
498
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
499
+			$payee_address .= $state instanceof EE_State ? $state->name() : '';
500
+			//Country
501
+			$payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
502
+			$payee_address .= ! empty($organization->zip) ? $organization->zip : '';
503
+		}
504
+		return $payee_address;
505
+	}
506
+
507
+
508
+
509
+	/**
510
+	 * Used to retrieve the appropriate content for the invoice payment instructions shortcode.
511
+	 *
512
+	 * @since 4.5.0
513
+	 * @return string
514
+	 */
515
+	private function _get_invoice_payment_instructions()
516
+	{
517
+		$instructions = null;
518
+		$pm = $this->_get_invoice_payment_method();
519
+		return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : '';
520
+	}
521
+
522
+
523
+
524
+	/**
525
+	 * get invoice/receipt switch button or url.
526
+	 *
527
+	 * @param bool $button true (default) returns the html for a button, false just returns the url.
528
+	 * @return string
529
+	 */
530
+	protected function _get_invoice_receipt_switcher($button = true)
531
+	{
532
+		$reg = $this->_data->primary_reg_obj;
533
+		$message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
534
+		if (! $reg instanceof EE_Registration || empty($message_type)) {
535
+			return '';
536
+		}
537
+		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
538
+		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type
539
+			? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
540
+		$switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
541
+		$switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
542
+		if (! $button) {
543
+			return $switch_to_url;
544
+		}
545
+		if (! empty($switch_to_url)) {
546
+			return '
547 547
 	<form method="post" action="' . $switch_to_url . '" >
548 548
 		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
549 549
 	</form>
550 550
 			';
551
-        }
552
-        return '';
553
-    }
554
-
555
-
556
-
557
-    /**
558
-     * This returns a subtotal.
559
-     *
560
-     * @param bool $tax if true then return the subtotal for tax otherwise return subtotal.
561
-     * @return int
562
-     */
563
-    private function _get_subtotal($tax = false)
564
-    {
565
-        $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
566
-        if (! $grand_total instanceof EE_Line_Item) {
567
-            return 0;
568
-        }
569
-        return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
570
-    }
571
-
572
-
573
-
574
-    /**
575
-     * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode
576
-     *
577
-     * @since 4.7.0
578
-     * @param string $shortcode the incoming shortcode
579
-     * @return string parsed.
580
-     */
581
-    private function _get_payment_link_if_needed($shortcode)
582
-    {
583
-        $valid_shortcodes = array('transaction');
584
-        $attrs = $this->_get_shortcode_attrs($shortcode);
585
-        //ensure default is set.
586
-        $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
587
-        $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
588
-            ? $addressee->txn->remaining() : 0;
589
-        if ($total_owing > 0) {
590
-            $class = isset($attrs['class']) ? $attrs['class'] : 'callout';
591
-            $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
592
-            $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
593
-            $opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
594
-            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
595
-            $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
596
-            $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
597
-            $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
598
-            //we need to re run this string through the parser to catch any shortcodes that are in it.
599
-            $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes,
600
-                $this->_message_type, $this->_messenger, $this->_message);
601
-        } else {
602
-            return '';
603
-        }
604
-        return $owing_content;
605
-    }
606
-
607
-
608
-
609
-    /**
610
-     * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode
611
-     *
612
-     * @since 4.8.28.rc.011
613
-     * @param string         $shortcode The shortcode being parsed.
614
-     * @param EE_Transaction $transaction
615
-     * @return string
616
-     */
617
-    protected function _get_payment_due_date($shortcode, EE_Transaction $transaction)
618
-    {
619
-        //if transaction is paid in full then we can just return an empty string
620
-        if ($transaction->remaining() === 0) {
621
-            return '';
622
-        }
623
-        $attrs = $this->_get_shortcode_attrs($shortcode);
624
-        $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
625
-        $days_until_due = isset($attrs['days_until_due']) ? (int)$attrs['days_until_due'] : 30;
626
-        $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text']
627
-            : esc_html__('Payment in full due by: ', 'event_espresso');
628
-        $transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
629
-        //setup date due:
630
-        try {
631
-            if ($transaction_created instanceof DateTime) {
632
-                $date_due = $transaction_created->add(new DateInterval('P' . $days_until_due . 'D'))->format($format);
633
-            } else {
634
-                throw new Exception();
635
-            }
636
-        } catch (Exception $e) {
637
-            //format was likely invalid.
638
-            $date_due = 'Unable to calculate date due, likely the format string is invalid.';
639
-        }
640
-        return $prefix_text . $date_due;
641
-    }
551
+		}
552
+		return '';
553
+	}
554
+
555
+
556
+
557
+	/**
558
+	 * This returns a subtotal.
559
+	 *
560
+	 * @param bool $tax if true then return the subtotal for tax otherwise return subtotal.
561
+	 * @return int
562
+	 */
563
+	private function _get_subtotal($tax = false)
564
+	{
565
+		$grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
566
+		if (! $grand_total instanceof EE_Line_Item) {
567
+			return 0;
568
+		}
569
+		return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
570
+	}
571
+
572
+
573
+
574
+	/**
575
+	 * parser for the [PAYMENT_LINK_IF_NEEDED_*] attribute type shortcode
576
+	 *
577
+	 * @since 4.7.0
578
+	 * @param string $shortcode the incoming shortcode
579
+	 * @return string parsed.
580
+	 */
581
+	private function _get_payment_link_if_needed($shortcode)
582
+	{
583
+		$valid_shortcodes = array('transaction');
584
+		$attrs = $this->_get_shortcode_attrs($shortcode);
585
+		//ensure default is set.
586
+		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
587
+		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction
588
+			? $addressee->txn->remaining() : 0;
589
+		if ($total_owing > 0) {
590
+			$class = isset($attrs['class']) ? $attrs['class'] : 'callout';
591
+			$custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
592
+			$container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
593
+			$opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
594
+			$opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
595
+			$opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
596
+			$closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
597
+			$content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
598
+			//we need to re run this string through the parser to catch any shortcodes that are in it.
599
+			$owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes,
600
+				$this->_message_type, $this->_messenger, $this->_message);
601
+		} else {
602
+			return '';
603
+		}
604
+		return $owing_content;
605
+	}
606
+
607
+
608
+
609
+	/**
610
+	 * Parser for the [PAYMENT_DUE_DATE_*] attribute type shortcode
611
+	 *
612
+	 * @since 4.8.28.rc.011
613
+	 * @param string         $shortcode The shortcode being parsed.
614
+	 * @param EE_Transaction $transaction
615
+	 * @return string
616
+	 */
617
+	protected function _get_payment_due_date($shortcode, EE_Transaction $transaction)
618
+	{
619
+		//if transaction is paid in full then we can just return an empty string
620
+		if ($transaction->remaining() === 0) {
621
+			return '';
622
+		}
623
+		$attrs = $this->_get_shortcode_attrs($shortcode);
624
+		$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
625
+		$days_until_due = isset($attrs['days_until_due']) ? (int)$attrs['days_until_due'] : 30;
626
+		$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text']
627
+			: esc_html__('Payment in full due by: ', 'event_espresso');
628
+		$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
629
+		//setup date due:
630
+		try {
631
+			if ($transaction_created instanceof DateTime) {
632
+				$date_due = $transaction_created->add(new DateInterval('P' . $days_until_due . 'D'))->format($format);
633
+			} else {
634
+				throw new Exception();
635
+			}
636
+		} catch (Exception $e) {
637
+			//format was likely invalid.
638
+			$date_due = 'Unable to calculate date due, likely the format string is invalid.';
639
+		}
640
+		return $prefix_text . $date_due;
641
+	}
642 642
 
643 643
 } //end EE_Transaction Shortcodes library
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                    && isset($this->_extra_data['data'])
174 174
                    && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment
175 175
             : $payment;
176
-        if (! $transaction instanceof EE_Transaction) {
176
+        if ( ! $transaction instanceof EE_Transaction) {
177 177
             return '';
178 178
         }
179 179
         switch ($shortcode) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $invoice_url = $transaction->invoice_url();
190 190
                 $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
191 191
                 return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'),
192
-                    '<a href="' . $invoice_url . '">', '</a>');
192
+                    '<a href="'.$invoice_url.'">', '</a>');
193 193
                 break; /**/
194 194
             case '[INVOICE_URL]' :
195 195
                 $invoice_url = $transaction->invoice_url();
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                 return $this->_data->total_ticket_count;
261 261
                 break;
262 262
             case '[TRANSACTION_ADMIN_URL]' :
263
-                require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
263
+                require_once EE_CORE.'admin/EE_Admin_Page.core.php';
264 264
                 $query_args = array(
265 265
                     'page'   => 'espresso_transactions',
266 266
                     'action' => 'view_transaction',
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             case '[RECEIPT_URL]' :
273 273
                 //get primary_registration
274 274
                 $reg = $this->_data->primary_reg_obj;
275
-                if (! $reg instanceof EE_Registration) {
275
+                if ( ! $reg instanceof EE_Registration) {
276 276
                     return '';
277 277
                 }
278 278
                 return $reg->receipt_url();
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      */
338 338
     private function _get_payment_gateway($transaction)
339 339
     {
340
-        if($transaction instanceof EE_Transaction){
340
+        if ($transaction instanceof EE_Transaction) {
341 341
             $pm = $transaction->payment_method();
342 342
         } else {
343 343
             $pm = null;
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         if (empty($invoice_logo_url)) {
371 371
             return '';
372 372
         }
373
-        if (! $img_tags) {
373
+        if ( ! $img_tags) {
374 374
             return $invoice_logo_url;
375 375
         }
376 376
         //image tags have been requested.
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         } else {
382 382
             $image_width = $image_size[0];
383 383
         }
384
-        return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />';
384
+        return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />';
385 385
     }
386 386
 
387 387
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
      */
413 413
     private function _get_invoice_payment_method()
414 414
     {
415
-        if (! $this->_invoice_pm instanceof EE_Payment_Method) {
415
+        if ( ! $this->_invoice_pm instanceof EE_Payment_Method) {
416 416
             $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
417 417
             $transaction = ! $transaction instanceof EE_Transaction
418 418
                            && is_array($this->_extra_data)
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
         $attrs = $this->_get_shortcode_attrs($shortcode);
472 472
         //prefix?
473 473
         $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso');
474
-        return $prefix . $payee_tax_number;
474
+        return $prefix.$payee_tax_number;
475 475
     }
476 476
 
477 477
 
@@ -491,14 +491,14 @@  discard block
 block discarded – undo
491 491
         }
492 492
         if (empty($payee_address)) {
493 493
             $organization = EE_Registry::instance()->CFG->organization;
494
-            $payee_address = $organization->get_pretty('address_1') . '<br>';
495
-            $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2') . '<br>' : '';
496
-            $payee_address .= $organization->get_pretty('city') . '<br>';
494
+            $payee_address = $organization->get_pretty('address_1').'<br>';
495
+            $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : '';
496
+            $payee_address .= $organization->get_pretty('city').'<br>';
497 497
             //state
498 498
             $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
499 499
             $payee_address .= $state instanceof EE_State ? $state->name() : '';
500 500
             //Country
501
-            $payee_address .= ! empty($organization->CNT_ISO) ? ', ' . $organization->CNT_ISO . '<br>' : '';
501
+            $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : '';
502 502
             $payee_address .= ! empty($organization->zip) ? $organization->zip : '';
503 503
         }
504 504
         return $payee_address;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     {
532 532
         $reg = $this->_data->primary_reg_obj;
533 533
         $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
534
-        if (! $reg instanceof EE_Registration || empty($message_type)) {
534
+        if ( ! $reg instanceof EE_Registration || empty($message_type)) {
535 535
             return '';
536 536
         }
537 537
         $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
@@ -539,13 +539,13 @@  discard block
 block discarded – undo
539 539
             ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso');
540 540
         $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label;
541 541
         $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
542
-        if (! $button) {
542
+        if ( ! $button) {
543 543
             return $switch_to_url;
544 544
         }
545
-        if (! empty($switch_to_url)) {
545
+        if ( ! empty($switch_to_url)) {
546 546
             return '
547
-	<form method="post" action="' . $switch_to_url . '" >
548
-		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
547
+	<form method="post" action="' . $switch_to_url.'" >
548
+		<input class="print_button" type="submit" value="' . $switch_to_label.'" />
549 549
 	</form>
550 550
 			';
551 551
         }
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
     private function _get_subtotal($tax = false)
564 564
     {
565 565
         $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null;
566
-        if (! $grand_total instanceof EE_Line_Item) {
566
+        if ( ! $grand_total instanceof EE_Line_Item) {
567 567
             return 0;
568 568
         }
569 569
         return $tax ? $grand_total->get_total_tax() : $grand_total->get_items_total();
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
             $class = isset($attrs['class']) ? $attrs['class'] : 'callout';
591 591
             $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
592 592
             $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
593
-            $opening_tag = ! empty($container_tag) ? '<' . $container_tag : '';
594
-            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="' . $class . '"' : $opening_tag;
593
+            $opening_tag = ! empty($container_tag) ? '<'.$container_tag : '';
594
+            $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag;
595 595
             $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
596
-            $closing_tag = ! empty($container_tag) ? '</' . $container_tag . '>' : '';
597
-            $content = $opening_tag . sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>') . $closing_tag;
596
+            $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : '';
597
+            $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag;
598 598
             //we need to re run this string through the parser to catch any shortcodes that are in it.
599 599
             $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes,
600 600
                 $this->_message_type, $this->_messenger, $this->_message);
@@ -622,14 +622,14 @@  discard block
 block discarded – undo
622 622
         }
623 623
         $attrs = $this->_get_shortcode_attrs($shortcode);
624 624
         $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
625
-        $days_until_due = isset($attrs['days_until_due']) ? (int)$attrs['days_until_due'] : 30;
625
+        $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
626 626
         $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text']
627 627
             : esc_html__('Payment in full due by: ', 'event_espresso');
628 628
         $transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
629 629
         //setup date due:
630 630
         try {
631 631
             if ($transaction_created instanceof DateTime) {
632
-                $date_due = $transaction_created->add(new DateInterval('P' . $days_until_due . 'D'))->format($format);
632
+                $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format);
633 633
             } else {
634 634
                 throw new Exception();
635 635
             }
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
             //format was likely invalid.
638 638
             $date_due = 'Unable to calculate date due, likely the format string is invalid.';
639 639
         }
640
-        return $prefix_text . $date_due;
640
+        return $prefix_text.$date_due;
641 641
     }
642 642
 
643 643
 } //end EE_Transaction Shortcodes library
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.35.rc.010');
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.35.rc.010');
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
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.