Completed
Branch BUG-10412-mcrypt-deprecated (d1c48b)
by
unknown
125:36 queued 113:25
created
modules/ticket_selector/templates/simple_ticket_selector.template.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/>
12 12
 <?php
13 13
 if ( $ticket instanceof EE_Ticket ) {
14
-    do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event );
15
-    $ticket_description = $ticket->description();
16
-    $ticket_description .= ! empty( $ticket_description )
17
-        ? '<br />' . $ticket_status_display
18
-        : $ticket_status_display;
19
-    if (strpos( $ticket_description, '<div' ) === false) {
20
-        $ticket_description = "<p>{$ticket_description}</p>";
21
-    }
14
+	do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event );
15
+	$ticket_description = $ticket->description();
16
+	$ticket_description .= ! empty( $ticket_description )
17
+		? '<br />' . $ticket_status_display
18
+		: $ticket_status_display;
19
+	if (strpos( $ticket_description, '<div' ) === false) {
20
+		$ticket_description = "<p>{$ticket_description}</p>";
21
+	}
22 22
 ?>
23 23
 <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv">
24 24
     <div class="no-tkt-slctr-ticket-content-dv">
@@ -28,6 +28,6 @@  discard block
 block discarded – undo
28 28
         <?php } ?>
29 29
     </div><!-- .no-tkt-slctr-ticket-content-dv -->
30 30
 <?php
31
-    do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
31
+	do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
32 32
 }
33 33
 ?>
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,24 +10,24 @@
 block discarded – undo
10 10
 <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="1"/>
11 11
 <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/>
12 12
 <?php
13
-if ( $ticket instanceof EE_Ticket ) {
14
-    do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event );
13
+if ($ticket instanceof EE_Ticket) {
14
+    do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event);
15 15
     $ticket_description = $ticket->description();
16
-    $ticket_description .= ! empty( $ticket_description )
17
-        ? '<br />' . $ticket_status_display
16
+    $ticket_description .= ! empty($ticket_description)
17
+        ? '<br />'.$ticket_status_display
18 18
         : $ticket_status_display;
19
-    if (strpos( $ticket_description, '<div' ) === false) {
19
+    if (strpos($ticket_description, '<div') === false) {
20 20
         $ticket_description = "<p>{$ticket_description}</p>";
21 21
     }
22 22
 ?>
23 23
 <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv">
24 24
     <div class="no-tkt-slctr-ticket-content-dv">
25 25
         <h5><?php echo $ticket->name(); ?></h5>
26
-        <?php if ( ! empty( $ticket_description ) ) { ?>
26
+        <?php if ( ! empty($ticket_description)) { ?>
27 27
         <?php echo $ticket_description; ?>
28 28
         <?php } ?>
29 29
     </div><!-- .no-tkt-slctr-ticket-content-dv -->
30 30
 <?php
31
-    do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
31
+    do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event);
32 32
 }
33 33
 ?>
Please login to merge, or discard this patch.
modules/ticket_selector/DisplayTicketSelector.php 2 patches
Indentation   +672 added lines, -672 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use WP_Post;
17 17
 
18 18
 if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
19
-    exit( 'No direct script access allowed' );
19
+	exit( 'No direct script access allowed' );
20 20
 }
21 21
 
22 22
 
@@ -33,680 +33,680 @@  discard block
 block discarded – undo
33 33
 class DisplayTicketSelector
34 34
 {
35 35
 
36
-    /**
37
-     * event that ticket selector is being generated for
38
-     *
39
-     * @access protected
40
-     * @var EE_Event $event
41
-     */
42
-    protected $event;
43
-
44
-    /**
45
-     * Used to flag when the ticket selector is being called from an external iframe.
46
-     *
47
-     * @var bool $iframe
48
-     */
49
-    protected $iframe = false;
50
-
51
-    /**
52
-     * max attendees that can register for event at one time
53
-     *
54
-     * @var int $max_attendees
55
-     */
56
-    private $max_attendees = EE_INF;
57
-
58
-    /**
59
-     *@var string $date_format
60
-     */
61
-    private $date_format;
62
-
63
-    /**
64
-     *@var string $time_format
65
-     */
66
-    private $time_format;
67
-
68
-
69
-
70
-    /**
71
-     * DisplayTicketSelector constructor.
72
-     */
73
-    public function __construct()
74
-    {
75
-        $this->date_format = apply_filters(
76
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
77
-            get_option('date_format')
78
-        );
79
-        $this->time_format = apply_filters(
80
-            'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
81
-            get_option('time_format')
82
-        );
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * @param boolean $iframe
89
-     */
90
-    public function setIframe( $iframe = true )
91
-    {
92
-        $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
93
-    }
94
-
95
-
96
-    /**
97
-     * finds and sets the \EE_Event object for use throughout class
98
-     *
99
-     * @param mixed $event
100
-     * @return bool
101
-     * @throws EE_Error
102
-     */
103
-    protected function setEvent( $event = null )
104
-    {
105
-        if ( $event === null ) {
106
-            global $post;
107
-            $event = $post;
108
-        }
109
-        if ( $event instanceof EE_Event ) {
110
-            $this->event = $event;
111
-        } else if ( $event instanceof WP_Post ) {
112
-            if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
113
-                $this->event = $event->EE_Event;
114
-            } else if ( $event->post_type === 'espresso_events' ) {
115
-                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
116
-                $this->event = $event->EE_Event;
117
-            }
118
-        } else {
119
-            $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
120
-            $dev_msg = $user_msg . __(
121
-                    'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
122
-                    'event_espresso'
123
-                );
124
-            EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
125
-            return false;
126
-        }
127
-        return true;
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @return int
134
-     */
135
-    public function getMaxAttendees()
136
-    {
137
-        return $this->max_attendees;
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * @param int $max_attendees
144
-     */
145
-    public function setMaxAttendees($max_attendees)
146
-    {
147
-        $this->max_attendees = absint(
148
-            apply_filters(
149
-                'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
150
-                $max_attendees
151
-            )
152
-        );
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     * creates buttons for selecting number of attendees for an event
159
-     *
160
-     * @param WP_Post|int $event
161
-     * @param bool         $view_details
162
-     * @return string
163
-     * @throws EE_Error
164
-     */
165
-    public function display( $event = null, $view_details = false )
166
-    {
167
-        // reset filter for displaying submit button
168
-        remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
169
-        // poke and prod incoming event till it tells us what it is
170
-        if ( ! $this->setEvent( $event ) ) {
171
-            return false;
172
-        }
173
-        // begin gathering template arguments by getting event status
174
-        $template_args = array( 'event_status' => $this->event->get_active_status() );
175
-        if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
176
-            return ! is_single() ? $this->displayViewDetailsButton() : '';
177
-        }
178
-        // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
179
-        $this->setMaxAttendees($this->event->additional_limit());
180
-        if ($this->getMaxAttendees() < 1) {
181
-            return $this->ticketSalesClosedMessage();
182
-        }
183
-        // is the event expired ?
184
-        $template_args['event_is_expired'] = $this->event->is_expired();
185
-        if ( $template_args[ 'event_is_expired' ] ) {
186
-            return $this->expiredEventMessage();
187
-        }
188
-        // get all tickets for this event ordered by the datetime
189
-        $tickets = $this->getTickets();
190
-        if (count($tickets) < 1) {
191
-            return $this->noTicketAvailableMessage();
192
-        }
193
-        if (EED_Events_Archive::is_iframe()){
194
-            $this->setIframe();
195
-        }
196
-        // redirecting to another site for registration ??
197
-        $external_url = (string) $this->event->external_url();
198
-        // if redirecting to another site for registration, then we don't load the TS
199
-        $ticket_selector = $external_url
200
-            ? $this->externalEventRegistration()
201
-            : $this->loadTicketSelector($tickets,$template_args);
202
-        // now set up the form (but not for the admin)
203
-        $ticket_selector = ! is_admin()
204
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
205
-            : $ticket_selector;
206
-        // submit button and form close tag
207
-        $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
208
-        return $ticket_selector;
209
-    }
210
-
211
-
212
-
213
-    /**
214
-     * displayTicketSelector
215
-     * examines the event properties and determines whether a Ticket Selector should be displayed
216
-     *
217
-     * @param WP_Post|int $event
218
-     * @param string       $_event_active_status
219
-     * @param bool         $view_details
220
-     * @return bool
221
-     * @throws EE_Error
222
-     */
223
-    protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
224
-    {
225
-        $event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
226
-        return ! is_admin()
227
-               && (
228
-                   ! $this->event->display_ticket_selector()
229
-                   || $view_details
230
-                   || post_password_required($event_post)
231
-                   || (
232
-                       $_event_active_status !== EE_Datetime::active
233
-                       && $_event_active_status !== EE_Datetime::upcoming
234
-                       && $_event_active_status !== EE_Datetime::sold_out
235
-                       && ! (
236
-                           $_event_active_status === EE_Datetime::inactive
237
-                           && is_user_logged_in()
238
-                       )
239
-                   )
240
-               );
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * noTicketAvailableMessage
247
-     * notice displayed if event is expired
248
-     *
249
-     * @return string
250
-     * @throws EE_Error
251
-     */
252
-    protected function expiredEventMessage()
253
-    {
254
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
255
-            'We\'re sorry, but all tickets sales have ended because the event is expired.',
256
-            'event_espresso'
257
-        ) . '</span></div><!-- .ee-event-expired-notice -->';
258
-    }
259
-
260
-
261
-
262
-    /**
263
-     * noTicketAvailableMessage
264
-     * notice displayed if event has no more tickets available
265
-     *
266
-     * @return string
267
-     * @throws EE_Error
268
-     */
269
-    protected function noTicketAvailableMessage()
270
-    {
271
-        $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
272
-        if (current_user_can('edit_post', $this->event->ID())) {
273
-            $no_ticket_available_msg .= sprintf(
274
-                esc_html__(
275
-                    '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
276
-                    'event_espresso'
277
-                ),
278
-                '<div class="ee-attention" style="text-align: left;"><b>',
279
-                '</b><br />',
280
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
281
-                '</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
282
-            );
283
-        }
284
-        return '
36
+	/**
37
+	 * event that ticket selector is being generated for
38
+	 *
39
+	 * @access protected
40
+	 * @var EE_Event $event
41
+	 */
42
+	protected $event;
43
+
44
+	/**
45
+	 * Used to flag when the ticket selector is being called from an external iframe.
46
+	 *
47
+	 * @var bool $iframe
48
+	 */
49
+	protected $iframe = false;
50
+
51
+	/**
52
+	 * max attendees that can register for event at one time
53
+	 *
54
+	 * @var int $max_attendees
55
+	 */
56
+	private $max_attendees = EE_INF;
57
+
58
+	/**
59
+	 *@var string $date_format
60
+	 */
61
+	private $date_format;
62
+
63
+	/**
64
+	 *@var string $time_format
65
+	 */
66
+	private $time_format;
67
+
68
+
69
+
70
+	/**
71
+	 * DisplayTicketSelector constructor.
72
+	 */
73
+	public function __construct()
74
+	{
75
+		$this->date_format = apply_filters(
76
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format',
77
+			get_option('date_format')
78
+		);
79
+		$this->time_format = apply_filters(
80
+			'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format',
81
+			get_option('time_format')
82
+		);
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * @param boolean $iframe
89
+	 */
90
+	public function setIframe( $iframe = true )
91
+	{
92
+		$this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
93
+	}
94
+
95
+
96
+	/**
97
+	 * finds and sets the \EE_Event object for use throughout class
98
+	 *
99
+	 * @param mixed $event
100
+	 * @return bool
101
+	 * @throws EE_Error
102
+	 */
103
+	protected function setEvent( $event = null )
104
+	{
105
+		if ( $event === null ) {
106
+			global $post;
107
+			$event = $post;
108
+		}
109
+		if ( $event instanceof EE_Event ) {
110
+			$this->event = $event;
111
+		} else if ( $event instanceof WP_Post ) {
112
+			if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
113
+				$this->event = $event->EE_Event;
114
+			} else if ( $event->post_type === 'espresso_events' ) {
115
+				$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
116
+				$this->event = $event->EE_Event;
117
+			}
118
+		} else {
119
+			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
120
+			$dev_msg = $user_msg . __(
121
+					'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
122
+					'event_espresso'
123
+				);
124
+			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
125
+			return false;
126
+		}
127
+		return true;
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @return int
134
+	 */
135
+	public function getMaxAttendees()
136
+	{
137
+		return $this->max_attendees;
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * @param int $max_attendees
144
+	 */
145
+	public function setMaxAttendees($max_attendees)
146
+	{
147
+		$this->max_attendees = absint(
148
+			apply_filters(
149
+				'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets',
150
+				$max_attendees
151
+			)
152
+		);
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 * creates buttons for selecting number of attendees for an event
159
+	 *
160
+	 * @param WP_Post|int $event
161
+	 * @param bool         $view_details
162
+	 * @return string
163
+	 * @throws EE_Error
164
+	 */
165
+	public function display( $event = null, $view_details = false )
166
+	{
167
+		// reset filter for displaying submit button
168
+		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
169
+		// poke and prod incoming event till it tells us what it is
170
+		if ( ! $this->setEvent( $event ) ) {
171
+			return false;
172
+		}
173
+		// begin gathering template arguments by getting event status
174
+		$template_args = array( 'event_status' => $this->event->get_active_status() );
175
+		if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
176
+			return ! is_single() ? $this->displayViewDetailsButton() : '';
177
+		}
178
+		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
179
+		$this->setMaxAttendees($this->event->additional_limit());
180
+		if ($this->getMaxAttendees() < 1) {
181
+			return $this->ticketSalesClosedMessage();
182
+		}
183
+		// is the event expired ?
184
+		$template_args['event_is_expired'] = $this->event->is_expired();
185
+		if ( $template_args[ 'event_is_expired' ] ) {
186
+			return $this->expiredEventMessage();
187
+		}
188
+		// get all tickets for this event ordered by the datetime
189
+		$tickets = $this->getTickets();
190
+		if (count($tickets) < 1) {
191
+			return $this->noTicketAvailableMessage();
192
+		}
193
+		if (EED_Events_Archive::is_iframe()){
194
+			$this->setIframe();
195
+		}
196
+		// redirecting to another site for registration ??
197
+		$external_url = (string) $this->event->external_url();
198
+		// if redirecting to another site for registration, then we don't load the TS
199
+		$ticket_selector = $external_url
200
+			? $this->externalEventRegistration()
201
+			: $this->loadTicketSelector($tickets,$template_args);
202
+		// now set up the form (but not for the admin)
203
+		$ticket_selector = ! is_admin()
204
+			? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
205
+			: $ticket_selector;
206
+		// submit button and form close tag
207
+		$ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
208
+		return $ticket_selector;
209
+	}
210
+
211
+
212
+
213
+	/**
214
+	 * displayTicketSelector
215
+	 * examines the event properties and determines whether a Ticket Selector should be displayed
216
+	 *
217
+	 * @param WP_Post|int $event
218
+	 * @param string       $_event_active_status
219
+	 * @param bool         $view_details
220
+	 * @return bool
221
+	 * @throws EE_Error
222
+	 */
223
+	protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details)
224
+	{
225
+		$event_post = $this->event instanceof EE_Event ? $this->event->ID() : $event;
226
+		return ! is_admin()
227
+			   && (
228
+				   ! $this->event->display_ticket_selector()
229
+				   || $view_details
230
+				   || post_password_required($event_post)
231
+				   || (
232
+					   $_event_active_status !== EE_Datetime::active
233
+					   && $_event_active_status !== EE_Datetime::upcoming
234
+					   && $_event_active_status !== EE_Datetime::sold_out
235
+					   && ! (
236
+						   $_event_active_status === EE_Datetime::inactive
237
+						   && is_user_logged_in()
238
+					   )
239
+				   )
240
+			   );
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * noTicketAvailableMessage
247
+	 * notice displayed if event is expired
248
+	 *
249
+	 * @return string
250
+	 * @throws EE_Error
251
+	 */
252
+	protected function expiredEventMessage()
253
+	{
254
+		return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
255
+			'We\'re sorry, but all tickets sales have ended because the event is expired.',
256
+			'event_espresso'
257
+		) . '</span></div><!-- .ee-event-expired-notice -->';
258
+	}
259
+
260
+
261
+
262
+	/**
263
+	 * noTicketAvailableMessage
264
+	 * notice displayed if event has no more tickets available
265
+	 *
266
+	 * @return string
267
+	 * @throws EE_Error
268
+	 */
269
+	protected function noTicketAvailableMessage()
270
+	{
271
+		$no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
272
+		if (current_user_can('edit_post', $this->event->ID())) {
273
+			$no_ticket_available_msg .= sprintf(
274
+				esc_html__(
275
+					'%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s',
276
+					'event_espresso'
277
+				),
278
+				'<div class="ee-attention" style="text-align: left;"><b>',
279
+				'</b><br />',
280
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
281
+				'</a></span></div><!-- .ee-attention noTicketAvailableMessage -->'
282
+			);
283
+		}
284
+		return '
285 285
             <div class="ee-event-expired-notice">
286 286
                 <span class="important-notice">' . $no_ticket_available_msg . '</span>
287 287
             </div><!-- .ee-event-expired-notice -->';
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * ticketSalesClosed
294
-     * notice displayed if event ticket sales are turned off
295
-     *
296
-     * @return string
297
-     * @throws EE_Error
298
-     */
299
-    protected function ticketSalesClosedMessage()
300
-    {
301
-        $sales_closed_msg = esc_html__(
302
-            'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
303
-            'event_espresso'
304
-        );
305
-        if (current_user_can('edit_post', $this->event->ID())) {
306
-            $sales_closed_msg .= sprintf(
307
-                esc_html__(
308
-                    '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
309
-                    'event_espresso'
310
-                ),
311
-                '<div class="ee-attention" style="text-align: left;"><b>',
312
-                '</b><br />',
313
-                '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
314
-                '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
315
-            );
316
-        }
317
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
318
-    }
319
-
320
-
321
-
322
-    /**
323
-     * getTickets
324
-     *
325
-     * @return \EE_Base_Class[]|\EE_Ticket[]
326
-     * @throws EE_Error
327
-     */
328
-    protected function getTickets()
329
-    {
330
-        $ticket_query_args = array(
331
-            array('Datetime.EVT_ID' => $this->event->ID()),
332
-            'order_by' => array(
333
-                'TKT_order'              => 'ASC',
334
-                'TKT_required'           => 'DESC',
335
-                'TKT_start_date'         => 'ASC',
336
-                'TKT_end_date'           => 'ASC',
337
-                'Datetime.DTT_EVT_start' => 'DESC',
338
-            ),
339
-        );
340
-        if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
341
-            //use the correct applicable time query depending on what version of core is being run.
342
-            $current_time = method_exists('EEM_Datetime', 'current_time_for_query')
343
-                ? time()
344
-                : current_time('timestamp');
345
-            $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
346
-        }
347
-        return EEM_Ticket::instance()->get_all($ticket_query_args);
348
-    }
349
-
350
-
351
-
352
-    /**
353
-     * loadTicketSelector
354
-     * begins to assemble template arguments
355
-     * and decides whether to load a "simple" ticket selector, or the standard
356
-     *
357
-     * @param \EE_Ticket[] $tickets
358
-     * @param array $template_args
359
-     * @return string
360
-     * @throws EE_Error
361
-     */
362
-    protected function loadTicketSelector(array $tickets, array $template_args)
363
-    {
364
-        $template_args['event'] = $this->event;
365
-        $template_args['EVT_ID'] = $this->event->ID();
366
-        $template_args['event_is_expired'] = $this->event->is_expired();
367
-        $template_args['max_atndz'] = $this->getMaxAttendees();
368
-        $template_args['date_format'] = $this->date_format;
369
-        $template_args['time_format'] = $this->time_format;
370
-        /**
371
-         * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
372
-         *
373
-         * @since 4.9.13
374
-         * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
375
-         * @param int $EVT_ID The Event ID
376
-         */
377
-        $template_args['anchor_id'] = apply_filters(
378
-            'FHEE__EE_Ticket_Selector__redirect_anchor_id',
379
-            '#tkt-slctr-tbl-' . $this->event->ID(),
380
-            $this->event->ID()
381
-        );
382
-        $template_args['tickets'] = $tickets;
383
-        $template_args['ticket_count'] = count($tickets);
384
-        $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
385
-        return $ticket_selector instanceof TicketSelectorSimple
386
-            ? $ticket_selector
387
-            : new TicketSelectorStandard(
388
-                $this->event,
389
-                $tickets,
390
-                $this->getMaxAttendees(),
391
-                $template_args,
392
-                $this->date_format,
393
-                $this->time_format
394
-            );
395
-    }
396
-
397
-
398
-
399
-    /**
400
-     * simpleTicketSelector
401
-     * there's one ticket, and max attendees is set to one,
402
-     * so if the event is free, then this is a "simple" ticket selector
403
-     * a.k.a. "Dude Where's my Ticket Selector?"
404
-     *
405
-     * @param \EE_Ticket[] $tickets
406
-     * @param array  $template_args
407
-     * @return string
408
-     * @throws EE_Error
409
-     */
410
-    protected function simpleTicketSelector($tickets, array $template_args)
411
-    {
412
-        // if there is only ONE ticket with a max qty of ONE
413
-        if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
414
-            return '';
415
-        }
416
-        /** @var \EE_Ticket $ticket */
417
-        $ticket = reset($tickets);
418
-        // if the ticket is free... then not much need for the ticket selector
419
-        if (
420
-            apply_filters(
421
-                'FHEE__ticket_selector_chart_template__hide_ticket_selector',
422
-                $ticket->is_free(),
423
-                $this->event->ID()
424
-            )
425
-        ) {
426
-            return new TicketSelectorSimple(
427
-                $this->event,
428
-                $ticket,
429
-                $this->getMaxAttendees(),
430
-                $template_args
431
-            );
432
-        }
433
-        return '';
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     * externalEventRegistration
440
-     *
441
-     * @return string
442
-     */
443
-    public function externalEventRegistration()
444
-    {
445
-        // if not we still need to trigger the display of the submit button
446
-        add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
447
-        //display notice to admin that registration is external
448
-        return is_admin()
449
-            ? esc_html__(
450
-                'Registration is at an external URL for this event.',
451
-                'event_espresso'
452
-            )
453
-            : '';
454
-    }
455
-
456
-
457
-
458
-    /**
459
-     * formOpen
460
-     *
461
-     * @param        int    $ID
462
-     * @param        string $external_url
463
-     * @return        string
464
-     */
465
-    public function formOpen( $ID = 0, $external_url = '' )
466
-    {
467
-        // if redirecting, we don't need any anything else
468
-        if ( $external_url ) {
469
-            $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
470
-            // open link in new window ?
471
-            $html .= apply_filters(
472
-                'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
473
-                EED_Events_Archive::is_iframe()
474
-            )
475
-                ? ' target="_blank"'
476
-                : '';
477
-            $html .= '>';
478
-            $query_args = EEH_URL::get_query_string( $external_url );
479
-            foreach ( (array)$query_args as $query_arg => $value ) {
480
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
481
-            }
482
-            return $html;
483
-        }
484
-        // if there is no submit button, then don't start building a form
485
-        // because the "View Details" button will build its own form
486
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
487
-            return '';
488
-        }
489
-        $checkout_url = EEH_Event_View::event_link_url( $ID );
490
-        if ( ! $checkout_url ) {
491
-            EE_Error::add_error(
492
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
493
-                __FILE__,
494
-                __FUNCTION__,
495
-                __LINE__
496
-            );
497
-        }
498
-        // set no cache headers and constants
499
-        EE_System::do_not_cache();
500
-        $extra_params = $this->iframe ? ' target="_blank"' : '';
501
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
502
-        $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
503
-        $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
504
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
505
-        return $html;
506
-    }
507
-
508
-
509
-
510
-    /**
511
-     * displaySubmitButton
512
-     *
513
-     * @param  string $external_url
514
-     * @return string
515
-     * @throws EE_Error
516
-     */
517
-    public function displaySubmitButton($external_url = '')
518
-    {
519
-        $html = '';
520
-        if ( ! is_admin()) {
521
-            // standard TS displayed with submit button, ie: "Register Now"
522
-            if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
523
-                $html .= $this->displayRegisterNowButton();
524
-                $html .= empty($external_url)
525
-                    ? $this->ticketSelectorEndDiv()
526
-                    : $this->clearTicketSelector();
527
-                $html .= '<br/>' . $this->formClose();
528
-            } else if ($this->getMaxAttendees() === 1) {
529
-                // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
530
-                if ($this->event->is_sold_out()) {
531
-                    // then instead of a View Details or Submit button, just display a "Sold Out" message
532
-                    $html .= apply_filters(
533
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
534
-                        sprintf(
535
-                            __(
536
-                                '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
537
-                                'event_espresso'
538
-                            ),
539
-                            '<p class="no-ticket-selector-msg clear-float">',
540
-                            $this->event->name(),
541
-                            '</p>',
542
-                            '<br />'
543
-                        ),
544
-                        $this->event
545
-                    );
546
-                    if (
547
-                        apply_filters(
548
-                            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
549
-                            false,
550
-                            $this->event
551
-                        )
552
-                    ) {
553
-                        $html .= $this->displayRegisterNowButton();
554
-                    }
555
-                    // sold out DWMTS event, no TS, no submit or view details button, but has additional content
556
-                    $html .=  $this->ticketSelectorEndDiv();
557
-                } else if (
558
-                    apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
559
-                    && ! is_single()
560
-                ) {
561
-                    // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
562
-                    // but no tickets are available, so display event's "View Details" button.
563
-                    // it is being viewed via somewhere other than a single post
564
-                    $html .= $this->displayViewDetailsButton(true);
565
-                } else {
566
-                    $html .= $this->ticketSelectorEndDiv();
567
-                }
568
-            } else if (is_archive()) {
569
-                // event list, no tickets available so display event's "View Details" button
570
-                $html .= $this->ticketSelectorEndDiv();
571
-                $html .= $this->displayViewDetailsButton();
572
-            } else {
573
-                if (
574
-                    apply_filters(
575
-                        'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
576
-                        false,
577
-                        $this->event
578
-                    )
579
-                ) {
580
-                    $html .= $this->displayRegisterNowButton();
581
-                }
582
-                // no submit or view details button, and no additional content
583
-                $html .= $this->ticketSelectorEndDiv();
584
-            }
585
-            if ( ! $this->iframe && ! is_archive()) {
586
-                $html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
587
-            }
588
-        }
589
-        return $html;
590
-    }
591
-
592
-
593
-
594
-    /**
595
-     * @return string
596
-     * @throws EE_Error
597
-     */
598
-    public function displayRegisterNowButton()
599
-    {
600
-        $btn_text = apply_filters(
601
-            'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
602
-            __('Register Now', 'event_espresso'),
603
-            $this->event
604
-        );
605
-        $external_url = $this->event->external_url();
606
-        $html = EEH_HTML::div(
607
-            '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
608
-        );
609
-        $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
610
-        $html .= ' class="ticket-selector-submit-btn ';
611
-        $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
612
-        $html .= ' type="submit" value="' . $btn_text . '" />';
613
-        $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
614
-        $html .= apply_filters(
615
-            'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
616
-            '',
617
-            $this->event
618
-        );
619
-        return $html;
620
-    }
621
-
622
-
623
-    /**
624
-     * displayViewDetailsButton
625
-     *
626
-     * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
627
-     *                    (ie: $_max_atndz === 1) where there are no available tickets,
628
-     *                    either because they are sold out, expired, or not yet on sale.
629
-     *                    In this case, we need to close the form BEFORE adding any closing divs
630
-     * @return string
631
-     * @throws EE_Error
632
-     */
633
-    public function displayViewDetailsButton( $DWMTS = false )
634
-    {
635
-        if ( ! $this->event->get_permalink() ) {
636
-            EE_Error::add_error(
637
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
638
-                __FILE__, __FUNCTION__, __LINE__
639
-            );
640
-        }
641
-        $view_details_btn = '<form method="POST" action="';
642
-        $view_details_btn .= apply_filters(
643
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
644
-            $this->event->get_permalink(),
645
-            $this->event
646
-        );
647
-        $view_details_btn .= '"';
648
-        // open link in new window ?
649
-        $view_details_btn .= apply_filters(
650
-            'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
651
-            EED_Events_Archive::is_iframe()
652
-        )
653
-            ? ' target="_blank"'
654
-            : '';
655
-        $view_details_btn .='>';
656
-        $btn_text = apply_filters(
657
-            'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
658
-            esc_html__('View Details', 'event_espresso'),
659
-            $this->event
660
-        );
661
-        $view_details_btn .= '<input id="ticket-selector-submit-'
662
-                             . $this->event->ID()
663
-                             . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
664
-                             . $btn_text
665
-                             . '" />';
666
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
667
-        if ($DWMTS) {
668
-            $view_details_btn .= $this->formClose();
669
-            $view_details_btn .= $this->ticketSelectorEndDiv();
670
-            $view_details_btn .= '<br/>';
671
-        } else {
672
-            $view_details_btn .= $this->clearTicketSelector();
673
-            $view_details_btn .= '<br/>';
674
-            $view_details_btn .= $this->formClose();
675
-        }
676
-        return $view_details_btn;
677
-    }
678
-
679
-
680
-
681
-    /**
682
-     * @return string
683
-     */
684
-    public function ticketSelectorEndDiv()
685
-    {
686
-        return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
687
-    }
688
-
689
-
690
-
691
-    /**
692
-     * @return string
693
-     */
694
-    public function clearTicketSelector()
695
-    {
696
-        // standard TS displayed, appears after a "Register Now" or "view Details" button
697
-        return '<div class="clear"></div><!-- clearTicketSelector -->';
698
-    }
699
-
700
-
701
-
702
-    /**
703
-     * @access        public
704
-     * @return        string
705
-     */
706
-    public function formClose()
707
-    {
708
-        return '</form>';
709
-    }
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * ticketSalesClosed
294
+	 * notice displayed if event ticket sales are turned off
295
+	 *
296
+	 * @return string
297
+	 * @throws EE_Error
298
+	 */
299
+	protected function ticketSalesClosedMessage()
300
+	{
301
+		$sales_closed_msg = esc_html__(
302
+			'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.',
303
+			'event_espresso'
304
+		);
305
+		if (current_user_can('edit_post', $this->event->ID())) {
306
+			$sales_closed_msg .= sprintf(
307
+				esc_html__(
308
+					'%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s',
309
+					'event_espresso'
310
+				),
311
+				'<div class="ee-attention" style="text-align: left;"><b>',
312
+				'</b><br />',
313
+				'<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">',
314
+				'</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
315
+			);
316
+		}
317
+		return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
318
+	}
319
+
320
+
321
+
322
+	/**
323
+	 * getTickets
324
+	 *
325
+	 * @return \EE_Base_Class[]|\EE_Ticket[]
326
+	 * @throws EE_Error
327
+	 */
328
+	protected function getTickets()
329
+	{
330
+		$ticket_query_args = array(
331
+			array('Datetime.EVT_ID' => $this->event->ID()),
332
+			'order_by' => array(
333
+				'TKT_order'              => 'ASC',
334
+				'TKT_required'           => 'DESC',
335
+				'TKT_start_date'         => 'ASC',
336
+				'TKT_end_date'           => 'ASC',
337
+				'Datetime.DTT_EVT_start' => 'DESC',
338
+			),
339
+		);
340
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
341
+			//use the correct applicable time query depending on what version of core is being run.
342
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query')
343
+				? time()
344
+				: current_time('timestamp');
345
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
346
+		}
347
+		return EEM_Ticket::instance()->get_all($ticket_query_args);
348
+	}
349
+
350
+
351
+
352
+	/**
353
+	 * loadTicketSelector
354
+	 * begins to assemble template arguments
355
+	 * and decides whether to load a "simple" ticket selector, or the standard
356
+	 *
357
+	 * @param \EE_Ticket[] $tickets
358
+	 * @param array $template_args
359
+	 * @return string
360
+	 * @throws EE_Error
361
+	 */
362
+	protected function loadTicketSelector(array $tickets, array $template_args)
363
+	{
364
+		$template_args['event'] = $this->event;
365
+		$template_args['EVT_ID'] = $this->event->ID();
366
+		$template_args['event_is_expired'] = $this->event->is_expired();
367
+		$template_args['max_atndz'] = $this->getMaxAttendees();
368
+		$template_args['date_format'] = $this->date_format;
369
+		$template_args['time_format'] = $this->time_format;
370
+		/**
371
+		 * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected
372
+		 *
373
+		 * @since 4.9.13
374
+		 * @param     string  '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to
375
+		 * @param int $EVT_ID The Event ID
376
+		 */
377
+		$template_args['anchor_id'] = apply_filters(
378
+			'FHEE__EE_Ticket_Selector__redirect_anchor_id',
379
+			'#tkt-slctr-tbl-' . $this->event->ID(),
380
+			$this->event->ID()
381
+		);
382
+		$template_args['tickets'] = $tickets;
383
+		$template_args['ticket_count'] = count($tickets);
384
+		$ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
385
+		return $ticket_selector instanceof TicketSelectorSimple
386
+			? $ticket_selector
387
+			: new TicketSelectorStandard(
388
+				$this->event,
389
+				$tickets,
390
+				$this->getMaxAttendees(),
391
+				$template_args,
392
+				$this->date_format,
393
+				$this->time_format
394
+			);
395
+	}
396
+
397
+
398
+
399
+	/**
400
+	 * simpleTicketSelector
401
+	 * there's one ticket, and max attendees is set to one,
402
+	 * so if the event is free, then this is a "simple" ticket selector
403
+	 * a.k.a. "Dude Where's my Ticket Selector?"
404
+	 *
405
+	 * @param \EE_Ticket[] $tickets
406
+	 * @param array  $template_args
407
+	 * @return string
408
+	 * @throws EE_Error
409
+	 */
410
+	protected function simpleTicketSelector($tickets, array $template_args)
411
+	{
412
+		// if there is only ONE ticket with a max qty of ONE
413
+		if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) {
414
+			return '';
415
+		}
416
+		/** @var \EE_Ticket $ticket */
417
+		$ticket = reset($tickets);
418
+		// if the ticket is free... then not much need for the ticket selector
419
+		if (
420
+			apply_filters(
421
+				'FHEE__ticket_selector_chart_template__hide_ticket_selector',
422
+				$ticket->is_free(),
423
+				$this->event->ID()
424
+			)
425
+		) {
426
+			return new TicketSelectorSimple(
427
+				$this->event,
428
+				$ticket,
429
+				$this->getMaxAttendees(),
430
+				$template_args
431
+			);
432
+		}
433
+		return '';
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 * externalEventRegistration
440
+	 *
441
+	 * @return string
442
+	 */
443
+	public function externalEventRegistration()
444
+	{
445
+		// if not we still need to trigger the display of the submit button
446
+		add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
447
+		//display notice to admin that registration is external
448
+		return is_admin()
449
+			? esc_html__(
450
+				'Registration is at an external URL for this event.',
451
+				'event_espresso'
452
+			)
453
+			: '';
454
+	}
455
+
456
+
457
+
458
+	/**
459
+	 * formOpen
460
+	 *
461
+	 * @param        int    $ID
462
+	 * @param        string $external_url
463
+	 * @return        string
464
+	 */
465
+	public function formOpen( $ID = 0, $external_url = '' )
466
+	{
467
+		// if redirecting, we don't need any anything else
468
+		if ( $external_url ) {
469
+			$html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
470
+			// open link in new window ?
471
+			$html .= apply_filters(
472
+				'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
473
+				EED_Events_Archive::is_iframe()
474
+			)
475
+				? ' target="_blank"'
476
+				: '';
477
+			$html .= '>';
478
+			$query_args = EEH_URL::get_query_string( $external_url );
479
+			foreach ( (array)$query_args as $query_arg => $value ) {
480
+				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
481
+			}
482
+			return $html;
483
+		}
484
+		// if there is no submit button, then don't start building a form
485
+		// because the "View Details" button will build its own form
486
+		if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
487
+			return '';
488
+		}
489
+		$checkout_url = EEH_Event_View::event_link_url( $ID );
490
+		if ( ! $checkout_url ) {
491
+			EE_Error::add_error(
492
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
493
+				__FILE__,
494
+				__FUNCTION__,
495
+				__LINE__
496
+			);
497
+		}
498
+		// set no cache headers and constants
499
+		EE_System::do_not_cache();
500
+		$extra_params = $this->iframe ? ' target="_blank"' : '';
501
+		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
502
+		$html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
503
+		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
504
+		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
505
+		return $html;
506
+	}
507
+
508
+
509
+
510
+	/**
511
+	 * displaySubmitButton
512
+	 *
513
+	 * @param  string $external_url
514
+	 * @return string
515
+	 * @throws EE_Error
516
+	 */
517
+	public function displaySubmitButton($external_url = '')
518
+	{
519
+		$html = '';
520
+		if ( ! is_admin()) {
521
+			// standard TS displayed with submit button, ie: "Register Now"
522
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
523
+				$html .= $this->displayRegisterNowButton();
524
+				$html .= empty($external_url)
525
+					? $this->ticketSelectorEndDiv()
526
+					: $this->clearTicketSelector();
527
+				$html .= '<br/>' . $this->formClose();
528
+			} else if ($this->getMaxAttendees() === 1) {
529
+				// its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
530
+				if ($this->event->is_sold_out()) {
531
+					// then instead of a View Details or Submit button, just display a "Sold Out" message
532
+					$html .= apply_filters(
533
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg',
534
+						sprintf(
535
+							__(
536
+								'%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s',
537
+								'event_espresso'
538
+							),
539
+							'<p class="no-ticket-selector-msg clear-float">',
540
+							$this->event->name(),
541
+							'</p>',
542
+							'<br />'
543
+						),
544
+						$this->event
545
+					);
546
+					if (
547
+						apply_filters(
548
+							'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
549
+							false,
550
+							$this->event
551
+						)
552
+					) {
553
+						$html .= $this->displayRegisterNowButton();
554
+					}
555
+					// sold out DWMTS event, no TS, no submit or view details button, but has additional content
556
+					$html .=  $this->ticketSelectorEndDiv();
557
+				} else if (
558
+					apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
559
+					&& ! is_single()
560
+				) {
561
+					// this is a "Dude Where's my Ticket Selector?" (DWMTS) type event,
562
+					// but no tickets are available, so display event's "View Details" button.
563
+					// it is being viewed via somewhere other than a single post
564
+					$html .= $this->displayViewDetailsButton(true);
565
+				} else {
566
+					$html .= $this->ticketSelectorEndDiv();
567
+				}
568
+			} else if (is_archive()) {
569
+				// event list, no tickets available so display event's "View Details" button
570
+				$html .= $this->ticketSelectorEndDiv();
571
+				$html .= $this->displayViewDetailsButton();
572
+			} else {
573
+				if (
574
+					apply_filters(
575
+						'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button',
576
+						false,
577
+						$this->event
578
+					)
579
+				) {
580
+					$html .= $this->displayRegisterNowButton();
581
+				}
582
+				// no submit or view details button, and no additional content
583
+				$html .= $this->ticketSelectorEndDiv();
584
+			}
585
+			if ( ! $this->iframe && ! is_archive()) {
586
+				$html .= EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector'));
587
+			}
588
+		}
589
+		return $html;
590
+	}
591
+
592
+
593
+
594
+	/**
595
+	 * @return string
596
+	 * @throws EE_Error
597
+	 */
598
+	public function displayRegisterNowButton()
599
+	{
600
+		$btn_text = apply_filters(
601
+			'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
602
+			__('Register Now', 'event_espresso'),
603
+			$this->event
604
+		);
605
+		$external_url = $this->event->external_url();
606
+		$html = EEH_HTML::div(
607
+			'', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
608
+		);
609
+		$html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
610
+		$html .= ' class="ticket-selector-submit-btn ';
611
+		$html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
612
+		$html .= ' type="submit" value="' . $btn_text . '" />';
613
+		$html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
614
+		$html .= apply_filters(
615
+			'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
616
+			'',
617
+			$this->event
618
+		);
619
+		return $html;
620
+	}
621
+
622
+
623
+	/**
624
+	 * displayViewDetailsButton
625
+	 *
626
+	 * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event
627
+	 *                    (ie: $_max_atndz === 1) where there are no available tickets,
628
+	 *                    either because they are sold out, expired, or not yet on sale.
629
+	 *                    In this case, we need to close the form BEFORE adding any closing divs
630
+	 * @return string
631
+	 * @throws EE_Error
632
+	 */
633
+	public function displayViewDetailsButton( $DWMTS = false )
634
+	{
635
+		if ( ! $this->event->get_permalink() ) {
636
+			EE_Error::add_error(
637
+				esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
638
+				__FILE__, __FUNCTION__, __LINE__
639
+			);
640
+		}
641
+		$view_details_btn = '<form method="POST" action="';
642
+		$view_details_btn .= apply_filters(
643
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url',
644
+			$this->event->get_permalink(),
645
+			$this->event
646
+		);
647
+		$view_details_btn .= '"';
648
+		// open link in new window ?
649
+		$view_details_btn .= apply_filters(
650
+			'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank',
651
+			EED_Events_Archive::is_iframe()
652
+		)
653
+			? ' target="_blank"'
654
+			: '';
655
+		$view_details_btn .='>';
656
+		$btn_text = apply_filters(
657
+			'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
658
+			esc_html__('View Details', 'event_espresso'),
659
+			$this->event
660
+		);
661
+		$view_details_btn .= '<input id="ticket-selector-submit-'
662
+							 . $this->event->ID()
663
+							 . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
664
+							 . $btn_text
665
+							 . '" />';
666
+		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
667
+		if ($DWMTS) {
668
+			$view_details_btn .= $this->formClose();
669
+			$view_details_btn .= $this->ticketSelectorEndDiv();
670
+			$view_details_btn .= '<br/>';
671
+		} else {
672
+			$view_details_btn .= $this->clearTicketSelector();
673
+			$view_details_btn .= '<br/>';
674
+			$view_details_btn .= $this->formClose();
675
+		}
676
+		return $view_details_btn;
677
+	}
678
+
679
+
680
+
681
+	/**
682
+	 * @return string
683
+	 */
684
+	public function ticketSelectorEndDiv()
685
+	{
686
+		return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
687
+	}
688
+
689
+
690
+
691
+	/**
692
+	 * @return string
693
+	 */
694
+	public function clearTicketSelector()
695
+	{
696
+		// standard TS displayed, appears after a "Register Now" or "view Details" button
697
+		return '<div class="clear"></div><!-- clearTicketSelector -->';
698
+	}
699
+
700
+
701
+
702
+	/**
703
+	 * @access        public
704
+	 * @return        string
705
+	 */
706
+	public function formClose()
707
+	{
708
+		return '</form>';
709
+	}
710 710
 
711 711
 
712 712
 
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 use EEM_Ticket;
16 16
 use WP_Post;
17 17
 
18
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
19
-    exit( 'No direct script access allowed' );
18
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
19
+    exit('No direct script access allowed');
20 20
 }
21 21
 
22 22
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
     /**
88 88
      * @param boolean $iframe
89 89
      */
90
-    public function setIframe( $iframe = true )
90
+    public function setIframe($iframe = true)
91 91
     {
92
-        $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN );
92
+        $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN);
93 93
     }
94 94
 
95 95
 
@@ -100,28 +100,28 @@  discard block
 block discarded – undo
100 100
      * @return bool
101 101
      * @throws EE_Error
102 102
      */
103
-    protected function setEvent( $event = null )
103
+    protected function setEvent($event = null)
104 104
     {
105
-        if ( $event === null ) {
105
+        if ($event === null) {
106 106
             global $post;
107 107
             $event = $post;
108 108
         }
109
-        if ( $event instanceof EE_Event ) {
109
+        if ($event instanceof EE_Event) {
110 110
             $this->event = $event;
111
-        } else if ( $event instanceof WP_Post ) {
112
-            if ( isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
111
+        } else if ($event instanceof WP_Post) {
112
+            if (isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
113 113
                 $this->event = $event->EE_Event;
114
-            } else if ( $event->post_type === 'espresso_events' ) {
115
-                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
114
+            } else if ($event->post_type === 'espresso_events') {
115
+                $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
116 116
                 $this->event = $event->EE_Event;
117 117
             }
118 118
         } else {
119
-            $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
120
-            $dev_msg = $user_msg . __(
119
+            $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
120
+            $dev_msg = $user_msg.__(
121 121
                     'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.',
122 122
                     'event_espresso'
123 123
                 );
124
-            EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
124
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
125 125
             return false;
126 126
         }
127 127
         return true;
@@ -162,17 +162,17 @@  discard block
 block discarded – undo
162 162
      * @return string
163 163
      * @throws EE_Error
164 164
      */
165
-    public function display( $event = null, $view_details = false )
165
+    public function display($event = null, $view_details = false)
166 166
     {
167 167
         // reset filter for displaying submit button
168
-        remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
168
+        remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
169 169
         // poke and prod incoming event till it tells us what it is
170
-        if ( ! $this->setEvent( $event ) ) {
170
+        if ( ! $this->setEvent($event)) {
171 171
             return false;
172 172
         }
173 173
         // begin gathering template arguments by getting event status
174
-        $template_args = array( 'event_status' => $this->event->get_active_status() );
175
-        if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) {
174
+        $template_args = array('event_status' => $this->event->get_active_status());
175
+        if ($this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details)) {
176 176
             return ! is_single() ? $this->displayViewDetailsButton() : '';
177 177
         }
178 178
         // filter the maximum qty that can appear in the Ticket Selector qty dropdowns
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         }
183 183
         // is the event expired ?
184 184
         $template_args['event_is_expired'] = $this->event->is_expired();
185
-        if ( $template_args[ 'event_is_expired' ] ) {
185
+        if ($template_args['event_is_expired']) {
186 186
             return $this->expiredEventMessage();
187 187
         }
188 188
         // get all tickets for this event ordered by the datetime
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         if (count($tickets) < 1) {
191 191
             return $this->noTicketAvailableMessage();
192 192
         }
193
-        if (EED_Events_Archive::is_iframe()){
193
+        if (EED_Events_Archive::is_iframe()) {
194 194
             $this->setIframe();
195 195
         }
196 196
         // redirecting to another site for registration ??
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
         // if redirecting to another site for registration, then we don't load the TS
199 199
         $ticket_selector = $external_url
200 200
             ? $this->externalEventRegistration()
201
-            : $this->loadTicketSelector($tickets,$template_args);
201
+            : $this->loadTicketSelector($tickets, $template_args);
202 202
         // now set up the form (but not for the admin)
203 203
         $ticket_selector = ! is_admin()
204
-            ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector
204
+            ? $this->formOpen($this->event->ID(), $external_url).$ticket_selector
205 205
             : $ticket_selector;
206 206
         // submit button and form close tag
207 207
         $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : '';
@@ -251,10 +251,10 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function expiredEventMessage()
253 253
     {
254
-        return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__(
254
+        return '<div class="ee-event-expired-notice"><span class="important-notice">'.esc_html__(
255 255
             'We\'re sorry, but all tickets sales have ended because the event is expired.',
256 256
             'event_espresso'
257
-        ) . '</span></div><!-- .ee-event-expired-notice -->';
257
+        ).'</span></div><!-- .ee-event-expired-notice -->';
258 258
     }
259 259
 
260 260
 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      */
269 269
     protected function noTicketAvailableMessage()
270 270
     {
271
-        $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' );
271
+        $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso');
272 272
         if (current_user_can('edit_post', $this->event->ID())) {
273 273
             $no_ticket_available_msg .= sprintf(
274 274
                 esc_html__(
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         }
284 284
         return '
285 285
             <div class="ee-event-expired-notice">
286
-                <span class="important-notice">' . $no_ticket_available_msg . '</span>
286
+                <span class="important-notice">' . $no_ticket_available_msg.'</span>
287 287
             </div><!-- .ee-event-expired-notice -->';
288 288
     }
289 289
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
                 '</a></span></div><!-- .ee-attention ticketSalesClosedMessage -->'
315 315
             );
316 316
         }
317
-        return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
317
+        return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
318 318
     }
319 319
 
320 320
 
@@ -376,12 +376,12 @@  discard block
 block discarded – undo
376 376
          */
377 377
         $template_args['anchor_id'] = apply_filters(
378 378
             'FHEE__EE_Ticket_Selector__redirect_anchor_id',
379
-            '#tkt-slctr-tbl-' . $this->event->ID(),
379
+            '#tkt-slctr-tbl-'.$this->event->ID(),
380 380
             $this->event->ID()
381 381
         );
382 382
         $template_args['tickets'] = $tickets;
383 383
         $template_args['ticket_count'] = count($tickets);
384
-        $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args);
384
+        $ticket_selector = $this->simpleTicketSelector($tickets, $template_args);
385 385
         return $ticket_selector instanceof TicketSelectorSimple
386 386
             ? $ticket_selector
387 387
             : new TicketSelectorStandard(
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
      * @param        string $external_url
463 463
      * @return        string
464 464
      */
465
-    public function formOpen( $ID = 0, $external_url = '' )
465
+    public function formOpen($ID = 0, $external_url = '')
466 466
     {
467 467
         // if redirecting, we don't need any anything else
468
-        if ( $external_url ) {
469
-            $html = '<form method="GET" action="' . EEH_URL::refactor_url($external_url) . '"';
468
+        if ($external_url) {
469
+            $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'"';
470 470
             // open link in new window ?
471 471
             $html .= apply_filters(
472 472
                 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank',
@@ -475,21 +475,21 @@  discard block
 block discarded – undo
475 475
                 ? ' target="_blank"'
476 476
                 : '';
477 477
             $html .= '>';
478
-            $query_args = EEH_URL::get_query_string( $external_url );
479
-            foreach ( (array)$query_args as $query_arg => $value ) {
480
-                $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
478
+            $query_args = EEH_URL::get_query_string($external_url);
479
+            foreach ((array) $query_args as $query_arg => $value) {
480
+                $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
481 481
             }
482 482
             return $html;
483 483
         }
484 484
         // if there is no submit button, then don't start building a form
485 485
         // because the "View Details" button will build its own form
486
-        if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) {
486
+        if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) {
487 487
             return '';
488 488
         }
489
-        $checkout_url = EEH_Event_View::event_link_url( $ID );
490
-        if ( ! $checkout_url ) {
489
+        $checkout_url = EEH_Event_View::event_link_url($ID);
490
+        if ( ! $checkout_url) {
491 491
             EE_Error::add_error(
492
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
492
+                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
493 493
                 __FILE__,
494 494
                 __FUNCTION__,
495 495
                 __LINE__
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
         // set no cache headers and constants
499 499
         EE_System::do_not_cache();
500 500
         $extra_params = $this->iframe ? ' target="_blank"' : '';
501
-        $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
502
-        $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false );
501
+        $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
502
+        $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, true, false);
503 503
         $html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
504
-        $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event );
504
+        $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event);
505 505
         return $html;
506 506
     }
507 507
 
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                 $html .= empty($external_url)
525 525
                     ? $this->ticketSelectorEndDiv()
526 526
                     : $this->clearTicketSelector();
527
-                $html .= '<br/>' . $this->formClose();
527
+                $html .= '<br/>'.$this->formClose();
528 528
             } else if ($this->getMaxAttendees() === 1) {
529 529
                 // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1)
530 530
                 if ($this->event->is_sold_out()) {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                         $html .= $this->displayRegisterNowButton();
554 554
                     }
555 555
                     // sold out DWMTS event, no TS, no submit or view details button, but has additional content
556
-                    $html .=  $this->ticketSelectorEndDiv();
556
+                    $html .= $this->ticketSelectorEndDiv();
557 557
                 } else if (
558 558
                     apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false)
559 559
                     && ! is_single()
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
         );
605 605
         $external_url = $this->event->external_url();
606 606
         $html = EEH_HTML::div(
607
-            '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap'
607
+            '', 'ticket-selector-submit-'.$this->event->ID().'-btn-wrap', 'ticket-selector-submit-btn-wrap'
608 608
         );
609
-        $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"';
609
+        $html .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"';
610 610
         $html .= ' class="ticket-selector-submit-btn ';
611 611
         $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"';
612
-        $html .= ' type="submit" value="' . $btn_text . '" />';
613
-        $html .= EEH_HTML::divx() . '<!-- .ticket-selector-submit-btn-wrap -->';
612
+        $html .= ' type="submit" value="'.$btn_text.'" />';
613
+        $html .= EEH_HTML::divx().'<!-- .ticket-selector-submit-btn-wrap -->';
614 614
         $html .= apply_filters(
615 615
             'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
616 616
             '',
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
      * @return string
631 631
      * @throws EE_Error
632 632
      */
633
-    public function displayViewDetailsButton( $DWMTS = false )
633
+    public function displayViewDetailsButton($DWMTS = false)
634 634
     {
635
-        if ( ! $this->event->get_permalink() ) {
635
+        if ( ! $this->event->get_permalink()) {
636 636
             EE_Error::add_error(
637
-                esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ),
637
+                esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'),
638 638
                 __FILE__, __FUNCTION__, __LINE__
639 639
             );
640 640
         }
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
         )
653 653
             ? ' target="_blank"'
654 654
             : '';
655
-        $view_details_btn .='>';
655
+        $view_details_btn .= '>';
656 656
         $btn_text = apply_filters(
657 657
             'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text',
658 658
             esc_html__('View Details', 'event_espresso'),
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                              . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'
664 664
                              . $btn_text
665 665
                              . '" />';
666
-        $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event );
666
+        $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event);
667 667
         if ($DWMTS) {
668 668
             $view_details_btn .= $this->formClose();
669 669
             $view_details_btn .= $this->ticketSelectorEndDiv();
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
      */
684 684
     public function ticketSelectorEndDiv()
685 685
     {
686
-        return $this->clearTicketSelector() . '</div><!-- ticketSelectorEndDiv -->';
686
+        return $this->clearTicketSelector().'</div><!-- ticketSelectorEndDiv -->';
687 687
     }
688 688
 
689 689
 
Please login to merge, or discard this patch.
core/helpers/EEH_Debug_Tools.helper.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 
376 376
 
377 377
     /**
378
-     * @param mixed  $var
378
+     * @param string  $var
379 379
      * @param string $var_name
380 380
      * @param string $file
381 381
      * @param int    $line
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 
571 571
     /**
572 572
      * @deprecated 4.9.39.rc.034
573
-     * @param null $timer_name
573
+     * @param string $timer_name
574 574
      */
575 575
     public function start_timer($timer_name = null)
576 576
     {
Please login to merge, or discard this patch.
Indentation   +636 added lines, -636 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\services\Benchmark;
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -17,626 +17,626 @@  discard block
 block discarded – undo
17 17
 class EEH_Debug_Tools
18 18
 {
19 19
 
20
-    /**
21
-     *    instance of the EEH_Autoloader object
22
-     *
23
-     * @var    $_instance
24
-     * @access    private
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var array
30
-     */
31
-    protected $_memory_usage_points = array();
32
-
33
-
34
-
35
-    /**
36
-     * @singleton method used to instantiate class object
37
-     * @access    public
38
-     * @return EEH_Debug_Tools
39
-     */
40
-    public static function instance()
41
-    {
42
-        // check if class object is instantiated, and instantiated properly
43
-        if (! self::$_instance instanceof EEH_Debug_Tools) {
44
-            self::$_instance = new self();
45
-        }
46
-        return self::$_instance;
47
-    }
48
-
49
-
50
-
51
-    /**
52
-     * private class constructor
53
-     */
54
-    private function __construct()
55
-    {
56
-        // load Kint PHP debugging library
57
-        if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
58
-            // despite EE4 having a check for an existing copy of the Kint debugging class,
59
-            // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
60
-            // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
61
-            // so we've moved it to our test folder so that it is not included with production releases
62
-            // plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
63
-            require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
64
-        }
65
-        // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
66
-        //add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
67
-        // }
68
-        $plugin = basename(EE_PLUGIN_DIR_PATH);
69
-        add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
70
-        add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
71
-        add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
72
-    }
73
-
74
-
75
-
76
-    /**
77
-     *    show_db_name
78
-     *
79
-     * @return void
80
-     */
81
-    public static function show_db_name()
82
-    {
83
-        if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
84
-            echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
85
-                 . DB_NAME
86
-                 . '</p>';
87
-        }
88
-        if (EE_DEBUG) {
89
-            Benchmark::displayResults();
90
-        }
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     *    dump EE_Session object at bottom of page after everything else has happened
97
-     *
98
-     * @return void
99
-     */
100
-    public function espresso_session_footer_dump()
101
-    {
102
-        if (
103
-            (defined('WP_DEBUG') && WP_DEBUG)
104
-            && ! defined('DOING_AJAX')
105
-            && class_exists('Kint')
106
-            && function_exists('wp_get_current_user')
107
-            && current_user_can('update_core')
108
-            && class_exists('EE_Registry')
109
-        ) {
110
-            Kint::dump(EE_Registry::instance()->SSN->id());
111
-            Kint::dump(EE_Registry::instance()->SSN);
112
-            //			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
113
-            $this->espresso_list_hooked_functions();
114
-            Benchmark::displayResults();
115
-        }
116
-    }
117
-
118
-
119
-
120
-    /**
121
-     *    List All Hooked Functions
122
-     *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
123
-     *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
124
-     *
125
-     * @param string $tag
126
-     * @return void
127
-     */
128
-    public function espresso_list_hooked_functions($tag = '')
129
-    {
130
-        global $wp_filter;
131
-        echo '<br/><br/><br/><h3>Hooked Functions</h3>';
132
-        if ($tag) {
133
-            $hook[$tag] = $wp_filter[$tag];
134
-            if (! is_array($hook[$tag])) {
135
-                trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
136
-                return;
137
-            }
138
-            echo '<h5>For Tag: ' . $tag . '</h5>';
139
-        } else {
140
-            $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
141
-            ksort($hook);
142
-        }
143
-        foreach ($hook as $tag_name => $priorities) {
144
-            echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
145
-            ksort($priorities);
146
-            foreach ($priorities as $priority => $function) {
147
-                echo $priority;
148
-                foreach ($function as $name => $properties) {
149
-                    echo "\t$name<br />";
150
-                }
151
-            }
152
-        }
153
-    }
154
-
155
-
156
-
157
-    /**
158
-     *    registered_filter_callbacks
159
-     *
160
-     * @param string $hook_name
161
-     * @return array
162
-     */
163
-    public static function registered_filter_callbacks($hook_name = '')
164
-    {
165
-        $filters = array();
166
-        global $wp_filter;
167
-        if (isset($wp_filter[$hook_name])) {
168
-            $filters[$hook_name] = array();
169
-            foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
170
-                $filters[$hook_name][$priority] = array();
171
-                foreach ($callbacks as $callback) {
172
-                    $filters[$hook_name][$priority][] = $callback['function'];
173
-                }
174
-            }
175
-        }
176
-        return $filters;
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     *    captures plugin activation errors for debugging
183
-     *
184
-     * @return void
185
-     * @throws EE_Error
186
-     */
187
-    public static function ee_plugin_activation_errors()
188
-    {
189
-        if (WP_DEBUG) {
190
-            $activation_errors = ob_get_contents();
191
-            if (! empty($activation_errors)) {
192
-                $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
193
-            }
194
-            espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
195
-            if (class_exists('EEH_File')) {
196
-                try {
197
-                    EEH_File::ensure_file_exists_and_is_writable(
198
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
199
-                    );
200
-                    EEH_File::write_to_file(
201
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
202
-                        $activation_errors
203
-                    );
204
-                } catch (EE_Error $e) {
205
-                    EE_Error::add_error(
206
-                        sprintf(
207
-                            __(
208
-                                'The Event Espresso activation errors file could not be setup because: %s',
209
-                                'event_espresso'
210
-                            ),
211
-                            $e->getMessage()
212
-                        ),
213
-                        __FILE__, __FUNCTION__, __LINE__
214
-                    );
215
-                }
216
-            } else {
217
-                // old school attempt
218
-                file_put_contents(
219
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
220
-                    $activation_errors
221
-                );
222
-            }
223
-            $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
224
-            update_option('ee_plugin_activation_errors', $activation_errors);
225
-        }
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
232
-     * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
233
-     * or we want to make sure they use something the right way.
234
-     *
235
-     * @access public
236
-     * @param string $function      The function that was called
237
-     * @param string $message       A message explaining what has been done incorrectly
238
-     * @param string $version       The version of Event Espresso where the error was added
239
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
240
-     *                              for a deprecated function. This allows deprecation to occur during one version,
241
-     *                              but not have any notices appear until a later version. This allows developers
242
-     *                              extra time to update their code before notices appear.
243
-     * @param int    $error_type
244
-     * @uses   trigger_error()
245
-     */
246
-    public function doing_it_wrong(
247
-        $function,
248
-        $message,
249
-        $version,
250
-        $applies_when = '',
251
-        $error_type = null
252
-    ) {
253
-        $applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
254
-        $error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
255
-        // because we swapped the parameter order around for the last two params,
256
-        // let's verify that some third party isn't still passing an error type value for the third param
257
-        if (is_int($applies_when)) {
258
-            $error_type = $applies_when;
259
-            $applies_when = espresso_version();
260
-        }
261
-        // if not displaying notices yet, then just leave
262
-        if (version_compare(espresso_version(), $applies_when, '<')) {
263
-            return;
264
-        }
265
-        do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
266
-        $version = $version === null
267
-            ? ''
268
-            : sprintf(
269
-                __('(This message was added in version %s of Event Espresso)', 'event_espresso'),
270
-                $version
271
-            );
272
-        $error_message = sprintf(
273
-            esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
274
-            $function,
275
-            '<strong>',
276
-            '</strong>',
277
-            $message,
278
-            $version
279
-        );
280
-        // don't trigger error if doing ajax,
281
-        // instead we'll add a transient EE_Error notice that in theory should show on the next request.
282
-        if (defined('DOING_AJAX') && DOING_AJAX) {
283
-            $error_message .= ' ' . esc_html__(
284
-                    'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
285
-                    'event_espresso'
286
-                );
287
-            $error_message .= '<ul><li>';
288
-            $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
289
-            $error_message .= '</ul>';
290
-            EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
291
-            //now we set this on the transient so it shows up on the next request.
292
-            EE_Error::get_notices(false, true);
293
-        } else {
294
-            trigger_error($error_message, $error_type);
295
-        }
296
-    }
297
-
298
-
299
-
300
-
301
-    /**
302
-     * Logger helpers
303
-     */
304
-    /**
305
-     * debug
306
-     *
307
-     * @param string $class
308
-     * @param string $func
309
-     * @param string $line
310
-     * @param array  $info
311
-     * @param bool   $display_request
312
-     * @param string $debug_index
313
-     * @param string $debug_key
314
-     * @throws EE_Error
315
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
316
-     */
317
-    public static function log(
318
-        $class = '',
319
-        $func = '',
320
-        $line = '',
321
-        $info = array(),
322
-        $display_request = false,
323
-        $debug_index = '',
324
-        $debug_key = 'EE_DEBUG_SPCO'
325
-    ) {
326
-        if (WP_DEBUG) {
327
-            $debug_key = $debug_key . '_' . EE_Session::instance()->id();
328
-            $debug_data = get_option($debug_key, array());
329
-            $default_data = array(
330
-                $class => $func . '() : ' . $line,
331
-                'REQ'  => $display_request ? $_REQUEST : '',
332
-            );
333
-            // don't serialize objects
334
-            $info = self::strip_objects($info);
335
-            $index = ! empty($debug_index) ? $debug_index : 0;
336
-            if (! isset($debug_data[$index])) {
337
-                $debug_data[$index] = array();
338
-            }
339
-            $debug_data[$index][microtime()] = array_merge($default_data, $info);
340
-            update_option($debug_key, $debug_data);
341
-        }
342
-    }
343
-
344
-
345
-
346
-    /**
347
-     * strip_objects
348
-     *
349
-     * @param array $info
350
-     * @return array
351
-     */
352
-    public static function strip_objects($info = array())
353
-    {
354
-        foreach ($info as $key => $value) {
355
-            if (is_array($value)) {
356
-                $info[$key] = self::strip_objects($value);
357
-            } else if (is_object($value)) {
358
-                $object_class = get_class($value);
359
-                $info[$object_class] = array();
360
-                $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
361
-                if (method_exists($value, 'ID')) {
362
-                    $info[$object_class]['ID'] = $value->ID();
363
-                }
364
-                if (method_exists($value, 'status')) {
365
-                    $info[$object_class]['status'] = $value->status();
366
-                } else if (method_exists($value, 'status_ID')) {
367
-                    $info[$object_class]['status'] = $value->status_ID();
368
-                }
369
-                unset($info[$key]);
370
-            }
371
-        }
372
-        return (array)$info;
373
-    }
374
-
375
-
376
-
377
-    /**
378
-     * @param mixed  $var
379
-     * @param string $var_name
380
-     * @param string $file
381
-     * @param int    $line
382
-     * @param int    $heading_tag
383
-     * @param bool   $die
384
-     * @param string $margin
385
-     */
386
-    public static function printv(
387
-        $var,
388
-        $var_name = '',
389
-        $file = __FILE__,
390
-        $line = __LINE__,
391
-        $heading_tag = 5,
392
-        $die = false,
393
-        $margin = ''
394
-    ) {
395
-        $var_name = ! $var_name ? 'string' : $var_name;
396
-        $var_name = ucwords(str_replace('$', '', $var_name));
397
-        $is_method = method_exists($var_name, $var);
398
-        $var_name = ucwords(str_replace('_', ' ', $var_name));
399
-        $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
400
-        $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
401
-        $result .= $is_method
402
-            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
-            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
404
-        $result .= EEH_Debug_Tools::file_and_line($file, $line);
405
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
406
-        if ($die) {
407
-            die($result);
408
-        }
409
-        echo $result;
410
-    }
411
-
412
-
413
-
414
-    /**
415
-     * @param string $var_name
416
-     * @param string $heading_tag
417
-     * @param string $margin
418
-     * @return string
419
-     */
420
-    protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '')
421
-    {
422
-        if (defined('EE_TESTS_DIR')) {
423
-            return "\n\n{$var_name}";
424
-        }
425
-        $margin = "25px 0 0 {$margin}";
426
-        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * @param string $heading_tag
433
-     * @return string
434
-     */
435
-    protected static function headingX($heading_tag = 'h5')
436
-    {
437
-        if (defined('EE_TESTS_DIR')) {
438
-            return "\n";
439
-        }
440
-        return '</' . $heading_tag . '>';
441
-    }
442
-
443
-
444
-
445
-    /**
446
-     * @param string $content
447
-     * @return string
448
-     */
449
-    protected static function grey_span($content = '')
450
-    {
451
-        if (defined('EE_TESTS_DIR')) {
452
-            return $content;
453
-        }
454
-        return '<span style="color:#999">' . $content . '</span>';
455
-    }
456
-
457
-
458
-
459
-    /**
460
-     * @param string $file
461
-     * @param int    $line
462
-     * @return string
463
-     */
464
-    protected static function file_and_line($file, $line)
465
-    {
466
-        if (defined('EE_TESTS_DIR')) {
467
-            return "\n (" . $file . ' line no: ' . $line . ' ) ';
468
-        }
469
-        return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
470
-               . $file
471
-               . '<br />line no: '
472
-               . $line
473
-               . '</span>';
474
-    }
475
-
476
-
477
-
478
-    /**
479
-     * @param string $content
480
-     * @return string
481
-     */
482
-    protected static function orange_span($content = '')
483
-    {
484
-        if (defined('EE_TESTS_DIR')) {
485
-            return $content;
486
-        }
487
-        return '<span style="color:#E76700">' . $content . '</span>';
488
-    }
489
-
490
-
491
-
492
-    /**
493
-     * @param mixed $var
494
-     * @return string
495
-     */
496
-    protected static function pre_span($var)
497
-    {
498
-        ob_start();
499
-        var_dump($var);
500
-        $var = ob_get_clean();
501
-        if (defined('EE_TESTS_DIR')) {
502
-            return "\n" . $var;
503
-        }
504
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
505
-    }
506
-
507
-
508
-
509
-    /**
510
-     * @param mixed  $var
511
-     * @param string $var_name
512
-     * @param string $file
513
-     * @param int    $line
514
-     * @param int    $heading_tag
515
-     * @param bool   $die
516
-     */
517
-    public static function printr(
518
-        $var,
519
-        $var_name = '',
520
-        $file = __FILE__,
521
-        $line = __LINE__,
522
-        $heading_tag = 5,
523
-        $die = false
524
-    ) {
525
-        // return;
526
-        $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
527
-        $margin = is_admin() ? ' 180px' : '0';
528
-        //$print_r = false;
529
-        if (is_string($var)) {
530
-            EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
531
-            return;
532
-        }
533
-        if (is_object($var)) {
534
-            $var_name = ! $var_name ? 'object' : $var_name;
535
-            //$print_r = true;
536
-        } else if (is_array($var)) {
537
-            $var_name = ! $var_name ? 'array' : $var_name;
538
-            //$print_r = true;
539
-        } else if (is_numeric($var)) {
540
-            $var_name = ! $var_name ? 'numeric' : $var_name;
541
-        } else if ($var === null) {
542
-            $var_name = ! $var_name ? 'null' : $var_name;
543
-        }
544
-        $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
545
-        $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
546
-        $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
547
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
548
-                EEH_Debug_Tools::pre_span($var)
549
-            );
550
-        $result .= EEH_Debug_Tools::file_and_line($file, $line);
551
-        $result .= EEH_Debug_Tools::headingX($heading_tag);
552
-        if ($die) {
553
-            die($result);
554
-        }
555
-        echo $result;
556
-    }
557
-
558
-
559
-
560
-    /******************** deprecated ********************/
561
-    /**
562
-     * @deprecated 4.9.39.rc.034
563
-     */
564
-    public function reset_times()
565
-    {
566
-        Benchmark::resetTimes();
567
-    }
568
-
569
-
570
-
571
-    /**
572
-     * @deprecated 4.9.39.rc.034
573
-     * @param null $timer_name
574
-     */
575
-    public function start_timer($timer_name = null)
576
-    {
577
-        Benchmark::startTimer($timer_name);
578
-    }
579
-
580
-
581
-
582
-    /**
583
-     * @deprecated 4.9.39.rc.034
584
-     * @param string $timer_name
585
-     */
586
-    public function stop_timer($timer_name = '')
587
-    {
588
-        Benchmark::stopTimer($timer_name);
589
-    }
590
-
591
-
592
-
593
-    /**
594
-     * @deprecated 4.9.39.rc.034
595
-     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
596
-     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
597
-     * @return void
598
-     */
599
-    public function measure_memory($label, $output_now = false)
600
-    {
601
-        Benchmark::measureMemory($label, $output_now);
602
-    }
603
-
604
-
605
-
606
-    /**
607
-     * @deprecated 4.9.39.rc.034
608
-     * @param int $size
609
-     * @return string
610
-     */
611
-    public function convert($size)
612
-    {
613
-        return Benchmark::convert($size);
614
-    }
615
-
616
-
617
-
618
-    /**
619
-     * @deprecated 4.9.39.rc.034
620
-     * @param bool $output_now
621
-     * @return string
622
-     */
623
-    public function show_times($output_now = true)
624
-    {
625
-        return Benchmark::displayResults($output_now);
626
-    }
627
-
628
-
629
-
630
-    /**
631
-     * @deprecated 4.9.39.rc.034
632
-     * @param string $timer_name
633
-     * @param float  $total_time
634
-     * @return string
635
-     */
636
-    public function format_time($timer_name, $total_time)
637
-    {
638
-        return Benchmark::formatTime($timer_name, $total_time);
639
-    }
20
+	/**
21
+	 *    instance of the EEH_Autoloader object
22
+	 *
23
+	 * @var    $_instance
24
+	 * @access    private
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var array
30
+	 */
31
+	protected $_memory_usage_points = array();
32
+
33
+
34
+
35
+	/**
36
+	 * @singleton method used to instantiate class object
37
+	 * @access    public
38
+	 * @return EEH_Debug_Tools
39
+	 */
40
+	public static function instance()
41
+	{
42
+		// check if class object is instantiated, and instantiated properly
43
+		if (! self::$_instance instanceof EEH_Debug_Tools) {
44
+			self::$_instance = new self();
45
+		}
46
+		return self::$_instance;
47
+	}
48
+
49
+
50
+
51
+	/**
52
+	 * private class constructor
53
+	 */
54
+	private function __construct()
55
+	{
56
+		// load Kint PHP debugging library
57
+		if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
58
+			// despite EE4 having a check for an existing copy of the Kint debugging class,
59
+			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
60
+			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
61
+			// so we've moved it to our test folder so that it is not included with production releases
62
+			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
63
+			require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
64
+		}
65
+		// if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
66
+		//add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
67
+		// }
68
+		$plugin = basename(EE_PLUGIN_DIR_PATH);
69
+		add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
70
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
71
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
72
+	}
73
+
74
+
75
+
76
+	/**
77
+	 *    show_db_name
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public static function show_db_name()
82
+	{
83
+		if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
84
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
85
+				 . DB_NAME
86
+				 . '</p>';
87
+		}
88
+		if (EE_DEBUG) {
89
+			Benchmark::displayResults();
90
+		}
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 *    dump EE_Session object at bottom of page after everything else has happened
97
+	 *
98
+	 * @return void
99
+	 */
100
+	public function espresso_session_footer_dump()
101
+	{
102
+		if (
103
+			(defined('WP_DEBUG') && WP_DEBUG)
104
+			&& ! defined('DOING_AJAX')
105
+			&& class_exists('Kint')
106
+			&& function_exists('wp_get_current_user')
107
+			&& current_user_can('update_core')
108
+			&& class_exists('EE_Registry')
109
+		) {
110
+			Kint::dump(EE_Registry::instance()->SSN->id());
111
+			Kint::dump(EE_Registry::instance()->SSN);
112
+			//			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
113
+			$this->espresso_list_hooked_functions();
114
+			Benchmark::displayResults();
115
+		}
116
+	}
117
+
118
+
119
+
120
+	/**
121
+	 *    List All Hooked Functions
122
+	 *    to list all functions for a specific hook, add ee_list_hooks={hook-name} to URL
123
+	 *    http://wp.smashingmagazine.com/2009/08/18/10-useful-wordpress-hook-hacks/
124
+	 *
125
+	 * @param string $tag
126
+	 * @return void
127
+	 */
128
+	public function espresso_list_hooked_functions($tag = '')
129
+	{
130
+		global $wp_filter;
131
+		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
132
+		if ($tag) {
133
+			$hook[$tag] = $wp_filter[$tag];
134
+			if (! is_array($hook[$tag])) {
135
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
136
+				return;
137
+			}
138
+			echo '<h5>For Tag: ' . $tag . '</h5>';
139
+		} else {
140
+			$hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
141
+			ksort($hook);
142
+		}
143
+		foreach ($hook as $tag_name => $priorities) {
144
+			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
145
+			ksort($priorities);
146
+			foreach ($priorities as $priority => $function) {
147
+				echo $priority;
148
+				foreach ($function as $name => $properties) {
149
+					echo "\t$name<br />";
150
+				}
151
+			}
152
+		}
153
+	}
154
+
155
+
156
+
157
+	/**
158
+	 *    registered_filter_callbacks
159
+	 *
160
+	 * @param string $hook_name
161
+	 * @return array
162
+	 */
163
+	public static function registered_filter_callbacks($hook_name = '')
164
+	{
165
+		$filters = array();
166
+		global $wp_filter;
167
+		if (isset($wp_filter[$hook_name])) {
168
+			$filters[$hook_name] = array();
169
+			foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
170
+				$filters[$hook_name][$priority] = array();
171
+				foreach ($callbacks as $callback) {
172
+					$filters[$hook_name][$priority][] = $callback['function'];
173
+				}
174
+			}
175
+		}
176
+		return $filters;
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 *    captures plugin activation errors for debugging
183
+	 *
184
+	 * @return void
185
+	 * @throws EE_Error
186
+	 */
187
+	public static function ee_plugin_activation_errors()
188
+	{
189
+		if (WP_DEBUG) {
190
+			$activation_errors = ob_get_contents();
191
+			if (! empty($activation_errors)) {
192
+				$activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
193
+			}
194
+			espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
195
+			if (class_exists('EEH_File')) {
196
+				try {
197
+					EEH_File::ensure_file_exists_and_is_writable(
198
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
199
+					);
200
+					EEH_File::write_to_file(
201
+						EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
202
+						$activation_errors
203
+					);
204
+				} catch (EE_Error $e) {
205
+					EE_Error::add_error(
206
+						sprintf(
207
+							__(
208
+								'The Event Espresso activation errors file could not be setup because: %s',
209
+								'event_espresso'
210
+							),
211
+							$e->getMessage()
212
+						),
213
+						__FILE__, __FUNCTION__, __LINE__
214
+					);
215
+				}
216
+			} else {
217
+				// old school attempt
218
+				file_put_contents(
219
+					EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
220
+					$activation_errors
221
+				);
222
+			}
223
+			$activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
224
+			update_option('ee_plugin_activation_errors', $activation_errors);
225
+		}
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 * This basically mimics the WordPress _doing_it_wrong() function except adds our own messaging etc.
232
+	 * Very useful for providing helpful messages to developers when the method of doing something has been deprecated,
233
+	 * or we want to make sure they use something the right way.
234
+	 *
235
+	 * @access public
236
+	 * @param string $function      The function that was called
237
+	 * @param string $message       A message explaining what has been done incorrectly
238
+	 * @param string $version       The version of Event Espresso where the error was added
239
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
240
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
241
+	 *                              but not have any notices appear until a later version. This allows developers
242
+	 *                              extra time to update their code before notices appear.
243
+	 * @param int    $error_type
244
+	 * @uses   trigger_error()
245
+	 */
246
+	public function doing_it_wrong(
247
+		$function,
248
+		$message,
249
+		$version,
250
+		$applies_when = '',
251
+		$error_type = null
252
+	) {
253
+		$applies_when = ! empty($applies_when) ? $applies_when : espresso_version();
254
+		$error_type = $error_type !== null ? $error_type : E_USER_NOTICE;
255
+		// because we swapped the parameter order around for the last two params,
256
+		// let's verify that some third party isn't still passing an error type value for the third param
257
+		if (is_int($applies_when)) {
258
+			$error_type = $applies_when;
259
+			$applies_when = espresso_version();
260
+		}
261
+		// if not displaying notices yet, then just leave
262
+		if (version_compare(espresso_version(), $applies_when, '<')) {
263
+			return;
264
+		}
265
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
266
+		$version = $version === null
267
+			? ''
268
+			: sprintf(
269
+				__('(This message was added in version %s of Event Espresso)', 'event_espresso'),
270
+				$version
271
+			);
272
+		$error_message = sprintf(
273
+			esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'),
274
+			$function,
275
+			'<strong>',
276
+			'</strong>',
277
+			$message,
278
+			$version
279
+		);
280
+		// don't trigger error if doing ajax,
281
+		// instead we'll add a transient EE_Error notice that in theory should show on the next request.
282
+		if (defined('DOING_AJAX') && DOING_AJAX) {
283
+			$error_message .= ' ' . esc_html__(
284
+					'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
285
+					'event_espresso'
286
+				);
287
+			$error_message .= '<ul><li>';
288
+			$error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
289
+			$error_message .= '</ul>';
290
+			EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
291
+			//now we set this on the transient so it shows up on the next request.
292
+			EE_Error::get_notices(false, true);
293
+		} else {
294
+			trigger_error($error_message, $error_type);
295
+		}
296
+	}
297
+
298
+
299
+
300
+
301
+	/**
302
+	 * Logger helpers
303
+	 */
304
+	/**
305
+	 * debug
306
+	 *
307
+	 * @param string $class
308
+	 * @param string $func
309
+	 * @param string $line
310
+	 * @param array  $info
311
+	 * @param bool   $display_request
312
+	 * @param string $debug_index
313
+	 * @param string $debug_key
314
+	 * @throws EE_Error
315
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
316
+	 */
317
+	public static function log(
318
+		$class = '',
319
+		$func = '',
320
+		$line = '',
321
+		$info = array(),
322
+		$display_request = false,
323
+		$debug_index = '',
324
+		$debug_key = 'EE_DEBUG_SPCO'
325
+	) {
326
+		if (WP_DEBUG) {
327
+			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
328
+			$debug_data = get_option($debug_key, array());
329
+			$default_data = array(
330
+				$class => $func . '() : ' . $line,
331
+				'REQ'  => $display_request ? $_REQUEST : '',
332
+			);
333
+			// don't serialize objects
334
+			$info = self::strip_objects($info);
335
+			$index = ! empty($debug_index) ? $debug_index : 0;
336
+			if (! isset($debug_data[$index])) {
337
+				$debug_data[$index] = array();
338
+			}
339
+			$debug_data[$index][microtime()] = array_merge($default_data, $info);
340
+			update_option($debug_key, $debug_data);
341
+		}
342
+	}
343
+
344
+
345
+
346
+	/**
347
+	 * strip_objects
348
+	 *
349
+	 * @param array $info
350
+	 * @return array
351
+	 */
352
+	public static function strip_objects($info = array())
353
+	{
354
+		foreach ($info as $key => $value) {
355
+			if (is_array($value)) {
356
+				$info[$key] = self::strip_objects($value);
357
+			} else if (is_object($value)) {
358
+				$object_class = get_class($value);
359
+				$info[$object_class] = array();
360
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
361
+				if (method_exists($value, 'ID')) {
362
+					$info[$object_class]['ID'] = $value->ID();
363
+				}
364
+				if (method_exists($value, 'status')) {
365
+					$info[$object_class]['status'] = $value->status();
366
+				} else if (method_exists($value, 'status_ID')) {
367
+					$info[$object_class]['status'] = $value->status_ID();
368
+				}
369
+				unset($info[$key]);
370
+			}
371
+		}
372
+		return (array)$info;
373
+	}
374
+
375
+
376
+
377
+	/**
378
+	 * @param mixed  $var
379
+	 * @param string $var_name
380
+	 * @param string $file
381
+	 * @param int    $line
382
+	 * @param int    $heading_tag
383
+	 * @param bool   $die
384
+	 * @param string $margin
385
+	 */
386
+	public static function printv(
387
+		$var,
388
+		$var_name = '',
389
+		$file = __FILE__,
390
+		$line = __LINE__,
391
+		$heading_tag = 5,
392
+		$die = false,
393
+		$margin = ''
394
+	) {
395
+		$var_name = ! $var_name ? 'string' : $var_name;
396
+		$var_name = ucwords(str_replace('$', '', $var_name));
397
+		$is_method = method_exists($var_name, $var);
398
+		$var_name = ucwords(str_replace('_', ' ', $var_name));
399
+		$heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
400
+		$result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
401
+		$result .= $is_method
402
+			? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
+			: EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
404
+		$result .= EEH_Debug_Tools::file_and_line($file, $line);
405
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
406
+		if ($die) {
407
+			die($result);
408
+		}
409
+		echo $result;
410
+	}
411
+
412
+
413
+
414
+	/**
415
+	 * @param string $var_name
416
+	 * @param string $heading_tag
417
+	 * @param string $margin
418
+	 * @return string
419
+	 */
420
+	protected static function heading($var_name = '', $heading_tag = 'h5', $margin = '')
421
+	{
422
+		if (defined('EE_TESTS_DIR')) {
423
+			return "\n\n{$var_name}";
424
+		}
425
+		$margin = "25px 0 0 {$margin}";
426
+		return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * @param string $heading_tag
433
+	 * @return string
434
+	 */
435
+	protected static function headingX($heading_tag = 'h5')
436
+	{
437
+		if (defined('EE_TESTS_DIR')) {
438
+			return "\n";
439
+		}
440
+		return '</' . $heading_tag . '>';
441
+	}
442
+
443
+
444
+
445
+	/**
446
+	 * @param string $content
447
+	 * @return string
448
+	 */
449
+	protected static function grey_span($content = '')
450
+	{
451
+		if (defined('EE_TESTS_DIR')) {
452
+			return $content;
453
+		}
454
+		return '<span style="color:#999">' . $content . '</span>';
455
+	}
456
+
457
+
458
+
459
+	/**
460
+	 * @param string $file
461
+	 * @param int    $line
462
+	 * @return string
463
+	 */
464
+	protected static function file_and_line($file, $line)
465
+	{
466
+		if (defined('EE_TESTS_DIR')) {
467
+			return "\n (" . $file . ' line no: ' . $line . ' ) ';
468
+		}
469
+		return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
470
+			   . $file
471
+			   . '<br />line no: '
472
+			   . $line
473
+			   . '</span>';
474
+	}
475
+
476
+
477
+
478
+	/**
479
+	 * @param string $content
480
+	 * @return string
481
+	 */
482
+	protected static function orange_span($content = '')
483
+	{
484
+		if (defined('EE_TESTS_DIR')) {
485
+			return $content;
486
+		}
487
+		return '<span style="color:#E76700">' . $content . '</span>';
488
+	}
489
+
490
+
491
+
492
+	/**
493
+	 * @param mixed $var
494
+	 * @return string
495
+	 */
496
+	protected static function pre_span($var)
497
+	{
498
+		ob_start();
499
+		var_dump($var);
500
+		$var = ob_get_clean();
501
+		if (defined('EE_TESTS_DIR')) {
502
+			return "\n" . $var;
503
+		}
504
+		return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
505
+	}
506
+
507
+
508
+
509
+	/**
510
+	 * @param mixed  $var
511
+	 * @param string $var_name
512
+	 * @param string $file
513
+	 * @param int    $line
514
+	 * @param int    $heading_tag
515
+	 * @param bool   $die
516
+	 */
517
+	public static function printr(
518
+		$var,
519
+		$var_name = '',
520
+		$file = __FILE__,
521
+		$line = __LINE__,
522
+		$heading_tag = 5,
523
+		$die = false
524
+	) {
525
+		// return;
526
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
527
+		$margin = is_admin() ? ' 180px' : '0';
528
+		//$print_r = false;
529
+		if (is_string($var)) {
530
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $heading_tag, $die, $margin);
531
+			return;
532
+		}
533
+		if (is_object($var)) {
534
+			$var_name = ! $var_name ? 'object' : $var_name;
535
+			//$print_r = true;
536
+		} else if (is_array($var)) {
537
+			$var_name = ! $var_name ? 'array' : $var_name;
538
+			//$print_r = true;
539
+		} else if (is_numeric($var)) {
540
+			$var_name = ! $var_name ? 'numeric' : $var_name;
541
+		} else if ($var === null) {
542
+			$var_name = ! $var_name ? 'null' : $var_name;
543
+		}
544
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
545
+		$heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
546
+		$result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
547
+		$result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
548
+				EEH_Debug_Tools::pre_span($var)
549
+			);
550
+		$result .= EEH_Debug_Tools::file_and_line($file, $line);
551
+		$result .= EEH_Debug_Tools::headingX($heading_tag);
552
+		if ($die) {
553
+			die($result);
554
+		}
555
+		echo $result;
556
+	}
557
+
558
+
559
+
560
+	/******************** deprecated ********************/
561
+	/**
562
+	 * @deprecated 4.9.39.rc.034
563
+	 */
564
+	public function reset_times()
565
+	{
566
+		Benchmark::resetTimes();
567
+	}
568
+
569
+
570
+
571
+	/**
572
+	 * @deprecated 4.9.39.rc.034
573
+	 * @param null $timer_name
574
+	 */
575
+	public function start_timer($timer_name = null)
576
+	{
577
+		Benchmark::startTimer($timer_name);
578
+	}
579
+
580
+
581
+
582
+	/**
583
+	 * @deprecated 4.9.39.rc.034
584
+	 * @param string $timer_name
585
+	 */
586
+	public function stop_timer($timer_name = '')
587
+	{
588
+		Benchmark::stopTimer($timer_name);
589
+	}
590
+
591
+
592
+
593
+	/**
594
+	 * @deprecated 4.9.39.rc.034
595
+	 * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
596
+	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
597
+	 * @return void
598
+	 */
599
+	public function measure_memory($label, $output_now = false)
600
+	{
601
+		Benchmark::measureMemory($label, $output_now);
602
+	}
603
+
604
+
605
+
606
+	/**
607
+	 * @deprecated 4.9.39.rc.034
608
+	 * @param int $size
609
+	 * @return string
610
+	 */
611
+	public function convert($size)
612
+	{
613
+		return Benchmark::convert($size);
614
+	}
615
+
616
+
617
+
618
+	/**
619
+	 * @deprecated 4.9.39.rc.034
620
+	 * @param bool $output_now
621
+	 * @return string
622
+	 */
623
+	public function show_times($output_now = true)
624
+	{
625
+		return Benchmark::displayResults($output_now);
626
+	}
627
+
628
+
629
+
630
+	/**
631
+	 * @deprecated 4.9.39.rc.034
632
+	 * @param string $timer_name
633
+	 * @param float  $total_time
634
+	 * @return string
635
+	 */
636
+	public function format_time($timer_name, $total_time)
637
+	{
638
+		return Benchmark::formatTime($timer_name, $total_time);
639
+	}
640 640
 
641 641
 
642 642
 
@@ -649,31 +649,31 @@  discard block
 block discarded – undo
649 649
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
650 650
  */
651 651
 if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
652
-    function dump_wp_query()
653
-    {
654
-        global $wp_query;
655
-        d($wp_query);
656
-    }
652
+	function dump_wp_query()
653
+	{
654
+		global $wp_query;
655
+		d($wp_query);
656
+	}
657 657
 }
658 658
 /**
659 659
  * borrowed from Kint Debugger
660 660
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
661 661
  */
662 662
 if (class_exists('Kint') && ! function_exists('dump_wp')) {
663
-    function dump_wp()
664
-    {
665
-        global $wp;
666
-        d($wp);
667
-    }
663
+	function dump_wp()
664
+	{
665
+		global $wp;
666
+		d($wp);
667
+	}
668 668
 }
669 669
 /**
670 670
  * borrowed from Kint Debugger
671 671
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
672 672
  */
673 673
 if (class_exists('Kint') && ! function_exists('dump_post')) {
674
-    function dump_post()
675
-    {
676
-        global $post;
677
-        d($post);
678
-    }
674
+	function dump_post()
675
+	{
676
+		global $post;
677
+		d($post);
678
+	}
679 679
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\services\Benchmark;
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public static function instance()
41 41
     {
42 42
         // check if class object is instantiated, and instantiated properly
43
-        if (! self::$_instance instanceof EEH_Debug_Tools) {
43
+        if ( ! self::$_instance instanceof EEH_Debug_Tools) {
44 44
             self::$_instance = new self();
45 45
         }
46 46
         return self::$_instance;
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
     private function __construct()
55 55
     {
56 56
         // load Kint PHP debugging library
57
-        if (! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php')) {
57
+        if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) {
58 58
             // despite EE4 having a check for an existing copy of the Kint debugging class,
59 59
             // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
60 60
             // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
61 61
             // so we've moved it to our test folder so that it is not included with production releases
62 62
             // plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
63
-            require_once(EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php');
63
+            require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php');
64 64
         }
65 65
         // if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
66 66
         //add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public static function show_db_name()
82 82
     {
83
-        if (! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
83
+        if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
84 84
             echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '
85 85
                  . DB_NAME
86 86
                  . '</p>';
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
         echo '<br/><br/><br/><h3>Hooked Functions</h3>';
132 132
         if ($tag) {
133 133
             $hook[$tag] = $wp_filter[$tag];
134
-            if (! is_array($hook[$tag])) {
134
+            if ( ! is_array($hook[$tag])) {
135 135
                 trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
136 136
                 return;
137 137
             }
138
-            echo '<h5>For Tag: ' . $tag . '</h5>';
138
+            echo '<h5>For Tag: '.$tag.'</h5>';
139 139
         } else {
140 140
             $hook = is_array($wp_filter) ? $wp_filter : array($wp_filter);
141 141
             ksort($hook);
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
     {
189 189
         if (WP_DEBUG) {
190 190
             $activation_errors = ob_get_contents();
191
-            if (! empty($activation_errors)) {
192
-                $activation_errors = date('Y-m-d H:i:s') . "\n" . $activation_errors;
191
+            if ( ! empty($activation_errors)) {
192
+                $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors;
193 193
             }
194
-            espresso_load_required('EEH_File', EE_HELPERS . 'EEH_File.helper.php');
194
+            espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php');
195 195
             if (class_exists('EEH_File')) {
196 196
                 try {
197 197
                     EEH_File::ensure_file_exists_and_is_writable(
198
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html'
198
+                        EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'
199 199
                     );
200 200
                     EEH_File::write_to_file(
201
-                        EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
201
+                        EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html',
202 202
                         $activation_errors
203 203
                     );
204 204
                 } catch (EE_Error $e) {
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
             } else {
217 217
                 // old school attempt
218 218
                 file_put_contents(
219
-                    EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html',
219
+                    EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html',
220 220
                     $activation_errors
221 221
                 );
222 222
             }
223
-            $activation_errors = get_option('ee_plugin_activation_errors', '') . $activation_errors;
223
+            $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors;
224 224
             update_option('ee_plugin_activation_errors', $activation_errors);
225 225
         }
226 226
     }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         // don't trigger error if doing ajax,
281 281
         // instead we'll add a transient EE_Error notice that in theory should show on the next request.
282 282
         if (defined('DOING_AJAX') && DOING_AJAX) {
283
-            $error_message .= ' ' . esc_html__(
283
+            $error_message .= ' '.esc_html__(
284 284
                     'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ',
285 285
                     'event_espresso'
286 286
                 );
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
         $debug_key = 'EE_DEBUG_SPCO'
325 325
     ) {
326 326
         if (WP_DEBUG) {
327
-            $debug_key = $debug_key . '_' . EE_Session::instance()->id();
327
+            $debug_key = $debug_key.'_'.EE_Session::instance()->id();
328 328
             $debug_data = get_option($debug_key, array());
329 329
             $default_data = array(
330
-                $class => $func . '() : ' . $line,
330
+                $class => $func.'() : '.$line,
331 331
                 'REQ'  => $display_request ? $_REQUEST : '',
332 332
             );
333 333
             // don't serialize objects
334 334
             $info = self::strip_objects($info);
335 335
             $index = ! empty($debug_index) ? $debug_index : 0;
336
-            if (! isset($debug_data[$index])) {
336
+            if ( ! isset($debug_data[$index])) {
337 337
                 $debug_data[$index] = array();
338 338
             }
339 339
             $debug_data[$index][microtime()] = array_merge($default_data, $info);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
                 unset($info[$key]);
370 370
             }
371 371
         }
372
-        return (array)$info;
372
+        return (array) $info;
373 373
     }
374 374
 
375 375
 
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
         $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
400 400
         $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
401 401
         $result .= $is_method
402
-            ? EEH_Debug_Tools::grey_span('::') . EEH_Debug_Tools::orange_span($var . '()')
403
-            : EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span($var);
402
+            ? EEH_Debug_Tools::grey_span('::').EEH_Debug_Tools::orange_span($var.'()')
403
+            : EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span($var);
404 404
         $result .= EEH_Debug_Tools::file_and_line($file, $line);
405 405
         $result .= EEH_Debug_Tools::headingX($heading_tag);
406 406
         if ($die) {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             return "\n\n{$var_name}";
424 424
         }
425 425
         $margin = "25px 0 0 {$margin}";
426
-        return '<' . $heading_tag . ' style="color:#2EA2CC; margin:' . $margin . ';"><b>' . $var_name . '</b>';
426
+        return '<'.$heading_tag.' style="color:#2EA2CC; margin:'.$margin.';"><b>'.$var_name.'</b>';
427 427
     }
428 428
 
429 429
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         if (defined('EE_TESTS_DIR')) {
438 438
             return "\n";
439 439
         }
440
-        return '</' . $heading_tag . '>';
440
+        return '</'.$heading_tag.'>';
441 441
     }
442 442
 
443 443
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
         if (defined('EE_TESTS_DIR')) {
452 452
             return $content;
453 453
         }
454
-        return '<span style="color:#999">' . $content . '</span>';
454
+        return '<span style="color:#999">'.$content.'</span>';
455 455
     }
456 456
 
457 457
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
     protected static function file_and_line($file, $line)
465 465
     {
466 466
         if (defined('EE_TESTS_DIR')) {
467
-            return "\n (" . $file . ' line no: ' . $line . ' ) ';
467
+            return "\n (".$file.' line no: '.$line.' ) ';
468 468
         }
469 469
         return '<br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'
470 470
                . $file
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
         if (defined('EE_TESTS_DIR')) {
485 485
             return $content;
486 486
         }
487
-        return '<span style="color:#E76700">' . $content . '</span>';
487
+        return '<span style="color:#E76700">'.$content.'</span>';
488 488
     }
489 489
 
490 490
 
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
         var_dump($var);
500 500
         $var = ob_get_clean();
501 501
         if (defined('EE_TESTS_DIR')) {
502
-            return "\n" . $var;
502
+            return "\n".$var;
503 503
         }
504
-        return '<pre style="color:#999; padding:1em; background: #fff">' . $var . '</pre>';
504
+        return '<pre style="color:#999; padding:1em; background: #fff">'.$var.'</pre>';
505 505
     }
506 506
 
507 507
 
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
545 545
         $heading_tag = is_int($heading_tag) ? "h{$heading_tag}" : 'h5';
546 546
         $result = EEH_Debug_Tools::heading($var_name, $heading_tag, $margin);
547
-        $result .= EEH_Debug_Tools::grey_span(' : ') . EEH_Debug_Tools::orange_span(
547
+        $result .= EEH_Debug_Tools::grey_span(' : ').EEH_Debug_Tools::orange_span(
548 548
                 EEH_Debug_Tools::pre_span($var)
549 549
             );
550 550
         $result .= EEH_Debug_Tools::file_and_line($file, $line);
Please login to merge, or discard this patch.
core/services/Benchmark.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         add_action(
124 124
             'shutdown',
125
-            function () {
125
+            function() {
126 126
                 Benchmark::displayResults();
127 127
             }
128 128
         );
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
             return '';
143 143
         }
144 144
         $output = '';
145
-        if (! empty(Benchmark::$times)) {
145
+        if ( ! empty(Benchmark::$times)) {
146 146
             $total = 0;
147 147
             $output .= '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />';
148 148
             foreach (Benchmark::$times as $timer_name => $total_time) {
149
-                $output .= Benchmark::formatTime($timer_name, $total_time) . '<br />';
149
+                $output .= Benchmark::formatTime($timer_name, $total_time).'<br />';
150 150
                 $total += $total_time;
151 151
             }
152 152
             $output .= '<br />';
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
             $output .= '<span style="color:darkorange">Zoinks!</span><br />';
163 163
             $output .= '<span style="color:red">Like...HEEELLLP</span><br />';
164 164
         }
165
-        if (! empty(Benchmark::$memory_usage)) {
166
-            $output .= '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage);
165
+        if ( ! empty(Benchmark::$memory_usage)) {
166
+            $output .= '<h5>Memory</h5>'.implode('<br />', Benchmark::$memory_usage);
167 167
         }
168 168
         if (empty($output)) {
169 169
             return '';
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     public static function convert($size)
193 193
     {
194 194
         $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
195
-        return round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[absint($i)];
195
+        return round($size / pow(1024, $i = floor(log($size, 1024))), 2).' '.$unit[absint($i)];
196 196
     }
197 197
 
198 198
 
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -17,229 +17,229 @@
 block discarded – undo
17 17
 class Benchmark
18 18
 {
19 19
 
20
-    /**
21
-     * array containing the start time for the timers
22
-     */
23
-    private static $start_times;
24
-
25
-    /**
26
-     * array containing all the timer'd times, which can be outputted via show_times()
27
-     */
28
-    private static $times = array();
29
-
30
-    /**
31
-     * @var array
32
-     */
33
-    protected static $memory_usage = array();
34
-
35
-
36
-
37
-    /**
38
-     * whether to benchmark code or not
39
-     */
40
-    public static function doNotRun()
41
-    {
42
-        return ! WP_DEBUG || (defined('DOING_AJAX') && DOING_AJAX);
43
-    }
44
-
45
-
46
-
47
-    /**
48
-     * resetTimes
49
-     */
50
-    public static function resetTimes()
51
-    {
52
-        Benchmark::$times = array();
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * Add Benchmark::startTimer() before a block of code you want to measure the performance of
59
-     *
60
-     * @param null $timer_name
61
-     */
62
-    public static function startTimer($timer_name = null)
63
-    {
64
-        if (Benchmark::doNotRun()) {
65
-            return;
66
-        }
67
-        $timer_name = $timer_name !== '' ? $timer_name : get_called_class();
68
-        Benchmark::$start_times[$timer_name] = microtime(true);
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * Add Benchmark::stopTimer() after a block of code you want to measure the performance of
75
-     *
76
-     * @param string $timer_name
77
-     */
78
-    public static function stopTimer($timer_name = '')
79
-    {
80
-        if (Benchmark::doNotRun()) {
81
-            return;
82
-        }
83
-        $timer_name = $timer_name !== '' ? $timer_name : get_called_class();
84
-        if (isset(Benchmark::$start_times[$timer_name])) {
85
-            $start_time = Benchmark::$start_times[$timer_name];
86
-            unset(Benchmark::$start_times[$timer_name]);
87
-        } else {
88
-            $start_time = array_pop(Benchmark::$start_times);
89
-        }
90
-        Benchmark::$times[$timer_name] = number_format(microtime(true) - $start_time, 8);
91
-    }
92
-
93
-
94
-
95
-    /**
96
-     * Measure the memory usage by PHP so far.
97
-     *
98
-     * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
99
-     * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
100
-     * @return void
101
-     */
102
-    public static function measureMemory($label, $output_now = false)
103
-    {
104
-        if (Benchmark::doNotRun()) {
105
-            return;
106
-        }
107
-        $memory_used = Benchmark::convert(memory_get_peak_usage(true));
108
-        Benchmark::$memory_usage[$label] = $memory_used;
109
-        if ($output_now) {
110
-            echo "\r\n<br>$label : $memory_used";
111
-        }
112
-    }
113
-
114
-
115
-
116
-    /**
117
-     * will display the benchmarking results at shutdown
118
-     *
119
-     * @return void
120
-     */
121
-    public static function displayResultsAtShutdown()
122
-    {
123
-        add_action(
124
-            'shutdown',
125
-            function () {
126
-                Benchmark::displayResults();
127
-            }
128
-        );
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     * displayResults
135
-     *
136
-     * @param bool $echo
137
-     * @return string
138
-     */
139
-    public static function displayResults($echo = true)
140
-    {
141
-        if (Benchmark::doNotRun()) {
142
-            return '';
143
-        }
144
-        $output = '';
145
-        if (! empty(Benchmark::$times)) {
146
-            $total = 0;
147
-            $output .= '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />';
148
-            foreach (Benchmark::$times as $timer_name => $total_time) {
149
-                $output .= Benchmark::formatTime($timer_name, $total_time) . '<br />';
150
-                $total += $total_time;
151
-            }
152
-            $output .= '<br />';
153
-            $output .= '<h4>TOTAL TIME</h4>';
154
-            $output .= Benchmark::formatTime('', $total);
155
-            $output .= '<span style="color:#999999; font-size:.8em;"> milliseconds</span><br />';
156
-            $output .= '<br />';
157
-            $output .= '<h5>Performance scale (from best to worse)</h5>';
158
-            $output .= '<span style="color:mediumpurple">Like wow! How about a Scooby snack?</span><br />';
159
-            $output .= '<span style="color:deepskyblue">Like...no way man!</span><br />';
160
-            $output .= '<span style="color:limegreen">Like...groovy!</span><br />';
161
-            $output .= '<span style="color:gold">Ruh Oh</span><br />';
162
-            $output .= '<span style="color:darkorange">Zoinks!</span><br />';
163
-            $output .= '<span style="color:red">Like...HEEELLLP</span><br />';
164
-        }
165
-        if (! empty(Benchmark::$memory_usage)) {
166
-            $output .= '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage);
167
-        }
168
-        if (empty($output)) {
169
-            return '';
170
-        }
171
-        $output = '<div style="border:1px solid #dddddd; background-color:#ffffff;'
172
-                  . (is_admin() ? ' margin:2em 2em 2em 180px;' : ' margin:2em;')
173
-                  . ' padding:2em;">'
174
-                  . '<h4>BENCHMARKING</h4>'
175
-                  . $output
176
-                  . '</div>';
177
-        if ($echo) {
178
-            echo $output;
179
-            return '';
180
-        }
181
-        return $output;
182
-    }
183
-
184
-
185
-
186
-    /**
187
-     * Converts a measure of memory bytes into the most logical units (eg kb, mb, etc)
188
-     *
189
-     * @param int $size
190
-     * @return string
191
-     */
192
-    public static function convert($size)
193
-    {
194
-        $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
195
-        return round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[absint($i)];
196
-    }
197
-
198
-
199
-
200
-    /**
201
-     * @param string $timer_name
202
-     * @param float  $total_time
203
-     * @return string
204
-     */
205
-    public static function formatTime($timer_name, $total_time)
206
-    {
207
-        $total_time *= 1000;
208
-        switch ($total_time) {
209
-            case $total_time > 12500 :
210
-                $color = 'red';
211
-                $bold = 'bold';
212
-                break;
213
-            case $total_time > 2500 :
214
-                $color = 'darkorange';
215
-                $bold = 'bold';
216
-                break;
217
-            case $total_time > 500 :
218
-                $color = 'gold';
219
-                $bold = 'bold';
220
-                break;
221
-            case $total_time > 100 :
222
-                $color = 'limegreen';
223
-                $bold = 'normal';
224
-                break;
225
-            case $total_time > 20 :
226
-                $color = 'deepskyblue';
227
-                $bold = 'normal';
228
-                break;
229
-            default :
230
-                $color = 'mediumpurple';
231
-                $bold = 'normal';
232
-                break;
233
-        }
234
-        return '<span style="min-width: 10px; margin:0 1em; color:'
235
-               . $color
236
-               . '; font-weight:'
237
-               . $bold
238
-               . '; font-size:1.2em;">'
239
-               . str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT)
240
-               . '</span> '
241
-               . $timer_name;
242
-    }
20
+	/**
21
+	 * array containing the start time for the timers
22
+	 */
23
+	private static $start_times;
24
+
25
+	/**
26
+	 * array containing all the timer'd times, which can be outputted via show_times()
27
+	 */
28
+	private static $times = array();
29
+
30
+	/**
31
+	 * @var array
32
+	 */
33
+	protected static $memory_usage = array();
34
+
35
+
36
+
37
+	/**
38
+	 * whether to benchmark code or not
39
+	 */
40
+	public static function doNotRun()
41
+	{
42
+		return ! WP_DEBUG || (defined('DOING_AJAX') && DOING_AJAX);
43
+	}
44
+
45
+
46
+
47
+	/**
48
+	 * resetTimes
49
+	 */
50
+	public static function resetTimes()
51
+	{
52
+		Benchmark::$times = array();
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * Add Benchmark::startTimer() before a block of code you want to measure the performance of
59
+	 *
60
+	 * @param null $timer_name
61
+	 */
62
+	public static function startTimer($timer_name = null)
63
+	{
64
+		if (Benchmark::doNotRun()) {
65
+			return;
66
+		}
67
+		$timer_name = $timer_name !== '' ? $timer_name : get_called_class();
68
+		Benchmark::$start_times[$timer_name] = microtime(true);
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * Add Benchmark::stopTimer() after a block of code you want to measure the performance of
75
+	 *
76
+	 * @param string $timer_name
77
+	 */
78
+	public static function stopTimer($timer_name = '')
79
+	{
80
+		if (Benchmark::doNotRun()) {
81
+			return;
82
+		}
83
+		$timer_name = $timer_name !== '' ? $timer_name : get_called_class();
84
+		if (isset(Benchmark::$start_times[$timer_name])) {
85
+			$start_time = Benchmark::$start_times[$timer_name];
86
+			unset(Benchmark::$start_times[$timer_name]);
87
+		} else {
88
+			$start_time = array_pop(Benchmark::$start_times);
89
+		}
90
+		Benchmark::$times[$timer_name] = number_format(microtime(true) - $start_time, 8);
91
+	}
92
+
93
+
94
+
95
+	/**
96
+	 * Measure the memory usage by PHP so far.
97
+	 *
98
+	 * @param string  $label      The label to show for this time eg "Start of calling Some_Class::some_function"
99
+	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
100
+	 * @return void
101
+	 */
102
+	public static function measureMemory($label, $output_now = false)
103
+	{
104
+		if (Benchmark::doNotRun()) {
105
+			return;
106
+		}
107
+		$memory_used = Benchmark::convert(memory_get_peak_usage(true));
108
+		Benchmark::$memory_usage[$label] = $memory_used;
109
+		if ($output_now) {
110
+			echo "\r\n<br>$label : $memory_used";
111
+		}
112
+	}
113
+
114
+
115
+
116
+	/**
117
+	 * will display the benchmarking results at shutdown
118
+	 *
119
+	 * @return void
120
+	 */
121
+	public static function displayResultsAtShutdown()
122
+	{
123
+		add_action(
124
+			'shutdown',
125
+			function () {
126
+				Benchmark::displayResults();
127
+			}
128
+		);
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 * displayResults
135
+	 *
136
+	 * @param bool $echo
137
+	 * @return string
138
+	 */
139
+	public static function displayResults($echo = true)
140
+	{
141
+		if (Benchmark::doNotRun()) {
142
+			return '';
143
+		}
144
+		$output = '';
145
+		if (! empty(Benchmark::$times)) {
146
+			$total = 0;
147
+			$output .= '<span style="color:#999999; font-size:.8em;">( time in milliseconds )</span><br />';
148
+			foreach (Benchmark::$times as $timer_name => $total_time) {
149
+				$output .= Benchmark::formatTime($timer_name, $total_time) . '<br />';
150
+				$total += $total_time;
151
+			}
152
+			$output .= '<br />';
153
+			$output .= '<h4>TOTAL TIME</h4>';
154
+			$output .= Benchmark::formatTime('', $total);
155
+			$output .= '<span style="color:#999999; font-size:.8em;"> milliseconds</span><br />';
156
+			$output .= '<br />';
157
+			$output .= '<h5>Performance scale (from best to worse)</h5>';
158
+			$output .= '<span style="color:mediumpurple">Like wow! How about a Scooby snack?</span><br />';
159
+			$output .= '<span style="color:deepskyblue">Like...no way man!</span><br />';
160
+			$output .= '<span style="color:limegreen">Like...groovy!</span><br />';
161
+			$output .= '<span style="color:gold">Ruh Oh</span><br />';
162
+			$output .= '<span style="color:darkorange">Zoinks!</span><br />';
163
+			$output .= '<span style="color:red">Like...HEEELLLP</span><br />';
164
+		}
165
+		if (! empty(Benchmark::$memory_usage)) {
166
+			$output .= '<h5>Memory</h5>' . implode('<br />', Benchmark::$memory_usage);
167
+		}
168
+		if (empty($output)) {
169
+			return '';
170
+		}
171
+		$output = '<div style="border:1px solid #dddddd; background-color:#ffffff;'
172
+				  . (is_admin() ? ' margin:2em 2em 2em 180px;' : ' margin:2em;')
173
+				  . ' padding:2em;">'
174
+				  . '<h4>BENCHMARKING</h4>'
175
+				  . $output
176
+				  . '</div>';
177
+		if ($echo) {
178
+			echo $output;
179
+			return '';
180
+		}
181
+		return $output;
182
+	}
183
+
184
+
185
+
186
+	/**
187
+	 * Converts a measure of memory bytes into the most logical units (eg kb, mb, etc)
188
+	 *
189
+	 * @param int $size
190
+	 * @return string
191
+	 */
192
+	public static function convert($size)
193
+	{
194
+		$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
195
+		return round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[absint($i)];
196
+	}
197
+
198
+
199
+
200
+	/**
201
+	 * @param string $timer_name
202
+	 * @param float  $total_time
203
+	 * @return string
204
+	 */
205
+	public static function formatTime($timer_name, $total_time)
206
+	{
207
+		$total_time *= 1000;
208
+		switch ($total_time) {
209
+			case $total_time > 12500 :
210
+				$color = 'red';
211
+				$bold = 'bold';
212
+				break;
213
+			case $total_time > 2500 :
214
+				$color = 'darkorange';
215
+				$bold = 'bold';
216
+				break;
217
+			case $total_time > 500 :
218
+				$color = 'gold';
219
+				$bold = 'bold';
220
+				break;
221
+			case $total_time > 100 :
222
+				$color = 'limegreen';
223
+				$bold = 'normal';
224
+				break;
225
+			case $total_time > 20 :
226
+				$color = 'deepskyblue';
227
+				$bold = 'normal';
228
+				break;
229
+			default :
230
+				$color = 'mediumpurple';
231
+				$bold = 'normal';
232
+				break;
233
+		}
234
+		return '<span style="min-width: 10px; margin:0 1em; color:'
235
+			   . $color
236
+			   . '; font-weight:'
237
+			   . $bold
238
+			   . '; font-size:1.2em;">'
239
+			   . str_pad(number_format($total_time, 3), 9, '0', STR_PAD_LEFT)
240
+			   . '</span> '
241
+			   . $timer_name;
242
+	}
243 243
 
244 244
 
245 245
 
Please login to merge, or discard this patch.
acceptance_tests/Helpers/TicketSelector.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     /**
16 16
      * Use to select a quantity from the first ticket for the given event (so this can be used on a event archive page).
17 17
      * @param int|string $event_id
18
-     * @param int|string $quantity
18
+     * @param integer $quantity
19 19
      */
20 20
     public function selectQuantityOfFirstTicketForEventId($event_id, $quantity = 1)
21 21
     {
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -12,23 +12,23 @@
 block discarded – undo
12 12
 trait TicketSelector
13 13
 {
14 14
 
15
-    /**
16
-     * Use to select a quantity from the first ticket for the given event (so this can be used on a event archive page).
17
-     * @param int|string $event_id
18
-     * @param int|string $quantity
19
-     */
20
-    public function selectQuantityOfFirstTicketForEventId($event_id, $quantity = 1)
21
-    {
22
-        $this->actor()->selectOption(TicketSelectorElements::ticketOptionByEventIdSelector($event_id), $quantity);
23
-    }
15
+	/**
16
+	 * Use to select a quantity from the first ticket for the given event (so this can be used on a event archive page).
17
+	 * @param int|string $event_id
18
+	 * @param int|string $quantity
19
+	 */
20
+	public function selectQuantityOfFirstTicketForEventId($event_id, $quantity = 1)
21
+	{
22
+		$this->actor()->selectOption(TicketSelectorElements::ticketOptionByEventIdSelector($event_id), $quantity);
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Used to submit the ticket selection for the given event id (so this can be used on an event archive page).
28
-     * @param int|string $event_id
29
-     */
30
-    public function submitTicketSelectionsForEventId($event_id)
31
-    {
32
-        $this->actor()->click(TicketSelectorElements::ticketSelectionSubmitSelectorByEventId($event_id));
33
-    }
26
+	/**
27
+	 * Used to submit the ticket selection for the given event id (so this can be used on an event archive page).
28
+	 * @param int|string $event_id
29
+	 */
30
+	public function submitTicketSelectionsForEventId($event_id)
31
+	{
32
+		$this->actor()->click(TicketSelectorElements::ticketSelectionSubmitSelectorByEventId($event_id));
33
+	}
34 34
 }
35 35
\ No newline at end of file
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.39.rc.039');
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.39.rc.039');
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.
acceptance_tests/Helpers/BaseCoreAdmin.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -13,25 +13,25 @@
 block discarded – undo
13 13
 trait BaseCoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * Core method for going to an Event Espresso Admin page.
18
-     * @param string $page
19
-     * @param string $action
20
-     * @param string $additional_params
21
-     */
22
-    public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
-    {
24
-        $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
-    }
16
+	/**
17
+	 * Core method for going to an Event Espresso Admin page.
18
+	 * @param string $page
19
+	 * @param string $action
20
+	 * @param string $additional_params
21
+	 */
22
+	public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
+	{
24
+		$this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
-     * @return \EventEspressoAcceptanceTester;
31
-     */
32
-    protected function actor()
33
-    {
34
-        /** @var \EventEspressoAcceptanceTester $this */
35
-        return $this;
36
-    }
28
+	/**
29
+	 * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
+	 * @return \EventEspressoAcceptanceTester;
31
+	 */
32
+	protected function actor()
33
+	{
34
+		/** @var \EventEspressoAcceptanceTester $this */
35
+		return $this;
36
+	}
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
 trait EventsAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * @param string $additional_params
18
-     */
19
-    public function amOnDefaultEventsListTablePage($additional_params = '')
20
-    {
21
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
22
-    }
16
+	/**
17
+	 * @param string $additional_params
18
+	 */
19
+	public function amOnDefaultEventsListTablePage($additional_params = '')
20
+	{
21
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * Triggers the publishing of the Event.
27
-     */
28
-    public function publishEvent()
29
-    {
30
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
31
-    }
25
+	/**
26
+	 * Triggers the publishing of the Event.
27
+	 */
28
+	public function publishEvent()
29
+	{
30
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
31
+	}
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/Checkout.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -13,39 +13,39 @@
 block discarded – undo
13 13
  */
14 14
 trait Checkout
15 15
 {
16
-    /**
17
-     * @param     $value
18
-     * @param int $attendee_number
19
-     */
20
-    public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1)
21
-    {
22
-        $this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value);
23
-    }
24
-
25
-    /**
26
-     * @param     $value
27
-     * @param int $attendee_number
28
-     */
29
-    public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1)
30
-    {
31
-        $this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value);
32
-    }
33
-
34
-    /**
35
-     * @param     $value
36
-     * @param int $attendee_number
37
-     */
38
-    public function fillOutEmailFieldForAttendee($value, $attendee_number = 1)
39
-    {
40
-        $this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value);
41
-    }
42
-
43
-
44
-    /**
45
-     * Clicks the next registration step button.
46
-     */
47
-    public function goToNextRegistrationStep()
48
-    {
49
-        $this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR);
50
-    }
16
+	/**
17
+	 * @param     $value
18
+	 * @param int $attendee_number
19
+	 */
20
+	public function fillOutFirstNameFieldForAttendee($value, $attendee_number = 1)
21
+	{
22
+		$this->actor()->fillField(CheckoutPage::firstNameFieldSelectorForAttendeeNumber($attendee_number), $value);
23
+	}
24
+
25
+	/**
26
+	 * @param     $value
27
+	 * @param int $attendee_number
28
+	 */
29
+	public function fillOutLastNameFieldForAttendee($value, $attendee_number = 1)
30
+	{
31
+		$this->actor()->fillField(CheckoutPage::lastNameFieldSelectorForAttendeeNumber($attendee_number), $value);
32
+	}
33
+
34
+	/**
35
+	 * @param     $value
36
+	 * @param int $attendee_number
37
+	 */
38
+	public function fillOutEmailFieldForAttendee($value, $attendee_number = 1)
39
+	{
40
+		$this->actor()->fillField(CheckoutPage::emailFieldSelectorForAttendeeNumber($attendee_number), $value);
41
+	}
42
+
43
+
44
+	/**
45
+	 * Clicks the next registration step button.
46
+	 */
47
+	public function goToNextRegistrationStep()
48
+	{
49
+		$this->actor()->click(CheckoutPage::NEXT_STEP_BUTTON_SELECTOR);
50
+	}
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.