Completed
Pull Request — master (#268)
by Michael
20:12 queued 13s
created
core/libraries/shortcodes/EE_Venue_Shortcodes.lib.php 2 patches
Indentation   +325 added lines, -325 removed lines patch added patch discarded remove patch
@@ -19,330 +19,330 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * Will hold the EE_Event if available
24
-     *
25
-     * @var EE_Event
26
-     */
27
-    protected $_event;
28
-
29
-    /**
30
-     * Will hold the EE_Venue if available
31
-     *
32
-     * @var EE_Venue
33
-     */
34
-    protected $_venue;
35
-
36
-
37
-    /**
38
-     * Initialize properties
39
-     */
40
-    protected function _init_props()
41
-    {
42
-        $this->label       = esc_html__('Venue Shortcodes', 'event_espresso');
43
-        $this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso');
44
-        $this->_shortcodes = array(
45
-            '[VENUE_TITLE]'             => esc_html__('The title for the event venue', 'event_espresso'),
46
-            '[VENUE_DESCRIPTION]'       => esc_html__('The description for the event venue', 'event_espresso'),
47
-            '[VENUE_URL]'               => esc_html__('A url to a webpage for the venue', 'event_espresso'),
48
-            '[VENUE_DETAILS_URL]'       => sprintf(
49
-                esc_html__(
50
-                    'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.',
51
-                    'event_espresso'
52
-                ),
53
-                '[VENUE_URL]'
54
-            ),
55
-            '[VENUE_IMAGE]'             => esc_html__('An image representing the event venue', 'event_espresso'),
56
-            '[VENUE_PHONE]'             => esc_html__('The phone number for the venue', 'event_espresso'),
57
-            '[VENUE_ADDRESS]'           => esc_html__('The address for the venue', 'event_espresso'),
58
-            '[VENUE_ADDRESS2]'          => esc_html__('Address 2 for the venue', 'event_espresso'),
59
-            '[VENUE_CITY]'              => esc_html__('The city the venue is in', 'event_espresso'),
60
-            '[VENUE_STATE]'             => esc_html__('The state the venue is located in', 'event_espresso'),
61
-            '[VENUE_COUNTRY]'           => esc_html__('The country the venue is located in', 'event_espresso'),
62
-            '[VENUE_FORMATTED_ADDRESS]' => esc_html__(
63
-                'This just outputs the venue address in a semantic address format.',
64
-                'event_espresso'
65
-            ),
66
-            '[VENUE_ZIP]'               => esc_html__('The zip code for the venue address', 'event_espresso'),
67
-            '[VENUE_META_*]'            => esc_html__(
68
-                'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.',
69
-                'event_espresso'
70
-            ),
71
-            '[GOOGLE_MAP_URL]'          => esc_html__(
72
-                'URL for the google map associated with the venue (optionally add custom width and height).',
73
-                'event_espresso'
74
-                ).
75
-                '<p><ul>' .
76
-                '<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
77
-                '<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
78
-                '</ul></p>',
79
-            '[GOOGLE_MAP_LINK]'         => esc_html__('Link to a google map for the venue (optionally add custom width and height).', 'event_espresso').
80
-                '<p><ul>' .
81
-                '<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
82
-                '<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
83
-                '</ul></p>',
84
-            '[GOOGLE_MAP_IMAGE]'        => esc_html__('Google map for venue wrapped in image tags  (optionally add custom width and height).', 'event_espresso').
85
-                '<p><ul>' .
86
-                '<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
87
-                '<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
88
-                '</ul></p>',
89
-        );
90
-    }
91
-
92
-
93
-    /**
94
-     * Parse incoming shortcode
95
-     *
96
-     * @param string $shortcode
97
-     * @return string
98
-     * @throws EE_Error
99
-     * @throws EntityNotFoundException
100
-     */
101
-    protected function _parser($shortcode)
102
-    {
103
-        $this->_venue = $this->_get_venue();
104
-        //If there is no venue object by now then get out.
105
-        if (! $this->_venue instanceof EE_Venue) {
106
-            return '';
107
-        }
108
-
109
-        switch ($shortcode) {
110
-            case '[VENUE_TITLE]':
111
-                return $this->_venue('title');
112
-                break;
113
-
114
-            case '[VENUE_DESCRIPTION]':
115
-                return $this->_venue('description');
116
-                break;
117
-
118
-            case '[VENUE_URL]':
119
-                return $this->_venue('url');
120
-                break;
121
-
122
-            case '[VENUE_IMAGE]':
123
-                return $this->_venue('image');
124
-                break;
125
-
126
-            case '[VENUE_PHONE]':
127
-                return $this->_venue('phone');
128
-                break;
129
-
130
-            case '[VENUE_ADDRESS]':
131
-                return $this->_venue('address');
132
-                break;
133
-
134
-            case '[VENUE_ADDRESS2]':
135
-                return $this->_venue('address2');
136
-                break;
137
-
138
-            case '[VENUE_CITY]':
139
-                return $this->_venue('city');
140
-                break;
141
-
142
-            case '[VENUE_COUNTRY]':
143
-                return $this->_venue('country');
144
-                break;
145
-
146
-            case '[VENUE_STATE]':
147
-                return $this->_venue('state');
148
-                break;
149
-
150
-            case '[VENUE_ZIP]':
151
-                return $this->_venue('zip');
152
-                break;
153
-
154
-            case '[VENUE_FORMATTED_ADDRESS]':
155
-                return $this->_venue('formatted_address');
156
-                break;
157
-
158
-            case '[VENUE_DETAILS_URL]':
159
-                return $this->_venue('permalink');
160
-                break;
161
-
162
-        }
22
+	/**
23
+	 * Will hold the EE_Event if available
24
+	 *
25
+	 * @var EE_Event
26
+	 */
27
+	protected $_event;
28
+
29
+	/**
30
+	 * Will hold the EE_Venue if available
31
+	 *
32
+	 * @var EE_Venue
33
+	 */
34
+	protected $_venue;
35
+
36
+
37
+	/**
38
+	 * Initialize properties
39
+	 */
40
+	protected function _init_props()
41
+	{
42
+		$this->label       = esc_html__('Venue Shortcodes', 'event_espresso');
43
+		$this->description = esc_html__('All shortcodes specific to venue related data', 'event_espresso');
44
+		$this->_shortcodes = array(
45
+			'[VENUE_TITLE]'             => esc_html__('The title for the event venue', 'event_espresso'),
46
+			'[VENUE_DESCRIPTION]'       => esc_html__('The description for the event venue', 'event_espresso'),
47
+			'[VENUE_URL]'               => esc_html__('A url to a webpage for the venue', 'event_espresso'),
48
+			'[VENUE_DETAILS_URL]'       => sprintf(
49
+				esc_html__(
50
+					'This shortcode outputs the url or website address to the venue details page on this website. This differs from %s which outputs what is entered in the "url" field in the venue details page.',
51
+					'event_espresso'
52
+				),
53
+				'[VENUE_URL]'
54
+			),
55
+			'[VENUE_IMAGE]'             => esc_html__('An image representing the event venue', 'event_espresso'),
56
+			'[VENUE_PHONE]'             => esc_html__('The phone number for the venue', 'event_espresso'),
57
+			'[VENUE_ADDRESS]'           => esc_html__('The address for the venue', 'event_espresso'),
58
+			'[VENUE_ADDRESS2]'          => esc_html__('Address 2 for the venue', 'event_espresso'),
59
+			'[VENUE_CITY]'              => esc_html__('The city the venue is in', 'event_espresso'),
60
+			'[VENUE_STATE]'             => esc_html__('The state the venue is located in', 'event_espresso'),
61
+			'[VENUE_COUNTRY]'           => esc_html__('The country the venue is located in', 'event_espresso'),
62
+			'[VENUE_FORMATTED_ADDRESS]' => esc_html__(
63
+				'This just outputs the venue address in a semantic address format.',
64
+				'event_espresso'
65
+			),
66
+			'[VENUE_ZIP]'               => esc_html__('The zip code for the venue address', 'event_espresso'),
67
+			'[VENUE_META_*]'            => esc_html__(
68
+				'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the venue then it will be output in place of this shortcode.',
69
+				'event_espresso'
70
+			),
71
+			'[GOOGLE_MAP_URL]'          => esc_html__(
72
+				'URL for the google map associated with the venue (optionally add custom width and height).',
73
+				'event_espresso'
74
+				).
75
+				'<p><ul>' .
76
+				'<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
77
+				'<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
78
+				'</ul></p>',
79
+			'[GOOGLE_MAP_LINK]'         => esc_html__('Link to a google map for the venue (optionally add custom width and height).', 'event_espresso').
80
+				'<p><ul>' .
81
+				'<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
82
+				'<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
83
+				'</ul></p>',
84
+			'[GOOGLE_MAP_IMAGE]'        => esc_html__('Google map for venue wrapped in image tags  (optionally add custom width and height).', 'event_espresso').
85
+				'<p><ul>' .
86
+				'<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
87
+				'<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
88
+				'</ul></p>',
89
+		);
90
+	}
91
+
92
+
93
+	/**
94
+	 * Parse incoming shortcode
95
+	 *
96
+	 * @param string $shortcode
97
+	 * @return string
98
+	 * @throws EE_Error
99
+	 * @throws EntityNotFoundException
100
+	 */
101
+	protected function _parser($shortcode)
102
+	{
103
+		$this->_venue = $this->_get_venue();
104
+		//If there is no venue object by now then get out.
105
+		if (! $this->_venue instanceof EE_Venue) {
106
+			return '';
107
+		}
108
+
109
+		switch ($shortcode) {
110
+			case '[VENUE_TITLE]':
111
+				return $this->_venue('title');
112
+				break;
113
+
114
+			case '[VENUE_DESCRIPTION]':
115
+				return $this->_venue('description');
116
+				break;
117
+
118
+			case '[VENUE_URL]':
119
+				return $this->_venue('url');
120
+				break;
121
+
122
+			case '[VENUE_IMAGE]':
123
+				return $this->_venue('image');
124
+				break;
125
+
126
+			case '[VENUE_PHONE]':
127
+				return $this->_venue('phone');
128
+				break;
129
+
130
+			case '[VENUE_ADDRESS]':
131
+				return $this->_venue('address');
132
+				break;
133
+
134
+			case '[VENUE_ADDRESS2]':
135
+				return $this->_venue('address2');
136
+				break;
137
+
138
+			case '[VENUE_CITY]':
139
+				return $this->_venue('city');
140
+				break;
141
+
142
+			case '[VENUE_COUNTRY]':
143
+				return $this->_venue('country');
144
+				break;
145
+
146
+			case '[VENUE_STATE]':
147
+				return $this->_venue('state');
148
+				break;
149
+
150
+			case '[VENUE_ZIP]':
151
+				return $this->_venue('zip');
152
+				break;
153
+
154
+			case '[VENUE_FORMATTED_ADDRESS]':
155
+				return $this->_venue('formatted_address');
156
+				break;
157
+
158
+			case '[VENUE_DETAILS_URL]':
159
+				return $this->_venue('permalink');
160
+				break;
161
+
162
+		}
163 163
         
164
-        if ( preg_match('/^\[GOOGLE_MAP_(LINK|IMAGE|URL)(_)?/', $shortcode, $matches) ) {
165
-            $field = 'gmap_';
166
-            if ($matches[1] == 'URL') {
167
-                $field .= 'url';
168
-            } else {
169
-                $field .= 'link';
170
-                if ($matches[1] == 'IMAGE') {
171
-                    $field .= '_img';
172
-                }
173
-            }
174
-            return $this->_venue($field, $this->_get_shortcode_attrs( $shortcode ));
175
-        }
176
-
177
-        if (strpos($shortcode, '[VENUE_META_*') !== false) {
178
-            $shortcode = str_replace('[VENUE_META_*', '', $shortcode);
179
-            $shortcode = trim(str_replace(']', '', $shortcode));
180
-
181
-            //pull the meta value from the venue post
182
-            $venue_meta = $this->_venue->get_post_meta($shortcode, true);
183
-
184
-            return ! empty($venue_meta) ? $venue_meta : '';
185
-
186
-        }
187
-    }
188
-
189
-    /**
190
-     * This retrieves the EE_Venue from the available data object.
191
-     *
192
-     * @return EE_Venue|null
193
-     * @throws EE_Error
194
-     * @throws EntityNotFoundException
195
-     */
196
-    private function _get_venue()
197
-    {
198
-
199
-        //we need the EE_Event object to get the venue.
200
-        $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
201
-
202
-        //if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the
203
-        // reg_obj instead.
204
-        if (! $this->_event instanceof EE_Event) {
205
-            $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
206
-            $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
207
-
208
-            $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
209
-                ? $aee->reg_obj->event()
210
-                : null;
211
-
212
-            //if still empty do we have a ticket data item?
213
-            $this->_event = ! $this->_event instanceof EE_Event
214
-                            && $this->_data instanceof EE_Ticket
215
-                            && $this->_extra_data['data'] instanceof EE_Messages_Addressee
216
-                ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event']
217
-                : $this->_event;
218
-
219
-            //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee
220
-            // and use that.
221
-            $this->_event       = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee
222
-                ? reset($aee->events)
223
-                : $this->_event;
224
-        }
225
-
226
-        //If we have an event object use it to pull the venue.
227
-        if ($this->_event instanceof EE_Event) {
228
-            return $this->_event->get_first_related('Venue');
229
-        }
230
-
231
-        return null;
232
-    }
233
-
234
-    /**
235
-     * This retrieves the specified venue information
236
-     *
237
-     * @param string $field What Venue field to retrieve
238
-     * @return string What was retrieved!
239
-     * @throws EE_Error
240
-     * @throws EntityNotFoundException
241
-     */
242
-    private function _venue($field, $args = array())
243
-    {
244
-
245
-        if (! $this->_venue instanceof EE_Venue) {
246
-            return '';
247
-        } //no venue so get out.
248
-
249
-        switch ($field) {
250
-            case 'title':
251
-                return $this->_venue->get('VNU_name');
252
-                break;
253
-
254
-            case 'description':
255
-                return $this->_venue->get('VNU_desc');
256
-                break;
257
-
258
-            case 'url':
259
-                $url = $this->_venue->get('VNU_url');
260
-                return empty($url) ? $this->_venue->get_permalink() : $url;
261
-                break;
262
-
263
-            case 'permalink':
264
-                return $this->_venue->get_permalink();
265
-                break;
266
-
267
-            case 'image':
268
-                return '<img src="' . $this->_venue->feature_image_url(array(200, 200,))
269
-                       . '" alt="' . sprintf(
270
-                           esc_attr__('%s Feature Image', 'event_espresso'),
271
-                           $this->_venue->get('VNU_name')
272
-                       ) . '" />';
273
-                break;
274
-
275
-            case 'phone':
276
-                return $this->_venue->get('VNU_phone');
277
-                break;
278
-
279
-            case 'address':
280
-                return $this->_venue->get('VNU_address');
281
-                break;
282
-
283
-            case 'address2':
284
-                return $this->_venue->get('VNU_address2');
285
-                break;
286
-
287
-            case 'city':
288
-                return $this->_venue->get('VNU_city');
289
-                break;
290
-
291
-            case 'state':
292
-                $state = $this->_venue->state_obj();
293
-                return is_object($state) ? $state->get('STA_name') : '';
294
-                break;
295
-
296
-            case 'country':
297
-                $country = $this->_venue->country_obj();
298
-                return is_object($country) ? $country->get('CNT_name') : '';
299
-                break;
300
-
301
-            case 'zip':
302
-                return $this->_venue->get('VNU_zip');
303
-                break;
304
-
305
-            case 'formatted_address':
306
-                return EEH_Address::format($this->_venue);
307
-                break;
308
-
309
-            case 'gmap_link':
310
-            case 'gmap_url':
311
-            case 'gmap_link_img':
312
-                $atts = $this->get_map_attributes($this->_venue, $field, $args);
313
-                return EEH_Maps::google_map_link($atts);
314
-                break;
315
-        }
316
-        return '';
317
-    }
318
-
319
-
320
-    /**
321
-     * Generates the attributes for retrieving a google_map artifact.
322
-     *
323
-     * @param EE_Venue $venue
324
-     * @param string   $field
325
-     * @return array
326
-     * @throws EE_Error
327
-     */
328
-    protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link', $args = array())
329
-    {
330
-        $state   = $venue->state_obj();
331
-        $country = $venue->country_obj();
332
-        $atts    = array(
333
-            'id'      => $venue->ID(),
334
-            'address' => $venue->get('VNU_address'),
335
-            'city'    => $venue->get('VNU_city'),
336
-            'state'   => is_object($state) ? $state->get('STA_name') : '',
337
-            'zip'     => $venue->get('VNU_zip'),
338
-            'country' => is_object($country) ? $country->get('CNT_name') : '',
339
-            'type'    => $field === 'gmap_link' ? 'url' : 'map',
340
-            'map_w'   => !empty($args['w']) ? abs((int) $args['w']) : 200,
341
-            'map_h'   => !empty($args['h']) ? abs((int) $args['h']) : 200
342
-        );
343
-        if ($field === 'gmap_url') {
344
-            $atts['type'] = 'url_only';
345
-        }
346
-        return $atts;
347
-    }
164
+		if ( preg_match('/^\[GOOGLE_MAP_(LINK|IMAGE|URL)(_)?/', $shortcode, $matches) ) {
165
+			$field = 'gmap_';
166
+			if ($matches[1] == 'URL') {
167
+				$field .= 'url';
168
+			} else {
169
+				$field .= 'link';
170
+				if ($matches[1] == 'IMAGE') {
171
+					$field .= '_img';
172
+				}
173
+			}
174
+			return $this->_venue($field, $this->_get_shortcode_attrs( $shortcode ));
175
+		}
176
+
177
+		if (strpos($shortcode, '[VENUE_META_*') !== false) {
178
+			$shortcode = str_replace('[VENUE_META_*', '', $shortcode);
179
+			$shortcode = trim(str_replace(']', '', $shortcode));
180
+
181
+			//pull the meta value from the venue post
182
+			$venue_meta = $this->_venue->get_post_meta($shortcode, true);
183
+
184
+			return ! empty($venue_meta) ? $venue_meta : '';
185
+
186
+		}
187
+	}
188
+
189
+	/**
190
+	 * This retrieves the EE_Venue from the available data object.
191
+	 *
192
+	 * @return EE_Venue|null
193
+	 * @throws EE_Error
194
+	 * @throws EntityNotFoundException
195
+	 */
196
+	private function _get_venue()
197
+	{
198
+
199
+		//we need the EE_Event object to get the venue.
200
+		$this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
201
+
202
+		//if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the
203
+		// reg_obj instead.
204
+		if (! $this->_event instanceof EE_Event) {
205
+			$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
206
+			$aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
207
+
208
+			$this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
209
+				? $aee->reg_obj->event()
210
+				: null;
211
+
212
+			//if still empty do we have a ticket data item?
213
+			$this->_event = ! $this->_event instanceof EE_Event
214
+							&& $this->_data instanceof EE_Ticket
215
+							&& $this->_extra_data['data'] instanceof EE_Messages_Addressee
216
+				? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event']
217
+				: $this->_event;
218
+
219
+			//if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee
220
+			// and use that.
221
+			$this->_event       = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee
222
+				? reset($aee->events)
223
+				: $this->_event;
224
+		}
225
+
226
+		//If we have an event object use it to pull the venue.
227
+		if ($this->_event instanceof EE_Event) {
228
+			return $this->_event->get_first_related('Venue');
229
+		}
230
+
231
+		return null;
232
+	}
233
+
234
+	/**
235
+	 * This retrieves the specified venue information
236
+	 *
237
+	 * @param string $field What Venue field to retrieve
238
+	 * @return string What was retrieved!
239
+	 * @throws EE_Error
240
+	 * @throws EntityNotFoundException
241
+	 */
242
+	private function _venue($field, $args = array())
243
+	{
244
+
245
+		if (! $this->_venue instanceof EE_Venue) {
246
+			return '';
247
+		} //no venue so get out.
248
+
249
+		switch ($field) {
250
+			case 'title':
251
+				return $this->_venue->get('VNU_name');
252
+				break;
253
+
254
+			case 'description':
255
+				return $this->_venue->get('VNU_desc');
256
+				break;
257
+
258
+			case 'url':
259
+				$url = $this->_venue->get('VNU_url');
260
+				return empty($url) ? $this->_venue->get_permalink() : $url;
261
+				break;
262
+
263
+			case 'permalink':
264
+				return $this->_venue->get_permalink();
265
+				break;
266
+
267
+			case 'image':
268
+				return '<img src="' . $this->_venue->feature_image_url(array(200, 200,))
269
+					   . '" alt="' . sprintf(
270
+						   esc_attr__('%s Feature Image', 'event_espresso'),
271
+						   $this->_venue->get('VNU_name')
272
+					   ) . '" />';
273
+				break;
274
+
275
+			case 'phone':
276
+				return $this->_venue->get('VNU_phone');
277
+				break;
278
+
279
+			case 'address':
280
+				return $this->_venue->get('VNU_address');
281
+				break;
282
+
283
+			case 'address2':
284
+				return $this->_venue->get('VNU_address2');
285
+				break;
286
+
287
+			case 'city':
288
+				return $this->_venue->get('VNU_city');
289
+				break;
290
+
291
+			case 'state':
292
+				$state = $this->_venue->state_obj();
293
+				return is_object($state) ? $state->get('STA_name') : '';
294
+				break;
295
+
296
+			case 'country':
297
+				$country = $this->_venue->country_obj();
298
+				return is_object($country) ? $country->get('CNT_name') : '';
299
+				break;
300
+
301
+			case 'zip':
302
+				return $this->_venue->get('VNU_zip');
303
+				break;
304
+
305
+			case 'formatted_address':
306
+				return EEH_Address::format($this->_venue);
307
+				break;
308
+
309
+			case 'gmap_link':
310
+			case 'gmap_url':
311
+			case 'gmap_link_img':
312
+				$atts = $this->get_map_attributes($this->_venue, $field, $args);
313
+				return EEH_Maps::google_map_link($atts);
314
+				break;
315
+		}
316
+		return '';
317
+	}
318
+
319
+
320
+	/**
321
+	 * Generates the attributes for retrieving a google_map artifact.
322
+	 *
323
+	 * @param EE_Venue $venue
324
+	 * @param string   $field
325
+	 * @return array
326
+	 * @throws EE_Error
327
+	 */
328
+	protected function get_map_attributes(EE_Venue $venue, $field = 'gmap_link', $args = array())
329
+	{
330
+		$state   = $venue->state_obj();
331
+		$country = $venue->country_obj();
332
+		$atts    = array(
333
+			'id'      => $venue->ID(),
334
+			'address' => $venue->get('VNU_address'),
335
+			'city'    => $venue->get('VNU_city'),
336
+			'state'   => is_object($state) ? $state->get('STA_name') : '',
337
+			'zip'     => $venue->get('VNU_zip'),
338
+			'country' => is_object($country) ? $country->get('CNT_name') : '',
339
+			'type'    => $field === 'gmap_link' ? 'url' : 'map',
340
+			'map_w'   => !empty($args['w']) ? abs((int) $args['w']) : 200,
341
+			'map_h'   => !empty($args['h']) ? abs((int) $args['h']) : 200
342
+		);
343
+		if ($field === 'gmap_url') {
344
+			$atts['type'] = 'url_only';
345
+		}
346
+		return $atts;
347
+	}
348 348
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -72,19 +72,19 @@  discard block
 block discarded – undo
72 72
                 'URL for the google map associated with the venue (optionally add custom width and height).',
73 73
                 'event_espresso'
74 74
                 ).
75
-                '<p><ul>' .
76
-                '<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
77
-                '<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
75
+                '<p><ul>'.
76
+                '<li><strong>h</strong>:'.__('Height of the Image in px.', 'event_espresso').'</li>'.
77
+                '<li><strong>w</strong>:'.__('Width of the Image in px.', 'event_espresso').'</li>'.
78 78
                 '</ul></p>',
79 79
             '[GOOGLE_MAP_LINK]'         => esc_html__('Link to a google map for the venue (optionally add custom width and height).', 'event_espresso').
80
-                '<p><ul>' .
81
-                '<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
82
-                '<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
80
+                '<p><ul>'.
81
+                '<li><strong>h</strong>:'.__('Height of the Image in px.', 'event_espresso').'</li>'.
82
+                '<li><strong>w</strong>:'.__('Width of the Image in px.', 'event_espresso').'</li>'.
83 83
                 '</ul></p>',
84 84
             '[GOOGLE_MAP_IMAGE]'        => esc_html__('Google map for venue wrapped in image tags  (optionally add custom width and height).', 'event_espresso').
85
-                '<p><ul>' .
86
-                '<li><strong>h</strong>:' . __('Height of the Image in px.', 'event_espresso') . '</li>' .
87
-                '<li><strong>w</strong>:' . __('Width of the Image in px.', 'event_espresso' ) . '</li>' .
85
+                '<p><ul>'.
86
+                '<li><strong>h</strong>:'.__('Height of the Image in px.', 'event_espresso').'</li>'.
87
+                '<li><strong>w</strong>:'.__('Width of the Image in px.', 'event_espresso').'</li>'.
88 88
                 '</ul></p>',
89 89
         );
90 90
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $this->_venue = $this->_get_venue();
104 104
         //If there is no venue object by now then get out.
105
-        if (! $this->_venue instanceof EE_Venue) {
105
+        if ( ! $this->_venue instanceof EE_Venue) {
106 106
             return '';
107 107
         }
108 108
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
         }
163 163
         
164
-        if ( preg_match('/^\[GOOGLE_MAP_(LINK|IMAGE|URL)(_)?/', $shortcode, $matches) ) {
164
+        if (preg_match('/^\[GOOGLE_MAP_(LINK|IMAGE|URL)(_)?/', $shortcode, $matches)) {
165 165
             $field = 'gmap_';
166 166
             if ($matches[1] == 'URL') {
167 167
                 $field .= 'url';
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                     $field .= '_img';
172 172
                 }
173 173
             }
174
-            return $this->_venue($field, $this->_get_shortcode_attrs( $shortcode ));
174
+            return $this->_venue($field, $this->_get_shortcode_attrs($shortcode));
175 175
         }
176 176
 
177 177
         if (strpos($shortcode, '[VENUE_META_*') !== false) {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
         //if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the
203 203
         // reg_obj instead.
204
-        if (! $this->_event instanceof EE_Event) {
204
+        if ( ! $this->_event instanceof EE_Event) {
205 205
             $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
206 206
             $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
207 207
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
             //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee
220 220
             // and use that.
221
-            $this->_event       = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee
221
+            $this->_event = ! $this->_event instanceof EE_Event && $aee instanceof EE_Messages_Addressee
222 222
                 ? reset($aee->events)
223 223
                 : $this->_event;
224 224
         }
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     private function _venue($field, $args = array())
243 243
     {
244 244
 
245
-        if (! $this->_venue instanceof EE_Venue) {
245
+        if ( ! $this->_venue instanceof EE_Venue) {
246 246
             return '';
247 247
         } //no venue so get out.
248 248
 
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
                 break;
266 266
 
267 267
             case 'image':
268
-                return '<img src="' . $this->_venue->feature_image_url(array(200, 200,))
269
-                       . '" alt="' . sprintf(
268
+                return '<img src="'.$this->_venue->feature_image_url(array(200, 200,))
269
+                       . '" alt="'.sprintf(
270 270
                            esc_attr__('%s Feature Image', 'event_espresso'),
271 271
                            $this->_venue->get('VNU_name')
272
-                       ) . '" />';
272
+                       ).'" />';
273 273
                 break;
274 274
 
275 275
             case 'phone':
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
             'zip'     => $venue->get('VNU_zip'),
338 338
             'country' => is_object($country) ? $country->get('CNT_name') : '',
339 339
             'type'    => $field === 'gmap_link' ? 'url' : 'map',
340
-            'map_w'   => !empty($args['w']) ? abs((int) $args['w']) : 200,
341
-            'map_h'   => !empty($args['h']) ? abs((int) $args['h']) : 200
340
+            'map_w'   => ! empty($args['w']) ? abs((int) $args['w']) : 200,
341
+            'map_h'   => ! empty($args['h']) ? abs((int) $args['h']) : 200
342 342
         );
343 343
         if ($field === 'gmap_url') {
344 344
             $atts['type'] = 'url_only';
Please login to merge, or discard this patch.
public/template_tags.php 1 patch
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
  * @param int | \EE_Event $event
15 15
  * @return bool
16 16
  */
17
-function is_espresso_event( $event = NULL ) {
18
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
17
+function is_espresso_event($event = NULL) {
18
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
19 19
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
20
-		$event = EEH_Event_View::get_event( $event );
20
+		$event = EEH_Event_View::get_event($event);
21 21
 		// do we have a valid event ?
22
-		return $event instanceof EE_Event  ? TRUE : FALSE;
22
+		return $event instanceof EE_Event ? TRUE : FALSE;
23 23
 	}
24 24
 	return FALSE;
25 25
 }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return bool
32 32
  */
33 33
 function is_espresso_event_single() {
34
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
34
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
35 35
 		global $wp_query;
36 36
 		// return conditionals set by CPTs
37 37
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * @return bool
47 47
  */
48 48
 function is_espresso_event_archive() {
49
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
49
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
50 50
 		global $wp_query;
51 51
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
52 52
 	}
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @return bool
61 61
  */
62 62
 function is_espresso_event_taxonomy() {
63
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
63
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
64 64
 		global $wp_query;
65 65
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
66 66
 	}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
  * @param int | \EE_Venue $venue
75 75
  * @return bool
76 76
  */
77
-function is_espresso_venue( $venue = NULL ) {
78
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
77
+function is_espresso_venue($venue = NULL) {
78
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
79 79
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
80
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
80
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
81 81
 		// do we have a valid event ?
82 82
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
83 83
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
  * @return bool
92 92
  */
93 93
 function is_espresso_venue_single() {
94
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
94
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
95 95
 		global $wp_query;
96 96
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
97 97
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
  * @return bool
106 106
  */
107 107
 function is_espresso_venue_archive() {
108
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
108
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
109 109
 		global $wp_query;
110 110
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
111 111
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
  * @return bool
120 120
  */
121 121
 function is_espresso_venue_taxonomy() {
122
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
122
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
123 123
 		global $wp_query;
124 124
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
125 125
 	}
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
  * @param $conditional_tag
134 134
  * @return bool
135 135
  */
136
-function can_use_espresso_conditionals( $conditional_tag ) {
137
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
136
+function can_use_espresso_conditionals($conditional_tag) {
137
+	if ( ! did_action('AHEE__EE_System__initialize')) {
138 138
 		EE_Error::doing_it_wrong(
139 139
 			__FUNCTION__,
140 140
 			sprintf(
141
-				__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
141
+				__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
142 142
 				$conditional_tag
143 143
 			),
144 144
 			'4.4.0'
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 
154 154
 /*************************** Event Queries ***************************/
155 155
 
156
-if ( ! function_exists( 'espresso_get_events' )) {
156
+if ( ! function_exists('espresso_get_events')) {
157 157
 	/**
158 158
 	 * 	espresso_get_events
159 159
 	 * @param array $params
160 160
 	 * @return array
161 161
 	 */
162
-	function espresso_get_events( $params = array() ) {
162
+	function espresso_get_events($params = array()) {
163 163
 		//set default params
164 164
 		$default_espresso_events_params = array(
165 165
 			'limit' => 10,
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 			'sort' => 'ASC'
171 171
 		);
172 172
 		// allow the defaults to be filtered
173
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
173
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
174 174
 		// grab params and merge with defaults, then extract
175
-		$params = array_merge( $default_espresso_events_params, $params );
175
+		$params = array_merge($default_espresso_events_params, $params);
176 176
 		// run the query
177
-		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params );
177
+		$events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params);
178 178
 		// assign results to a variable so we can return it
179 179
 		$events = $events_query->have_posts() ? $events_query->posts : array();
180 180
 		// but first reset the query and postdata
181 181
 		wp_reset_query();
182 182
 		wp_reset_postdata();
183 183
 		EED_Events_Archive::remove_all_events_archive_filters();
184
-		unset( $events_query );
184
+		unset($events_query);
185 185
 		return $events;
186 186
 	}
187 187
 }
@@ -195,33 +195,33 @@  discard block
 block discarded – undo
195 195
  * espresso_load_ticket_selector
196 196
  */
197 197
 function espresso_load_ticket_selector() {
198
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
198
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
199 199
 }
200 200
 
201
-if ( ! function_exists( 'espresso_ticket_selector' )) {
201
+if ( ! function_exists('espresso_ticket_selector')) {
202 202
 	/**
203 203
 	 * espresso_ticket_selector
204 204
 	 * @param null $event
205 205
 	 */
206
-	function espresso_ticket_selector( $event = NULL ) {
207
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
206
+	function espresso_ticket_selector($event = NULL) {
207
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
208 208
 			espresso_load_ticket_selector();
209 209
             \EED_Ticket_Selector::set_definitions();
210
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
210
+			echo EED_Ticket_Selector::display_ticket_selector($event);
211 211
 		}
212 212
 	}
213 213
 }
214 214
 
215 215
 
216
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
216
+	if ( ! function_exists('espresso_view_details_btn')) {
217 217
 	/**
218 218
 	 * espresso_view_details_btn
219 219
 	 * @param null $event
220 220
 	 */
221
-	function espresso_view_details_btn( $event = NULL ) {
222
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
221
+	function espresso_view_details_btn($event = NULL) {
222
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
223 223
 			espresso_load_ticket_selector();
224
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
224
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
225 225
 		}
226 226
 	}
227 227
 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 /*************************** EEH_Event_View ***************************/
233 233
 
234
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
234
+if ( ! function_exists('espresso_load_event_list_assets')) {
235 235
 	/**
236 236
 	 * espresso_load_event_list_assets
237 237
 	 * ensures that event list styles and scripts are loaded
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	function espresso_load_event_list_assets() {
242 242
 		$event_list = EED_Events_Archive::instance();
243
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
244
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
243
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
244
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
245 245
 	}
246 246
 }
247 247
 
248 248
 
249
-if ( ! function_exists( 'espresso_event_reg_button' )) {
249
+if ( ! function_exists('espresso_event_reg_button')) {
250 250
 	/**
251 251
 	 * espresso_event_reg_button
252 252
 	 * returns the "Register Now" button if event is active,
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 * @param bool $EVT_ID
259 259
 	 * @return string
260 260
 	 */
261
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
262
-		$event_status = EEH_Event_View::event_active_status( $EVT_ID );
263
-		switch ( $event_status ) {
261
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
262
+		$event_status = EEH_Event_View::event_active_status($EVT_ID);
263
+		switch ($event_status) {
264 264
 			case EE_Datetime::sold_out :
265 265
 				$btn_text = __('Sold Out', 'event_espresso');
266 266
 				$class = 'ee-pink';
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 			case EE_Datetime::upcoming :
277 277
 			case EE_Datetime::active :
278 278
 			default :
279
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' );
279
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso');
280 280
 				$class = 'ee-green';
281 281
 		}
282
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
282
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
283 283
 			$btn_text = $btn_text_if_inactive;
284 284
 			$class = 'ee-grey';
285 285
 		}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
 
295 295
 
296
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
296
+if ( ! function_exists('espresso_display_ticket_selector')) {
297 297
 	/**
298 298
 	 * espresso_display_ticket_selector
299 299
 	 * whether or not to display the Ticket Selector for an event
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 	 * @param bool $EVT_ID
302 302
 	 * @return boolean
303 303
 	 */
304
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
305
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
304
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
305
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
306 306
 	}
307 307
 }
308 308
 
309 309
 
310 310
 
311
-if ( ! function_exists( 'espresso_event_status_banner' )) {
311
+if ( ! function_exists('espresso_event_status_banner')) {
312 312
 	/**
313 313
 	 * espresso_event_status
314 314
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 * @param bool $EVT_ID
317 317
 	 * @return string
318 318
 	 */
319
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
320
-		return EEH_Event_View::event_status( $EVT_ID );
319
+	function espresso_event_status_banner($EVT_ID = FALSE) {
320
+		return EEH_Event_View::event_status($EVT_ID);
321 321
 	}
322 322
 }
323 323
 
324 324
 
325
-if ( ! function_exists( 'espresso_event_status' )) {
325
+if ( ! function_exists('espresso_event_status')) {
326 326
 	/**
327 327
 	 * espresso_event_status
328 328
 	 * returns the event status if it is sold out, expired, or inactive
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
 	 * @param bool $echo
332 332
 	 * @return string
333 333
 	 */
334
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
335
-		if ( $echo ) {
336
-			echo EEH_Event_View::event_active_status( $EVT_ID );
334
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
335
+		if ($echo) {
336
+			echo EEH_Event_View::event_active_status($EVT_ID);
337 337
 			return '';
338 338
 		}
339
-		return EEH_Event_View::event_active_status( $EVT_ID );
339
+		return EEH_Event_View::event_active_status($EVT_ID);
340 340
 	}
341 341
 }
342 342
 
343 343
 
344
-if ( ! function_exists( 'espresso_event_categories' )) {
344
+if ( ! function_exists('espresso_event_categories')) {
345 345
 	/**
346 346
 	 * espresso_event_categories
347 347
 	 * returns the terms associated with an event
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 	 * @param bool $echo
352 352
 	 * @return string
353 353
 	 */
354
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
355
-		if ( $echo ) {
356
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
354
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
355
+		if ($echo) {
356
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
357 357
 			return '';
358 358
 		}
359
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
359
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
360 360
 	}
361 361
 }
362 362
 
363 363
 
364
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
364
+if ( ! function_exists('espresso_event_tickets_available')) {
365 365
 	/**
366 366
 	 * espresso_event_tickets_available
367 367
 	 * returns the ticket types available for purchase for an event
@@ -371,26 +371,26 @@  discard block
 block discarded – undo
371 371
 	 * @param bool $format
372 372
 	 * @return string
373 373
 	 */
374
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
375
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
376
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
374
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
375
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
376
+		if (is_array($tickets) && ! empty($tickets)) {
377 377
 			// if formatting then $html will be a string, else it will be an array of ticket objects
378
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
379
-			foreach ( $tickets as $ticket ) {
380
-				if ( $ticket instanceof EE_Ticket ) {
381
-					if ( $format ) {
382
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
383
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
378
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
379
+			foreach ($tickets as $ticket) {
380
+				if ($ticket instanceof EE_Ticket) {
381
+					if ($format) {
382
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
383
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
384 384
 						$html .= '</li>';
385 385
 					} else {
386 386
 						$html[] = $ticket;
387 387
 					}
388 388
 				}
389 389
 			}
390
-			if ( $format ) {
390
+			if ($format) {
391 391
 				$html .= '</ul>';
392 392
 			}
393
-			if ( $echo && ! $format ) {
393
+			if ($echo && ! $format) {
394 394
 				echo $html;
395 395
 				return '';
396 396
 			}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 }
402 402
 
403
-if ( ! function_exists( 'espresso_event_date_obj' )) {
403
+if ( ! function_exists('espresso_event_date_obj')) {
404 404
 	/**
405 405
 	 * espresso_event_date_obj
406 406
 	 * returns the primary date object for an event
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 	 * @param bool $EVT_ID
409 409
 	 * @return object
410 410
 	 */
411
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
412
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
411
+	function espresso_event_date_obj($EVT_ID = FALSE) {
412
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
413 413
 	}
414 414
 }
415 415
 
416 416
 
417
-if ( ! function_exists( 'espresso_event_date' )) {
417
+if ( ! function_exists('espresso_event_date')) {
418 418
 	/**
419 419
 	 * espresso_event_date
420 420
 	 * returns the primary date for an event
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 	 * @param bool $echo
426 426
 	 * @return string
427 427
 	 */
428
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
429
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
430
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
431
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
432
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
433
-		if($echo){
434
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
428
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
429
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
430
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
431
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
432
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
433
+		if ($echo) {
434
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
435 435
 			return '';
436 436
 		}
437
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
437
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
438 438
 
439 439
 	}
440 440
 }
441 441
 
442 442
 
443
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
443
+if ( ! function_exists('espresso_list_of_event_dates')) {
444 444
 	/**
445 445
 	 * espresso_list_of_event_dates
446 446
 	 * returns a unordered list of dates for an event
@@ -455,53 +455,53 @@  discard block
 block discarded – undo
455 455
 	 * @param null   $limit
456 456
 	 * @return string
457 457
 	 */
458
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
459
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
460
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
461
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
462
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
463
-		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
464
-		if ( ! $format ) {
465
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
458
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
459
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
460
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
461
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
462
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
463
+		$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
464
+		if ( ! $format) {
465
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
466 466
 		}
467 467
 		//d( $datetimes );
468
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
468
+		if (is_array($datetimes) && ! empty($datetimes)) {
469 469
 			global $post;
470
-			$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
-			foreach ( $datetimes as $datetime ) {
472
-				if ( $datetime instanceof EE_Datetime ) {
473
-					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
474
-					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
470
+			$html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : '';
471
+			foreach ($datetimes as $datetime) {
472
+				if ($datetime instanceof EE_Datetime) {
473
+					$html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
474
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
475 475
 					
476 476
 					$datetime_name = $datetime->name();
477
-					if (!empty( $datetime_name )) {
478
-						$html .= '<strong class="ee-event-datetime-name'.($add_breaks ? ' ee-break-after' : '').'">' . $datetime_name . '</strong>';
477
+					if ( ! empty($datetime_name)) {
478
+						$html .= '<strong class="ee-event-datetime-name'.($add_breaks ? ' ee-break-after' : '').'">'.$datetime_name.'</strong>';
479 479
 					}
480 480
 					
481 481
 					$html .= '<span class="ee-event-datetime-date">';
482
-					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">' . $datetime->date_range( $date_format ) . '</span>';
482
+					$html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">'.$datetime->date_range($date_format).'</span>';
483 483
 					$html .= '</span>';
484 484
 					
485 485
 					$html .= '<span class="ee-event-datetime-time">';
486
-					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">' . $datetime->time_range( $time_format ) . '</span>';
486
+					$html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">'.$datetime->time_range($time_format).'</span>';
487 487
 					$html .= '</span>';
488 488
 					
489 489
 					$datetime_description = $datetime->description();
490
-					if (!empty( $datetime_description )) {
490
+					if ( ! empty($datetime_description)) {
491 491
 						$html .= '<span class="ee-event-datetime-description'.($add_breaks ? ' ee-break-before' : '').'">';
492
-						$html .= ' - ' . $datetime_description;
492
+						$html .= ' - '.$datetime_description;
493 493
 						$html .= '</span>';
494 494
 					}
495 495
 					
496
-					$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
496
+					$html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime);
497 497
 					$html .= '</li>';
498 498
 				}
499 499
 			}
500 500
 			$html .= $format ? '</ul>' : '';
501 501
 		} else {
502
-			$html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
502
+			$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : '';
503 503
 		}
504
-		if ( $echo ) {
504
+		if ($echo) {
505 505
 			echo $html;
506 506
 			return '';
507 507
 		}
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 }
511 511
 
512 512
 
513
-if ( ! function_exists( 'espresso_event_end_date' )) {
513
+if ( ! function_exists('espresso_event_end_date')) {
514 514
 	/**
515 515
 	 * espresso_event_end_date
516 516
 	 * returns the last date for an event
@@ -521,20 +521,20 @@  discard block
 block discarded – undo
521 521
 	 * @param bool   $echo
522 522
 	 * @return string
523 523
 	 */
524
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
525
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
526
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
527
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
528
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
529
-		if($echo){
530
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
524
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
525
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
526
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
527
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
528
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
529
+		if ($echo) {
530
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
531 531
 			return '';
532 532
 		}
533
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
533
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
534 534
 	}
535 535
 }
536 536
 
537
-if ( ! function_exists( 'espresso_event_date_range' )) {
537
+if ( ! function_exists('espresso_event_date_range')) {
538 538
 	/**
539 539
 	 * espresso_event_date_range
540 540
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -547,31 +547,31 @@  discard block
 block discarded – undo
547 547
 	 * @param bool   $echo
548 548
 	 * @return string
549 549
 	 */
550
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
550
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
551 551
 		// set and filter date and time formats when a range is returned
552
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
553
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
552
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
553
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
554 554
 		// get the start and end date with NO time portion
555
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
556
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
555
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
556
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
557 557
 		// now we can determine if date range spans more than one day
558
-		if ( $the_event_date != $the_event_end_date ) {
559
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
560
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
558
+		if ($the_event_date != $the_event_end_date) {
559
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
560
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
561 561
 			$html = sprintf(
562
-				__( '%1$s - %2$s', 'event_espresso' ),
563
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
564
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
562
+				__('%1$s - %2$s', 'event_espresso'),
563
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
564
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
565 565
 			);
566 566
 		} else {
567 567
 			// set and filter date and time formats when only a single datetime is returned
568
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
569
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
570
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
571
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
572
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
568
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
569
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
570
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
571
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
572
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
573 573
 		}
574
-		if ( $echo ) {
574
+		if ($echo) {
575 575
 			echo $html;
576 576
 			return '';
577 577
 		}
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 }
581 581
 
582 582
 
583
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
583
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
584 584
 	/**
585 585
 	 * espresso_event_date_as_calendar_page
586 586
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
 	 * @param bool $EVT_ID
589 589
 	 * @return string
590 590
 	 */
591
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
592
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
591
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
592
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
593 593
 	}
594 594
 }
595 595
 
596 596
 
597 597
 
598 598
 
599
-if ( ! function_exists( 'espresso_event_link_url' )) {
599
+if ( ! function_exists('espresso_event_link_url')) {
600 600
 	/**
601 601
 	 * espresso_event_link_url
602 602
 	 *
@@ -604,18 +604,18 @@  discard block
 block discarded – undo
604 604
 	 * @param bool $echo
605 605
 	 * @return string
606 606
 	 */
607
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
608
-		if ( $echo ) {
609
-			echo EEH_Event_View::event_link_url( $EVT_ID );
607
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
608
+		if ($echo) {
609
+			echo EEH_Event_View::event_link_url($EVT_ID);
610 610
 			return '';
611 611
 		}
612
-		return EEH_Event_View::event_link_url( $EVT_ID );
612
+		return EEH_Event_View::event_link_url($EVT_ID);
613 613
 	}
614 614
 }
615 615
 
616 616
 
617 617
 
618
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
618
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
619 619
 	/**
620 620
 	 *    espresso_event_has_content_or_excerpt
621 621
 	 *
@@ -623,15 +623,15 @@  discard block
 block discarded – undo
623 623
 	 * @param bool $EVT_ID
624 624
 	 * @return    boolean
625 625
 	 */
626
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
627
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
626
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
627
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
628 628
 	}
629 629
 }
630 630
 
631 631
 
632 632
 
633 633
 
634
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
634
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
635 635
 	/**
636 636
 	 * espresso_event_content_or_excerpt
637 637
 	 *
@@ -640,18 +640,18 @@  discard block
 block discarded – undo
640 640
 	 * @param bool $echo
641 641
 	 * @return string
642 642
 	 */
643
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
644
-		if ( $echo ) {
645
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
643
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
644
+		if ($echo) {
645
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
646 646
 			return '';
647 647
 		}
648
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
648
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
649 649
 	}
650 650
 }
651 651
 
652 652
 
653 653
 
654
-if ( ! function_exists( 'espresso_event_phone' )) {
654
+if ( ! function_exists('espresso_event_phone')) {
655 655
 	/**
656 656
 	 * espresso_event_phone
657 657
 	 *
@@ -659,18 +659,18 @@  discard block
 block discarded – undo
659 659
 	 * @param bool $echo
660 660
 	 * @return string
661 661
 	 */
662
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
663
-		if ( $echo ) {
664
-			echo EEH_Event_View::event_phone( $EVT_ID );
662
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
663
+		if ($echo) {
664
+			echo EEH_Event_View::event_phone($EVT_ID);
665 665
 			return '';
666 666
 		}
667
-		return EEH_Event_View::event_phone( $EVT_ID );
667
+		return EEH_Event_View::event_phone($EVT_ID);
668 668
 	}
669 669
 }
670 670
 
671 671
 
672 672
 
673
-if ( ! function_exists( 'espresso_edit_event_link' )) {
673
+if ( ! function_exists('espresso_edit_event_link')) {
674 674
 	/**
675 675
 	 * espresso_edit_event_link
676 676
 	 * returns a link to edit an event
@@ -679,39 +679,39 @@  discard block
 block discarded – undo
679 679
 	 * @param bool $echo
680 680
 	 * @return string
681 681
 	 */
682
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
683
-		if ( $echo ) {
684
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
682
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
683
+		if ($echo) {
684
+			echo EEH_Event_View::edit_event_link($EVT_ID);
685 685
 			return '';
686 686
 		}
687
-		return EEH_Event_View::edit_event_link( $EVT_ID );
687
+		return EEH_Event_View::edit_event_link($EVT_ID);
688 688
 	}
689 689
 }
690 690
 
691 691
 
692
-if ( ! function_exists( 'espresso_organization_name' )) {
692
+if ( ! function_exists('espresso_organization_name')) {
693 693
 	/**
694 694
 	 * espresso_organization_name
695 695
 	 * @param bool $echo
696 696
 	 * @return string
697 697
 	 */
698 698
 	function espresso_organization_name($echo = TRUE) {
699
-		if($echo){
700
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
699
+		if ($echo) {
700
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
701 701
 			return '';
702 702
 		}
703
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
703
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
704 704
 	}
705 705
 }
706 706
 
707
-if ( ! function_exists( 'espresso_organization_address' )) {
707
+if ( ! function_exists('espresso_organization_address')) {
708 708
 	/**
709 709
 	 * espresso_organization_address
710 710
 	 * @param string $type
711 711
 	 * @return string
712 712
 	 */
713
-	function espresso_organization_address( $type = 'inline' ) {
714
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
713
+	function espresso_organization_address($type = 'inline') {
714
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
715 715
 			$address = new EventEspresso\core\domain\entities\GenericAddress(
716 716
 				EE_Registry::instance()->CFG->organization->address_1,
717 717
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -720,129 +720,129 @@  discard block
 block discarded – undo
720 720
 				EE_Registry::instance()->CFG->organization->zip,
721 721
 				EE_Registry::instance()->CFG->organization->CNT_ISO
722 722
 			);
723
-			return EEH_Address::format( $address, $type );
723
+			return EEH_Address::format($address, $type);
724 724
 		}
725 725
 		return '';
726 726
 	}
727 727
 }
728 728
 
729
-if ( ! function_exists( 'espresso_organization_email' )) {
729
+if ( ! function_exists('espresso_organization_email')) {
730 730
 	/**
731 731
 	 * espresso_organization_email
732 732
 	 * @param bool $echo
733 733
 	 * @return string
734 734
 	 */
735
-	function espresso_organization_email( $echo = TRUE ) {
736
-		if($echo){
737
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
735
+	function espresso_organization_email($echo = TRUE) {
736
+		if ($echo) {
737
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
738 738
 			return '';
739 739
 		}
740
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
740
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
741 741
 	}
742 742
 }
743 743
 
744
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
744
+if ( ! function_exists('espresso_organization_logo_url')) {
745 745
 	/**
746 746
 	 * espresso_organization_logo_url
747 747
 	 * @param bool $echo
748 748
 	 * @return string
749 749
 	 */
750
-	function espresso_organization_logo_url( $echo = TRUE ) {
751
-		if($echo){
752
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
750
+	function espresso_organization_logo_url($echo = TRUE) {
751
+		if ($echo) {
752
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
753 753
 			return '';
754 754
 		}
755
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
755
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
756 756
 	}
757 757
 }
758 758
 
759
-if ( ! function_exists( 'espresso_organization_facebook' )) {
759
+if ( ! function_exists('espresso_organization_facebook')) {
760 760
 	/**
761 761
 	 * espresso_organization_facebook
762 762
 	 * @param bool $echo
763 763
 	 * @return string
764 764
 	 */
765
-	function espresso_organization_facebook( $echo = TRUE ) {
766
-		if($echo){
767
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
765
+	function espresso_organization_facebook($echo = TRUE) {
766
+		if ($echo) {
767
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
768 768
 			return '';
769 769
 		}
770
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
770
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
771 771
 	}
772 772
 }
773 773
 
774
-if ( ! function_exists( 'espresso_organization_twitter' )) {
774
+if ( ! function_exists('espresso_organization_twitter')) {
775 775
 	/**
776 776
 	 * espresso_organization_twitter
777 777
 	 * @param bool $echo
778 778
 	 * @return string
779 779
 	 */
780
-	function espresso_organization_twitter( $echo = TRUE ) {
781
-		if($echo){
782
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
780
+	function espresso_organization_twitter($echo = TRUE) {
781
+		if ($echo) {
782
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
783 783
 			return '';
784 784
 		}
785
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
785
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
786 786
 	}
787 787
 }
788 788
 
789
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
789
+if ( ! function_exists('espresso_organization_linkedin')) {
790 790
 	/**
791 791
 	 * espresso_organization_linkedin
792 792
 	 * @param bool $echo
793 793
 	 * @return string
794 794
 	 */
795
-	function espresso_organization_linkedin( $echo = TRUE ) {
796
-		if($echo){
797
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
795
+	function espresso_organization_linkedin($echo = TRUE) {
796
+		if ($echo) {
797
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
798 798
 			return '';
799 799
 		}
800
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
800
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
801 801
 	}
802 802
 }
803 803
 
804
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
804
+if ( ! function_exists('espresso_organization_pinterest')) {
805 805
 	/**
806 806
 	 * espresso_organization_pinterest
807 807
 	 * @param bool $echo
808 808
 	 * @return string
809 809
 	 */
810
-	function espresso_organization_pinterest( $echo = TRUE ) {
811
-		if($echo){
812
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
810
+	function espresso_organization_pinterest($echo = TRUE) {
811
+		if ($echo) {
812
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
813 813
 			return '';
814 814
 		}
815
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
815
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
816 816
 	}
817 817
 }
818 818
 
819
-if ( ! function_exists( 'espresso_organization_google' )) {
819
+if ( ! function_exists('espresso_organization_google')) {
820 820
 	/**
821 821
 	 * espresso_organization_google
822 822
 	 * @param bool $echo
823 823
 	 * @return string
824 824
 	 */
825
-	function espresso_organization_google( $echo = TRUE ) {
826
-		if($echo){
827
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
825
+	function espresso_organization_google($echo = TRUE) {
826
+		if ($echo) {
827
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
828 828
 			return '';
829 829
 		}
830
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
830
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
831 831
 	}
832 832
 }
833 833
 
834
-if ( ! function_exists( 'espresso_organization_instagram' )) {
834
+if ( ! function_exists('espresso_organization_instagram')) {
835 835
 	/**
836 836
 	 * espresso_organization_instagram
837 837
 	 * @param bool $echo
838 838
 	 * @return string
839 839
 	 */
840
-	function espresso_organization_instagram( $echo = TRUE ) {
841
-		if($echo){
842
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
840
+	function espresso_organization_instagram($echo = TRUE) {
841
+		if ($echo) {
842
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
843 843
 			return '';
844 844
 		}
845
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
845
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
846 846
 	}
847 847
 }
848 848
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 
853 853
 
854 854
 
855
-if ( ! function_exists( 'espresso_event_venues' )) {
855
+if ( ! function_exists('espresso_event_venues')) {
856 856
 	/**
857 857
 	 * espresso_event_venues
858 858
 	 *
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 
867 867
 
868 868
 
869
-if ( ! function_exists( 'espresso_venue_id' )) {
869
+if ( ! function_exists('espresso_venue_id')) {
870 870
 	/**
871 871
 	 *    espresso_venue_name
872 872
 	 *
@@ -874,15 +874,15 @@  discard block
 block discarded – undo
874 874
 	 * @param     int $EVT_ID
875 875
 	 * @return    string
876 876
 	 */
877
-	function espresso_venue_id( $EVT_ID = 0 ) {
878
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
877
+	function espresso_venue_id($EVT_ID = 0) {
878
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
879 879
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
880 880
 	}
881 881
 }
882 882
 
883 883
 
884 884
 
885
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
885
+if ( ! function_exists('espresso_is_venue_private')) {
886 886
 	/**
887 887
 	 * Return whether a venue is private or not.
888 888
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -891,45 +891,45 @@  discard block
 block discarded – undo
891 891
 	 *
892 892
 	 * @return bool | null
893 893
 	 */
894
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
895
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
894
+	function espresso_is_venue_private($VNU_ID = 0) {
895
+		return EEH_Venue_View::is_venue_private($VNU_ID);
896 896
 	}
897 897
 }
898 898
 
899 899
 
900 900
 
901
-if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) {
901
+if ( ! function_exists('espresso_venue_is_password_protected')) {
902 902
 	/**
903 903
 	 * returns true or false if a venue is password protected or not
904 904
 	 *
905 905
 	 * @param int     $VNU_ID optional, the venue id to check.
906 906
 	 * @return string
907 907
 	 */
908
-	function espresso_venue_is_password_protected( $VNU_ID = 0 ) {
909
-		EE_Registry::instance()->load_helper( 'Venue_View' );
910
-		return EEH_Venue_View::is_venue_password_protected( $VNU_ID );
908
+	function espresso_venue_is_password_protected($VNU_ID = 0) {
909
+		EE_Registry::instance()->load_helper('Venue_View');
910
+		return EEH_Venue_View::is_venue_password_protected($VNU_ID);
911 911
 	}
912 912
 }
913 913
 
914 914
 
915 915
 
916
-if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) {
916
+if ( ! function_exists('espresso_password_protected_venue_form')) {
917 917
 	/**
918 918
 	 * Returns a password form if venue is password protected.
919 919
 	 *
920 920
 	 * @param int     $VNU_ID optional, the venue id to check.
921 921
 	 * @return string
922 922
 	 */
923
-	function espresso_password_protected_venue_form( $VNU_ID = 0 ) {
924
-		EE_Registry::instance()->load_helper( 'Venue_View' );
925
-		return EEH_Venue_View::password_protected_venue_form( $VNU_ID );
923
+	function espresso_password_protected_venue_form($VNU_ID = 0) {
924
+		EE_Registry::instance()->load_helper('Venue_View');
925
+		return EEH_Venue_View::password_protected_venue_form($VNU_ID);
926 926
 	}
927 927
 }
928 928
 
929 929
 
930 930
 
931 931
 
932
-if ( ! function_exists( 'espresso_venue_name' )) {
932
+if ( ! function_exists('espresso_venue_name')) {
933 933
 	/**
934 934
 	 *    espresso_venue_name
935 935
 	 *
@@ -939,19 +939,19 @@  discard block
 block discarded – undo
939 939
 	 * @param bool   $echo
940 940
 	 * @return    string
941 941
 	 */
942
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
943
-		if($echo){
944
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
942
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
943
+		if ($echo) {
944
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
945 945
 			return '';
946 946
 		}
947
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
947
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
948 948
 	}
949 949
 }
950 950
 
951 951
 
952 952
 
953 953
 
954
-if ( ! function_exists( 'espresso_venue_link' )) {
954
+if ( ! function_exists('espresso_venue_link')) {
955 955
 	/**
956 956
 	 * 	espresso_venue_link
957 957
 	 *
@@ -960,14 +960,14 @@  discard block
 block discarded – undo
960 960
 	 *  @param 	string 	$text
961 961
 	 *  @return 	string
962 962
 	 */
963
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
964
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
963
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
964
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
965 965
 	}
966 966
 }
967 967
 
968 968
 
969 969
 
970
-if ( ! function_exists( 'espresso_venue_description' )) {
970
+if ( ! function_exists('espresso_venue_description')) {
971 971
 	/**
972 972
 	 *    espresso_venue_description
973 973
 	 *
@@ -976,17 +976,17 @@  discard block
 block discarded – undo
976 976
 	 * @param bool $echo
977 977
 	 * @return    string
978 978
 	 */
979
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
980
-		if($echo){
981
-			echo EEH_Venue_View::venue_description( $VNU_ID );
979
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
980
+		if ($echo) {
981
+			echo EEH_Venue_View::venue_description($VNU_ID);
982 982
 			return '';
983 983
 		}
984
-		return EEH_Venue_View::venue_description( $VNU_ID );
984
+		return EEH_Venue_View::venue_description($VNU_ID);
985 985
 	}
986 986
 }
987 987
 
988 988
 
989
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
989
+if ( ! function_exists('espresso_venue_excerpt')) {
990 990
 	/**
991 991
 	 *    espresso_venue_excerpt
992 992
 	 *
@@ -995,18 +995,18 @@  discard block
 block discarded – undo
995 995
 	 * @param bool $echo
996 996
 	 * @return    string
997 997
 	 */
998
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
999
-		if ( $echo ) {
1000
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
998
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
999
+		if ($echo) {
1000
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
1001 1001
 			return '';
1002 1002
 		}
1003
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
1003
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
1004 1004
 	}
1005 1005
 }
1006 1006
 
1007 1007
 
1008 1008
 
1009
-if ( ! function_exists( 'espresso_venue_categories' )) {
1009
+if ( ! function_exists('espresso_venue_categories')) {
1010 1010
 	/**
1011 1011
 	 * espresso_venue_categories
1012 1012
 	 * returns the terms associated with a venue
@@ -1016,17 +1016,17 @@  discard block
 block discarded – undo
1016 1016
 	 * @param bool $echo
1017 1017
 	 * @return string
1018 1018
 	 */
1019
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
1020
-		if ( $echo ) {
1021
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1019
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
1020
+		if ($echo) {
1021
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1022 1022
 			return '';
1023 1023
 		}
1024
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
1024
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
1025 1025
 	}
1026 1026
 }
1027 1027
 
1028 1028
 
1029
-if ( ! function_exists( 'espresso_venue_address' )) {
1029
+if ( ! function_exists('espresso_venue_address')) {
1030 1030
 	/**
1031 1031
 	 * espresso_venue_address
1032 1032
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1036,17 +1036,17 @@  discard block
 block discarded – undo
1036 1036
 	 * @param bool   $echo
1037 1037
 	 * @return string
1038 1038
 	 */
1039
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1040
-		if ( $echo ) {
1041
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1039
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1040
+		if ($echo) {
1041
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1042 1042
 			return '';
1043 1043
 		}
1044
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1044
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1045 1045
 	}
1046 1046
 }
1047 1047
 
1048 1048
 
1049
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1049
+if ( ! function_exists('espresso_venue_raw_address')) {
1050 1050
 	/**
1051 1051
 	 * espresso_venue_address
1052 1052
 	 * returns an UN-formatted string containing a venue's address
@@ -1056,17 +1056,17 @@  discard block
 block discarded – undo
1056 1056
 	 * @param bool     $echo
1057 1057
 	 * @return string
1058 1058
 	 */
1059
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1060
-		if ( $echo ) {
1061
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1059
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1060
+		if ($echo) {
1061
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1062 1062
 			return '';
1063 1063
 		}
1064
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1064
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1065 1065
 	}
1066 1066
 }
1067 1067
 
1068 1068
 
1069
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1069
+if ( ! function_exists('espresso_venue_has_address')) {
1070 1070
 	/**
1071 1071
 	 * espresso_venue_has_address
1072 1072
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1074,13 +1074,13 @@  discard block
 block discarded – undo
1074 1074
 	 * @param int $VNU_ID
1075 1075
 	 * @return bool
1076 1076
 	 */
1077
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1078
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1077
+	function espresso_venue_has_address($VNU_ID = 0) {
1078
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1079 1079
 	}
1080 1080
 }
1081 1081
 
1082 1082
 
1083
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1083
+if ( ! function_exists('espresso_venue_gmap')) {
1084 1084
 	/**
1085 1085
 	 * espresso_venue_gmap
1086 1086
 	 * returns a google map for the venue address
@@ -1091,17 +1091,17 @@  discard block
 block discarded – undo
1091 1091
 	 * @param bool     $echo
1092 1092
 	 * @return string
1093 1093
 	 */
1094
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1095
-		if ( $echo ) {
1096
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1094
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1095
+		if ($echo) {
1096
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1097 1097
 			return '';
1098 1098
 		}
1099
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1099
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1100 1100
 	}
1101 1101
 }
1102 1102
 
1103 1103
 
1104
-if ( ! function_exists( 'espresso_venue_phone' )) {
1104
+if ( ! function_exists('espresso_venue_phone')) {
1105 1105
 	/**
1106 1106
 	 * espresso_venue_phone
1107 1107
 	 *
@@ -1109,18 +1109,18 @@  discard block
 block discarded – undo
1109 1109
 	 * @param bool $echo
1110 1110
 	 * @return string
1111 1111
 	 */
1112
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1113
-		if ( $echo ) {
1114
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1112
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1113
+		if ($echo) {
1114
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1115 1115
 			return '';
1116 1116
 		}
1117
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1117
+		return EEH_Venue_View::venue_phone($VNU_ID);
1118 1118
 	}
1119 1119
 }
1120 1120
 
1121 1121
 
1122 1122
 
1123
-if ( ! function_exists( 'espresso_venue_website' )) {
1123
+if ( ! function_exists('espresso_venue_website')) {
1124 1124
 	/**
1125 1125
 	 * espresso_venue_website
1126 1126
 	 *
@@ -1128,18 +1128,18 @@  discard block
 block discarded – undo
1128 1128
 	 * @param bool $echo
1129 1129
 	 * @return string
1130 1130
 	 */
1131
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1132
-		if ( $echo ) {
1133
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1131
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1132
+		if ($echo) {
1133
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1134 1134
 			return '';
1135 1135
 		}
1136
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1136
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1137 1137
 	}
1138 1138
 }
1139 1139
 
1140 1140
 
1141 1141
 
1142
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1142
+if ( ! function_exists('espresso_edit_venue_link')) {
1143 1143
 	/**
1144 1144
 	 * espresso_edit_venue_link
1145 1145
 	 *
@@ -1147,12 +1147,12 @@  discard block
 block discarded – undo
1147 1147
 	 * @param bool $echo
1148 1148
 	 * @return string
1149 1149
 	 */
1150
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1151
-		if($echo){
1152
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1150
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1151
+		if ($echo) {
1152
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1153 1153
 			return '';
1154 1154
 		}
1155
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1155
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1156 1156
 	}
1157 1157
 }
1158 1158
 
Please login to merge, or discard this patch.
modules/ticket_selector/ProcessTicketSelector.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             );
50 50
         } else {
51 51
             wp_safe_redirect(
52
-                site_url('/' . \EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
52
+                site_url('/'.\EE_Registry::instance()->CFG->core->event_cpt_slug.'/')
53 53
             );
54 54
         }
55 55
         exit();
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
                 'event_espresso'
162 162
             );
163 163
             $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
164
-            \EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
165
-        } elseif ( apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid) ) {
164
+            \EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
165
+        } elseif (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid)) {
166 166
             // all data appears to be valid
167 167
             $tckts_slctd = false;
168 168
             $tickets_added = 0;
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
         // cycle through $inputs_to_clean array
308 308
         foreach ($inputs_to_clean as $what => $input_to_clean) {
309 309
             // check for POST data
310
-            if (\EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
310
+            if (\EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
311 311
                 // grab value
312
-                $input_value = \EE_Registry::instance()->REQ->get($input_to_clean . $id);
312
+                $input_value = \EE_Registry::instance()->REQ->get($input_to_clean.$id);
313 313
                 switch ($what) {
314 314
                     // integers
315 315
                     case 'event_id':
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
331 331
                         if ( ! is_array($row_qty)) {
332 332
                             // get number of rows
333
-                            $rows = \EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
334
-                                ? absint(\EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
333
+                            $rows = \EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id)
334
+                                ? absint(\EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id))
335 335
                                 : 1;
336 336
                             // explode ints by the dash
337 337
                             $row_qty = explode('-', $row_qty);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
                     case 'ticket_id':
358 358
                         $value_array = array();
359 359
                         // cycle thru values
360
-                        foreach ((array)$input_value as $key => $value) {
360
+                        foreach ((array) $input_value as $key => $value) {
361 361
                             // allow only numbers, letters,  spaces, commas and dashes
362 362
                             $value_array[$key] = wp_strip_all_tags($value);
363 363
                             // get ticket via the ticket id we put in the form
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                             $input_value = explode('#', $input_value);
376 376
                             $input_value = end($input_value);
377 377
                             // use event list url instead, but append anchor
378
-                            $input_value = \EEH_Event_View::event_archive_url() . '#' . $input_value;
378
+                            $input_value = \EEH_Event_View::event_archive_url().'#'.$input_value;
379 379
                         }
380 380
                         $valid_data[$what] = $input_value;
381 381
                         break;
Please login to merge, or discard this patch.
Indentation   +569 added lines, -569 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\modules\ticket_selector;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -19,576 +19,576 @@  discard block
 block discarded – undo
19 19
 class ProcessTicketSelector
20 20
 {
21 21
 
22
-    /**
23
-     * array of datetimes and the spaces available for them
24
-     *
25
-     * @access private
26
-     * @var array
27
-     */
28
-    private static $_available_spaces = array();
29
-
30
-
31
-
32
-    /**
33
-     * cancelTicketSelections
34
-     *
35
-     * @return        string
36
-     */
37
-    public function cancelTicketSelections()
38
-    {
39
-        // check nonce
40
-        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
41
-            return false;
42
-        }
43
-        \EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
44
-        if (\EE_Registry::instance()->REQ->is_set('event_id')) {
45
-            wp_safe_redirect(
46
-                \EEH_Event_View::event_link_url(
47
-                    \EE_Registry::instance()->REQ->get('event_id')
48
-                )
49
-            );
50
-        } else {
51
-            wp_safe_redirect(
52
-                site_url('/' . \EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
53
-            );
54
-        }
55
-        exit();
56
-    }
57
-
58
-
59
-
60
-    /**
61
-     * processTicketSelectorNonce
62
-     *
63
-     * @param  string $nonce_name
64
-     * @param string  $id
65
-     * @return bool
66
-     */
67
-    private function processTicketSelectorNonce($nonce_name, $id = '')
68
-    {
69
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
70
-        if (
71
-            ! is_admin()
72
-            && (
73
-                ! \EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
74
-                || ! wp_verify_nonce(
75
-                    \EE_Registry::instance()->REQ->get($nonce_name_with_id),
76
-                    $nonce_name
77
-                )
78
-            )
79
-        ) {
80
-            \EE_Error::add_error(
81
-                sprintf(
82
-                    __(
83
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
84
-                        'event_espresso'
85
-                    ),
86
-                    '<br/>'
87
-                ),
88
-                __FILE__,
89
-                __FUNCTION__,
90
-                __LINE__
91
-            );
92
-            return false;
93
-        }
94
-        return true;
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * process_ticket_selections
101
-     *
102
-     * @return array|bool
103
-     * @throws \EE_Error
104
-     */
105
-    public function processTicketSelections()
106
-    {
107
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
108
-        // do we have an event id?
109
-        if ( ! \EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
110
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
111
-            \EE_Error::add_error(
112
-                sprintf(
113
-                    __(
114
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
115
-                        'event_espresso'
116
-                    ),
117
-                    '<br/>'
118
-                ),
119
-                __FILE__,
120
-                __FUNCTION__,
121
-                __LINE__
122
-            );
123
-        }
124
-        //if event id is valid
125
-        $id = absint(\EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
126
-        //		d( \EE_Registry::instance()->REQ );
127
-        self::$_available_spaces = array(
128
-            'tickets'   => array(),
129
-            'datetimes' => array(),
130
-        );
131
-        //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
132
-        // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
133
-        \EE_Registry::instance()->load_core('Session');
134
-        // unless otherwise requested, clear the session
135
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
136
-            \EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
137
-        }
138
-        //d( \EE_Registry::instance()->SSN );
139
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
140
-        // validate/sanitize data
141
-        $valid = $this->validatePostData($id);
142
-        //EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
143
-        //EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
144
-        //EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
145
-        //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
146
-        //check total tickets ordered vs max number of attendees that can register
147
-        if ($valid['total_tickets'] > $valid['max_atndz']) {
148
-            // ordering too many tickets !!!
149
-            $total_tickets_string = _n(
150
-                'You have attempted to purchase %s ticket.',
151
-                'You have attempted to purchase %s tickets.',
152
-                $valid['total_tickets'],
153
-                'event_espresso'
154
-            );
155
-            $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
156
-            // dev only message
157
-            $max_atndz_string = _n(
158
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
159
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
160
-                $valid['max_atndz'],
161
-                'event_espresso'
162
-            );
163
-            $limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
164
-            \EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
165
-        } elseif ( apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid) ) {
166
-            // all data appears to be valid
167
-            $tckts_slctd = false;
168
-            $tickets_added = 0;
169
-            $valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid);
170
-            if ($valid['total_tickets'] > 0) {
171
-                // load cart
172
-                \EE_Registry::instance()->load_core('Cart');
173
-                // cycle thru the number of data rows sent from the event listing
174
-                for ($x = 0; $x < $valid['rows']; $x++) {
175
-                    // does this row actually contain a ticket quantity?
176
-                    if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
177
-                        // YES we have a ticket quantity
178
-                        $tckts_slctd = true;
179
-                        //						d( $valid['ticket_obj'][$x] );
180
-                        if ($valid['ticket_obj'][$x] instanceof \EE_Ticket) {
181
-                            // then add ticket to cart
182
-                            $tickets_added += $this->addTicketToCart(
183
-                                $valid['ticket_obj'][$x],
184
-                                $valid['qty'][$x]
185
-                            );
186
-                            if (\EE_Error::has_error()) {
187
-                                break;
188
-                            }
189
-                        } else {
190
-                            // nothing added to cart retrieved
191
-                            \EE_Error::add_error(
192
-                                sprintf(
193
-                                    __(
194
-                                        'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
195
-                                        'event_espresso'
196
-                                    ),
197
-                                    '<br/>'
198
-                                ),
199
-                                __FILE__, __FUNCTION__, __LINE__
200
-                            );
201
-                        }
202
-                    }
203
-                }
204
-            }
205
-            do_action(
206
-                'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
207
-                \EE_Registry::instance()->CART,
208
-                $this
209
-            );
210
-            //d( \EE_Registry::instance()->CART );
211
-            //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
212
-            if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
213
-                if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
214
-                    do_action(
215
-                        'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
216
-                        \EE_Registry::instance()->CART,
217
-                        $this
218
-                    );
219
-                    \EE_Registry::instance()->CART->recalculate_all_cart_totals();
220
-                    \EE_Registry::instance()->CART->save_cart(false);
221
-                    // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
222
-                    // just return TRUE for registrations being made from admin
223
-                    if (is_admin()) {
224
-                        return true;
225
-                    }
226
-                    \EE_Error::get_notices(false, true);
227
-                    wp_safe_redirect(
228
-                        apply_filters(
229
-                            'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
230
-                            \EE_Registry::instance()->CFG->core->reg_page_url()
231
-                        )
232
-                    );
233
-                    exit();
234
-                } else {
235
-                    if ( ! \EE_Error::has_error() && ! \EE_Error::has_error(true, 'attention')) {
236
-                        // nothing added to cart
237
-                        \EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
238
-                            __FILE__, __FUNCTION__, __LINE__);
239
-                    }
240
-                }
241
-            } else {
242
-                // no ticket quantities were selected
243
-                \EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
244
-                    'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
245
-            }
22
+	/**
23
+	 * array of datetimes and the spaces available for them
24
+	 *
25
+	 * @access private
26
+	 * @var array
27
+	 */
28
+	private static $_available_spaces = array();
29
+
30
+
31
+
32
+	/**
33
+	 * cancelTicketSelections
34
+	 *
35
+	 * @return        string
36
+	 */
37
+	public function cancelTicketSelections()
38
+	{
39
+		// check nonce
40
+		if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
41
+			return false;
42
+		}
43
+		\EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
44
+		if (\EE_Registry::instance()->REQ->is_set('event_id')) {
45
+			wp_safe_redirect(
46
+				\EEH_Event_View::event_link_url(
47
+					\EE_Registry::instance()->REQ->get('event_id')
48
+				)
49
+			);
50
+		} else {
51
+			wp_safe_redirect(
52
+				site_url('/' . \EE_Registry::instance()->CFG->core->event_cpt_slug . '/')
53
+			);
54
+		}
55
+		exit();
56
+	}
57
+
58
+
59
+
60
+	/**
61
+	 * processTicketSelectorNonce
62
+	 *
63
+	 * @param  string $nonce_name
64
+	 * @param string  $id
65
+	 * @return bool
66
+	 */
67
+	private function processTicketSelectorNonce($nonce_name, $id = '')
68
+	{
69
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
70
+		if (
71
+			! is_admin()
72
+			&& (
73
+				! \EE_Registry::instance()->REQ->is_set($nonce_name_with_id)
74
+				|| ! wp_verify_nonce(
75
+					\EE_Registry::instance()->REQ->get($nonce_name_with_id),
76
+					$nonce_name
77
+				)
78
+			)
79
+		) {
80
+			\EE_Error::add_error(
81
+				sprintf(
82
+					__(
83
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
84
+						'event_espresso'
85
+					),
86
+					'<br/>'
87
+				),
88
+				__FILE__,
89
+				__FUNCTION__,
90
+				__LINE__
91
+			);
92
+			return false;
93
+		}
94
+		return true;
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * process_ticket_selections
101
+	 *
102
+	 * @return array|bool
103
+	 * @throws \EE_Error
104
+	 */
105
+	public function processTicketSelections()
106
+	{
107
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
108
+		// do we have an event id?
109
+		if ( ! \EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
110
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
111
+			\EE_Error::add_error(
112
+				sprintf(
113
+					__(
114
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
115
+						'event_espresso'
116
+					),
117
+					'<br/>'
118
+				),
119
+				__FILE__,
120
+				__FUNCTION__,
121
+				__LINE__
122
+			);
123
+		}
124
+		//if event id is valid
125
+		$id = absint(\EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
126
+		//		d( \EE_Registry::instance()->REQ );
127
+		self::$_available_spaces = array(
128
+			'tickets'   => array(),
129
+			'datetimes' => array(),
130
+		);
131
+		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
132
+		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
133
+		\EE_Registry::instance()->load_core('Session');
134
+		// unless otherwise requested, clear the session
135
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
136
+			\EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
137
+		}
138
+		//d( \EE_Registry::instance()->SSN );
139
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
140
+		// validate/sanitize data
141
+		$valid = $this->validatePostData($id);
142
+		//EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
143
+		//EEH_Debug_Tools::printr( $valid, '$valid', __FILE__, __LINE__ );
144
+		//EEH_Debug_Tools::printr( $valid[ 'total_tickets' ], 'total_tickets', __FILE__, __LINE__ );
145
+		//EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ );
146
+		//check total tickets ordered vs max number of attendees that can register
147
+		if ($valid['total_tickets'] > $valid['max_atndz']) {
148
+			// ordering too many tickets !!!
149
+			$total_tickets_string = _n(
150
+				'You have attempted to purchase %s ticket.',
151
+				'You have attempted to purchase %s tickets.',
152
+				$valid['total_tickets'],
153
+				'event_espresso'
154
+			);
155
+			$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
156
+			// dev only message
157
+			$max_atndz_string = _n(
158
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
159
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
160
+				$valid['max_atndz'],
161
+				'event_espresso'
162
+			);
163
+			$limit_error_2 = sprintf($max_atndz_string, $valid['max_atndz'], $valid['max_atndz']);
164
+			\EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
165
+		} elseif ( apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__validate_requested_tickets', true, $valid) ) {
166
+			// all data appears to be valid
167
+			$tckts_slctd = false;
168
+			$tickets_added = 0;
169
+			$valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid);
170
+			if ($valid['total_tickets'] > 0) {
171
+				// load cart
172
+				\EE_Registry::instance()->load_core('Cart');
173
+				// cycle thru the number of data rows sent from the event listing
174
+				for ($x = 0; $x < $valid['rows']; $x++) {
175
+					// does this row actually contain a ticket quantity?
176
+					if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
177
+						// YES we have a ticket quantity
178
+						$tckts_slctd = true;
179
+						//						d( $valid['ticket_obj'][$x] );
180
+						if ($valid['ticket_obj'][$x] instanceof \EE_Ticket) {
181
+							// then add ticket to cart
182
+							$tickets_added += $this->addTicketToCart(
183
+								$valid['ticket_obj'][$x],
184
+								$valid['qty'][$x]
185
+							);
186
+							if (\EE_Error::has_error()) {
187
+								break;
188
+							}
189
+						} else {
190
+							// nothing added to cart retrieved
191
+							\EE_Error::add_error(
192
+								sprintf(
193
+									__(
194
+										'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
195
+										'event_espresso'
196
+									),
197
+									'<br/>'
198
+								),
199
+								__FILE__, __FUNCTION__, __LINE__
200
+							);
201
+						}
202
+					}
203
+				}
204
+			}
205
+			do_action(
206
+				'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
207
+				\EE_Registry::instance()->CART,
208
+				$this
209
+			);
210
+			//d( \EE_Registry::instance()->CART );
211
+			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
212
+			if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
213
+				if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
214
+					do_action(
215
+						'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
216
+						\EE_Registry::instance()->CART,
217
+						$this
218
+					);
219
+					\EE_Registry::instance()->CART->recalculate_all_cart_totals();
220
+					\EE_Registry::instance()->CART->save_cart(false);
221
+					// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
222
+					// just return TRUE for registrations being made from admin
223
+					if (is_admin()) {
224
+						return true;
225
+					}
226
+					\EE_Error::get_notices(false, true);
227
+					wp_safe_redirect(
228
+						apply_filters(
229
+							'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
230
+							\EE_Registry::instance()->CFG->core->reg_page_url()
231
+						)
232
+					);
233
+					exit();
234
+				} else {
235
+					if ( ! \EE_Error::has_error() && ! \EE_Error::has_error(true, 'attention')) {
236
+						// nothing added to cart
237
+						\EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'),
238
+							__FILE__, __FUNCTION__, __LINE__);
239
+					}
240
+				}
241
+			} else {
242
+				// no ticket quantities were selected
243
+				\EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.',
244
+					'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
245
+			}
246 246
             
247
-        } elseif ( ! \EE_Error::has_error() && ! \EE_Error::has_error(true, 'attention')) {
248
-            // nothing added to cart
249
-            \EE_Error::add_attention(__('There was an error adding your tickets to the cart', 'event_espresso'), __FILE__,
250
-                __FUNCTION__, __LINE__);
251
-        }
247
+		} elseif ( ! \EE_Error::has_error() && ! \EE_Error::has_error(true, 'attention')) {
248
+			// nothing added to cart
249
+			\EE_Error::add_attention(__('There was an error adding your tickets to the cart', 'event_espresso'), __FILE__,
250
+				__FUNCTION__, __LINE__);
251
+		}
252 252
         
253
-        //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
254
-        // at this point, just return if registration is being made from admin
255
-        if (is_admin()) {
256
-            return false;
257
-        }
258
-        if ($valid['return_url']) {
259
-            \EE_Error::get_notices(false, true);
260
-            wp_safe_redirect($valid['return_url']);
261
-            exit();
262
-        } elseif (isset($event_to_add['id'])) {
263
-            \EE_Error::get_notices(false, true);
264
-            wp_safe_redirect(get_permalink($event_to_add['id']));
265
-            exit();
266
-        } else {
267
-            echo \EE_Error::get_notices();
268
-        }
269
-        return false;
270
-    }
271
-
272
-
273
-
274
-    /**
275
-     * validate_post_data
276
-     *
277
-     * @param int $id
278
-     * @return array|FALSE
279
-     */
280
-    private function validatePostData($id = 0)
281
-    {
282
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
283
-        if ( ! $id) {
284
-            \EE_Error::add_error(
285
-                __('The event id provided was not valid.', 'event_espresso'),
286
-                __FILE__,
287
-                __FUNCTION__,
288
-                __LINE__
289
-            );
290
-            return false;
291
-        }
292
-        // start with an empty array()
293
-        $valid_data = array();
294
-        // grab valid id
295
-        $valid_data['id'] = $id;
296
-        // array of other form names
297
-        $inputs_to_clean = array(
298
-            'event_id'   => 'tkt-slctr-event-id',
299
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
300
-            'rows'       => 'tkt-slctr-rows-',
301
-            'qty'        => 'tkt-slctr-qty-',
302
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
303
-            'return_url' => 'tkt-slctr-return-url-',
304
-        );
305
-        // let's track the total number of tickets ordered.'
306
-        $valid_data['total_tickets'] = 0;
307
-        // cycle through $inputs_to_clean array
308
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
309
-            // check for POST data
310
-            if (\EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
311
-                // grab value
312
-                $input_value = \EE_Registry::instance()->REQ->get($input_to_clean . $id);
313
-                switch ($what) {
314
-                    // integers
315
-                    case 'event_id':
316
-                        $valid_data[$what] = absint($input_value);
317
-                        // get event via the event id we put in the form
318
-                        $valid_data['event'] = \EE_Registry::instance()
319
-                                                           ->load_model('Event')
320
-                                                           ->get_one_by_ID($valid_data['event_id']);
321
-                        break;
322
-                    case 'rows':
323
-                    case 'max_atndz':
324
-                        $valid_data[$what] = absint($input_value);
325
-                        break;
326
-                    // arrays of integers
327
-                    case 'qty':
328
-                        /** @var array $row_qty */
329
-                        $row_qty = $input_value;
330
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
331
-                        if ( ! is_array($row_qty)) {
332
-                            // get number of rows
333
-                            $rows = \EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
334
-                                ? absint(\EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
335
-                                : 1;
336
-                            // explode ints by the dash
337
-                            $row_qty = explode('-', $row_qty);
338
-                            $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
339
-                            $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
340
-                            $row_qty = array($row => $qty);
341
-                            for ($x = 1; $x <= $rows; $x++) {
342
-                                if ( ! isset($row_qty[$x])) {
343
-                                    $row_qty[$x] = 0;
344
-                                }
345
-                            }
346
-                        }
347
-                        ksort($row_qty);
348
-                        // cycle thru values
349
-                        foreach ($row_qty as $qty) {
350
-                            $qty = absint($qty);
351
-                            // sanitize as integers
352
-                            $valid_data[$what][] = $qty;
353
-                            $valid_data['total_tickets'] += $qty;
354
-                        }
355
-                        break;
356
-                    // array of integers
357
-                    case 'ticket_id':
358
-                        $value_array = array();
359
-                        // cycle thru values
360
-                        foreach ((array)$input_value as $key => $value) {
361
-                            // allow only numbers, letters,  spaces, commas and dashes
362
-                            $value_array[$key] = wp_strip_all_tags($value);
363
-                            // get ticket via the ticket id we put in the form
364
-                            $ticket_obj = \EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
365
-                            $valid_data['ticket_obj'][$key] = $ticket_obj;
366
-                        }
367
-                        $valid_data[$what] = $value_array;
368
-                        break;
369
-                    case 'return_url' :
370
-                        // grab and sanitize return-url
371
-                        $input_value = esc_url_raw($input_value);
372
-                        // was the request coming from an iframe ? if so, then:
373
-                        if (strpos($input_value, 'event_list=iframe')) {
374
-                            // get anchor fragment
375
-                            $input_value = explode('#', $input_value);
376
-                            $input_value = end($input_value);
377
-                            // use event list url instead, but append anchor
378
-                            $input_value = \EEH_Event_View::event_archive_url() . '#' . $input_value;
379
-                        }
380
-                        $valid_data[$what] = $input_value;
381
-                        break;
382
-                }    // end switch $what
383
-            }
384
-        }    // end foreach $inputs_to_clean
385
-        return $valid_data;
386
-    }
387
-
388
-
389
-
390
-    /**
391
-     * adds a ticket to the cart
392
-     *
393
-     * @param \EE_Ticket $ticket
394
-     * @param int        $qty
395
-     * @return TRUE on success, FALSE on fail
396
-     * @throws \EE_Error
397
-     */
398
-    private function addTicketToCart(\EE_Ticket $ticket = null, $qty = 1)
399
-    {
400
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
401
-        // get the number of spaces left for this datetime ticket
402
-        $available_spaces = $this->ticketDatetimeAvailability($ticket);
403
-        // compare available spaces against the number of tickets being purchased
404
-        if ($available_spaces >= $qty) {
405
-            // allow addons to prevent a ticket from being added to cart
406
-            if (
407
-            ! apply_filters(
408
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
409
-                true,
410
-                $ticket,
411
-                $qty,
412
-                $available_spaces
413
-            )
414
-            ) {
415
-                return false;
416
-            }
417
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
418
-            // add event to cart
419
-            if (\EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
420
-                $this->recalculateTicketDatetimeAvailability($ticket, $qty);
421
-                return true;
422
-            }
423
-            return false;
424
-        }
425
-        // tickets can not be purchased but let's find the exact number left
426
-        // for the last ticket selected PRIOR to subtracting tickets
427
-        $available_spaces = $this->ticketDatetimeAvailability($ticket, true);
428
-        // greedy greedy greedy eh?
429
-        if ($available_spaces > 0) {
430
-            if (
431
-            apply_filters(
432
-                'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
433
-                true,
434
-                $ticket,
435
-                $qty,
436
-                $available_spaces
437
-            )
438
-            ) {
439
-                $this->displayAvailabilityError($available_spaces);
440
-            }
441
-        } else {
442
-            \EE_Error::add_error(
443
-                __(
444
-                    'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
445
-                    'event_espresso'
446
-                ),
447
-                __FILE__, __FUNCTION__, __LINE__
448
-            );
449
-        }
450
-        return false;
451
-    }
452
-
453
-
454
-
455
-    /**
456
-     * @param int $available_spaces
457
-     * @throws \EE_Error
458
-     */
459
-    private function displayAvailabilityError($available_spaces = 1)
460
-    {
461
-        // add error messaging - we're using the _n function that will generate
462
-        // the appropriate singular or plural message based on the number of $available_spaces
463
-        if (\EE_Registry::instance()->CART->all_ticket_quantity_count()) {
464
-            $msg = sprintf(
465
-                _n(
466
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
467
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
468
-                    $available_spaces,
469
-                    'event_espresso'
470
-                ),
471
-                $available_spaces,
472
-                '<br />'
473
-            );
474
-        } else {
475
-            $msg = sprintf(
476
-                _n(
477
-                    'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
478
-                    'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
479
-                    $available_spaces,
480
-                    'event_espresso'
481
-                ),
482
-                $available_spaces,
483
-                '<br />'
484
-            );
485
-        }
486
-        \EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
487
-    }
488
-
489
-
490
-
491
-    /**
492
-     * ticketDatetimeAvailability
493
-     * creates an array of tickets plus all of the datetimes available to each ticket
494
-     * and tracks the spaces remaining for each of those datetimes
495
-     *
496
-     * @param \EE_Ticket $ticket - selected ticket
497
-     * @param bool       $get_original_ticket_spaces
498
-     * @return int
499
-     * @throws \EE_Error
500
-     */
501
-    private function ticketDatetimeAvailability(\EE_Ticket $ticket, $get_original_ticket_spaces = false)
502
-    {
503
-        // if the $_available_spaces array has not been set up yet...
504
-        if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
505
-            $this->setInitialTicketDatetimeAvailability($ticket);
506
-        }
507
-        $available_spaces = $ticket->qty() - $ticket->sold();
508
-        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
509
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
510
-            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
511
-                // if we want the original datetime availability BEFORE we started subtracting tickets ?
512
-                if ($get_original_ticket_spaces) {
513
-                    // then grab the available spaces from the "tickets" array
514
-                    // and compare with the above to get the lowest number
515
-                    $available_spaces = min(
516
-                        $available_spaces,
517
-                        self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]
518
-                    );
519
-                } else {
520
-                    // we want the updated ticket availability as stored in the "datetimes" array
521
-                    $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
522
-                }
523
-            }
524
-        }
525
-        return $available_spaces;
526
-    }
527
-
528
-
529
-
530
-    /**
531
-     * @param \EE_Ticket $ticket
532
-     * @return void
533
-     * @throws \EE_Error
534
-     */
535
-    private function setInitialTicketDatetimeAvailability(\EE_Ticket $ticket)
536
-    {
537
-        // first, get all of the datetimes that are available to this ticket
538
-        $datetimes = $ticket->get_many_related(
539
-            'Datetime',
540
-            array(
541
-                array(
542
-                    'DTT_EVT_end' => array(
543
-                        '>=',
544
-                        \EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
545
-                    ),
546
-                ),
547
-                'order_by' => array('DTT_EVT_start' => 'ASC'),
548
-            )
549
-        );
550
-        if ( ! empty($datetimes)) {
551
-            // now loop thru all of the datetimes
552
-            foreach ($datetimes as $datetime) {
553
-                if ($datetime instanceof \EE_Datetime) {
554
-                    // the number of spaces available for the datetime without considering individual ticket quantities
555
-                    $spaces_remaining = $datetime->spaces_remaining();
556
-                    // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
557
-                    // or the datetime spaces remaining) to this ticket using the datetime ID as the key
558
-                    self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
559
-                        $ticket->qty() - $ticket->sold(),
560
-                        $spaces_remaining
561
-                    );
562
-                    // if the remaining spaces for this datetime is already set,
563
-                    // then compare that against the datetime spaces remaining, and take the lowest number,
564
-                    // else just take the datetime spaces remaining, and assign to the datetimes array
565
-                    self::$_available_spaces['datetimes'][$datetime->ID()] = isset(
566
-                        self::$_available_spaces['datetimes'][$datetime->ID()]
567
-                    )
568
-                        ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
569
-                        : $spaces_remaining;
570
-                }
571
-            }
572
-        }
573
-    }
574
-
575
-
576
-
577
-    /**
578
-     * @param    \EE_Ticket $ticket
579
-     * @param    int        $qty
580
-     * @return    void
581
-     */
582
-    private function recalculateTicketDatetimeAvailability(\EE_Ticket $ticket, $qty = 0)
583
-    {
584
-        if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
585
-            // loop thru tickets, which will ALSO include individual ticket records AND a total
586
-            foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
587
-                // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
588
-                self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
589
-            }
590
-        }
591
-    }
253
+		//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
254
+		// at this point, just return if registration is being made from admin
255
+		if (is_admin()) {
256
+			return false;
257
+		}
258
+		if ($valid['return_url']) {
259
+			\EE_Error::get_notices(false, true);
260
+			wp_safe_redirect($valid['return_url']);
261
+			exit();
262
+		} elseif (isset($event_to_add['id'])) {
263
+			\EE_Error::get_notices(false, true);
264
+			wp_safe_redirect(get_permalink($event_to_add['id']));
265
+			exit();
266
+		} else {
267
+			echo \EE_Error::get_notices();
268
+		}
269
+		return false;
270
+	}
271
+
272
+
273
+
274
+	/**
275
+	 * validate_post_data
276
+	 *
277
+	 * @param int $id
278
+	 * @return array|FALSE
279
+	 */
280
+	private function validatePostData($id = 0)
281
+	{
282
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
283
+		if ( ! $id) {
284
+			\EE_Error::add_error(
285
+				__('The event id provided was not valid.', 'event_espresso'),
286
+				__FILE__,
287
+				__FUNCTION__,
288
+				__LINE__
289
+			);
290
+			return false;
291
+		}
292
+		// start with an empty array()
293
+		$valid_data = array();
294
+		// grab valid id
295
+		$valid_data['id'] = $id;
296
+		// array of other form names
297
+		$inputs_to_clean = array(
298
+			'event_id'   => 'tkt-slctr-event-id',
299
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
300
+			'rows'       => 'tkt-slctr-rows-',
301
+			'qty'        => 'tkt-slctr-qty-',
302
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
303
+			'return_url' => 'tkt-slctr-return-url-',
304
+		);
305
+		// let's track the total number of tickets ordered.'
306
+		$valid_data['total_tickets'] = 0;
307
+		// cycle through $inputs_to_clean array
308
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
309
+			// check for POST data
310
+			if (\EE_Registry::instance()->REQ->is_set($input_to_clean . $id)) {
311
+				// grab value
312
+				$input_value = \EE_Registry::instance()->REQ->get($input_to_clean . $id);
313
+				switch ($what) {
314
+					// integers
315
+					case 'event_id':
316
+						$valid_data[$what] = absint($input_value);
317
+						// get event via the event id we put in the form
318
+						$valid_data['event'] = \EE_Registry::instance()
319
+														   ->load_model('Event')
320
+														   ->get_one_by_ID($valid_data['event_id']);
321
+						break;
322
+					case 'rows':
323
+					case 'max_atndz':
324
+						$valid_data[$what] = absint($input_value);
325
+						break;
326
+					// arrays of integers
327
+					case 'qty':
328
+						/** @var array $row_qty */
329
+						$row_qty = $input_value;
330
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
331
+						if ( ! is_array($row_qty)) {
332
+							// get number of rows
333
+							$rows = \EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-' . $id)
334
+								? absint(\EE_Registry::instance()->REQ->get('tkt-slctr-rows-' . $id))
335
+								: 1;
336
+							// explode ints by the dash
337
+							$row_qty = explode('-', $row_qty);
338
+							$row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
339
+							$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
340
+							$row_qty = array($row => $qty);
341
+							for ($x = 1; $x <= $rows; $x++) {
342
+								if ( ! isset($row_qty[$x])) {
343
+									$row_qty[$x] = 0;
344
+								}
345
+							}
346
+						}
347
+						ksort($row_qty);
348
+						// cycle thru values
349
+						foreach ($row_qty as $qty) {
350
+							$qty = absint($qty);
351
+							// sanitize as integers
352
+							$valid_data[$what][] = $qty;
353
+							$valid_data['total_tickets'] += $qty;
354
+						}
355
+						break;
356
+					// array of integers
357
+					case 'ticket_id':
358
+						$value_array = array();
359
+						// cycle thru values
360
+						foreach ((array)$input_value as $key => $value) {
361
+							// allow only numbers, letters,  spaces, commas and dashes
362
+							$value_array[$key] = wp_strip_all_tags($value);
363
+							// get ticket via the ticket id we put in the form
364
+							$ticket_obj = \EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
365
+							$valid_data['ticket_obj'][$key] = $ticket_obj;
366
+						}
367
+						$valid_data[$what] = $value_array;
368
+						break;
369
+					case 'return_url' :
370
+						// grab and sanitize return-url
371
+						$input_value = esc_url_raw($input_value);
372
+						// was the request coming from an iframe ? if so, then:
373
+						if (strpos($input_value, 'event_list=iframe')) {
374
+							// get anchor fragment
375
+							$input_value = explode('#', $input_value);
376
+							$input_value = end($input_value);
377
+							// use event list url instead, but append anchor
378
+							$input_value = \EEH_Event_View::event_archive_url() . '#' . $input_value;
379
+						}
380
+						$valid_data[$what] = $input_value;
381
+						break;
382
+				}    // end switch $what
383
+			}
384
+		}    // end foreach $inputs_to_clean
385
+		return $valid_data;
386
+	}
387
+
388
+
389
+
390
+	/**
391
+	 * adds a ticket to the cart
392
+	 *
393
+	 * @param \EE_Ticket $ticket
394
+	 * @param int        $qty
395
+	 * @return TRUE on success, FALSE on fail
396
+	 * @throws \EE_Error
397
+	 */
398
+	private function addTicketToCart(\EE_Ticket $ticket = null, $qty = 1)
399
+	{
400
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
401
+		// get the number of spaces left for this datetime ticket
402
+		$available_spaces = $this->ticketDatetimeAvailability($ticket);
403
+		// compare available spaces against the number of tickets being purchased
404
+		if ($available_spaces >= $qty) {
405
+			// allow addons to prevent a ticket from being added to cart
406
+			if (
407
+			! apply_filters(
408
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
409
+				true,
410
+				$ticket,
411
+				$qty,
412
+				$available_spaces
413
+			)
414
+			) {
415
+				return false;
416
+			}
417
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
418
+			// add event to cart
419
+			if (\EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
420
+				$this->recalculateTicketDatetimeAvailability($ticket, $qty);
421
+				return true;
422
+			}
423
+			return false;
424
+		}
425
+		// tickets can not be purchased but let's find the exact number left
426
+		// for the last ticket selected PRIOR to subtracting tickets
427
+		$available_spaces = $this->ticketDatetimeAvailability($ticket, true);
428
+		// greedy greedy greedy eh?
429
+		if ($available_spaces > 0) {
430
+			if (
431
+			apply_filters(
432
+				'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
433
+				true,
434
+				$ticket,
435
+				$qty,
436
+				$available_spaces
437
+			)
438
+			) {
439
+				$this->displayAvailabilityError($available_spaces);
440
+			}
441
+		} else {
442
+			\EE_Error::add_error(
443
+				__(
444
+					'We\'re sorry, but there are no available spaces left for this event at this particular date and time.',
445
+					'event_espresso'
446
+				),
447
+				__FILE__, __FUNCTION__, __LINE__
448
+			);
449
+		}
450
+		return false;
451
+	}
452
+
453
+
454
+
455
+	/**
456
+	 * @param int $available_spaces
457
+	 * @throws \EE_Error
458
+	 */
459
+	private function displayAvailabilityError($available_spaces = 1)
460
+	{
461
+		// add error messaging - we're using the _n function that will generate
462
+		// the appropriate singular or plural message based on the number of $available_spaces
463
+		if (\EE_Registry::instance()->CART->all_ticket_quantity_count()) {
464
+			$msg = sprintf(
465
+				_n(
466
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
467
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
468
+					$available_spaces,
469
+					'event_espresso'
470
+				),
471
+				$available_spaces,
472
+				'<br />'
473
+			);
474
+		} else {
475
+			$msg = sprintf(
476
+				_n(
477
+					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
478
+					'We\'re sorry, but there are only %1$s available spaces left for this event at this particular date and time. Please select a different number (or different combination) of tickets.',
479
+					$available_spaces,
480
+					'event_espresso'
481
+				),
482
+				$available_spaces,
483
+				'<br />'
484
+			);
485
+		}
486
+		\EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
487
+	}
488
+
489
+
490
+
491
+	/**
492
+	 * ticketDatetimeAvailability
493
+	 * creates an array of tickets plus all of the datetimes available to each ticket
494
+	 * and tracks the spaces remaining for each of those datetimes
495
+	 *
496
+	 * @param \EE_Ticket $ticket - selected ticket
497
+	 * @param bool       $get_original_ticket_spaces
498
+	 * @return int
499
+	 * @throws \EE_Error
500
+	 */
501
+	private function ticketDatetimeAvailability(\EE_Ticket $ticket, $get_original_ticket_spaces = false)
502
+	{
503
+		// if the $_available_spaces array has not been set up yet...
504
+		if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
505
+			$this->setInitialTicketDatetimeAvailability($ticket);
506
+		}
507
+		$available_spaces = $ticket->qty() - $ticket->sold();
508
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
509
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
510
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
511
+				// if we want the original datetime availability BEFORE we started subtracting tickets ?
512
+				if ($get_original_ticket_spaces) {
513
+					// then grab the available spaces from the "tickets" array
514
+					// and compare with the above to get the lowest number
515
+					$available_spaces = min(
516
+						$available_spaces,
517
+						self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]
518
+					);
519
+				} else {
520
+					// we want the updated ticket availability as stored in the "datetimes" array
521
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
522
+				}
523
+			}
524
+		}
525
+		return $available_spaces;
526
+	}
527
+
528
+
529
+
530
+	/**
531
+	 * @param \EE_Ticket $ticket
532
+	 * @return void
533
+	 * @throws \EE_Error
534
+	 */
535
+	private function setInitialTicketDatetimeAvailability(\EE_Ticket $ticket)
536
+	{
537
+		// first, get all of the datetimes that are available to this ticket
538
+		$datetimes = $ticket->get_many_related(
539
+			'Datetime',
540
+			array(
541
+				array(
542
+					'DTT_EVT_end' => array(
543
+						'>=',
544
+						\EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'),
545
+					),
546
+				),
547
+				'order_by' => array('DTT_EVT_start' => 'ASC'),
548
+			)
549
+		);
550
+		if ( ! empty($datetimes)) {
551
+			// now loop thru all of the datetimes
552
+			foreach ($datetimes as $datetime) {
553
+				if ($datetime instanceof \EE_Datetime) {
554
+					// the number of spaces available for the datetime without considering individual ticket quantities
555
+					$spaces_remaining = $datetime->spaces_remaining();
556
+					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold
557
+					// or the datetime spaces remaining) to this ticket using the datetime ID as the key
558
+					self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(
559
+						$ticket->qty() - $ticket->sold(),
560
+						$spaces_remaining
561
+					);
562
+					// if the remaining spaces for this datetime is already set,
563
+					// then compare that against the datetime spaces remaining, and take the lowest number,
564
+					// else just take the datetime spaces remaining, and assign to the datetimes array
565
+					self::$_available_spaces['datetimes'][$datetime->ID()] = isset(
566
+						self::$_available_spaces['datetimes'][$datetime->ID()]
567
+					)
568
+						? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining)
569
+						: $spaces_remaining;
570
+				}
571
+			}
572
+		}
573
+	}
574
+
575
+
576
+
577
+	/**
578
+	 * @param    \EE_Ticket $ticket
579
+	 * @param    int        $qty
580
+	 * @return    void
581
+	 */
582
+	private function recalculateTicketDatetimeAvailability(\EE_Ticket $ticket, $qty = 0)
583
+	{
584
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
585
+			// loop thru tickets, which will ALSO include individual ticket records AND a total
586
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
587
+				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
588
+				self::$_available_spaces['datetimes'][$DTD_ID] -= $qty;
589
+			}
590
+		}
591
+	}
592 592
 
593 593
 
594 594
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +931 added lines, -931 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Event Espresso
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
 
17 17
 
18 18
 if ( ! function_exists('espresso_get_template_part')) {
19
-    /**
20
-     * espresso_get_template_part
21
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
22
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
23
-     *
24
-     * @param string $slug The slug name for the generic template.
25
-     * @param string $name The name of the specialised template.
26
-     * @return string        the html output for the formatted money value
27
-     */
28
-    function espresso_get_template_part($slug = null, $name = null)
29
-    {
30
-        EEH_Template::get_template_part($slug, $name);
31
-    }
19
+	/**
20
+	 * espresso_get_template_part
21
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
22
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
23
+	 *
24
+	 * @param string $slug The slug name for the generic template.
25
+	 * @param string $name The name of the specialised template.
26
+	 * @return string        the html output for the formatted money value
27
+	 */
28
+	function espresso_get_template_part($slug = null, $name = null)
29
+	{
30
+		EEH_Template::get_template_part($slug, $name);
31
+	}
32 32
 }
33 33
 
34 34
 
35 35
 if ( ! function_exists('espresso_get_object_css_class')) {
36
-    /**
37
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38
-     *
39
-     * @param EE_Base_Class $object the EE object the css class is being generated for
40
-     * @param  string       $prefix added to the beginning of the generated class
41
-     * @param  string       $suffix added to the end of the generated class
42
-     * @return string
43
-     */
44
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
45
-    {
46
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47
-    }
36
+	/**
37
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38
+	 *
39
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
40
+	 * @param  string       $prefix added to the beginning of the generated class
41
+	 * @param  string       $suffix added to the end of the generated class
42
+	 * @return string
43
+	 */
44
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
45
+	{
46
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47
+	}
48 48
 }
49 49
 
50 50
 
@@ -59,653 +59,653 @@  discard block
 block discarded – undo
59 59
 class EEH_Template
60 60
 {
61 61
 
62
-    private static $_espresso_themes = array();
63
-
64
-
65
-    /**
66
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
67
-     *
68
-     * @return boolean
69
-     */
70
-    public static function is_espresso_theme()
71
-    {
72
-        return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
73
-    }
74
-
75
-    /**
76
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
77
-     *    load it's functions.php file ( if not already loaded )
78
-     *
79
-     * @return void
80
-     */
81
-    public static function load_espresso_theme_functions()
82
-    {
83
-        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
86
-            }
87
-        }
88
-    }
89
-
90
-
91
-    /**
92
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
93
-     *
94
-     * @return array
95
-     */
96
-    public static function get_espresso_themes()
97
-    {
98
-        if (empty(EEH_Template::$_espresso_themes)) {
99
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
100
-            if (empty($espresso_themes)) {
101
-                return array();
102
-            }
103
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
104
-                unset($espresso_themes[$key]);
105
-            }
106
-            EEH_Template::$_espresso_themes = array();
107
-            foreach ($espresso_themes as $espresso_theme) {
108
-                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
109
-            }
110
-        }
111
-        return EEH_Template::$_espresso_themes;
112
-    }
113
-
114
-
115
-    /**
116
-     * EEH_Template::get_template_part
117
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
118
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
119
-     * filtering based off of the entire template part name
120
-     *
121
-     * @param string $slug The slug name for the generic template.
122
-     * @param string $name The name of the specialised template.
123
-     * @param array  $template_args
124
-     * @param bool   $return_string
125
-     * @return string        the html output for the formatted money value
126
-     */
127
-    public static function get_template_part(
128
-        $slug = null,
129
-        $name = null,
130
-        $template_args = array(),
131
-        $return_string = false
132
-    ) {
133
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134
-        $templates = array();
135
-        $name      = (string)$name;
136
-        if ($name != '') {
137
-            $templates[] = "{$slug}-{$name}.php";
138
-        }
139
-        // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
140
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
141
-            EEH_Template::locate_template($templates, $template_args, true, $return_string);
142
-        }
143
-    }
144
-
145
-
146
-    /**
147
-     *    locate_template
148
-     *    locate a template file by looking in the following places, in the following order:
149
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
150
-     *        <assumed full absolute server path>
151
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
152
-     *        <server path up to>/wp-content/uploads/espresso/templates/
153
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
154
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
155
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
156
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
157
-     *        Example:
158
-     *          You are using the WordPress Twenty Sixteen theme,
159
-     *        and you want to customize the "some-event.template.php" template,
160
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
161
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
162
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
163
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
-     *        /relative/path/to/some-event.template.php
165
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
166
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
167
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
168
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
169
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
170
-     *          Had you passed an absolute path to your template that was in some other location,
171
-     *        ie: "/absolute/path/to/some-event.template.php"
172
-     *          then the search would have been :
173
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
174
-     *        /absolute/path/to/some-event.template.php
175
-     *          and stopped there upon finding it in the second location
176
-     *
177
-     * @param array|string $templates       array of template file names including extension (or just a single string)
178
-     * @param  array       $template_args   an array of arguments to be extracted for use in the template
179
-     * @param  boolean     $load            whether to pass the located template path on to the
180
-     *                                      EEH_Template::display_template() method or simply return it
181
-     * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
182
-     *                                      string
183
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
184
-     *                                      generate a custom template or not. Used in places where you don't actually
185
-     *                                      load the template, you just want to know if there's a custom version of it.
186
-     * @return mixed
187
-     */
188
-    public static function locate_template(
189
-        $templates = array(),
190
-        $template_args = array(),
191
-        $load = true,
192
-        $return_string = true,
193
-        $check_if_custom = false
194
-    ) {
195
-        // first use WP locate_template to check for template in the current theme folder
196
-        $template_path = locate_template($templates);
197
-
198
-        if ($check_if_custom && ! empty($template_path)) {
199
-            return true;
200
-        }
201
-
202
-        // not in the theme
203
-        if (empty($template_path)) {
204
-            // not even a template to look for ?
205
-            if (empty($templates)) {
206
-                // get post_type
207
-                $post_type = EE_Registry::instance()->REQ->get('post_type');
208
-                // get array of EE Custom Post Types
209
-                $EE_CPTs = EE_Register_CPTs::get_CPTs();
210
-                // build template name based on request
211
-                if (isset($EE_CPTs[$post_type])) {
212
-                    $archive_or_single = is_archive() ? 'archive' : '';
213
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
214
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
215
-                }
216
-            }
217
-            // currently active EE template theme
218
-            $current_theme = EE_Config::get_current_theme();
219
-
220
-            // array of paths to folders that may contain templates
221
-            $template_folder_paths = array(
222
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
224
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
225
-                EVENT_ESPRESSO_TEMPLATE_DIR,
226
-            );
227
-
228
-            //add core plugin folders for checking only if we're not $check_if_custom
229
-            if ( ! $check_if_custom) {
230
-                $core_paths            = array(
231
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
-                    EE_PUBLIC . $current_theme,
233
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
-                    EE_TEMPLATES . $current_theme,
235
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236
-                    EE_PLUGIN_DIR_PATH,
237
-                );
238
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
239
-            }
240
-
241
-            // now filter that array
242
-            $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
243
-                $template_folder_paths);
244
-            $templates             = is_array($templates) ? $templates : array($templates);
245
-            $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
246
-            // array to hold all possible template paths
247
-            $full_template_paths = array();
248
-
249
-            // loop through $templates
250
-            foreach ($templates as $template) {
251
-                // normalize directory separators
252
-                $template                      = EEH_File::standardise_directory_separators($template);
253
-                $file_name                     = basename($template);
254
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
255
-                // while looping through all template folder paths
256
-                foreach ($template_folder_paths as $template_folder_path) {
257
-                    // normalize directory separators
258
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
259
-                    // determine if any common base path exists between the two paths
260
-                    $common_base_path = EEH_Template::_find_common_base_path(
261
-                        array($template_folder_path, $template_path_minus_file_name)
262
-                    );
263
-                    if ($common_base_path !== '') {
264
-                        // both paths have a common base, so just tack the filename onto our search path
265
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
266
-                    } else {
267
-                        // no common base path, so let's just concatenate
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
269
-                    }
270
-                    // build up our template locations array by adding our resolved paths
271
-                    $full_template_paths[] = $resolved_path;
272
-                }
273
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274
-                array_unshift($full_template_paths, $template);
275
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
277
-            }
278
-            // filter final array of full template paths
279
-            $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280
-                $full_template_paths, $file_name);
281
-            // now loop through our final array of template location paths and check each location
282
-            foreach ((array)$full_template_paths as $full_template_path) {
283
-                if (is_readable($full_template_path)) {
284
-                    $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285
-                    break;
286
-                }
287
-            }
288
-        }
289
-
290
-        // hook that can be used to display the full template path that will be used
291
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
292
-
293
-        // if we got it and you want to see it...
294
-        if ($template_path && $load && ! $check_if_custom) {
295
-            if ($return_string) {
296
-                return EEH_Template::display_template($template_path, $template_args, true);
297
-            } else {
298
-                EEH_Template::display_template($template_path, $template_args, false);
299
-            }
300
-        }
301
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
302
-    }
303
-
304
-
305
-    /**
306
-     * _find_common_base_path
307
-     * given two paths, this determines if there is a common base path between the two
308
-     *
309
-     * @param array $paths
310
-     * @return string
311
-     */
312
-    protected static function _find_common_base_path($paths)
313
-    {
314
-        $last_offset      = 0;
315
-        $common_base_path = '';
316
-        while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
317
-            $dir_length = $index - $last_offset + 1;
318
-            $directory  = substr($paths[0], $last_offset, $dir_length);
319
-            foreach ($paths as $path) {
320
-                if (substr($path, $last_offset, $dir_length) != $directory) {
321
-                    return $common_base_path;
322
-                }
323
-            }
324
-            $common_base_path .= $directory;
325
-            $last_offset = $index + 1;
326
-        }
327
-        return substr($common_base_path, 0, -1);
328
-    }
329
-
330
-
331
-    /**
332
-     * load and display a template
333
-     *
334
-     * @param bool|string $template_path server path to the file to be loaded, including file name and extension
335
-     * @param  array      $template_args an array of arguments to be extracted for use in the template
336
-     * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
337
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
338
-     *                                      not found or is not readable
339
-     * @return mixed string
340
-     * @throws \DomainException
341
-     */
62
+	private static $_espresso_themes = array();
63
+
64
+
65
+	/**
66
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
67
+	 *
68
+	 * @return boolean
69
+	 */
70
+	public static function is_espresso_theme()
71
+	{
72
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
73
+	}
74
+
75
+	/**
76
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
77
+	 *    load it's functions.php file ( if not already loaded )
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public static function load_espresso_theme_functions()
82
+	{
83
+		if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
86
+			}
87
+		}
88
+	}
89
+
90
+
91
+	/**
92
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
93
+	 *
94
+	 * @return array
95
+	 */
96
+	public static function get_espresso_themes()
97
+	{
98
+		if (empty(EEH_Template::$_espresso_themes)) {
99
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
100
+			if (empty($espresso_themes)) {
101
+				return array();
102
+			}
103
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
104
+				unset($espresso_themes[$key]);
105
+			}
106
+			EEH_Template::$_espresso_themes = array();
107
+			foreach ($espresso_themes as $espresso_theme) {
108
+				EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
109
+			}
110
+		}
111
+		return EEH_Template::$_espresso_themes;
112
+	}
113
+
114
+
115
+	/**
116
+	 * EEH_Template::get_template_part
117
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
118
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
119
+	 * filtering based off of the entire template part name
120
+	 *
121
+	 * @param string $slug The slug name for the generic template.
122
+	 * @param string $name The name of the specialised template.
123
+	 * @param array  $template_args
124
+	 * @param bool   $return_string
125
+	 * @return string        the html output for the formatted money value
126
+	 */
127
+	public static function get_template_part(
128
+		$slug = null,
129
+		$name = null,
130
+		$template_args = array(),
131
+		$return_string = false
132
+	) {
133
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134
+		$templates = array();
135
+		$name      = (string)$name;
136
+		if ($name != '') {
137
+			$templates[] = "{$slug}-{$name}.php";
138
+		}
139
+		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
140
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
141
+			EEH_Template::locate_template($templates, $template_args, true, $return_string);
142
+		}
143
+	}
144
+
145
+
146
+	/**
147
+	 *    locate_template
148
+	 *    locate a template file by looking in the following places, in the following order:
149
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
150
+	 *        <assumed full absolute server path>
151
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
152
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
153
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
154
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
155
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
156
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
157
+	 *        Example:
158
+	 *          You are using the WordPress Twenty Sixteen theme,
159
+	 *        and you want to customize the "some-event.template.php" template,
160
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
161
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
162
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
163
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
+	 *        /relative/path/to/some-event.template.php
165
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
166
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
167
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
168
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
169
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
170
+	 *          Had you passed an absolute path to your template that was in some other location,
171
+	 *        ie: "/absolute/path/to/some-event.template.php"
172
+	 *          then the search would have been :
173
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
174
+	 *        /absolute/path/to/some-event.template.php
175
+	 *          and stopped there upon finding it in the second location
176
+	 *
177
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
178
+	 * @param  array       $template_args   an array of arguments to be extracted for use in the template
179
+	 * @param  boolean     $load            whether to pass the located template path on to the
180
+	 *                                      EEH_Template::display_template() method or simply return it
181
+	 * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
182
+	 *                                      string
183
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
184
+	 *                                      generate a custom template or not. Used in places where you don't actually
185
+	 *                                      load the template, you just want to know if there's a custom version of it.
186
+	 * @return mixed
187
+	 */
188
+	public static function locate_template(
189
+		$templates = array(),
190
+		$template_args = array(),
191
+		$load = true,
192
+		$return_string = true,
193
+		$check_if_custom = false
194
+	) {
195
+		// first use WP locate_template to check for template in the current theme folder
196
+		$template_path = locate_template($templates);
197
+
198
+		if ($check_if_custom && ! empty($template_path)) {
199
+			return true;
200
+		}
201
+
202
+		// not in the theme
203
+		if (empty($template_path)) {
204
+			// not even a template to look for ?
205
+			if (empty($templates)) {
206
+				// get post_type
207
+				$post_type = EE_Registry::instance()->REQ->get('post_type');
208
+				// get array of EE Custom Post Types
209
+				$EE_CPTs = EE_Register_CPTs::get_CPTs();
210
+				// build template name based on request
211
+				if (isset($EE_CPTs[$post_type])) {
212
+					$archive_or_single = is_archive() ? 'archive' : '';
213
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
214
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
215
+				}
216
+			}
217
+			// currently active EE template theme
218
+			$current_theme = EE_Config::get_current_theme();
219
+
220
+			// array of paths to folders that may contain templates
221
+			$template_folder_paths = array(
222
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
224
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
225
+				EVENT_ESPRESSO_TEMPLATE_DIR,
226
+			);
227
+
228
+			//add core plugin folders for checking only if we're not $check_if_custom
229
+			if ( ! $check_if_custom) {
230
+				$core_paths            = array(
231
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
+					EE_PUBLIC . $current_theme,
233
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
+					EE_TEMPLATES . $current_theme,
235
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236
+					EE_PLUGIN_DIR_PATH,
237
+				);
238
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
239
+			}
240
+
241
+			// now filter that array
242
+			$template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
243
+				$template_folder_paths);
244
+			$templates             = is_array($templates) ? $templates : array($templates);
245
+			$template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
246
+			// array to hold all possible template paths
247
+			$full_template_paths = array();
248
+
249
+			// loop through $templates
250
+			foreach ($templates as $template) {
251
+				// normalize directory separators
252
+				$template                      = EEH_File::standardise_directory_separators($template);
253
+				$file_name                     = basename($template);
254
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
255
+				// while looping through all template folder paths
256
+				foreach ($template_folder_paths as $template_folder_path) {
257
+					// normalize directory separators
258
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
259
+					// determine if any common base path exists between the two paths
260
+					$common_base_path = EEH_Template::_find_common_base_path(
261
+						array($template_folder_path, $template_path_minus_file_name)
262
+					);
263
+					if ($common_base_path !== '') {
264
+						// both paths have a common base, so just tack the filename onto our search path
265
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
266
+					} else {
267
+						// no common base path, so let's just concatenate
268
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
269
+					}
270
+					// build up our template locations array by adding our resolved paths
271
+					$full_template_paths[] = $resolved_path;
272
+				}
273
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274
+				array_unshift($full_template_paths, $template);
275
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
+				array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
277
+			}
278
+			// filter final array of full template paths
279
+			$full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280
+				$full_template_paths, $file_name);
281
+			// now loop through our final array of template location paths and check each location
282
+			foreach ((array)$full_template_paths as $full_template_path) {
283
+				if (is_readable($full_template_path)) {
284
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285
+					break;
286
+				}
287
+			}
288
+		}
289
+
290
+		// hook that can be used to display the full template path that will be used
291
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
292
+
293
+		// if we got it and you want to see it...
294
+		if ($template_path && $load && ! $check_if_custom) {
295
+			if ($return_string) {
296
+				return EEH_Template::display_template($template_path, $template_args, true);
297
+			} else {
298
+				EEH_Template::display_template($template_path, $template_args, false);
299
+			}
300
+		}
301
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
302
+	}
303
+
304
+
305
+	/**
306
+	 * _find_common_base_path
307
+	 * given two paths, this determines if there is a common base path between the two
308
+	 *
309
+	 * @param array $paths
310
+	 * @return string
311
+	 */
312
+	protected static function _find_common_base_path($paths)
313
+	{
314
+		$last_offset      = 0;
315
+		$common_base_path = '';
316
+		while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
317
+			$dir_length = $index - $last_offset + 1;
318
+			$directory  = substr($paths[0], $last_offset, $dir_length);
319
+			foreach ($paths as $path) {
320
+				if (substr($path, $last_offset, $dir_length) != $directory) {
321
+					return $common_base_path;
322
+				}
323
+			}
324
+			$common_base_path .= $directory;
325
+			$last_offset = $index + 1;
326
+		}
327
+		return substr($common_base_path, 0, -1);
328
+	}
329
+
330
+
331
+	/**
332
+	 * load and display a template
333
+	 *
334
+	 * @param bool|string $template_path server path to the file to be loaded, including file name and extension
335
+	 * @param  array      $template_args an array of arguments to be extracted for use in the template
336
+	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
337
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
338
+	 *                                      not found or is not readable
339
+	 * @return mixed string
340
+	 * @throws \DomainException
341
+	 */
342 342
 	public static function display_template(
343
-        $template_path    = false,
344
-        $template_args    = array(),
345
-        $return_string    = false,
346
-        $throw_exceptions = false
347
-    ) {
348
-
349
-        /**
350
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
351
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
352
-         * the display_template method are templates we DON'T want modified (usually because of js
353
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
354
-         * using this.
355
-         *
356
-         * @since 4.6.0
357
-         */
358
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
359
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
360
-
361
-        // you gimme nuttin - YOU GET NUTTIN !!
362
-        if ( ! $template_path || ! is_readable($template_path)) {
363
-            return '';
364
-        }
365
-        // if $template_args are not in an array, then make it so
366
-        if ( ! is_array($template_args) && ! is_object($template_args)) {
367
-            $template_args = array($template_args);
368
-        }
369
-        extract( $template_args, EXTR_SKIP );
370
-        // ignore whether template is accessible ?
371
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
372
-            throw new \DomainException(
373
-                    esc_html__(
374
-                            'Invalid, unreadable, or missing file.',
375
-                            'event_espresso'
376
-                    )
377
-            );
378
-        }
379
-
380
-
381
-        if ($return_string) {
382
-            // because we want to return a string, we are going to capture the output
383
-            ob_start();
384
-            include($template_path);
385
-            return ob_get_clean();
386
-        } else {
387
-            include($template_path);
388
-        }
389
-        return '';
390
-    }
391
-
392
-
393
-    /**
394
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
395
-     *
396
-     * @param EE_Base_Class $object the EE object the css class is being generated for
397
-     * @param  string       $prefix added to the beginning of the generated class
398
-     * @param  string       $suffix added to the end of the generated class
399
-     * @return string
400
-     */
401
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402
-    {
403
-        // in the beginning...
404
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
405
-        // da muddle
406
-        $class = '';
407
-        // the end
408
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
409
-        // is the passed object an EE object ?
410
-        if ($object instanceof EE_Base_Class) {
411
-            // grab the exact type of object
412
-            $obj_class = get_class($object);
413
-            // depending on the type of object...
414
-            switch ($obj_class) {
415
-                // no specifics just yet...
416
-                default :
417
-                    $class = strtolower(str_replace('_', '-', $obj_class));
418
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
419
-
420
-            }
421
-        }
343
+		$template_path    = false,
344
+		$template_args    = array(),
345
+		$return_string    = false,
346
+		$throw_exceptions = false
347
+	) {
348
+
349
+		/**
350
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
351
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
352
+		 * the display_template method are templates we DON'T want modified (usually because of js
353
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
354
+		 * using this.
355
+		 *
356
+		 * @since 4.6.0
357
+		 */
358
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
359
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
360
+
361
+		// you gimme nuttin - YOU GET NUTTIN !!
362
+		if ( ! $template_path || ! is_readable($template_path)) {
363
+			return '';
364
+		}
365
+		// if $template_args are not in an array, then make it so
366
+		if ( ! is_array($template_args) && ! is_object($template_args)) {
367
+			$template_args = array($template_args);
368
+		}
369
+		extract( $template_args, EXTR_SKIP );
370
+		// ignore whether template is accessible ?
371
+		if ( $throw_exceptions && ! is_readable( $template_path ) ) {
372
+			throw new \DomainException(
373
+					esc_html__(
374
+							'Invalid, unreadable, or missing file.',
375
+							'event_espresso'
376
+					)
377
+			);
378
+		}
379
+
380
+
381
+		if ($return_string) {
382
+			// because we want to return a string, we are going to capture the output
383
+			ob_start();
384
+			include($template_path);
385
+			return ob_get_clean();
386
+		} else {
387
+			include($template_path);
388
+		}
389
+		return '';
390
+	}
391
+
392
+
393
+	/**
394
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
395
+	 *
396
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
397
+	 * @param  string       $prefix added to the beginning of the generated class
398
+	 * @param  string       $suffix added to the end of the generated class
399
+	 * @return string
400
+	 */
401
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402
+	{
403
+		// in the beginning...
404
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
405
+		// da muddle
406
+		$class = '';
407
+		// the end
408
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
409
+		// is the passed object an EE object ?
410
+		if ($object instanceof EE_Base_Class) {
411
+			// grab the exact type of object
412
+			$obj_class = get_class($object);
413
+			// depending on the type of object...
414
+			switch ($obj_class) {
415
+				// no specifics just yet...
416
+				default :
417
+					$class = strtolower(str_replace('_', '-', $obj_class));
418
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
419
+
420
+			}
421
+		}
422 422
         
423
-        $class_string = $prefix . $class . $suffix;
423
+		$class_string = $prefix . $class . $suffix;
424 424
         
425
-        return apply_filters('FHEE__EEH_Template__get_object_css_class__class_string', $class_string, $object, $prefix, $suffix);
426
-    }
427
-
428
-
429
-
430
-    /**
431
-     * EEH_Template::format_currency
432
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
433
-     * the country currency settings from the supplied country ISO code
434
-     *
435
-     * @param  float   $amount       raw money value
436
-     * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
437
-     * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
438
-     * @param string   $CNT_ISO      2 letter ISO code for a country
439
-     * @param string   $cur_code_span_class
440
-     * @return string        the html output for the formatted money value
441
-     * @throws \EE_Error
442
-     */
443
-    public static function format_currency(
444
-        $amount = null,
445
-        $return_raw = false,
446
-        $display_code = true,
447
-        $CNT_ISO = '',
448
-        $cur_code_span_class = 'currency-code'
449
-    ) {
450
-        // ensure amount was received
451
-        if ($amount === null) {
452
-            $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
453
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
454
-            return '';
455
-        }
456
-        //ensure amount is float
457
-        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
458
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
459
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
460
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
461
-        // still a number or was amount converted to a string like "free" ?
462
-        if (is_float($amount_formatted)) {
463
-            // was a country ISO code passed ? if so generate currency config object for that country
464
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
465
-            // verify results
466
-            if ( ! $mny instanceof EE_Currency_Config) {
467
-                // set default config country currency settings
468
-                $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
469
-                    ? EE_Registry::instance()->CFG->currency
470
-                    : new EE_Currency_Config();
471
-            }
472
-            // format float
473
-            $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
474
-            // add formatting ?
475
-            if ( ! $return_raw) {
476
-                // add currency sign
477
-                if ($mny->sign_b4) {
478
-                    if ($amount >= 0) {
479
-                        $amount_formatted = $mny->sign . $amount_formatted;
480
-                    } else {
481
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
482
-                    }
483
-
484
-                } else {
485
-                    $amount_formatted = $amount_formatted . $mny->sign;
486
-                }
487
-
488
-                // filter to allow global setting of display_code
489
-                $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
490
-
491
-                // add currency code ?
492
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
493
-            }
494
-            // filter results
495
-            $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
496
-                $amount_formatted, $mny, $return_raw);
497
-        }
498
-        // clean up vars
499
-        unset($mny);
500
-        // return formatted currency amount
501
-        return $amount_formatted;
502
-    }
503
-
504
-
505
-    /**
506
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
507
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
508
-     * related status model or model object (i.e. in documentation etc.)
509
-     *
510
-     * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
511
-     *                            match, then 'Unknown' will be returned.
512
-     * @param  boolean $plural    Whether to return plural or not
513
-     * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
514
-     * @return string             The localized label for the status id.
515
-     */
516
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
517
-    {
518
-        /** @type EEM_Status $EEM_Status */
519
-        $EEM_Status = EE_Registry::instance()->load_model('Status');
520
-        $status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
521
-            $schema);
522
-        return $status[$status_id];
523
-    }
524
-
525
-
526
-    /**
527
-     * This helper just returns a button or link for the given parameters
528
-     *
529
-     * @param  string $url   the url for the link, note that `esc_url` will be called on it
530
-     * @param  string $label What is the label you want displayed for the button
531
-     * @param  string $class what class is used for the button (defaults to 'button-primary')
532
-     * @param string  $icon
533
-     * @param string  $title
534
-     * @return string the html output for the button
535
-     */
536
-    public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
537
-    {
538
-        $icon_html = '';
539
-        if ( ! empty($icon)) {
540
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
541
-            $dashicons = array_filter($dashicons);
542
-            $count     = count($dashicons);
543
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
544
-            foreach ($dashicons as $dashicon) {
545
-                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
546
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
547
-            }
548
-            $icon_html .= $count > 1 ? '</span>' : '';
549
-        }
550
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
551
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
552
-        return $button;
553
-    }
554
-
555
-
556
-    /**
557
-     * This returns a generated link that will load the related help tab on admin pages.
558
-     *
559
-     * @param  string     $help_tab_id the id for the connected help tab
560
-     * @param bool|string $page        The page identifier for the page the help tab is on
561
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
562
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
563
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
564
-     * @return string              generated link
565
-     */
566
-    public static function get_help_tab_link(
567
-        $help_tab_id,
568
-        $page = false,
569
-        $action = false,
570
-        $icon_style = false,
571
-        $help_text = false
572
-    ) {
573
-
574
-        if ( ! $page) {
575
-            $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
576
-        }
577
-
578
-        if ( ! $action) {
579
-            $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
580
-        }
581
-
582
-        $action = empty($action) ? 'default' : $action;
583
-
584
-
585
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
586
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
587
-        $help_text    = ! $help_text ? '' : $help_text;
588
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
589
-                'event_espresso') . '" > ' . $help_text . ' </a>';
590
-    }
591
-
592
-
593
-    /**
594
-     * This helper generates the html structure for the jquery joyride plugin with the given params.
595
-     *
596
-     * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
597
-     * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
598
-     * @param EE_Help_Tour
599
-     * @return string         html
600
-     */
601
-    public static function help_tour_stops_generator(EE_Help_Tour $tour)
602
-    {
603
-        $id    = $tour->get_slug();
604
-        $stops = $tour->get_stops();
605
-
606
-        $content = '<ol style="display:none" id="' . $id . '">';
607
-
608
-        foreach ($stops as $stop) {
609
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
610
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
611
-
612
-            //if container is set to modal then let's make sure we set the options accordingly
613
-            if (empty($data_id) && empty($data_class)) {
614
-                $stop['options']['modal']  = true;
615
-                $stop['options']['expose'] = true;
616
-            }
617
-
618
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
619
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
620
-            $inner_content = isset($stop['content']) ? $stop['content'] : '';
621
-
622
-            //options
623
-            if (isset($stop['options']) && is_array($stop['options'])) {
624
-                $options = ' data-options="';
625
-                foreach ($stop['options'] as $option => $value) {
626
-                    $options .= $option . ':' . $value . ';';
627
-                }
628
-                $options .= '"';
629
-            } else {
630
-                $options = '';
631
-            }
632
-
633
-            //let's put all together
634
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
635
-        }
636
-
637
-        $content .= '</ol>';
638
-        return $content;
639
-    }
640
-
641
-
642
-    /**
643
-     * This is a helper method to generate a status legend for a given status array.
644
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
645
-     * status_array.
646
-     *
647
-     * @param  array  $status_array  array of statuses that will make up the legend. In format:
648
-     *                               array(
649
-     *                               'status_item' => 'status_name'
650
-     *                               )
651
-     * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
652
-     *                               the legend.
653
-     * @throws EE_Error
654
-     * @return string               html structure for status.
655
-     */
656
-    public static function status_legend($status_array, $active_status = '')
657
-    {
658
-        if ( ! is_array($status_array)) {
659
-            throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
660
-                'event_espresso'));
661
-        }
662
-
663
-        $setup_array = array();
664
-        foreach ($status_array as $item => $status) {
665
-            $setup_array[$item] = array(
666
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
667
-                'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
668
-                'status' => $status,
669
-            );
670
-        }
671
-
672
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
673
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
674
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
675
-        foreach ($setup_array as $item => $details) {
676
-            $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
677
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
678
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
679
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
680
-            $content .= '</dt>' . "\n";
681
-        }
682
-        $content .= '</dl>' . "\n";
683
-        $content .= '</div>' . "\n";
684
-        return $content;
685
-    }
686
-
687
-
688
-    /**
689
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
690
-     * that's nice for presenting in the wp admin
691
-     *
692
-     * @param mixed $data
693
-     * @return string
694
-     */
695
-    public static function layout_array_as_table($data)
696
-    {
697
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
698
-            $data = (array)$data;
699
-        }
700
-        ob_start();
701
-        if (is_array($data)) {
702
-            if (EEH_Array::is_associative_array($data)) {
703
-                ?>
425
+		return apply_filters('FHEE__EEH_Template__get_object_css_class__class_string', $class_string, $object, $prefix, $suffix);
426
+	}
427
+
428
+
429
+
430
+	/**
431
+	 * EEH_Template::format_currency
432
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
433
+	 * the country currency settings from the supplied country ISO code
434
+	 *
435
+	 * @param  float   $amount       raw money value
436
+	 * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
437
+	 * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
438
+	 * @param string   $CNT_ISO      2 letter ISO code for a country
439
+	 * @param string   $cur_code_span_class
440
+	 * @return string        the html output for the formatted money value
441
+	 * @throws \EE_Error
442
+	 */
443
+	public static function format_currency(
444
+		$amount = null,
445
+		$return_raw = false,
446
+		$display_code = true,
447
+		$CNT_ISO = '',
448
+		$cur_code_span_class = 'currency-code'
449
+	) {
450
+		// ensure amount was received
451
+		if ($amount === null) {
452
+			$msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
453
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
454
+			return '';
455
+		}
456
+		//ensure amount is float
457
+		$amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
458
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
459
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
460
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
461
+		// still a number or was amount converted to a string like "free" ?
462
+		if (is_float($amount_formatted)) {
463
+			// was a country ISO code passed ? if so generate currency config object for that country
464
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
465
+			// verify results
466
+			if ( ! $mny instanceof EE_Currency_Config) {
467
+				// set default config country currency settings
468
+				$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
469
+					? EE_Registry::instance()->CFG->currency
470
+					: new EE_Currency_Config();
471
+			}
472
+			// format float
473
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
474
+			// add formatting ?
475
+			if ( ! $return_raw) {
476
+				// add currency sign
477
+				if ($mny->sign_b4) {
478
+					if ($amount >= 0) {
479
+						$amount_formatted = $mny->sign . $amount_formatted;
480
+					} else {
481
+						$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
482
+					}
483
+
484
+				} else {
485
+					$amount_formatted = $amount_formatted . $mny->sign;
486
+				}
487
+
488
+				// filter to allow global setting of display_code
489
+				$display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
490
+
491
+				// add currency code ?
492
+				$amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
493
+			}
494
+			// filter results
495
+			$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
496
+				$amount_formatted, $mny, $return_raw);
497
+		}
498
+		// clean up vars
499
+		unset($mny);
500
+		// return formatted currency amount
501
+		return $amount_formatted;
502
+	}
503
+
504
+
505
+	/**
506
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
507
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
508
+	 * related status model or model object (i.e. in documentation etc.)
509
+	 *
510
+	 * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
511
+	 *                            match, then 'Unknown' will be returned.
512
+	 * @param  boolean $plural    Whether to return plural or not
513
+	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
514
+	 * @return string             The localized label for the status id.
515
+	 */
516
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
517
+	{
518
+		/** @type EEM_Status $EEM_Status */
519
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
520
+		$status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
521
+			$schema);
522
+		return $status[$status_id];
523
+	}
524
+
525
+
526
+	/**
527
+	 * This helper just returns a button or link for the given parameters
528
+	 *
529
+	 * @param  string $url   the url for the link, note that `esc_url` will be called on it
530
+	 * @param  string $label What is the label you want displayed for the button
531
+	 * @param  string $class what class is used for the button (defaults to 'button-primary')
532
+	 * @param string  $icon
533
+	 * @param string  $title
534
+	 * @return string the html output for the button
535
+	 */
536
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
537
+	{
538
+		$icon_html = '';
539
+		if ( ! empty($icon)) {
540
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
541
+			$dashicons = array_filter($dashicons);
542
+			$count     = count($dashicons);
543
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
544
+			foreach ($dashicons as $dashicon) {
545
+				$type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
546
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
547
+			}
548
+			$icon_html .= $count > 1 ? '</span>' : '';
549
+		}
550
+		$label  = ! empty($icon) ? $icon_html . $label : $label;
551
+		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
552
+		return $button;
553
+	}
554
+
555
+
556
+	/**
557
+	 * This returns a generated link that will load the related help tab on admin pages.
558
+	 *
559
+	 * @param  string     $help_tab_id the id for the connected help tab
560
+	 * @param bool|string $page        The page identifier for the page the help tab is on
561
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
562
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
563
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
564
+	 * @return string              generated link
565
+	 */
566
+	public static function get_help_tab_link(
567
+		$help_tab_id,
568
+		$page = false,
569
+		$action = false,
570
+		$icon_style = false,
571
+		$help_text = false
572
+	) {
573
+
574
+		if ( ! $page) {
575
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
576
+		}
577
+
578
+		if ( ! $action) {
579
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
580
+		}
581
+
582
+		$action = empty($action) ? 'default' : $action;
583
+
584
+
585
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
586
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
587
+		$help_text    = ! $help_text ? '' : $help_text;
588
+		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
589
+				'event_espresso') . '" > ' . $help_text . ' </a>';
590
+	}
591
+
592
+
593
+	/**
594
+	 * This helper generates the html structure for the jquery joyride plugin with the given params.
595
+	 *
596
+	 * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
597
+	 * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
598
+	 * @param EE_Help_Tour
599
+	 * @return string         html
600
+	 */
601
+	public static function help_tour_stops_generator(EE_Help_Tour $tour)
602
+	{
603
+		$id    = $tour->get_slug();
604
+		$stops = $tour->get_stops();
605
+
606
+		$content = '<ol style="display:none" id="' . $id . '">';
607
+
608
+		foreach ($stops as $stop) {
609
+			$data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
610
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
611
+
612
+			//if container is set to modal then let's make sure we set the options accordingly
613
+			if (empty($data_id) && empty($data_class)) {
614
+				$stop['options']['modal']  = true;
615
+				$stop['options']['expose'] = true;
616
+			}
617
+
618
+			$custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
619
+			$button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
620
+			$inner_content = isset($stop['content']) ? $stop['content'] : '';
621
+
622
+			//options
623
+			if (isset($stop['options']) && is_array($stop['options'])) {
624
+				$options = ' data-options="';
625
+				foreach ($stop['options'] as $option => $value) {
626
+					$options .= $option . ':' . $value . ';';
627
+				}
628
+				$options .= '"';
629
+			} else {
630
+				$options = '';
631
+			}
632
+
633
+			//let's put all together
634
+			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
635
+		}
636
+
637
+		$content .= '</ol>';
638
+		return $content;
639
+	}
640
+
641
+
642
+	/**
643
+	 * This is a helper method to generate a status legend for a given status array.
644
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
645
+	 * status_array.
646
+	 *
647
+	 * @param  array  $status_array  array of statuses that will make up the legend. In format:
648
+	 *                               array(
649
+	 *                               'status_item' => 'status_name'
650
+	 *                               )
651
+	 * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
652
+	 *                               the legend.
653
+	 * @throws EE_Error
654
+	 * @return string               html structure for status.
655
+	 */
656
+	public static function status_legend($status_array, $active_status = '')
657
+	{
658
+		if ( ! is_array($status_array)) {
659
+			throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
660
+				'event_espresso'));
661
+		}
662
+
663
+		$setup_array = array();
664
+		foreach ($status_array as $item => $status) {
665
+			$setup_array[$item] = array(
666
+				'class'  => 'ee-status-legend ee-status-legend-' . $status,
667
+				'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
668
+				'status' => $status,
669
+			);
670
+		}
671
+
672
+		$content = '<div class="ee-list-table-legend-container">' . "\n";
673
+		$content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
674
+		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
675
+		foreach ($setup_array as $item => $details) {
676
+			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
677
+			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
678
+			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
679
+			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
680
+			$content .= '</dt>' . "\n";
681
+		}
682
+		$content .= '</dl>' . "\n";
683
+		$content .= '</div>' . "\n";
684
+		return $content;
685
+	}
686
+
687
+
688
+	/**
689
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
690
+	 * that's nice for presenting in the wp admin
691
+	 *
692
+	 * @param mixed $data
693
+	 * @return string
694
+	 */
695
+	public static function layout_array_as_table($data)
696
+	{
697
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
698
+			$data = (array)$data;
699
+		}
700
+		ob_start();
701
+		if (is_array($data)) {
702
+			if (EEH_Array::is_associative_array($data)) {
703
+				?>
704 704
                 <table class="widefat">
705 705
                     <tbody>
706 706
                     <?php
707
-                    foreach ($data as $data_key => $data_values) {
708
-                        ?>
707
+					foreach ($data as $data_key => $data_values) {
708
+						?>
709 709
                         <tr>
710 710
                             <td>
711 711
                                 <?php echo $data_key; ?>
@@ -715,248 +715,248 @@  discard block
 block discarded – undo
715 715
                             </td>
716 716
                         </tr>
717 717
                         <?php
718
-                    } ?>
718
+					} ?>
719 719
                     </tbody>
720 720
                 </table>
721 721
                 <?php
722
-            } else {
723
-                ?>
722
+			} else {
723
+				?>
724 724
                 <ul>
725 725
                     <?php
726
-                    foreach ($data as $datum) {
727
-                        echo "<li>";
728
-                        echo self::layout_array_as_table($datum);
729
-                        echo "</li>";
730
-                    } ?>
726
+					foreach ($data as $datum) {
727
+						echo "<li>";
728
+						echo self::layout_array_as_table($datum);
729
+						echo "</li>";
730
+					} ?>
731 731
                 </ul>
732 732
                 <?php
733
-            }
734
-        } else {
735
-            //simple value
736
-            echo esc_html($data);
737
-        }
738
-        return ob_get_clean();
739
-    }
740
-
741
-
742
-    /**
743
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
744
-     *
745
-     * @since 4.4.0
746
-     * @see   self:get_paging_html() for argument docs.
747
-     * @param        $total_items
748
-     * @param        $current
749
-     * @param        $per_page
750
-     * @param        $url
751
-     * @param bool   $show_num_field
752
-     * @param string $paged_arg_name
753
-     * @param array  $items_label
754
-     * @return string
755
-     */
756
-    public static function paging_html(
757
-        $total_items,
758
-        $current,
759
-        $per_page,
760
-        $url,
761
-        $show_num_field = true,
762
-        $paged_arg_name = 'paged',
763
-        $items_label = array()
764
-    ) {
765
-        echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
766
-            $items_label);
767
-    }
768
-
769
-
770
-    /**
771
-     * A method for generating paging similar to WP_List_Table
772
-     *
773
-     * @since    4.4.0
774
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
775
-     * @param  integer $total_items     How many total items there are to page.
776
-     * @param  integer $current         What the current page is.
777
-     * @param  integer $per_page        How many items per page.
778
-     * @param  string  $url             What the base url for page links is.
779
-     * @param  boolean $show_num_field  Whether to show the input for changing page number.
780
-     * @param  string  $paged_arg_name  The name of the key for the paged query argument.
781
-     * @param  array   $items_label     An array of singular/plural values for the items label:
782
-     *                                  array(
783
-     *                                  'single' => 'item',
784
-     *                                  'plural' => 'items'
785
-     *                                  )
786
-     * @return  string
787
-     */
788
-    public static function get_paging_html(
789
-        $total_items,
790
-        $current,
791
-        $per_page,
792
-        $url,
793
-        $show_num_field = true,
794
-        $paged_arg_name = 'paged',
795
-        $items_label = array()
796
-    ) {
797
-        $page_links     = array();
798
-        $disable_first  = $disable_last = '';
799
-        $total_items    = (int)$total_items;
800
-        $per_page       = (int)$per_page;
801
-        $current        = (int)$current;
802
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
803
-
804
-        //filter items_label
805
-        $items_label = apply_filters(
806
-            'FHEE__EEH_Template__get_paging_html__items_label',
807
-            $items_label
808
-        );
809
-
810
-        if (empty($items_label)
811
-            || ! is_array($items_label)
812
-            || ! isset($items_label['single'])
813
-            || ! isset($items_label['plural'])
814
-        ) {
815
-            $items_label = array(
816
-                'single' => __('1 item', 'event_espresso'),
817
-                'plural' => __('%s items', 'event_espresso'),
818
-            );
819
-        } else {
820
-            $items_label = array(
821
-                'single' => '1 ' . esc_html($items_label['single']),
822
-                'plural' => '%s ' . esc_html($items_label['plural']),
823
-            );
824
-        }
825
-
826
-        $total_pages = ceil($total_items / $per_page);
827
-
828
-        if ($total_pages <= 1) {
829
-            return '';
830
-        }
831
-
832
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
833
-
834
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
835
-
836
-        if ($current === 1) {
837
-            $disable_first = ' disabled';
838
-        }
839
-        if ($current == $total_pages) {
840
-            $disable_last = ' disabled';
841
-        }
842
-
843
-        $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
844
-            'first-page' . $disable_first,
845
-            esc_attr__('Go to the first page'),
846
-            esc_url(remove_query_arg($paged_arg_name, $url)),
847
-            '&laquo;'
848
-        );
849
-
850
-        $page_links[] = sprintf(
851
-            '<a class="%s" title="%s" href="%s">%s</a>',
852
-            'prev-page' . $disable_first,
853
-            esc_attr__('Go to the previous page'),
854
-            esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
855
-            '&lsaquo;'
856
-        );
857
-
858
-        if ( ! $show_num_field) {
859
-            $html_current_page = $current;
860
-        } else {
861
-            $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
862
-                esc_attr__('Current page'),
863
-                $current,
864
-                strlen($total_pages)
865
-            );
866
-        }
867
-
868
-        $html_total_pages = sprintf(
869
-            '<span class="total-pages">%s</span>',
870
-            number_format_i18n($total_pages)
871
-        );
872
-        $page_links[]     = sprintf(
873
-            _x('%3$s%1$s of %2$s%4$s', 'paging'),
874
-            $html_current_page,
875
-            $html_total_pages,
876
-            '<span class="paging-input">',
877
-            '</span>'
878
-        );
879
-
880
-        $page_links[] = sprintf(
881
-            '<a class="%s" title="%s" href="%s">%s</a>',
882
-            'next-page' . $disable_last,
883
-            esc_attr__('Go to the next page'),
884
-            esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
885
-            '&rsaquo;'
886
-        );
887
-
888
-        $page_links[] = sprintf(
889
-            '<a class="%s" title="%s" href="%s">%s</a>',
890
-            'last-page' . $disable_last,
891
-            esc_attr__('Go to the last page'),
892
-            esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
893
-            '&raquo;'
894
-        );
895
-
896
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
897
-        // set page class
898
-        if ($total_pages) {
899
-            $page_class = $total_pages < 2 ? ' one-page' : '';
900
-        } else {
901
-            $page_class = ' no-pages';
902
-        }
903
-
904
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
905
-    }
906
-
907
-
908
-    /**
909
-     * @param string $wrap_class
910
-     * @param string $wrap_id
911
-     * @return string
912
-     */
913
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
914
-    {
915
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
916
-        if (
917
-            ! $admin &&
918
-            ! apply_filters(
919
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
920
-                EE_Registry::instance()->CFG->admin->show_reg_footer
921
-            )
922
-        ) {
923
-            return '';
924
-        }
925
-        $tag        = $admin ? 'span' : 'div';
926
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
927
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
928
-        $attributes .= ! empty($wrap_class)
929
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
930
-            : ' class="powered-by-event-espresso-credit"';
931
-        $query_args = array_merge(
932
-            array(
933
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
934
-                'utm_source'   => 'powered_by_event_espresso',
935
-                'utm_medium'   => 'link',
936
-                'utm_campaign' => 'powered_by',
937
-            ),
938
-            $query_args
939
-        );
940
-        $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
941
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
942
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
943
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
944
-        return (string)apply_filters(
945
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
946
-            sprintf(
947
-                esc_html_x(
948
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
949
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
950
-                    'event_espresso'
951
-                ),
952
-                "<{$tag}{$attributes}>",
953
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
954
-                $admin ? '' : '<br />'
955
-            ),
956
-            $wrap_class,
957
-            $wrap_id
958
-        );
959
-    }
733
+			}
734
+		} else {
735
+			//simple value
736
+			echo esc_html($data);
737
+		}
738
+		return ob_get_clean();
739
+	}
740
+
741
+
742
+	/**
743
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
744
+	 *
745
+	 * @since 4.4.0
746
+	 * @see   self:get_paging_html() for argument docs.
747
+	 * @param        $total_items
748
+	 * @param        $current
749
+	 * @param        $per_page
750
+	 * @param        $url
751
+	 * @param bool   $show_num_field
752
+	 * @param string $paged_arg_name
753
+	 * @param array  $items_label
754
+	 * @return string
755
+	 */
756
+	public static function paging_html(
757
+		$total_items,
758
+		$current,
759
+		$per_page,
760
+		$url,
761
+		$show_num_field = true,
762
+		$paged_arg_name = 'paged',
763
+		$items_label = array()
764
+	) {
765
+		echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
766
+			$items_label);
767
+	}
768
+
769
+
770
+	/**
771
+	 * A method for generating paging similar to WP_List_Table
772
+	 *
773
+	 * @since    4.4.0
774
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
775
+	 * @param  integer $total_items     How many total items there are to page.
776
+	 * @param  integer $current         What the current page is.
777
+	 * @param  integer $per_page        How many items per page.
778
+	 * @param  string  $url             What the base url for page links is.
779
+	 * @param  boolean $show_num_field  Whether to show the input for changing page number.
780
+	 * @param  string  $paged_arg_name  The name of the key for the paged query argument.
781
+	 * @param  array   $items_label     An array of singular/plural values for the items label:
782
+	 *                                  array(
783
+	 *                                  'single' => 'item',
784
+	 *                                  'plural' => 'items'
785
+	 *                                  )
786
+	 * @return  string
787
+	 */
788
+	public static function get_paging_html(
789
+		$total_items,
790
+		$current,
791
+		$per_page,
792
+		$url,
793
+		$show_num_field = true,
794
+		$paged_arg_name = 'paged',
795
+		$items_label = array()
796
+	) {
797
+		$page_links     = array();
798
+		$disable_first  = $disable_last = '';
799
+		$total_items    = (int)$total_items;
800
+		$per_page       = (int)$per_page;
801
+		$current        = (int)$current;
802
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
803
+
804
+		//filter items_label
805
+		$items_label = apply_filters(
806
+			'FHEE__EEH_Template__get_paging_html__items_label',
807
+			$items_label
808
+		);
809
+
810
+		if (empty($items_label)
811
+			|| ! is_array($items_label)
812
+			|| ! isset($items_label['single'])
813
+			|| ! isset($items_label['plural'])
814
+		) {
815
+			$items_label = array(
816
+				'single' => __('1 item', 'event_espresso'),
817
+				'plural' => __('%s items', 'event_espresso'),
818
+			);
819
+		} else {
820
+			$items_label = array(
821
+				'single' => '1 ' . esc_html($items_label['single']),
822
+				'plural' => '%s ' . esc_html($items_label['plural']),
823
+			);
824
+		}
825
+
826
+		$total_pages = ceil($total_items / $per_page);
827
+
828
+		if ($total_pages <= 1) {
829
+			return '';
830
+		}
831
+
832
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
833
+
834
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
835
+
836
+		if ($current === 1) {
837
+			$disable_first = ' disabled';
838
+		}
839
+		if ($current == $total_pages) {
840
+			$disable_last = ' disabled';
841
+		}
842
+
843
+		$page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
844
+			'first-page' . $disable_first,
845
+			esc_attr__('Go to the first page'),
846
+			esc_url(remove_query_arg($paged_arg_name, $url)),
847
+			'&laquo;'
848
+		);
849
+
850
+		$page_links[] = sprintf(
851
+			'<a class="%s" title="%s" href="%s">%s</a>',
852
+			'prev-page' . $disable_first,
853
+			esc_attr__('Go to the previous page'),
854
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
855
+			'&lsaquo;'
856
+		);
857
+
858
+		if ( ! $show_num_field) {
859
+			$html_current_page = $current;
860
+		} else {
861
+			$html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
862
+				esc_attr__('Current page'),
863
+				$current,
864
+				strlen($total_pages)
865
+			);
866
+		}
867
+
868
+		$html_total_pages = sprintf(
869
+			'<span class="total-pages">%s</span>',
870
+			number_format_i18n($total_pages)
871
+		);
872
+		$page_links[]     = sprintf(
873
+			_x('%3$s%1$s of %2$s%4$s', 'paging'),
874
+			$html_current_page,
875
+			$html_total_pages,
876
+			'<span class="paging-input">',
877
+			'</span>'
878
+		);
879
+
880
+		$page_links[] = sprintf(
881
+			'<a class="%s" title="%s" href="%s">%s</a>',
882
+			'next-page' . $disable_last,
883
+			esc_attr__('Go to the next page'),
884
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
885
+			'&rsaquo;'
886
+		);
887
+
888
+		$page_links[] = sprintf(
889
+			'<a class="%s" title="%s" href="%s">%s</a>',
890
+			'last-page' . $disable_last,
891
+			esc_attr__('Go to the last page'),
892
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
893
+			'&raquo;'
894
+		);
895
+
896
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
897
+		// set page class
898
+		if ($total_pages) {
899
+			$page_class = $total_pages < 2 ? ' one-page' : '';
900
+		} else {
901
+			$page_class = ' no-pages';
902
+		}
903
+
904
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
905
+	}
906
+
907
+
908
+	/**
909
+	 * @param string $wrap_class
910
+	 * @param string $wrap_id
911
+	 * @return string
912
+	 */
913
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
914
+	{
915
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
916
+		if (
917
+			! $admin &&
918
+			! apply_filters(
919
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
920
+				EE_Registry::instance()->CFG->admin->show_reg_footer
921
+			)
922
+		) {
923
+			return '';
924
+		}
925
+		$tag        = $admin ? 'span' : 'div';
926
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
927
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
928
+		$attributes .= ! empty($wrap_class)
929
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
930
+			: ' class="powered-by-event-espresso-credit"';
931
+		$query_args = array_merge(
932
+			array(
933
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
934
+				'utm_source'   => 'powered_by_event_espresso',
935
+				'utm_medium'   => 'link',
936
+				'utm_campaign' => 'powered_by',
937
+			),
938
+			$query_args
939
+		);
940
+		$powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
941
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
942
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
943
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
944
+		return (string)apply_filters(
945
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
946
+			sprintf(
947
+				esc_html_x(
948
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
949
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
950
+					'event_espresso'
951
+				),
952
+				"<{$tag}{$attributes}>",
953
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
954
+				$admin ? '' : '<br />'
955
+			),
956
+			$wrap_class,
957
+			$wrap_id
958
+		);
959
+	}
960 960
 
961 961
 
962 962
 } //end EEH_Template class
@@ -965,33 +965,33 @@  discard block
 block discarded – undo
965 965
 
966 966
 
967 967
 if ( ! function_exists('espresso_pagination')) {
968
-    /**
969
-     *    espresso_pagination
970
-     *
971
-     * @access    public
972
-     * @return    void
973
-     */
974
-    function espresso_pagination()
975
-    {
976
-        global $wp_query;
977
-        $big        = 999999999; // need an unlikely integer
978
-        $pagination = paginate_links(
979
-            array(
980
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
981
-                'format'       => '?paged=%#%',
982
-                'current'      => max(1, get_query_var('paged')),
983
-                'total'        => $wp_query->max_num_pages,
984
-                'show_all'     => true,
985
-                'end_size'     => 10,
986
-                'mid_size'     => 6,
987
-                'prev_next'    => true,
988
-                'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
989
-                'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
990
-                'type'         => 'plain',
991
-                'add_args'     => false,
992
-                'add_fragment' => '',
993
-            )
994
-        );
995
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
996
-    }
968
+	/**
969
+	 *    espresso_pagination
970
+	 *
971
+	 * @access    public
972
+	 * @return    void
973
+	 */
974
+	function espresso_pagination()
975
+	{
976
+		global $wp_query;
977
+		$big        = 999999999; // need an unlikely integer
978
+		$pagination = paginate_links(
979
+			array(
980
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
981
+				'format'       => '?paged=%#%',
982
+				'current'      => max(1, get_query_var('paged')),
983
+				'total'        => $wp_query->max_num_pages,
984
+				'show_all'     => true,
985
+				'end_size'     => 10,
986
+				'mid_size'     => 6,
987
+				'prev_next'    => true,
988
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
989
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
990
+				'type'         => 'plain',
991
+				'add_args'     => false,
992
+				'add_fragment' => '',
993
+			)
994
+		);
995
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
996
+	}
997 997
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 /**
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     public static function load_espresso_theme_functions()
82 82
     {
83 83
         if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
84
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) {
85
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php');
86 86
             }
87 87
         }
88 88
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     public static function get_espresso_themes()
97 97
     {
98 98
         if (empty(EEH_Template::$_espresso_themes)) {
99
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
99
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
100 100
             if (empty($espresso_themes)) {
101 101
                 return array();
102 102
             }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     ) {
133 133
         do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134 134
         $templates = array();
135
-        $name      = (string)$name;
135
+        $name      = (string) $name;
136 136
         if ($name != '') {
137 137
             $templates[] = "{$slug}-{$name}.php";
138 138
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 if (isset($EE_CPTs[$post_type])) {
212 212
                     $archive_or_single = is_archive() ? 'archive' : '';
213 213
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
214
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
214
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
215 215
                 }
216 216
             }
217 217
             // currently active EE template theme
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
             // array of paths to folders that may contain templates
221 221
             $template_folder_paths = array(
222 222
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
223
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
224 224
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
225 225
                 EVENT_ESPRESSO_TEMPLATE_DIR,
226 226
             );
227 227
 
228 228
             //add core plugin folders for checking only if we're not $check_if_custom
229 229
             if ( ! $check_if_custom) {
230
-                $core_paths            = array(
230
+                $core_paths = array(
231 231
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
-                    EE_PUBLIC . $current_theme,
232
+                    EE_PUBLIC.$current_theme,
233 233
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
-                    EE_TEMPLATES . $current_theme,
234
+                    EE_TEMPLATES.$current_theme,
235 235
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236 236
                     EE_PLUGIN_DIR_PATH,
237 237
                 );
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
                     );
263 263
                     if ($common_base_path !== '') {
264 264
                         // both paths have a common base, so just tack the filename onto our search path
265
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
265
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
266 266
                     } else {
267 267
                         // no common base path, so let's just concatenate
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
268
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
269 269
                     }
270 270
                     // build up our template locations array by adding our resolved paths
271 271
                     $full_template_paths[] = $resolved_path;
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274 274
                 array_unshift($full_template_paths, $template);
275 275
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
276
+                array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name);
277 277
             }
278 278
             // filter final array of full template paths
279 279
             $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280 280
                 $full_template_paths, $file_name);
281 281
             // now loop through our final array of template location paths and check each location
282
-            foreach ((array)$full_template_paths as $full_template_path) {
282
+            foreach ((array) $full_template_paths as $full_template_path) {
283 283
                 if (is_readable($full_template_path)) {
284 284
                     $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285 285
                     break;
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
         if ( ! is_array($template_args) && ! is_object($template_args)) {
367 367
             $template_args = array($template_args);
368 368
         }
369
-        extract( $template_args, EXTR_SKIP );
369
+        extract($template_args, EXTR_SKIP);
370 370
         // ignore whether template is accessible ?
371
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
371
+        if ($throw_exceptions && ! is_readable($template_path)) {
372 372
             throw new \DomainException(
373 373
                     esc_html__(
374 374
                             'Invalid, unreadable, or missing file.',
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402 402
     {
403 403
         // in the beginning...
404
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
404
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
405 405
         // da muddle
406 406
         $class = '';
407 407
         // the end
408
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
408
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
409 409
         // is the passed object an EE object ?
410 410
         if ($object instanceof EE_Base_Class) {
411 411
             // grab the exact type of object
@@ -415,12 +415,12 @@  discard block
 block discarded – undo
415 415
                 // no specifics just yet...
416 416
                 default :
417 417
                     $class = strtolower(str_replace('_', '-', $obj_class));
418
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
418
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
419 419
 
420 420
             }
421 421
         }
422 422
         
423
-        $class_string = $prefix . $class . $suffix;
423
+        $class_string = $prefix.$class.$suffix;
424 424
         
425 425
         return apply_filters('FHEE__EEH_Template__get_object_css_class__class_string', $class_string, $object, $prefix, $suffix);
426 426
     }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
             return '';
455 455
         }
456 456
         //ensure amount is float
457
-        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
457
+        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
458 458
         $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
459 459
         // filter raw amount (allows 0.00 to be changed to "free" for example)
460 460
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
@@ -476,20 +476,20 @@  discard block
 block discarded – undo
476 476
                 // add currency sign
477 477
                 if ($mny->sign_b4) {
478 478
                     if ($amount >= 0) {
479
-                        $amount_formatted = $mny->sign . $amount_formatted;
479
+                        $amount_formatted = $mny->sign.$amount_formatted;
480 480
                     } else {
481
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
481
+                        $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
482 482
                     }
483 483
 
484 484
                 } else {
485
-                    $amount_formatted = $amount_formatted . $mny->sign;
485
+                    $amount_formatted = $amount_formatted.$mny->sign;
486 486
                 }
487 487
 
488 488
                 // filter to allow global setting of display_code
489 489
                 $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
490 490
 
491 491
                 // add currency code ?
492
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
492
+                $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted;
493 493
             }
494 494
             // filter results
495 495
             $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
544 544
             foreach ($dashicons as $dashicon) {
545 545
                 $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
546
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
546
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
547 547
             }
548 548
             $icon_html .= $count > 1 ? '</span>' : '';
549 549
         }
550
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
551
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
550
+        $label  = ! empty($icon) ? $icon_html.$label : $label;
551
+        $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.esc_url($url).'" class="'.$class.'" title="'.$title.'">'.$label.'</a>';
552 552
         return $button;
553 553
     }
554 554
 
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
         $action = empty($action) ? 'default' : $action;
583 583
 
584 584
 
585
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
585
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
586 586
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
587 587
         $help_text    = ! $help_text ? '' : $help_text;
588
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
589
-                'event_espresso') . '" > ' . $help_text . ' </a>';
588
+        return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
589
+                'event_espresso').'" > '.$help_text.' </a>';
590 590
     }
591 591
 
592 592
 
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
         $id    = $tour->get_slug();
604 604
         $stops = $tour->get_stops();
605 605
 
606
-        $content = '<ol style="display:none" id="' . $id . '">';
606
+        $content = '<ol style="display:none" id="'.$id.'">';
607 607
 
608 608
         foreach ($stops as $stop) {
609
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
610
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
609
+            $data_id    = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
610
+            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
611 611
 
612 612
             //if container is set to modal then let's make sure we set the options accordingly
613 613
             if (empty($data_id) && empty($data_class)) {
@@ -615,15 +615,15 @@  discard block
 block discarded – undo
615 615
                 $stop['options']['expose'] = true;
616 616
             }
617 617
 
618
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
619
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
618
+            $custom_class  = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
619
+            $button_text   = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
620 620
             $inner_content = isset($stop['content']) ? $stop['content'] : '';
621 621
 
622 622
             //options
623 623
             if (isset($stop['options']) && is_array($stop['options'])) {
624 624
                 $options = ' data-options="';
625 625
                 foreach ($stop['options'] as $option => $value) {
626
-                    $options .= $option . ':' . $value . ';';
626
+                    $options .= $option.':'.$value.';';
627 627
                 }
628 628
                 $options .= '"';
629 629
             } else {
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
             }
632 632
 
633 633
             //let's put all together
634
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
634
+            $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
635 635
         }
636 636
 
637 637
         $content .= '</ol>';
@@ -663,24 +663,24 @@  discard block
 block discarded – undo
663 663
         $setup_array = array();
664 664
         foreach ($status_array as $item => $status) {
665 665
             $setup_array[$item] = array(
666
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
666
+                'class'  => 'ee-status-legend ee-status-legend-'.$status,
667 667
                 'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
668 668
                 'status' => $status,
669 669
             );
670 670
         }
671 671
 
672
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
673
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
674
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
672
+        $content = '<div class="ee-list-table-legend-container">'."\n";
673
+        $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n";
674
+        $content .= '<dl class="ee-list-table-legend">'."\n\t";
675 675
         foreach ($setup_array as $item => $details) {
676 676
             $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
677
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
678
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
679
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
680
-            $content .= '</dt>' . "\n";
677
+            $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
678
+            $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
679
+            $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
680
+            $content .= '</dt>'."\n";
681 681
         }
682
-        $content .= '</dl>' . "\n";
683
-        $content .= '</div>' . "\n";
682
+        $content .= '</dl>'."\n";
683
+        $content .= '</div>'."\n";
684 684
         return $content;
685 685
     }
686 686
 
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
     public static function layout_array_as_table($data)
696 696
     {
697 697
         if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
698
-            $data = (array)$data;
698
+            $data = (array) $data;
699 699
         }
700 700
         ob_start();
701 701
         if (is_array($data)) {
@@ -796,9 +796,9 @@  discard block
 block discarded – undo
796 796
     ) {
797 797
         $page_links     = array();
798 798
         $disable_first  = $disable_last = '';
799
-        $total_items    = (int)$total_items;
800
-        $per_page       = (int)$per_page;
801
-        $current        = (int)$current;
799
+        $total_items    = (int) $total_items;
800
+        $per_page       = (int) $per_page;
801
+        $current        = (int) $current;
802 802
         $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
803 803
 
804 804
         //filter items_label
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
             );
819 819
         } else {
820 820
             $items_label = array(
821
-                'single' => '1 ' . esc_html($items_label['single']),
822
-                'plural' => '%s ' . esc_html($items_label['plural']),
821
+                'single' => '1 '.esc_html($items_label['single']),
822
+                'plural' => '%s '.esc_html($items_label['plural']),
823 823
             );
824 824
         }
825 825
 
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 
832 832
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
833 833
 
834
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
834
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
835 835
 
836 836
         if ($current === 1) {
837 837
             $disable_first = ' disabled';
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
         }
842 842
 
843 843
         $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
844
-            'first-page' . $disable_first,
844
+            'first-page'.$disable_first,
845 845
             esc_attr__('Go to the first page'),
846 846
             esc_url(remove_query_arg($paged_arg_name, $url)),
847 847
             '&laquo;'
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 
850 850
         $page_links[] = sprintf(
851 851
             '<a class="%s" title="%s" href="%s">%s</a>',
852
-            'prev-page' . $disable_first,
852
+            'prev-page'.$disable_first,
853 853
             esc_attr__('Go to the previous page'),
854 854
             esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
855 855
             '&lsaquo;'
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
             '<span class="total-pages">%s</span>',
870 870
             number_format_i18n($total_pages)
871 871
         );
872
-        $page_links[]     = sprintf(
872
+        $page_links[] = sprintf(
873 873
             _x('%3$s%1$s of %2$s%4$s', 'paging'),
874 874
             $html_current_page,
875 875
             $html_total_pages,
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
 
880 880
         $page_links[] = sprintf(
881 881
             '<a class="%s" title="%s" href="%s">%s</a>',
882
-            'next-page' . $disable_last,
882
+            'next-page'.$disable_last,
883 883
             esc_attr__('Go to the next page'),
884 884
             esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
885 885
             '&rsaquo;'
@@ -887,13 +887,13 @@  discard block
 block discarded – undo
887 887
 
888 888
         $page_links[] = sprintf(
889 889
             '<a class="%s" title="%s" href="%s">%s</a>',
890
-            'last-page' . $disable_last,
890
+            'last-page'.$disable_last,
891 891
             esc_attr__('Go to the last page'),
892 892
             esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
893 893
             '&raquo;'
894 894
         );
895 895
 
896
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
896
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
897 897
         // set page class
898 898
         if ($total_pages) {
899 899
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
             $page_class = ' no-pages';
902 902
         }
903 903
 
904
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
904
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
905 905
     }
906 906
 
907 907
 
@@ -938,10 +938,10 @@  discard block
 block discarded – undo
938 938
             $query_args
939 939
         );
940 940
         $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
941
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
941
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso');
942 942
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
943 943
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
944
-        return (string)apply_filters(
944
+        return (string) apply_filters(
945 945
             'FHEE__EEH_Template__powered_by_event_espresso__html',
946 946
             sprintf(
947 947
                 esc_html_x(
@@ -992,6 +992,6 @@  discard block
 block discarded – undo
992 992
                 'add_fragment' => '',
993 993
             )
994 994
         );
995
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
995
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
996 996
     }
997 997
 }
Please login to merge, or discard this patch.