@@ -15,675 +15,675 @@ |
||
15 | 15 | class EEH_Event_Query |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Start Date |
|
20 | - * |
|
21 | - * @var $_event_query_month |
|
22 | - */ |
|
23 | - protected static $_event_query_month; |
|
24 | - |
|
25 | - /** |
|
26 | - * Category |
|
27 | - * |
|
28 | - * @var $_event_query_category |
|
29 | - */ |
|
30 | - protected static $_event_query_category; |
|
31 | - |
|
32 | - /** |
|
33 | - * whether to display expired events in the event list |
|
34 | - * |
|
35 | - * @var bool $_show_expired |
|
36 | - */ |
|
37 | - protected static $_event_query_show_expired = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * list of params for controlling how the query results are ordered |
|
41 | - * |
|
42 | - * @var array $_event_query_orderby |
|
43 | - */ |
|
44 | - protected static $_event_query_orderby = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * direction list is sorted |
|
48 | - * |
|
49 | - * @var string $_event_query_sort |
|
50 | - */ |
|
51 | - protected static $_event_query_sort; |
|
52 | - |
|
53 | - /** |
|
54 | - * list of params used to build the query's various clauses |
|
55 | - * |
|
56 | - * @var $_query_params |
|
57 | - */ |
|
58 | - protected static $_query_params = array(); |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public static function add_query_filters() |
|
66 | - { |
|
67 | - // add query filters |
|
68 | - add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param WP_Query $WP_Query |
|
75 | - * @return bool |
|
76 | - */ |
|
77 | - public static function apply_query_filters(WP_Query $WP_Query) |
|
78 | - { |
|
79 | - return ( |
|
80 | - isset($WP_Query->query['post_type']) |
|
81 | - && $WP_Query->query['post_type'] === 'espresso_events' |
|
82 | - ) |
|
83 | - || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param WP_Query $WP_Query |
|
89 | - */ |
|
90 | - public static function filter_query_parts(WP_Query $WP_Query) |
|
91 | - { |
|
92 | - // ONLY add our filters if this isn't the main wp_query, |
|
93 | - // because if this is the main wp_query we already have |
|
94 | - // our cpt strategies take care of adding things in. |
|
95 | - if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
96 | - // build event list query |
|
97 | - add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
98 | - add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
99 | - add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
100 | - add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
101 | - add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $month |
|
109 | - * @param string $category |
|
110 | - * @param bool $show_expired |
|
111 | - * @param string $orderby |
|
112 | - * @param string $sort |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws InvalidDataTypeException |
|
115 | - * @throws InvalidInterfaceException |
|
116 | - */ |
|
117 | - public static function set_query_params( |
|
118 | - $month = '', |
|
119 | - $category = '', |
|
120 | - $show_expired = false, |
|
121 | - $orderby = 'start_date', |
|
122 | - $sort = 'ASC' |
|
123 | - ) { |
|
124 | - self::$_query_params = array(); |
|
125 | - EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
126 | - EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
127 | - EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
128 | - EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
129 | - EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * what month should the event list display events for? |
|
136 | - * |
|
137 | - * @param string $month |
|
138 | - * @return string |
|
139 | - * @throws InvalidArgumentException |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidInterfaceException |
|
142 | - */ |
|
143 | - private static function _display_month($month = '') |
|
144 | - { |
|
145 | - return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month', $month)); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @param string $category |
|
152 | - * @return string |
|
153 | - * @throws InvalidArgumentException |
|
154 | - * @throws InvalidDataTypeException |
|
155 | - * @throws InvalidInterfaceException |
|
156 | - */ |
|
157 | - private static function _event_category_slug($category = '') |
|
158 | - { |
|
159 | - return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category', $category)); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param bool $show_expired |
|
166 | - * @return bool |
|
167 | - * @throws InvalidArgumentException |
|
168 | - * @throws InvalidDataTypeException |
|
169 | - * @throws InvalidInterfaceException |
|
170 | - */ |
|
171 | - private static function _show_expired($show_expired = false) |
|
172 | - { |
|
173 | - // override default expired option if set via filter |
|
174 | - return filter_var( |
|
175 | - EE_Registry::instance()->REQ->get('event_query_show_expired', $show_expired), |
|
176 | - FILTER_VALIDATE_BOOLEAN |
|
177 | - ); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * @param string $orderby |
|
184 | - * @return array |
|
185 | - * @throws InvalidArgumentException |
|
186 | - * @throws InvalidDataTypeException |
|
187 | - * @throws InvalidInterfaceException |
|
188 | - */ |
|
189 | - private static function _orderby($orderby = 'start_date') |
|
190 | - { |
|
191 | - $event_query_orderby = EE_Registry::instance()->REQ->get('event_query_orderby', $orderby); |
|
192 | - $event_query_orderby = is_array($event_query_orderby) |
|
193 | - ? $event_query_orderby |
|
194 | - : explode(',', $event_query_orderby); |
|
195 | - $event_query_orderby = array_map('trim', $event_query_orderby); |
|
196 | - $event_query_orderby = array_map('sanitize_text_field', $event_query_orderby); |
|
197 | - return $event_query_orderby; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @param string $sort |
|
204 | - * @return string |
|
205 | - * @throws InvalidArgumentException |
|
206 | - * @throws InvalidDataTypeException |
|
207 | - * @throws InvalidInterfaceException |
|
208 | - */ |
|
209 | - private static function _sort($sort = 'ASC') |
|
210 | - { |
|
211 | - $sort = EE_Registry::instance()->REQ->get('event_query_sort', $sort); |
|
212 | - return in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
213 | - ? strtoupper($sort) |
|
214 | - : 'ASC'; |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * Filters the clauses for the WP_Query object |
|
221 | - * |
|
222 | - * @param array $clauses array of clauses |
|
223 | - * @param WP_Query $wp_query |
|
224 | - * @return array array of clauses |
|
225 | - */ |
|
226 | - public static function posts_clauses($clauses, WP_Query $wp_query) |
|
227 | - { |
|
228 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
229 | - global $wpdb; |
|
230 | - $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
231 | - } |
|
232 | - return $clauses; |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * @param string $SQL |
|
239 | - * @param WP_Query $wp_query |
|
240 | - * @return string |
|
241 | - * @throws EE_Error |
|
242 | - * @throws InvalidArgumentException |
|
243 | - * @throws InvalidDataTypeException |
|
244 | - * @throws InvalidInterfaceException |
|
245 | - */ |
|
246 | - public static function posts_fields($SQL, WP_Query $wp_query) |
|
247 | - { |
|
248 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
249 | - // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
|
250 | - $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
251 | - } |
|
252 | - return $SQL; |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * @param array $orderby_params |
|
259 | - * @return string |
|
260 | - * @throws EE_Error |
|
261 | - * @throws InvalidArgumentException |
|
262 | - * @throws InvalidDataTypeException |
|
263 | - * @throws InvalidInterfaceException |
|
264 | - */ |
|
265 | - public static function posts_fields_sql_for_orderby(array $orderby_params = array()) |
|
266 | - { |
|
267 | - $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date '; |
|
268 | - foreach ($orderby_params as $orderby) { |
|
269 | - switch ($orderby) { |
|
270 | - case 'ticket_start': |
|
271 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date'; |
|
272 | - break; |
|
273 | - case 'ticket_end': |
|
274 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date'; |
|
275 | - break; |
|
276 | - case 'venue_title': |
|
277 | - $SQL .= ', Venue.post_title AS venue_title'; |
|
278 | - break; |
|
279 | - case 'city': |
|
280 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city'; |
|
281 | - break; |
|
282 | - case 'state': |
|
283 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name'; |
|
284 | - break; |
|
285 | - } |
|
286 | - } |
|
287 | - return $SQL; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * @param string $SQL |
|
294 | - * @param WP_Query $wp_query |
|
295 | - * @return string |
|
296 | - * @throws EE_Error |
|
297 | - * @throws InvalidArgumentException |
|
298 | - * @throws InvalidDataTypeException |
|
299 | - * @throws InvalidInterfaceException |
|
300 | - */ |
|
301 | - public static function posts_join($SQL = '', WP_Query $wp_query) |
|
302 | - { |
|
303 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
304 | - // Category |
|
305 | - $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
306 | - $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
307 | - $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
308 | - } |
|
309 | - return $SQL; |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * @param string $SQL |
|
316 | - * @param boolean $show_expired if TRUE, then displayed past events |
|
317 | - * @return string |
|
318 | - * @throws EE_Error |
|
319 | - * @throws InvalidArgumentException |
|
320 | - * @throws InvalidDataTypeException |
|
321 | - * @throws InvalidInterfaceException |
|
322 | - */ |
|
323 | - public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = false) |
|
324 | - { |
|
325 | - if (! $show_expired) { |
|
326 | - $join = EEM_Event::instance()->table() . '.ID = '; |
|
327 | - $join .= EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
328 | - // don't add if this is already in the SQL |
|
329 | - if (strpos($SQL, $join) === false) { |
|
330 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
331 | - } |
|
332 | - } |
|
333 | - return $SQL; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * @param string $SQL |
|
340 | - * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get |
|
341 | - * used for anything yet |
|
342 | - * @return string |
|
343 | - */ |
|
344 | - public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') |
|
345 | - { |
|
346 | - if (! empty($join_terms)) { |
|
347 | - global $wpdb; |
|
348 | - $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
|
349 | - $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
|
350 | - $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) "; |
|
351 | - } |
|
352 | - return $SQL; |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * usage: $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
359 | - * |
|
360 | - * @param string $SQL |
|
361 | - * @param array $orderby_params |
|
362 | - * @return string |
|
363 | - * @throws EE_Error |
|
364 | - * @throws InvalidArgumentException |
|
365 | - * @throws InvalidDataTypeException |
|
366 | - * @throws InvalidInterfaceException |
|
367 | - */ |
|
368 | - public static function posts_join_for_orderby($SQL = '', array $orderby_params = array()) |
|
369 | - { |
|
370 | - foreach ($orderby_params as $orderby) { |
|
371 | - switch ($orderby) { |
|
372 | - case 'ticket_start': |
|
373 | - case 'ticket_end': |
|
374 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( |
|
375 | - $SQL, |
|
376 | - EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() |
|
377 | - ); |
|
378 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table(); |
|
379 | - $SQL .= ' ON ('; |
|
380 | - $SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
381 | - $SQL .= ' = '; |
|
382 | - $SQL .= EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
383 | - $SQL .= ' )'; |
|
384 | - break; |
|
385 | - case 'venue_title': |
|
386 | - case 'city': |
|
387 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
388 | - break; |
|
389 | - case 'state': |
|
390 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
391 | - $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
392 | - break; |
|
393 | - case 'start_date': |
|
394 | - default: |
|
395 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table() . '.ID'); |
|
396 | - break; |
|
397 | - } |
|
398 | - } |
|
399 | - return $SQL; |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * @param string $SQL |
|
406 | - * @param string $join |
|
407 | - * @return string |
|
408 | - * @throws EE_Error |
|
409 | - * @throws InvalidArgumentException |
|
410 | - * @throws InvalidDataTypeException |
|
411 | - * @throws InvalidInterfaceException |
|
412 | - */ |
|
413 | - protected static function _posts_join_for_datetime($SQL = '', $join = '') |
|
414 | - { |
|
415 | - if (! empty($join)) { |
|
416 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
417 | - if (strpos($SQL, $join) === false) { |
|
418 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
419 | - } |
|
420 | - } |
|
421 | - return ''; |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - /** |
|
426 | - * @param string $SQL |
|
427 | - * @return string |
|
428 | - * @throws EE_Error |
|
429 | - * @throws InvalidArgumentException |
|
430 | - * @throws InvalidDataTypeException |
|
431 | - * @throws InvalidInterfaceException |
|
432 | - * @throws ReflectionException |
|
433 | - */ |
|
434 | - protected static function _posts_join_for_event_venue(string $SQL = ''): string |
|
435 | - { |
|
436 | - // grab venue table PK name & event_meta table name |
|
437 | - $VNU_ID = EEM_Venue::instance()->primary_key_name(); |
|
438 | - $event_meta = EEM_Event::instance()->second_table(); |
|
439 | - // generate conditions for: Event <=> Venue JOIN clause |
|
440 | - $event_venue_join = "Venue.ID = $event_meta.$VNU_ID"; |
|
441 | - // don't add joins if they have already been added |
|
442 | - if (strpos($SQL, $event_venue_join) === false) { |
|
443 | - global $wpdb; |
|
444 | - // grab wp_posts (event), venue, and venue_meta table names |
|
445 | - $wp_posts = $wpdb->posts; |
|
446 | - $venue = EEM_Venue::instance()->table(); |
|
447 | - $venue_meta = EEM_Venue::instance()->second_table(); |
|
448 | - // generate JOIN clause for: Event <=> Event Meta |
|
449 | - $venue_SQL = " LEFT JOIN $event_meta ON ( $wp_posts.ID = $event_meta.EVT_ID )"; |
|
450 | - // generate JOIN clause for: Event Meta <=> Venue |
|
451 | - $venue_SQL .= " LEFT JOIN $venue AS Venue ON ( $event_venue_join )"; |
|
452 | - // generate JOIN clause for: Venue <=> Venue Meta |
|
453 | - $venue_SQL .= " LEFT JOIN $venue_meta ON ( Venue.ID = $venue_meta.$VNU_ID )"; |
|
454 | - unset($venue, $VNU_ID, $event_meta, $venue_meta, $event_venue_join); |
|
455 | - return $venue_SQL; |
|
456 | - } |
|
457 | - unset($VNU_ID, $event_meta, $event_venue_join); |
|
458 | - return ''; |
|
459 | - } |
|
460 | - |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * @param string $SQL |
|
465 | - * @return string |
|
466 | - * @throws EE_Error |
|
467 | - * @throws InvalidArgumentException |
|
468 | - * @throws InvalidDataTypeException |
|
469 | - * @throws InvalidInterfaceException |
|
470 | - */ |
|
471 | - protected static function _posts_join_for_venue_state($SQL = '') |
|
472 | - { |
|
473 | - // Venue Meta table name |
|
474 | - $venue_meta_table = EEM_Venue::instance()->second_table(); |
|
475 | - // State table name |
|
476 | - $state_table = EEM_State::instance()->table(); |
|
477 | - // State table pk |
|
478 | - $state_table_pk = EEM_State::instance()->primary_key_name(); |
|
479 | - // verify vars |
|
480 | - if ($venue_meta_table && $state_table && $state_table_pk) { |
|
481 | - // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
|
482 | - $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
|
483 | - // don't add join if it has already been added |
|
484 | - if (strpos($SQL, $join) === false) { |
|
485 | - unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
486 | - return " LEFT JOIN $state_table ON ( $join )"; |
|
487 | - } |
|
488 | - } |
|
489 | - unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
490 | - return ''; |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - |
|
495 | - /** |
|
496 | - * @param string $SQL |
|
497 | - * @param WP_Query $wp_query |
|
498 | - * @return string |
|
499 | - * @throws EE_Error |
|
500 | - * @throws InvalidArgumentException |
|
501 | - * @throws InvalidDataTypeException |
|
502 | - * @throws InvalidInterfaceException |
|
503 | - */ |
|
504 | - public static function posts_where($SQL = '', WP_Query $wp_query) |
|
505 | - { |
|
506 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
507 | - // Show Expired ? |
|
508 | - $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
509 | - // Category |
|
510 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
511 | - // Start Date |
|
512 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
513 | - } |
|
514 | - return $SQL; |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * @param boolean $show_expired if TRUE, then displayed past events |
|
521 | - * @return string |
|
522 | - * @throws EE_Error |
|
523 | - * @throws InvalidArgumentException |
|
524 | - * @throws InvalidDataTypeException |
|
525 | - * @throws InvalidInterfaceException |
|
526 | - */ |
|
527 | - public static function posts_where_sql_for_show_expired($show_expired = false) |
|
528 | - { |
|
529 | - return ! $show_expired |
|
530 | - ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time('mysql', true) . '\' ' |
|
531 | - : ''; |
|
532 | - } |
|
533 | - |
|
534 | - |
|
535 | - |
|
536 | - /** |
|
537 | - * @param boolean $event_category_slug |
|
538 | - * @return string |
|
539 | - */ |
|
540 | - public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
541 | - { |
|
542 | - global $wpdb; |
|
543 | - if (! empty($event_category_slug)) { |
|
544 | - $event_category_slugs_array = array_map('trim', explode(',', $event_category_slug)); |
|
545 | - $event_category_slugs_prepare = implode(', ', array_fill(0, count($event_category_slugs_array), '%s')); |
|
546 | - return $wpdb->prepare(" AND {$wpdb->terms}.slug IN ({$event_category_slugs_prepare}) ", $event_category_slugs_array); |
|
547 | - } |
|
548 | - return ''; |
|
549 | - } |
|
550 | - |
|
551 | - |
|
552 | - |
|
553 | - /** |
|
554 | - * @param boolean $month |
|
555 | - * @return string |
|
556 | - * @throws EE_Error |
|
557 | - * @throws InvalidArgumentException |
|
558 | - * @throws InvalidDataTypeException |
|
559 | - * @throws InvalidInterfaceException |
|
560 | - */ |
|
561 | - public static function posts_where_sql_for_event_list_month($month = null) |
|
562 | - { |
|
563 | - $SQL = ''; |
|
564 | - if (! empty($month)) { |
|
565 | - $datetime_table = EEM_Datetime::instance()->table(); |
|
566 | - // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
|
567 | - $SQL = " AND {$datetime_table}.DTT_EVT_start <= '"; |
|
568 | - $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "'"; |
|
569 | - // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
|
570 | - $SQL .= " AND {$datetime_table}.DTT_EVT_end >= '"; |
|
571 | - $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "' "; |
|
572 | - } |
|
573 | - return $SQL; |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - |
|
578 | - /** |
|
579 | - * @param string $SQL |
|
580 | - * @param WP_Query $wp_query |
|
581 | - * @return string |
|
582 | - * @throws EE_Error |
|
583 | - * @throws InvalidArgumentException |
|
584 | - * @throws InvalidDataTypeException |
|
585 | - * @throws InvalidInterfaceException |
|
586 | - */ |
|
587 | - public static function posts_orderby($SQL = '', WP_Query $wp_query) |
|
588 | - { |
|
589 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
590 | - $SQL = EEH_Event_Query::posts_orderby_sql( |
|
591 | - EEH_Event_Query::$_event_query_orderby, |
|
592 | - EEH_Event_Query::$_event_query_sort |
|
593 | - ); |
|
594 | - } |
|
595 | - return $SQL; |
|
596 | - } |
|
597 | - |
|
598 | - |
|
599 | - |
|
600 | - /** |
|
601 | - * posts_orderby_sql |
|
602 | - * possible parameters: |
|
603 | - * ID |
|
604 | - * start_date |
|
605 | - * end_date |
|
606 | - * event_name |
|
607 | - * category_slug |
|
608 | - * ticket_start |
|
609 | - * ticket_end |
|
610 | - * venue_title |
|
611 | - * city |
|
612 | - * state |
|
613 | - * **IMPORTANT** |
|
614 | - * make sure to also send the $orderby_params array to the posts_join_for_orderby() method |
|
615 | - * or else some of the table references below will result in MySQL errors |
|
616 | - * |
|
617 | - * @param array $orderby_params |
|
618 | - * @param string $sort |
|
619 | - * @return string |
|
620 | - * @throws EE_Error |
|
621 | - * @throws InvalidArgumentException |
|
622 | - * @throws InvalidDataTypeException |
|
623 | - * @throws InvalidInterfaceException |
|
624 | - */ |
|
625 | - public static function posts_orderby_sql(array $orderby_params = array(), $sort = 'ASC') |
|
626 | - { |
|
627 | - global $wpdb; |
|
628 | - $SQL = ''; |
|
629 | - $counter = 0; |
|
630 | - $sort = in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
631 | - ? strtoupper($sort) |
|
632 | - : 'ASC'; |
|
633 | - // make sure 'orderby' is set in query params |
|
634 | - if (! isset(self::$_query_params['orderby'])) { |
|
635 | - self::$_query_params['orderby'] = array(); |
|
636 | - } |
|
637 | - // loop thru $orderby_params (type cast as array) |
|
638 | - foreach ($orderby_params as $orderby) { |
|
639 | - // check if we have already added this param |
|
640 | - if (isset(self::$_query_params['orderby'][ $orderby ])) { |
|
641 | - // if so then remove from the $orderby_params so that the count() method below is accurate |
|
642 | - unset($orderby_params[ $orderby ]); |
|
643 | - // then bump ahead to the next param |
|
644 | - continue; |
|
645 | - } |
|
646 | - // this will ad a comma depending on whether this is the first or last param |
|
647 | - $glue = $counter === 0 || $counter === count($orderby_params) ? ' ' : ', '; |
|
648 | - // ok what's we dealing with? |
|
649 | - switch ($orderby) { |
|
650 | - case 'id': |
|
651 | - case 'ID': |
|
652 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
653 | - break; |
|
654 | - case 'end_date': |
|
655 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
656 | - break; |
|
657 | - case 'event_name': |
|
658 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
659 | - break; |
|
660 | - case 'category_slug': |
|
661 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
662 | - break; |
|
663 | - case 'ticket_start': |
|
664 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
665 | - break; |
|
666 | - case 'ticket_end': |
|
667 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
668 | - break; |
|
669 | - case 'venue_title': |
|
670 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
671 | - break; |
|
672 | - case 'city': |
|
673 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
674 | - break; |
|
675 | - case 'state': |
|
676 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
677 | - break; |
|
678 | - case 'start_date': |
|
679 | - default: |
|
680 | - $SQL .= $glue . ' event_start_date ' . $sort; |
|
681 | - break; |
|
682 | - } |
|
683 | - // add to array of orderby params that have been added |
|
684 | - self::$_query_params['orderby'][ $orderby ] = true; |
|
685 | - $counter++; |
|
686 | - } |
|
687 | - return $SQL; |
|
688 | - } |
|
18 | + /** |
|
19 | + * Start Date |
|
20 | + * |
|
21 | + * @var $_event_query_month |
|
22 | + */ |
|
23 | + protected static $_event_query_month; |
|
24 | + |
|
25 | + /** |
|
26 | + * Category |
|
27 | + * |
|
28 | + * @var $_event_query_category |
|
29 | + */ |
|
30 | + protected static $_event_query_category; |
|
31 | + |
|
32 | + /** |
|
33 | + * whether to display expired events in the event list |
|
34 | + * |
|
35 | + * @var bool $_show_expired |
|
36 | + */ |
|
37 | + protected static $_event_query_show_expired = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * list of params for controlling how the query results are ordered |
|
41 | + * |
|
42 | + * @var array $_event_query_orderby |
|
43 | + */ |
|
44 | + protected static $_event_query_orderby = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * direction list is sorted |
|
48 | + * |
|
49 | + * @var string $_event_query_sort |
|
50 | + */ |
|
51 | + protected static $_event_query_sort; |
|
52 | + |
|
53 | + /** |
|
54 | + * list of params used to build the query's various clauses |
|
55 | + * |
|
56 | + * @var $_query_params |
|
57 | + */ |
|
58 | + protected static $_query_params = array(); |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public static function add_query_filters() |
|
66 | + { |
|
67 | + // add query filters |
|
68 | + add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param WP_Query $WP_Query |
|
75 | + * @return bool |
|
76 | + */ |
|
77 | + public static function apply_query_filters(WP_Query $WP_Query) |
|
78 | + { |
|
79 | + return ( |
|
80 | + isset($WP_Query->query['post_type']) |
|
81 | + && $WP_Query->query['post_type'] === 'espresso_events' |
|
82 | + ) |
|
83 | + || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param WP_Query $WP_Query |
|
89 | + */ |
|
90 | + public static function filter_query_parts(WP_Query $WP_Query) |
|
91 | + { |
|
92 | + // ONLY add our filters if this isn't the main wp_query, |
|
93 | + // because if this is the main wp_query we already have |
|
94 | + // our cpt strategies take care of adding things in. |
|
95 | + if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
96 | + // build event list query |
|
97 | + add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
98 | + add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
99 | + add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
100 | + add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
101 | + add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $month |
|
109 | + * @param string $category |
|
110 | + * @param bool $show_expired |
|
111 | + * @param string $orderby |
|
112 | + * @param string $sort |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws InvalidDataTypeException |
|
115 | + * @throws InvalidInterfaceException |
|
116 | + */ |
|
117 | + public static function set_query_params( |
|
118 | + $month = '', |
|
119 | + $category = '', |
|
120 | + $show_expired = false, |
|
121 | + $orderby = 'start_date', |
|
122 | + $sort = 'ASC' |
|
123 | + ) { |
|
124 | + self::$_query_params = array(); |
|
125 | + EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
126 | + EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
127 | + EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
128 | + EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
129 | + EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * what month should the event list display events for? |
|
136 | + * |
|
137 | + * @param string $month |
|
138 | + * @return string |
|
139 | + * @throws InvalidArgumentException |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidInterfaceException |
|
142 | + */ |
|
143 | + private static function _display_month($month = '') |
|
144 | + { |
|
145 | + return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month', $month)); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @param string $category |
|
152 | + * @return string |
|
153 | + * @throws InvalidArgumentException |
|
154 | + * @throws InvalidDataTypeException |
|
155 | + * @throws InvalidInterfaceException |
|
156 | + */ |
|
157 | + private static function _event_category_slug($category = '') |
|
158 | + { |
|
159 | + return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category', $category)); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param bool $show_expired |
|
166 | + * @return bool |
|
167 | + * @throws InvalidArgumentException |
|
168 | + * @throws InvalidDataTypeException |
|
169 | + * @throws InvalidInterfaceException |
|
170 | + */ |
|
171 | + private static function _show_expired($show_expired = false) |
|
172 | + { |
|
173 | + // override default expired option if set via filter |
|
174 | + return filter_var( |
|
175 | + EE_Registry::instance()->REQ->get('event_query_show_expired', $show_expired), |
|
176 | + FILTER_VALIDATE_BOOLEAN |
|
177 | + ); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * @param string $orderby |
|
184 | + * @return array |
|
185 | + * @throws InvalidArgumentException |
|
186 | + * @throws InvalidDataTypeException |
|
187 | + * @throws InvalidInterfaceException |
|
188 | + */ |
|
189 | + private static function _orderby($orderby = 'start_date') |
|
190 | + { |
|
191 | + $event_query_orderby = EE_Registry::instance()->REQ->get('event_query_orderby', $orderby); |
|
192 | + $event_query_orderby = is_array($event_query_orderby) |
|
193 | + ? $event_query_orderby |
|
194 | + : explode(',', $event_query_orderby); |
|
195 | + $event_query_orderby = array_map('trim', $event_query_orderby); |
|
196 | + $event_query_orderby = array_map('sanitize_text_field', $event_query_orderby); |
|
197 | + return $event_query_orderby; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @param string $sort |
|
204 | + * @return string |
|
205 | + * @throws InvalidArgumentException |
|
206 | + * @throws InvalidDataTypeException |
|
207 | + * @throws InvalidInterfaceException |
|
208 | + */ |
|
209 | + private static function _sort($sort = 'ASC') |
|
210 | + { |
|
211 | + $sort = EE_Registry::instance()->REQ->get('event_query_sort', $sort); |
|
212 | + return in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
213 | + ? strtoupper($sort) |
|
214 | + : 'ASC'; |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * Filters the clauses for the WP_Query object |
|
221 | + * |
|
222 | + * @param array $clauses array of clauses |
|
223 | + * @param WP_Query $wp_query |
|
224 | + * @return array array of clauses |
|
225 | + */ |
|
226 | + public static function posts_clauses($clauses, WP_Query $wp_query) |
|
227 | + { |
|
228 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
229 | + global $wpdb; |
|
230 | + $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
231 | + } |
|
232 | + return $clauses; |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * @param string $SQL |
|
239 | + * @param WP_Query $wp_query |
|
240 | + * @return string |
|
241 | + * @throws EE_Error |
|
242 | + * @throws InvalidArgumentException |
|
243 | + * @throws InvalidDataTypeException |
|
244 | + * @throws InvalidInterfaceException |
|
245 | + */ |
|
246 | + public static function posts_fields($SQL, WP_Query $wp_query) |
|
247 | + { |
|
248 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
249 | + // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
|
250 | + $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
251 | + } |
|
252 | + return $SQL; |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * @param array $orderby_params |
|
259 | + * @return string |
|
260 | + * @throws EE_Error |
|
261 | + * @throws InvalidArgumentException |
|
262 | + * @throws InvalidDataTypeException |
|
263 | + * @throws InvalidInterfaceException |
|
264 | + */ |
|
265 | + public static function posts_fields_sql_for_orderby(array $orderby_params = array()) |
|
266 | + { |
|
267 | + $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date '; |
|
268 | + foreach ($orderby_params as $orderby) { |
|
269 | + switch ($orderby) { |
|
270 | + case 'ticket_start': |
|
271 | + $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date'; |
|
272 | + break; |
|
273 | + case 'ticket_end': |
|
274 | + $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date'; |
|
275 | + break; |
|
276 | + case 'venue_title': |
|
277 | + $SQL .= ', Venue.post_title AS venue_title'; |
|
278 | + break; |
|
279 | + case 'city': |
|
280 | + $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city'; |
|
281 | + break; |
|
282 | + case 'state': |
|
283 | + $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name'; |
|
284 | + break; |
|
285 | + } |
|
286 | + } |
|
287 | + return $SQL; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * @param string $SQL |
|
294 | + * @param WP_Query $wp_query |
|
295 | + * @return string |
|
296 | + * @throws EE_Error |
|
297 | + * @throws InvalidArgumentException |
|
298 | + * @throws InvalidDataTypeException |
|
299 | + * @throws InvalidInterfaceException |
|
300 | + */ |
|
301 | + public static function posts_join($SQL = '', WP_Query $wp_query) |
|
302 | + { |
|
303 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
304 | + // Category |
|
305 | + $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
306 | + $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
307 | + $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
308 | + } |
|
309 | + return $SQL; |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * @param string $SQL |
|
316 | + * @param boolean $show_expired if TRUE, then displayed past events |
|
317 | + * @return string |
|
318 | + * @throws EE_Error |
|
319 | + * @throws InvalidArgumentException |
|
320 | + * @throws InvalidDataTypeException |
|
321 | + * @throws InvalidInterfaceException |
|
322 | + */ |
|
323 | + public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = false) |
|
324 | + { |
|
325 | + if (! $show_expired) { |
|
326 | + $join = EEM_Event::instance()->table() . '.ID = '; |
|
327 | + $join .= EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
328 | + // don't add if this is already in the SQL |
|
329 | + if (strpos($SQL, $join) === false) { |
|
330 | + $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
331 | + } |
|
332 | + } |
|
333 | + return $SQL; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * @param string $SQL |
|
340 | + * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get |
|
341 | + * used for anything yet |
|
342 | + * @return string |
|
343 | + */ |
|
344 | + public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') |
|
345 | + { |
|
346 | + if (! empty($join_terms)) { |
|
347 | + global $wpdb; |
|
348 | + $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
|
349 | + $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
|
350 | + $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) "; |
|
351 | + } |
|
352 | + return $SQL; |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * usage: $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
359 | + * |
|
360 | + * @param string $SQL |
|
361 | + * @param array $orderby_params |
|
362 | + * @return string |
|
363 | + * @throws EE_Error |
|
364 | + * @throws InvalidArgumentException |
|
365 | + * @throws InvalidDataTypeException |
|
366 | + * @throws InvalidInterfaceException |
|
367 | + */ |
|
368 | + public static function posts_join_for_orderby($SQL = '', array $orderby_params = array()) |
|
369 | + { |
|
370 | + foreach ($orderby_params as $orderby) { |
|
371 | + switch ($orderby) { |
|
372 | + case 'ticket_start': |
|
373 | + case 'ticket_end': |
|
374 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime( |
|
375 | + $SQL, |
|
376 | + EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() |
|
377 | + ); |
|
378 | + $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table(); |
|
379 | + $SQL .= ' ON ('; |
|
380 | + $SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
381 | + $SQL .= ' = '; |
|
382 | + $SQL .= EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
383 | + $SQL .= ' )'; |
|
384 | + break; |
|
385 | + case 'venue_title': |
|
386 | + case 'city': |
|
387 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
388 | + break; |
|
389 | + case 'state': |
|
390 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
391 | + $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
392 | + break; |
|
393 | + case 'start_date': |
|
394 | + default: |
|
395 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table() . '.ID'); |
|
396 | + break; |
|
397 | + } |
|
398 | + } |
|
399 | + return $SQL; |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * @param string $SQL |
|
406 | + * @param string $join |
|
407 | + * @return string |
|
408 | + * @throws EE_Error |
|
409 | + * @throws InvalidArgumentException |
|
410 | + * @throws InvalidDataTypeException |
|
411 | + * @throws InvalidInterfaceException |
|
412 | + */ |
|
413 | + protected static function _posts_join_for_datetime($SQL = '', $join = '') |
|
414 | + { |
|
415 | + if (! empty($join)) { |
|
416 | + $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
417 | + if (strpos($SQL, $join) === false) { |
|
418 | + return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
419 | + } |
|
420 | + } |
|
421 | + return ''; |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + /** |
|
426 | + * @param string $SQL |
|
427 | + * @return string |
|
428 | + * @throws EE_Error |
|
429 | + * @throws InvalidArgumentException |
|
430 | + * @throws InvalidDataTypeException |
|
431 | + * @throws InvalidInterfaceException |
|
432 | + * @throws ReflectionException |
|
433 | + */ |
|
434 | + protected static function _posts_join_for_event_venue(string $SQL = ''): string |
|
435 | + { |
|
436 | + // grab venue table PK name & event_meta table name |
|
437 | + $VNU_ID = EEM_Venue::instance()->primary_key_name(); |
|
438 | + $event_meta = EEM_Event::instance()->second_table(); |
|
439 | + // generate conditions for: Event <=> Venue JOIN clause |
|
440 | + $event_venue_join = "Venue.ID = $event_meta.$VNU_ID"; |
|
441 | + // don't add joins if they have already been added |
|
442 | + if (strpos($SQL, $event_venue_join) === false) { |
|
443 | + global $wpdb; |
|
444 | + // grab wp_posts (event), venue, and venue_meta table names |
|
445 | + $wp_posts = $wpdb->posts; |
|
446 | + $venue = EEM_Venue::instance()->table(); |
|
447 | + $venue_meta = EEM_Venue::instance()->second_table(); |
|
448 | + // generate JOIN clause for: Event <=> Event Meta |
|
449 | + $venue_SQL = " LEFT JOIN $event_meta ON ( $wp_posts.ID = $event_meta.EVT_ID )"; |
|
450 | + // generate JOIN clause for: Event Meta <=> Venue |
|
451 | + $venue_SQL .= " LEFT JOIN $venue AS Venue ON ( $event_venue_join )"; |
|
452 | + // generate JOIN clause for: Venue <=> Venue Meta |
|
453 | + $venue_SQL .= " LEFT JOIN $venue_meta ON ( Venue.ID = $venue_meta.$VNU_ID )"; |
|
454 | + unset($venue, $VNU_ID, $event_meta, $venue_meta, $event_venue_join); |
|
455 | + return $venue_SQL; |
|
456 | + } |
|
457 | + unset($VNU_ID, $event_meta, $event_venue_join); |
|
458 | + return ''; |
|
459 | + } |
|
460 | + |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * @param string $SQL |
|
465 | + * @return string |
|
466 | + * @throws EE_Error |
|
467 | + * @throws InvalidArgumentException |
|
468 | + * @throws InvalidDataTypeException |
|
469 | + * @throws InvalidInterfaceException |
|
470 | + */ |
|
471 | + protected static function _posts_join_for_venue_state($SQL = '') |
|
472 | + { |
|
473 | + // Venue Meta table name |
|
474 | + $venue_meta_table = EEM_Venue::instance()->second_table(); |
|
475 | + // State table name |
|
476 | + $state_table = EEM_State::instance()->table(); |
|
477 | + // State table pk |
|
478 | + $state_table_pk = EEM_State::instance()->primary_key_name(); |
|
479 | + // verify vars |
|
480 | + if ($venue_meta_table && $state_table && $state_table_pk) { |
|
481 | + // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
|
482 | + $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
|
483 | + // don't add join if it has already been added |
|
484 | + if (strpos($SQL, $join) === false) { |
|
485 | + unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
486 | + return " LEFT JOIN $state_table ON ( $join )"; |
|
487 | + } |
|
488 | + } |
|
489 | + unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
490 | + return ''; |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + |
|
495 | + /** |
|
496 | + * @param string $SQL |
|
497 | + * @param WP_Query $wp_query |
|
498 | + * @return string |
|
499 | + * @throws EE_Error |
|
500 | + * @throws InvalidArgumentException |
|
501 | + * @throws InvalidDataTypeException |
|
502 | + * @throws InvalidInterfaceException |
|
503 | + */ |
|
504 | + public static function posts_where($SQL = '', WP_Query $wp_query) |
|
505 | + { |
|
506 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
507 | + // Show Expired ? |
|
508 | + $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
509 | + // Category |
|
510 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
511 | + // Start Date |
|
512 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
513 | + } |
|
514 | + return $SQL; |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * @param boolean $show_expired if TRUE, then displayed past events |
|
521 | + * @return string |
|
522 | + * @throws EE_Error |
|
523 | + * @throws InvalidArgumentException |
|
524 | + * @throws InvalidDataTypeException |
|
525 | + * @throws InvalidInterfaceException |
|
526 | + */ |
|
527 | + public static function posts_where_sql_for_show_expired($show_expired = false) |
|
528 | + { |
|
529 | + return ! $show_expired |
|
530 | + ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time('mysql', true) . '\' ' |
|
531 | + : ''; |
|
532 | + } |
|
533 | + |
|
534 | + |
|
535 | + |
|
536 | + /** |
|
537 | + * @param boolean $event_category_slug |
|
538 | + * @return string |
|
539 | + */ |
|
540 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
541 | + { |
|
542 | + global $wpdb; |
|
543 | + if (! empty($event_category_slug)) { |
|
544 | + $event_category_slugs_array = array_map('trim', explode(',', $event_category_slug)); |
|
545 | + $event_category_slugs_prepare = implode(', ', array_fill(0, count($event_category_slugs_array), '%s')); |
|
546 | + return $wpdb->prepare(" AND {$wpdb->terms}.slug IN ({$event_category_slugs_prepare}) ", $event_category_slugs_array); |
|
547 | + } |
|
548 | + return ''; |
|
549 | + } |
|
550 | + |
|
551 | + |
|
552 | + |
|
553 | + /** |
|
554 | + * @param boolean $month |
|
555 | + * @return string |
|
556 | + * @throws EE_Error |
|
557 | + * @throws InvalidArgumentException |
|
558 | + * @throws InvalidDataTypeException |
|
559 | + * @throws InvalidInterfaceException |
|
560 | + */ |
|
561 | + public static function posts_where_sql_for_event_list_month($month = null) |
|
562 | + { |
|
563 | + $SQL = ''; |
|
564 | + if (! empty($month)) { |
|
565 | + $datetime_table = EEM_Datetime::instance()->table(); |
|
566 | + // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
|
567 | + $SQL = " AND {$datetime_table}.DTT_EVT_start <= '"; |
|
568 | + $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "'"; |
|
569 | + // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
|
570 | + $SQL .= " AND {$datetime_table}.DTT_EVT_end >= '"; |
|
571 | + $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "' "; |
|
572 | + } |
|
573 | + return $SQL; |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + |
|
578 | + /** |
|
579 | + * @param string $SQL |
|
580 | + * @param WP_Query $wp_query |
|
581 | + * @return string |
|
582 | + * @throws EE_Error |
|
583 | + * @throws InvalidArgumentException |
|
584 | + * @throws InvalidDataTypeException |
|
585 | + * @throws InvalidInterfaceException |
|
586 | + */ |
|
587 | + public static function posts_orderby($SQL = '', WP_Query $wp_query) |
|
588 | + { |
|
589 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
590 | + $SQL = EEH_Event_Query::posts_orderby_sql( |
|
591 | + EEH_Event_Query::$_event_query_orderby, |
|
592 | + EEH_Event_Query::$_event_query_sort |
|
593 | + ); |
|
594 | + } |
|
595 | + return $SQL; |
|
596 | + } |
|
597 | + |
|
598 | + |
|
599 | + |
|
600 | + /** |
|
601 | + * posts_orderby_sql |
|
602 | + * possible parameters: |
|
603 | + * ID |
|
604 | + * start_date |
|
605 | + * end_date |
|
606 | + * event_name |
|
607 | + * category_slug |
|
608 | + * ticket_start |
|
609 | + * ticket_end |
|
610 | + * venue_title |
|
611 | + * city |
|
612 | + * state |
|
613 | + * **IMPORTANT** |
|
614 | + * make sure to also send the $orderby_params array to the posts_join_for_orderby() method |
|
615 | + * or else some of the table references below will result in MySQL errors |
|
616 | + * |
|
617 | + * @param array $orderby_params |
|
618 | + * @param string $sort |
|
619 | + * @return string |
|
620 | + * @throws EE_Error |
|
621 | + * @throws InvalidArgumentException |
|
622 | + * @throws InvalidDataTypeException |
|
623 | + * @throws InvalidInterfaceException |
|
624 | + */ |
|
625 | + public static function posts_orderby_sql(array $orderby_params = array(), $sort = 'ASC') |
|
626 | + { |
|
627 | + global $wpdb; |
|
628 | + $SQL = ''; |
|
629 | + $counter = 0; |
|
630 | + $sort = in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
631 | + ? strtoupper($sort) |
|
632 | + : 'ASC'; |
|
633 | + // make sure 'orderby' is set in query params |
|
634 | + if (! isset(self::$_query_params['orderby'])) { |
|
635 | + self::$_query_params['orderby'] = array(); |
|
636 | + } |
|
637 | + // loop thru $orderby_params (type cast as array) |
|
638 | + foreach ($orderby_params as $orderby) { |
|
639 | + // check if we have already added this param |
|
640 | + if (isset(self::$_query_params['orderby'][ $orderby ])) { |
|
641 | + // if so then remove from the $orderby_params so that the count() method below is accurate |
|
642 | + unset($orderby_params[ $orderby ]); |
|
643 | + // then bump ahead to the next param |
|
644 | + continue; |
|
645 | + } |
|
646 | + // this will ad a comma depending on whether this is the first or last param |
|
647 | + $glue = $counter === 0 || $counter === count($orderby_params) ? ' ' : ', '; |
|
648 | + // ok what's we dealing with? |
|
649 | + switch ($orderby) { |
|
650 | + case 'id': |
|
651 | + case 'ID': |
|
652 | + $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
653 | + break; |
|
654 | + case 'end_date': |
|
655 | + $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
656 | + break; |
|
657 | + case 'event_name': |
|
658 | + $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
659 | + break; |
|
660 | + case 'category_slug': |
|
661 | + $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
662 | + break; |
|
663 | + case 'ticket_start': |
|
664 | + $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
665 | + break; |
|
666 | + case 'ticket_end': |
|
667 | + $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
668 | + break; |
|
669 | + case 'venue_title': |
|
670 | + $SQL .= $glue . 'venue_title ' . $sort; |
|
671 | + break; |
|
672 | + case 'city': |
|
673 | + $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
674 | + break; |
|
675 | + case 'state': |
|
676 | + $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
677 | + break; |
|
678 | + case 'start_date': |
|
679 | + default: |
|
680 | + $SQL .= $glue . ' event_start_date ' . $sort; |
|
681 | + break; |
|
682 | + } |
|
683 | + // add to array of orderby params that have been added |
|
684 | + self::$_query_params['orderby'][ $orderby ] = true; |
|
685 | + $counter++; |
|
686 | + } |
|
687 | + return $SQL; |
|
688 | + } |
|
689 | 689 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | if (EEH_Event_Query::apply_query_filters($wp_query)) { |
229 | 229 | global $wpdb; |
230 | - $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
230 | + $clauses['groupby'] = $wpdb->posts.'.ID '; |
|
231 | 231 | } |
232 | 232 | return $clauses; |
233 | 233 | } |
@@ -264,23 +264,23 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function posts_fields_sql_for_orderby(array $orderby_params = array()) |
266 | 266 | { |
267 | - $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date '; |
|
267 | + $SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date '; |
|
268 | 268 | foreach ($orderby_params as $orderby) { |
269 | 269 | switch ($orderby) { |
270 | 270 | case 'ticket_start': |
271 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date'; |
|
271 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date'; |
|
272 | 272 | break; |
273 | 273 | case 'ticket_end': |
274 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date'; |
|
274 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date'; |
|
275 | 275 | break; |
276 | 276 | case 'venue_title': |
277 | 277 | $SQL .= ', Venue.post_title AS venue_title'; |
278 | 278 | break; |
279 | 279 | case 'city': |
280 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city'; |
|
280 | + $SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city'; |
|
281 | 281 | break; |
282 | 282 | case 'state': |
283 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name'; |
|
283 | + $SQL .= ', '.EEM_State::instance()->table().'.STA_name'; |
|
284 | 284 | break; |
285 | 285 | } |
286 | 286 | } |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = false) |
324 | 324 | { |
325 | - if (! $show_expired) { |
|
326 | - $join = EEM_Event::instance()->table() . '.ID = '; |
|
327 | - $join .= EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
325 | + if ( ! $show_expired) { |
|
326 | + $join = EEM_Event::instance()->table().'.ID = '; |
|
327 | + $join .= EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
328 | 328 | // don't add if this is already in the SQL |
329 | 329 | if (strpos($SQL, $join) === false) { |
330 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
330 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) '; |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | return $SQL; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') |
345 | 345 | { |
346 | - if (! empty($join_terms)) { |
|
346 | + if ( ! empty($join_terms)) { |
|
347 | 347 | global $wpdb; |
348 | 348 | $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
349 | 349 | $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | case 'ticket_end': |
374 | 374 | $SQL .= EEH_Event_Query::_posts_join_for_datetime( |
375 | 375 | $SQL, |
376 | - EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() |
|
376 | + EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name() |
|
377 | 377 | ); |
378 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table(); |
|
378 | + $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table(); |
|
379 | 379 | $SQL .= ' ON ('; |
380 | - $SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
380 | + $SQL .= EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name(); |
|
381 | 381 | $SQL .= ' = '; |
382 | - $SQL .= EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
382 | + $SQL .= EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name(); |
|
383 | 383 | $SQL .= ' )'; |
384 | 384 | break; |
385 | 385 | case 'venue_title': |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | break; |
393 | 393 | case 'start_date': |
394 | 394 | default: |
395 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table() . '.ID'); |
|
395 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID'); |
|
396 | 396 | break; |
397 | 397 | } |
398 | 398 | } |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | */ |
413 | 413 | protected static function _posts_join_for_datetime($SQL = '', $join = '') |
414 | 414 | { |
415 | - if (! empty($join)) { |
|
416 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
415 | + if ( ! empty($join)) { |
|
416 | + $join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
417 | 417 | if (strpos($SQL, $join) === false) { |
418 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
418 | + return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )'; |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | return ''; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | public static function posts_where_sql_for_show_expired($show_expired = false) |
528 | 528 | { |
529 | 529 | return ! $show_expired |
530 | - ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time('mysql', true) . '\' ' |
|
530 | + ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > \''.current_time('mysql', true).'\' ' |
|
531 | 531 | : ''; |
532 | 532 | } |
533 | 533 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
541 | 541 | { |
542 | 542 | global $wpdb; |
543 | - if (! empty($event_category_slug)) { |
|
543 | + if ( ! empty($event_category_slug)) { |
|
544 | 544 | $event_category_slugs_array = array_map('trim', explode(',', $event_category_slug)); |
545 | 545 | $event_category_slugs_prepare = implode(', ', array_fill(0, count($event_category_slugs_array), '%s')); |
546 | 546 | return $wpdb->prepare(" AND {$wpdb->terms}.slug IN ({$event_category_slugs_prepare}) ", $event_category_slugs_array); |
@@ -561,14 +561,14 @@ discard block |
||
561 | 561 | public static function posts_where_sql_for_event_list_month($month = null) |
562 | 562 | { |
563 | 563 | $SQL = ''; |
564 | - if (! empty($month)) { |
|
564 | + if ( ! empty($month)) { |
|
565 | 565 | $datetime_table = EEM_Datetime::instance()->table(); |
566 | 566 | // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
567 | 567 | $SQL = " AND {$datetime_table}.DTT_EVT_start <= '"; |
568 | - $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "'"; |
|
568 | + $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month))."'"; |
|
569 | 569 | // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
570 | 570 | $SQL .= " AND {$datetime_table}.DTT_EVT_end >= '"; |
571 | - $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "' "; |
|
571 | + $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month))."' "; |
|
572 | 572 | } |
573 | 573 | return $SQL; |
574 | 574 | } |
@@ -631,15 +631,15 @@ discard block |
||
631 | 631 | ? strtoupper($sort) |
632 | 632 | : 'ASC'; |
633 | 633 | // make sure 'orderby' is set in query params |
634 | - if (! isset(self::$_query_params['orderby'])) { |
|
634 | + if ( ! isset(self::$_query_params['orderby'])) { |
|
635 | 635 | self::$_query_params['orderby'] = array(); |
636 | 636 | } |
637 | 637 | // loop thru $orderby_params (type cast as array) |
638 | 638 | foreach ($orderby_params as $orderby) { |
639 | 639 | // check if we have already added this param |
640 | - if (isset(self::$_query_params['orderby'][ $orderby ])) { |
|
640 | + if (isset(self::$_query_params['orderby'][$orderby])) { |
|
641 | 641 | // if so then remove from the $orderby_params so that the count() method below is accurate |
642 | - unset($orderby_params[ $orderby ]); |
|
642 | + unset($orderby_params[$orderby]); |
|
643 | 643 | // then bump ahead to the next param |
644 | 644 | continue; |
645 | 645 | } |
@@ -649,39 +649,39 @@ discard block |
||
649 | 649 | switch ($orderby) { |
650 | 650 | case 'id': |
651 | 651 | case 'ID': |
652 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
652 | + $SQL .= $glue.$wpdb->posts.'.ID '.$sort; |
|
653 | 653 | break; |
654 | 654 | case 'end_date': |
655 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
655 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort; |
|
656 | 656 | break; |
657 | 657 | case 'event_name': |
658 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
658 | + $SQL .= $glue.$wpdb->posts.'.post_title '.$sort; |
|
659 | 659 | break; |
660 | 660 | case 'category_slug': |
661 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
661 | + $SQL .= $glue.$wpdb->terms.'.slug '.$sort; |
|
662 | 662 | break; |
663 | 663 | case 'ticket_start': |
664 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
664 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort; |
|
665 | 665 | break; |
666 | 666 | case 'ticket_end': |
667 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
667 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort; |
|
668 | 668 | break; |
669 | 669 | case 'venue_title': |
670 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
670 | + $SQL .= $glue.'venue_title '.$sort; |
|
671 | 671 | break; |
672 | 672 | case 'city': |
673 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
673 | + $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort; |
|
674 | 674 | break; |
675 | 675 | case 'state': |
676 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
676 | + $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort; |
|
677 | 677 | break; |
678 | 678 | case 'start_date': |
679 | 679 | default: |
680 | - $SQL .= $glue . ' event_start_date ' . $sort; |
|
680 | + $SQL .= $glue.' event_start_date '.$sort; |
|
681 | 681 | break; |
682 | 682 | } |
683 | 683 | // add to array of orderby params that have been added |
684 | - self::$_query_params['orderby'][ $orderby ] = true; |
|
684 | + self::$_query_params['orderby'][$orderby] = true; |
|
685 | 685 | $counter++; |
686 | 686 | } |
687 | 687 | return $SQL; |
@@ -11,189 +11,189 @@ |
||
11 | 11 | class EEM_Venue extends EEM_CPT_Base |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the Attendee object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the Attendee object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | - protected function __construct($timezone = null) |
|
20 | - { |
|
21 | - $this->singular_item = __('Venue', 'event_espresso'); |
|
22 | - $this->plural_item = __('Venues', 'event_espresso'); |
|
23 | - $this->_tables = array( |
|
24 | - 'Venue_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
25 | - 'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'), |
|
26 | - ); |
|
27 | - $this->_fields = array( |
|
28 | - 'Venue_CPT' => array( |
|
29 | - 'VNU_ID' => new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
|
30 | - 'VNU_name' => new EE_Plain_Text_Field( |
|
31 | - 'post_title', |
|
32 | - __("Venue Name", "event_espresso"), |
|
33 | - false, |
|
34 | - '' |
|
35 | - ), |
|
36 | - 'VNU_desc' => new EE_Post_Content_Field( |
|
37 | - 'post_content', |
|
38 | - __("Venue Description", "event_espresso"), |
|
39 | - false, |
|
40 | - '' |
|
41 | - ), |
|
42 | - 'VNU_identifier' => new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
43 | - 'VNU_created' => new EE_Datetime_Field( |
|
44 | - 'post_date', |
|
45 | - __("Date Venue Created", "event_espresso"), |
|
46 | - false, |
|
47 | - EE_Datetime_Field::now |
|
48 | - ), |
|
49 | - 'VNU_short_desc' => new EE_Plain_Text_Field( |
|
50 | - 'post_excerpt', |
|
51 | - __("Short Description of Venue", "event_espresso"), |
|
52 | - true, |
|
53 | - '' |
|
54 | - ), |
|
55 | - 'VNU_modified' => new EE_Datetime_Field( |
|
56 | - 'post_modified', |
|
57 | - __("Venue Modified Date", "event_espresso"), |
|
58 | - false, |
|
59 | - EE_Datetime_Field::now |
|
60 | - ), |
|
61 | - 'VNU_wp_user' => new EE_WP_User_Field( |
|
62 | - 'post_author', |
|
63 | - __("Venue Creator ID", "event_espresso"), |
|
64 | - false |
|
65 | - ), |
|
66 | - 'parent' => new EE_Integer_Field( |
|
67 | - 'post_parent', |
|
68 | - __("Venue Parent ID", "event_espresso"), |
|
69 | - false, |
|
70 | - 0 |
|
71 | - ), |
|
72 | - 'VNU_order' => new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
|
73 | - 'post_type' => new EE_WP_Post_Type_Field('espresso_venues'), |
|
74 | - 'password' => new EE_Password_Field( |
|
75 | - 'post_password', |
|
76 | - __('Password', 'event_espresso'), |
|
77 | - false, |
|
78 | - '', |
|
79 | - array( |
|
80 | - 'VNU_desc', |
|
81 | - 'VNU_short_desc', |
|
82 | - 'VNU_address', |
|
83 | - 'VNU_address2', |
|
84 | - 'VNU_city', |
|
85 | - 'STA_ID', |
|
86 | - 'CNT_ISO', |
|
87 | - 'VNU_zip', |
|
88 | - 'VNU_phone', |
|
89 | - 'VNU_capacity', |
|
90 | - 'VNU_url', |
|
91 | - 'VNU_virtual_phone', |
|
92 | - 'VNU_virtual_url', |
|
93 | - 'VNU_google_map_link', |
|
94 | - 'VNU_enable_for_gmap', |
|
95 | - ) |
|
96 | - ) |
|
97 | - ), |
|
98 | - 'Venue_Meta' => array( |
|
99 | - 'VNUM_ID' => new EE_DB_Only_Int_Field( |
|
100 | - 'VNUM_ID', |
|
101 | - __("ID of Venue Meta Row", "event_espresso"), |
|
102 | - false |
|
103 | - ), |
|
104 | - 'VNU_ID_fk' => new EE_DB_Only_Int_Field( |
|
105 | - 'VNU_ID', |
|
106 | - __("Foreign Key to Venue Post ", "event_espresso"), |
|
107 | - false |
|
108 | - ), |
|
109 | - 'VNU_address' => new EE_Plain_Text_Field( |
|
110 | - 'VNU_address', |
|
111 | - __("Venue Address line 1", "event_espresso"), |
|
112 | - true, |
|
113 | - '' |
|
114 | - ), |
|
115 | - 'VNU_address2' => new EE_Plain_Text_Field( |
|
116 | - 'VNU_address2', |
|
117 | - __("Venue Address line 2", "event_espresso"), |
|
118 | - true, |
|
119 | - '' |
|
120 | - ), |
|
121 | - 'VNU_city' => new EE_Plain_Text_Field( |
|
122 | - 'VNU_city', |
|
123 | - __("Venue City", "event_espresso"), |
|
124 | - true, |
|
125 | - '' |
|
126 | - ), |
|
127 | - 'STA_ID' => new EE_Foreign_Key_Int_Field( |
|
128 | - 'STA_ID', |
|
129 | - __("State ID", "event_espresso"), |
|
130 | - true, |
|
131 | - null, |
|
132 | - 'State' |
|
133 | - ), |
|
134 | - 'CNT_ISO' => new EE_Foreign_Key_String_Field( |
|
135 | - 'CNT_ISO', |
|
136 | - __("Country Code", "event_espresso"), |
|
137 | - true, |
|
138 | - null, |
|
139 | - 'Country' |
|
140 | - ), |
|
141 | - 'VNU_zip' => new EE_Plain_Text_Field( |
|
142 | - 'VNU_zip', |
|
143 | - __("Venue Zip/Postal Code", "event_espresso"), |
|
144 | - true |
|
145 | - ), |
|
146 | - 'VNU_phone' => new EE_Plain_Text_Field( |
|
147 | - 'VNU_phone', |
|
148 | - __("Venue Phone", "event_espresso"), |
|
149 | - true |
|
150 | - ), |
|
151 | - 'VNU_capacity' => new EE_Infinite_Integer_Field( |
|
152 | - 'VNU_capacity', |
|
153 | - __("Venue Capacity", "event_espresso"), |
|
154 | - true, |
|
155 | - EE_INF |
|
156 | - ), |
|
157 | - 'VNU_url' => new EE_Plain_Text_Field( |
|
158 | - 'VNU_url', |
|
159 | - __('Venue Website', 'event_espresso'), |
|
160 | - true |
|
161 | - ), |
|
162 | - 'VNU_virtual_phone' => new EE_Plain_Text_Field( |
|
163 | - 'VNU_virtual_phone', |
|
164 | - __('Call in Number', 'event_espresso'), |
|
165 | - true |
|
166 | - ), |
|
167 | - 'VNU_virtual_url' => new EE_Plain_Text_Field( |
|
168 | - 'VNU_virtual_url', |
|
169 | - __('Virtual URL', 'event_espresso'), |
|
170 | - true |
|
171 | - ), |
|
172 | - 'VNU_google_map_link' => new EE_Plain_Text_Field( |
|
173 | - 'VNU_google_map_link', |
|
174 | - __('Google Map Link', 'event_espresso'), |
|
175 | - true |
|
176 | - ), |
|
177 | - 'VNU_enable_for_gmap' => new EE_Boolean_Field( |
|
178 | - 'VNU_enable_for_gmap', |
|
179 | - __('Show Google Map?', 'event_espresso'), |
|
180 | - false, |
|
181 | - false |
|
182 | - ), |
|
183 | - ), |
|
184 | - ); |
|
185 | - $this->_model_relations = array( |
|
186 | - 'Country' => new EE_Belongs_To_Relation(), |
|
187 | - 'Event' => new EE_Has_Many_Relation(), |
|
188 | - 'Datetime' => new EE_Has_Many_Relation(), |
|
189 | - 'State' => new EE_Belongs_To_Relation(), |
|
190 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
191 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
192 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
193 | - ); |
|
194 | - // this model is generally available for reading |
|
195 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
196 | - $this->model_chain_to_password = ''; |
|
197 | - parent::__construct($timezone); |
|
198 | - } |
|
19 | + protected function __construct($timezone = null) |
|
20 | + { |
|
21 | + $this->singular_item = __('Venue', 'event_espresso'); |
|
22 | + $this->plural_item = __('Venues', 'event_espresso'); |
|
23 | + $this->_tables = array( |
|
24 | + 'Venue_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
25 | + 'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'), |
|
26 | + ); |
|
27 | + $this->_fields = array( |
|
28 | + 'Venue_CPT' => array( |
|
29 | + 'VNU_ID' => new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
|
30 | + 'VNU_name' => new EE_Plain_Text_Field( |
|
31 | + 'post_title', |
|
32 | + __("Venue Name", "event_espresso"), |
|
33 | + false, |
|
34 | + '' |
|
35 | + ), |
|
36 | + 'VNU_desc' => new EE_Post_Content_Field( |
|
37 | + 'post_content', |
|
38 | + __("Venue Description", "event_espresso"), |
|
39 | + false, |
|
40 | + '' |
|
41 | + ), |
|
42 | + 'VNU_identifier' => new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
43 | + 'VNU_created' => new EE_Datetime_Field( |
|
44 | + 'post_date', |
|
45 | + __("Date Venue Created", "event_espresso"), |
|
46 | + false, |
|
47 | + EE_Datetime_Field::now |
|
48 | + ), |
|
49 | + 'VNU_short_desc' => new EE_Plain_Text_Field( |
|
50 | + 'post_excerpt', |
|
51 | + __("Short Description of Venue", "event_espresso"), |
|
52 | + true, |
|
53 | + '' |
|
54 | + ), |
|
55 | + 'VNU_modified' => new EE_Datetime_Field( |
|
56 | + 'post_modified', |
|
57 | + __("Venue Modified Date", "event_espresso"), |
|
58 | + false, |
|
59 | + EE_Datetime_Field::now |
|
60 | + ), |
|
61 | + 'VNU_wp_user' => new EE_WP_User_Field( |
|
62 | + 'post_author', |
|
63 | + __("Venue Creator ID", "event_espresso"), |
|
64 | + false |
|
65 | + ), |
|
66 | + 'parent' => new EE_Integer_Field( |
|
67 | + 'post_parent', |
|
68 | + __("Venue Parent ID", "event_espresso"), |
|
69 | + false, |
|
70 | + 0 |
|
71 | + ), |
|
72 | + 'VNU_order' => new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
|
73 | + 'post_type' => new EE_WP_Post_Type_Field('espresso_venues'), |
|
74 | + 'password' => new EE_Password_Field( |
|
75 | + 'post_password', |
|
76 | + __('Password', 'event_espresso'), |
|
77 | + false, |
|
78 | + '', |
|
79 | + array( |
|
80 | + 'VNU_desc', |
|
81 | + 'VNU_short_desc', |
|
82 | + 'VNU_address', |
|
83 | + 'VNU_address2', |
|
84 | + 'VNU_city', |
|
85 | + 'STA_ID', |
|
86 | + 'CNT_ISO', |
|
87 | + 'VNU_zip', |
|
88 | + 'VNU_phone', |
|
89 | + 'VNU_capacity', |
|
90 | + 'VNU_url', |
|
91 | + 'VNU_virtual_phone', |
|
92 | + 'VNU_virtual_url', |
|
93 | + 'VNU_google_map_link', |
|
94 | + 'VNU_enable_for_gmap', |
|
95 | + ) |
|
96 | + ) |
|
97 | + ), |
|
98 | + 'Venue_Meta' => array( |
|
99 | + 'VNUM_ID' => new EE_DB_Only_Int_Field( |
|
100 | + 'VNUM_ID', |
|
101 | + __("ID of Venue Meta Row", "event_espresso"), |
|
102 | + false |
|
103 | + ), |
|
104 | + 'VNU_ID_fk' => new EE_DB_Only_Int_Field( |
|
105 | + 'VNU_ID', |
|
106 | + __("Foreign Key to Venue Post ", "event_espresso"), |
|
107 | + false |
|
108 | + ), |
|
109 | + 'VNU_address' => new EE_Plain_Text_Field( |
|
110 | + 'VNU_address', |
|
111 | + __("Venue Address line 1", "event_espresso"), |
|
112 | + true, |
|
113 | + '' |
|
114 | + ), |
|
115 | + 'VNU_address2' => new EE_Plain_Text_Field( |
|
116 | + 'VNU_address2', |
|
117 | + __("Venue Address line 2", "event_espresso"), |
|
118 | + true, |
|
119 | + '' |
|
120 | + ), |
|
121 | + 'VNU_city' => new EE_Plain_Text_Field( |
|
122 | + 'VNU_city', |
|
123 | + __("Venue City", "event_espresso"), |
|
124 | + true, |
|
125 | + '' |
|
126 | + ), |
|
127 | + 'STA_ID' => new EE_Foreign_Key_Int_Field( |
|
128 | + 'STA_ID', |
|
129 | + __("State ID", "event_espresso"), |
|
130 | + true, |
|
131 | + null, |
|
132 | + 'State' |
|
133 | + ), |
|
134 | + 'CNT_ISO' => new EE_Foreign_Key_String_Field( |
|
135 | + 'CNT_ISO', |
|
136 | + __("Country Code", "event_espresso"), |
|
137 | + true, |
|
138 | + null, |
|
139 | + 'Country' |
|
140 | + ), |
|
141 | + 'VNU_zip' => new EE_Plain_Text_Field( |
|
142 | + 'VNU_zip', |
|
143 | + __("Venue Zip/Postal Code", "event_espresso"), |
|
144 | + true |
|
145 | + ), |
|
146 | + 'VNU_phone' => new EE_Plain_Text_Field( |
|
147 | + 'VNU_phone', |
|
148 | + __("Venue Phone", "event_espresso"), |
|
149 | + true |
|
150 | + ), |
|
151 | + 'VNU_capacity' => new EE_Infinite_Integer_Field( |
|
152 | + 'VNU_capacity', |
|
153 | + __("Venue Capacity", "event_espresso"), |
|
154 | + true, |
|
155 | + EE_INF |
|
156 | + ), |
|
157 | + 'VNU_url' => new EE_Plain_Text_Field( |
|
158 | + 'VNU_url', |
|
159 | + __('Venue Website', 'event_espresso'), |
|
160 | + true |
|
161 | + ), |
|
162 | + 'VNU_virtual_phone' => new EE_Plain_Text_Field( |
|
163 | + 'VNU_virtual_phone', |
|
164 | + __('Call in Number', 'event_espresso'), |
|
165 | + true |
|
166 | + ), |
|
167 | + 'VNU_virtual_url' => new EE_Plain_Text_Field( |
|
168 | + 'VNU_virtual_url', |
|
169 | + __('Virtual URL', 'event_espresso'), |
|
170 | + true |
|
171 | + ), |
|
172 | + 'VNU_google_map_link' => new EE_Plain_Text_Field( |
|
173 | + 'VNU_google_map_link', |
|
174 | + __('Google Map Link', 'event_espresso'), |
|
175 | + true |
|
176 | + ), |
|
177 | + 'VNU_enable_for_gmap' => new EE_Boolean_Field( |
|
178 | + 'VNU_enable_for_gmap', |
|
179 | + __('Show Google Map?', 'event_espresso'), |
|
180 | + false, |
|
181 | + false |
|
182 | + ), |
|
183 | + ), |
|
184 | + ); |
|
185 | + $this->_model_relations = array( |
|
186 | + 'Country' => new EE_Belongs_To_Relation(), |
|
187 | + 'Event' => new EE_Has_Many_Relation(), |
|
188 | + 'Datetime' => new EE_Has_Many_Relation(), |
|
189 | + 'State' => new EE_Belongs_To_Relation(), |
|
190 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
191 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
192 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
193 | + ); |
|
194 | + // this model is generally available for reading |
|
195 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
196 | + $this->model_chain_to_password = ''; |
|
197 | + parent::__construct($timezone); |
|
198 | + } |
|
199 | 199 | } |
@@ -192,7 +192,7 @@ |
||
192 | 192 | 'WP_User' => new EE_Belongs_To_Relation(), |
193 | 193 | ); |
194 | 194 | // this model is generally available for reading |
195 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
195 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
196 | 196 | $this->model_chain_to_password = ''; |
197 | 197 | parent::__construct($timezone); |
198 | 198 | } |
@@ -25,227 +25,227 @@ |
||
25 | 25 | class Event extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Event constructor. |
|
30 | - * |
|
31 | - * @param EEM_Event $event_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Event $event_model) |
|
34 | - { |
|
35 | - $this->setName($this->namespace . 'Event'); |
|
36 | - $this->setIsCustomPostType(true); |
|
37 | - parent::__construct($event_model); |
|
38 | - } |
|
28 | + /** |
|
29 | + * Event constructor. |
|
30 | + * |
|
31 | + * @param EEM_Event $event_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Event $event_model) |
|
34 | + { |
|
35 | + $this->setName($this->namespace . 'Event'); |
|
36 | + $this->setIsCustomPostType(true); |
|
37 | + parent::__construct($event_model); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @return GraphQLFieldInterface[] |
|
43 | - */ |
|
44 | - public function getFields(): array |
|
45 | - { |
|
46 | - $fields = [ |
|
47 | - new GraphQLField( |
|
48 | - 'allowDonations', |
|
49 | - 'Boolean', |
|
50 | - 'donations', |
|
51 | - esc_html__('Accept Donations?', 'event_espresso') |
|
52 | - ), |
|
53 | - new GraphQLField( |
|
54 | - 'allowOverflow', |
|
55 | - 'Boolean', |
|
56 | - 'allow_overflow', |
|
57 | - esc_html__('Enable Wait List for Event', 'event_espresso') |
|
58 | - ), |
|
59 | - new GraphQLField( |
|
60 | - 'altRegPage', |
|
61 | - 'String', |
|
62 | - 'external_url', |
|
63 | - esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
64 | - ), |
|
65 | - new GraphQLOutputField( |
|
66 | - 'cacheId', |
|
67 | - ['non_null' => 'String'], |
|
68 | - null, |
|
69 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
70 | - ), |
|
71 | - new GraphQLField( |
|
72 | - 'created', |
|
73 | - 'String', |
|
74 | - 'created', |
|
75 | - esc_html__('Date/Time Event Created', 'event_espresso') |
|
76 | - ), |
|
77 | - new GraphQLOutputField( |
|
78 | - 'dbId', |
|
79 | - ['non_null' => 'Int'], |
|
80 | - 'ID', |
|
81 | - esc_html__('The event ID.', 'event_espresso') |
|
82 | - ), |
|
83 | - new GraphQLField( |
|
84 | - 'defaultRegStatus', |
|
85 | - $this->namespace . 'RegistrationStatusEnum', |
|
86 | - 'default_registration_status', |
|
87 | - esc_html__('Default Event Registration Status', 'event_espresso') |
|
88 | - ), |
|
89 | - new GraphQLField( |
|
90 | - 'description', |
|
91 | - 'String', |
|
92 | - 'description', |
|
93 | - esc_html__('Event Description', 'event_espresso') |
|
94 | - ), |
|
95 | - new GraphQLField( |
|
96 | - 'displayDescription', |
|
97 | - 'Boolean', |
|
98 | - 'display_description', |
|
99 | - esc_html__('Display Description Flag', 'event_espresso') |
|
100 | - ), |
|
101 | - new GraphQLField( |
|
102 | - 'displayTicketSelector', |
|
103 | - 'Boolean', |
|
104 | - 'display_ticket_selector', |
|
105 | - esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
106 | - ), |
|
107 | - new GraphQLOutputField( |
|
108 | - 'isActive', |
|
109 | - 'Boolean', |
|
110 | - 'is_active', |
|
111 | - esc_html__('Flag indicating event is active', 'event_espresso') |
|
112 | - ), |
|
113 | - new GraphQLOutputField( |
|
114 | - 'isCancelled', |
|
115 | - 'Boolean', |
|
116 | - 'is_cancelled', |
|
117 | - esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
118 | - ), |
|
119 | - new GraphQLOutputField( |
|
120 | - 'isExpired', |
|
121 | - 'Boolean', |
|
122 | - 'is_expired', |
|
123 | - esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
124 | - ), |
|
125 | - new GraphQLOutputField( |
|
126 | - 'isInactive', |
|
127 | - 'Boolean', |
|
128 | - 'is_inactive', |
|
129 | - esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
130 | - ), |
|
131 | - new GraphQLOutputField( |
|
132 | - 'isPostponed', |
|
133 | - 'Boolean', |
|
134 | - 'is_postponed', |
|
135 | - esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
136 | - ), |
|
137 | - new GraphQLOutputField( |
|
138 | - 'isSoldOut', |
|
139 | - 'Boolean', |
|
140 | - 'is_sold_out', |
|
141 | - esc_html__( |
|
142 | - 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
143 | - 'event_espresso' |
|
144 | - ) |
|
145 | - ), |
|
146 | - new GraphQLOutputField( |
|
147 | - 'isUpcoming', |
|
148 | - 'Boolean', |
|
149 | - 'is_upcoming', |
|
150 | - esc_html__('Whether the event is upcoming', 'event_espresso') |
|
151 | - ), |
|
152 | - new GraphQLInputField( |
|
153 | - 'manager', |
|
154 | - 'String', |
|
155 | - null, |
|
156 | - esc_html__('Globally unique event ID for the event manager', 'event_espresso') |
|
157 | - ), |
|
158 | - new GraphQLOutputField( |
|
159 | - 'manager', |
|
160 | - 'User', |
|
161 | - null, |
|
162 | - esc_html__('Event Manager', 'event_espresso') |
|
163 | - ), |
|
164 | - new GraphQLField( |
|
165 | - 'maxRegistrations', |
|
166 | - 'Int', |
|
167 | - 'additional_limit', |
|
168 | - esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
169 | - ), |
|
170 | - new GraphQLField( |
|
171 | - 'memberOnly', |
|
172 | - 'Boolean', |
|
173 | - 'member_only', |
|
174 | - esc_html__('Member-Only Event Flag', 'event_espresso') |
|
175 | - ), |
|
176 | - new GraphQLField( |
|
177 | - 'name', |
|
178 | - 'String', |
|
179 | - 'name', |
|
180 | - esc_html__('Event Name', 'event_espresso') |
|
181 | - ), |
|
182 | - new GraphQLField( |
|
183 | - 'order', |
|
184 | - 'Int', |
|
185 | - 'order', |
|
186 | - esc_html__('Event Menu Order', 'event_espresso') |
|
187 | - ), |
|
188 | - new GraphQLField( |
|
189 | - 'phoneNumber', |
|
190 | - 'String', |
|
191 | - 'phone', |
|
192 | - esc_html__('Event Phone Number', 'event_espresso') |
|
193 | - ), |
|
194 | - new GraphQLField( |
|
195 | - 'shortDescription', |
|
196 | - 'String', |
|
197 | - 'short_description', |
|
198 | - esc_html__('Event Short Description', 'event_espresso') |
|
199 | - ), |
|
200 | - new GraphQLField( |
|
201 | - 'timezoneString', |
|
202 | - 'String', |
|
203 | - 'timezone_string', |
|
204 | - esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
205 | - ), |
|
206 | - new GraphQLField( |
|
207 | - 'visibleOn', |
|
208 | - 'String', |
|
209 | - 'visible_on', |
|
210 | - esc_html__('Event Visible Date', 'event_espresso') |
|
211 | - ), |
|
212 | - new GraphQLField( |
|
213 | - 'venue', |
|
214 | - 'String', |
|
215 | - null, |
|
216 | - esc_html__('Event venue ID', 'event_espresso'), |
|
217 | - null, |
|
218 | - function (EE_Event $source) { |
|
219 | - $venue_ID = $source->venue_ID(); |
|
220 | - return $venue_ID |
|
221 | - // Since venue is a CPT, $type will be 'post' |
|
222 | - ? Relay::toGlobalId('post', $venue_ID) |
|
223 | - : null; |
|
224 | - } |
|
225 | - ), |
|
226 | - ]; |
|
41 | + /** |
|
42 | + * @return GraphQLFieldInterface[] |
|
43 | + */ |
|
44 | + public function getFields(): array |
|
45 | + { |
|
46 | + $fields = [ |
|
47 | + new GraphQLField( |
|
48 | + 'allowDonations', |
|
49 | + 'Boolean', |
|
50 | + 'donations', |
|
51 | + esc_html__('Accept Donations?', 'event_espresso') |
|
52 | + ), |
|
53 | + new GraphQLField( |
|
54 | + 'allowOverflow', |
|
55 | + 'Boolean', |
|
56 | + 'allow_overflow', |
|
57 | + esc_html__('Enable Wait List for Event', 'event_espresso') |
|
58 | + ), |
|
59 | + new GraphQLField( |
|
60 | + 'altRegPage', |
|
61 | + 'String', |
|
62 | + 'external_url', |
|
63 | + esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
64 | + ), |
|
65 | + new GraphQLOutputField( |
|
66 | + 'cacheId', |
|
67 | + ['non_null' => 'String'], |
|
68 | + null, |
|
69 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
70 | + ), |
|
71 | + new GraphQLField( |
|
72 | + 'created', |
|
73 | + 'String', |
|
74 | + 'created', |
|
75 | + esc_html__('Date/Time Event Created', 'event_espresso') |
|
76 | + ), |
|
77 | + new GraphQLOutputField( |
|
78 | + 'dbId', |
|
79 | + ['non_null' => 'Int'], |
|
80 | + 'ID', |
|
81 | + esc_html__('The event ID.', 'event_espresso') |
|
82 | + ), |
|
83 | + new GraphQLField( |
|
84 | + 'defaultRegStatus', |
|
85 | + $this->namespace . 'RegistrationStatusEnum', |
|
86 | + 'default_registration_status', |
|
87 | + esc_html__('Default Event Registration Status', 'event_espresso') |
|
88 | + ), |
|
89 | + new GraphQLField( |
|
90 | + 'description', |
|
91 | + 'String', |
|
92 | + 'description', |
|
93 | + esc_html__('Event Description', 'event_espresso') |
|
94 | + ), |
|
95 | + new GraphQLField( |
|
96 | + 'displayDescription', |
|
97 | + 'Boolean', |
|
98 | + 'display_description', |
|
99 | + esc_html__('Display Description Flag', 'event_espresso') |
|
100 | + ), |
|
101 | + new GraphQLField( |
|
102 | + 'displayTicketSelector', |
|
103 | + 'Boolean', |
|
104 | + 'display_ticket_selector', |
|
105 | + esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
106 | + ), |
|
107 | + new GraphQLOutputField( |
|
108 | + 'isActive', |
|
109 | + 'Boolean', |
|
110 | + 'is_active', |
|
111 | + esc_html__('Flag indicating event is active', 'event_espresso') |
|
112 | + ), |
|
113 | + new GraphQLOutputField( |
|
114 | + 'isCancelled', |
|
115 | + 'Boolean', |
|
116 | + 'is_cancelled', |
|
117 | + esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
118 | + ), |
|
119 | + new GraphQLOutputField( |
|
120 | + 'isExpired', |
|
121 | + 'Boolean', |
|
122 | + 'is_expired', |
|
123 | + esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
124 | + ), |
|
125 | + new GraphQLOutputField( |
|
126 | + 'isInactive', |
|
127 | + 'Boolean', |
|
128 | + 'is_inactive', |
|
129 | + esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
130 | + ), |
|
131 | + new GraphQLOutputField( |
|
132 | + 'isPostponed', |
|
133 | + 'Boolean', |
|
134 | + 'is_postponed', |
|
135 | + esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
136 | + ), |
|
137 | + new GraphQLOutputField( |
|
138 | + 'isSoldOut', |
|
139 | + 'Boolean', |
|
140 | + 'is_sold_out', |
|
141 | + esc_html__( |
|
142 | + 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
143 | + 'event_espresso' |
|
144 | + ) |
|
145 | + ), |
|
146 | + new GraphQLOutputField( |
|
147 | + 'isUpcoming', |
|
148 | + 'Boolean', |
|
149 | + 'is_upcoming', |
|
150 | + esc_html__('Whether the event is upcoming', 'event_espresso') |
|
151 | + ), |
|
152 | + new GraphQLInputField( |
|
153 | + 'manager', |
|
154 | + 'String', |
|
155 | + null, |
|
156 | + esc_html__('Globally unique event ID for the event manager', 'event_espresso') |
|
157 | + ), |
|
158 | + new GraphQLOutputField( |
|
159 | + 'manager', |
|
160 | + 'User', |
|
161 | + null, |
|
162 | + esc_html__('Event Manager', 'event_espresso') |
|
163 | + ), |
|
164 | + new GraphQLField( |
|
165 | + 'maxRegistrations', |
|
166 | + 'Int', |
|
167 | + 'additional_limit', |
|
168 | + esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
169 | + ), |
|
170 | + new GraphQLField( |
|
171 | + 'memberOnly', |
|
172 | + 'Boolean', |
|
173 | + 'member_only', |
|
174 | + esc_html__('Member-Only Event Flag', 'event_espresso') |
|
175 | + ), |
|
176 | + new GraphQLField( |
|
177 | + 'name', |
|
178 | + 'String', |
|
179 | + 'name', |
|
180 | + esc_html__('Event Name', 'event_espresso') |
|
181 | + ), |
|
182 | + new GraphQLField( |
|
183 | + 'order', |
|
184 | + 'Int', |
|
185 | + 'order', |
|
186 | + esc_html__('Event Menu Order', 'event_espresso') |
|
187 | + ), |
|
188 | + new GraphQLField( |
|
189 | + 'phoneNumber', |
|
190 | + 'String', |
|
191 | + 'phone', |
|
192 | + esc_html__('Event Phone Number', 'event_espresso') |
|
193 | + ), |
|
194 | + new GraphQLField( |
|
195 | + 'shortDescription', |
|
196 | + 'String', |
|
197 | + 'short_description', |
|
198 | + esc_html__('Event Short Description', 'event_espresso') |
|
199 | + ), |
|
200 | + new GraphQLField( |
|
201 | + 'timezoneString', |
|
202 | + 'String', |
|
203 | + 'timezone_string', |
|
204 | + esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
205 | + ), |
|
206 | + new GraphQLField( |
|
207 | + 'visibleOn', |
|
208 | + 'String', |
|
209 | + 'visible_on', |
|
210 | + esc_html__('Event Visible Date', 'event_espresso') |
|
211 | + ), |
|
212 | + new GraphQLField( |
|
213 | + 'venue', |
|
214 | + 'String', |
|
215 | + null, |
|
216 | + esc_html__('Event venue ID', 'event_espresso'), |
|
217 | + null, |
|
218 | + function (EE_Event $source) { |
|
219 | + $venue_ID = $source->venue_ID(); |
|
220 | + return $venue_ID |
|
221 | + // Since venue is a CPT, $type will be 'post' |
|
222 | + ? Relay::toGlobalId('post', $venue_ID) |
|
223 | + : null; |
|
224 | + } |
|
225 | + ), |
|
226 | + ]; |
|
227 | 227 | |
228 | - return apply_filters( |
|
229 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__event_fields', |
|
230 | - $fields, |
|
231 | - $this->name, |
|
232 | - $this->model |
|
233 | - ); |
|
234 | - } |
|
228 | + return apply_filters( |
|
229 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__event_fields', |
|
230 | + $fields, |
|
231 | + $this->name, |
|
232 | + $this->model |
|
233 | + ); |
|
234 | + } |
|
235 | 235 | |
236 | 236 | |
237 | - /** |
|
238 | - * Extends the existing WP GraphQL mutations. |
|
239 | - * |
|
240 | - * @since $VID:$ |
|
241 | - */ |
|
242 | - public function extendMutations() |
|
243 | - { |
|
244 | - add_action( |
|
245 | - 'graphql_post_object_mutation_update_additional_data', |
|
246 | - EventUpdate::mutateFields($this->model, $this), |
|
247 | - 10, |
|
248 | - 6 |
|
249 | - ); |
|
250 | - } |
|
237 | + /** |
|
238 | + * Extends the existing WP GraphQL mutations. |
|
239 | + * |
|
240 | + * @since $VID:$ |
|
241 | + */ |
|
242 | + public function extendMutations() |
|
243 | + { |
|
244 | + add_action( |
|
245 | + 'graphql_post_object_mutation_update_additional_data', |
|
246 | + EventUpdate::mutateFields($this->model, $this), |
|
247 | + 10, |
|
248 | + 6 |
|
249 | + ); |
|
250 | + } |
|
251 | 251 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function __construct(EEM_Event $event_model) |
34 | 34 | { |
35 | - $this->setName($this->namespace . 'Event'); |
|
35 | + $this->setName($this->namespace.'Event'); |
|
36 | 36 | $this->setIsCustomPostType(true); |
37 | 37 | parent::__construct($event_model); |
38 | 38 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ), |
83 | 83 | new GraphQLField( |
84 | 84 | 'defaultRegStatus', |
85 | - $this->namespace . 'RegistrationStatusEnum', |
|
85 | + $this->namespace.'RegistrationStatusEnum', |
|
86 | 86 | 'default_registration_status', |
87 | 87 | esc_html__('Default Event Registration Status', 'event_espresso') |
88 | 88 | ), |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | null, |
216 | 216 | esc_html__('Event venue ID', 'event_espresso'), |
217 | 217 | null, |
218 | - function (EE_Event $source) { |
|
218 | + function(EE_Event $source) { |
|
219 | 219 | $venue_ID = $source->venue_ID(); |
220 | 220 | return $venue_ID |
221 | 221 | // Since venue is a CPT, $type will be 'post' |
@@ -13,1024 +13,1024 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @return EED_Events_Archive_Filters |
|
18 | - */ |
|
19 | - public static function instance() |
|
20 | - { |
|
21 | - return parent::get_instance(__CLASS__); |
|
22 | - } |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Start Date |
|
27 | - * |
|
28 | - * @var $_elf_month |
|
29 | - * @access protected |
|
30 | - */ |
|
31 | - protected $_elf_month = null; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Category |
|
36 | - * |
|
37 | - * @var $_elf_category |
|
38 | - * @access protected |
|
39 | - */ |
|
40 | - protected $_elf_category = null; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * whether to display expired events in the event list |
|
45 | - * |
|
46 | - * @var $_show_expired |
|
47 | - * @access protected |
|
48 | - */ |
|
49 | - protected $_show_expired = null; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * whether to display the event list as a grid or list |
|
54 | - * |
|
55 | - * @var $_type |
|
56 | - * @access protected |
|
57 | - */ |
|
58 | - protected static $_type = null; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * array of existing event list views |
|
63 | - * |
|
64 | - * @var $_types |
|
65 | - * @access protected |
|
66 | - */ |
|
67 | - protected static $_types = array('grid', 'text', 'dates'); |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
73 | - * |
|
74 | - * @access public |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - public static function set_hooks() |
|
78 | - { |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
83 | - * |
|
84 | - * @access public |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public static function set_hooks_admin() |
|
88 | - { |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * set_definitions |
|
94 | - * |
|
95 | - * @access public |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public static function set_definitions() |
|
99 | - { |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * run - initial module setup |
|
105 | - * |
|
106 | - * @access public |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function run($WP) |
|
110 | - { |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * event_list |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @return void |
|
119 | - */ |
|
120 | - public function event_list() |
|
121 | - { |
|
122 | - // load other required components |
|
123 | - $this->_load_assests(); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * _filter_query_parts |
|
129 | - * |
|
130 | - * @access public |
|
131 | - * @return void |
|
132 | - */ |
|
133 | - private function _filter_query_parts() |
|
134 | - { |
|
135 | - // build event list query |
|
136 | - add_filter('posts_join', array($this, 'posts_join'), 1, 2); |
|
137 | - add_filter('posts_where', array($this, 'posts_where'), 1, 2); |
|
138 | - add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * _type - the type of event list : grid, text, dates |
|
143 | - * |
|
144 | - * @access public |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public static function set_type() |
|
148 | - { |
|
149 | - do_action('AHEE__EED_Events_Archive_Filters__before_set_type'); |
|
150 | - EED_Events_Archive_Filters::$_types = apply_filters( |
|
151 | - 'EED_Events_Archive_Filters__set_type__types', |
|
152 | - EED_Events_Archive_Filters::$_types |
|
153 | - ); |
|
154 | - $view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance( |
|
155 | - )->CFG->EED_Events_Archive_Filters['default_type'] : 'grid'; |
|
156 | - $elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field( |
|
157 | - EE_Registry::instance()->REQ->get('elf_type') |
|
158 | - ) : ''; |
|
159 | - $view = ! empty($elf_type) ? $elf_type : $view; |
|
160 | - $view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view); |
|
161 | - if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) { |
|
162 | - self::$_type = $view; |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * _show_expired |
|
168 | - * |
|
169 | - * @access private |
|
170 | - * @param boolean $req_only if TRUE, then ignore defaults and only return $_POST value |
|
171 | - * @return boolean |
|
172 | - */ |
|
173 | - private static function _show_expired($req_only = false) |
|
174 | - { |
|
175 | - // get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings |
|
176 | - $show_expired = ! $req_only && isset( |
|
177 | - EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] |
|
178 | - ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : false; |
|
179 | - // override default expired option if set via filter |
|
180 | - $show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint( |
|
181 | - EE_Registry::instance()->REQ->get('elf_expired_chk') |
|
182 | - ) : $show_expired; |
|
183 | - return $show_expired ? true : false; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * _event_category_slug |
|
188 | - * |
|
189 | - * @access private |
|
190 | - * @return string |
|
191 | - */ |
|
192 | - private static function _event_category_slug() |
|
193 | - { |
|
194 | - return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field( |
|
195 | - EE_Registry::instance()->REQ->get('elf_category_dd') |
|
196 | - ) : ''; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * _display_month - what month should the event list display events for? |
|
201 | - * |
|
202 | - * @access private |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - private static function _display_month() |
|
206 | - { |
|
207 | - return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field( |
|
208 | - EE_Registry::instance()->REQ->get('elf_month_dd') |
|
209 | - ) : ''; |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * get_post_data |
|
215 | - * |
|
216 | - * @access public |
|
217 | - * @return void |
|
218 | - */ |
|
219 | - public function get_post_data() |
|
220 | - { |
|
221 | - $this->_elf_month = EED_Events_Archive_Filters::_display_month(); |
|
222 | - $this->_elf_category = EED_Events_Archive_Filters::_event_category_slug(); |
|
223 | - $this->_show_expired = EED_Events_Archive_Filters::_show_expired(true); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * posts_join |
|
229 | - * |
|
230 | - * @access public |
|
231 | - * @return void |
|
232 | - */ |
|
233 | - public function posts_join($SQL, WP_Query $wp_query) |
|
234 | - { |
|
235 | - if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') { |
|
236 | - // Category |
|
237 | - $SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms( |
|
238 | - EED_Events_Archive_Filters::_event_category_slug() |
|
239 | - ); |
|
240 | - } |
|
241 | - return $SQL; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * posts_join_sql_for_terms |
|
247 | - * |
|
248 | - * @access public |
|
249 | - * @param mixed boolean|string $join_terms pass TRUE or term string, doesn't really matter since this value |
|
250 | - * doesn't really get used for anything yet |
|
251 | - * @return string |
|
252 | - */ |
|
253 | - public static function posts_join_sql_for_terms($join_terms = null) |
|
254 | - { |
|
255 | - $SQL = ''; |
|
256 | - if (! empty($join_terms)) { |
|
257 | - global $wpdb; |
|
258 | - $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
|
259 | - $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
|
260 | - $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) "; |
|
261 | - } |
|
262 | - return $SQL; |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * usage: $SQL .= EED_Events_Archive_Filters::posts_join_for_orderby( $orderby_params ); |
|
268 | - * |
|
269 | - * @param array $orderby_params |
|
270 | - * @return string |
|
271 | - * @throws EE_Error |
|
272 | - * @throws ReflectionException |
|
273 | - */ |
|
274 | - public static function posts_join_for_orderby(array $orderby_params = array()): string |
|
275 | - { |
|
276 | - global $wpdb; |
|
277 | - $SQL = ''; |
|
278 | - $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params); |
|
279 | - foreach ($orderby_params as $orderby) { |
|
280 | - switch ($orderby) { |
|
281 | - case 'ticket_start': |
|
282 | - case 'ticket_end': |
|
283 | - $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON (' |
|
284 | - . EEM_Datetime::instance()->table() . '.DTT_ID = ' |
|
285 | - . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )'; |
|
286 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' |
|
287 | - . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = ' |
|
288 | - . EEM_Ticket::instance()->table() . '.TKT_ID )'; |
|
289 | - break; |
|
290 | - |
|
291 | - case 'city': |
|
292 | - case 'state': |
|
293 | - case 'venue_title': |
|
294 | - // grab wp_posts (event), venue, and event_meta table names |
|
295 | - $wp_posts = $wpdb->posts; |
|
296 | - $venue = EEM_Venue::instance()->table(); |
|
297 | - $event_meta = EEM_Event::instance()->second_table(); |
|
298 | - $SQL .= " LEFT JOIN $event_meta ON ( $wp_posts.ID = $event_meta.EVT_ID )"; |
|
299 | - $SQL .= " LEFT JOIN $venue ON ( $event_meta.VNU_ID = $venue.VNU_ID )"; |
|
300 | - break; |
|
301 | - } |
|
302 | - } |
|
303 | - return $SQL; |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * posts_where |
|
309 | - * |
|
310 | - * @access public |
|
311 | - * @return void |
|
312 | - */ |
|
313 | - public function posts_where($SQL, WP_Query $wp_query) |
|
314 | - { |
|
315 | - if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') { |
|
316 | - // Show Expired ? |
|
317 | - $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired( |
|
318 | - EED_Events_Archive_Filters::_show_expired() |
|
319 | - ); |
|
320 | - // Category |
|
321 | - // $elf_category = EED_Events_Archive_Filters::_event_category_slug(); |
|
322 | - $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug( |
|
323 | - EED_Events_Archive_Filters::_event_category_slug() |
|
324 | - ); |
|
325 | - // Start Date |
|
326 | - // $elf_month = EED_Events_Archive_Filters::_display_month(); |
|
327 | - $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month( |
|
328 | - EED_Events_Archive_Filters::_display_month() |
|
329 | - ); |
|
330 | - } |
|
331 | - return $SQL; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * posts_where_sql_for_show_expired |
|
337 | - * |
|
338 | - * @access public |
|
339 | - * @param boolean $show_expired if TRUE, then displayed past events |
|
340 | - * @return string |
|
341 | - */ |
|
342 | - public static function posts_where_sql_for_show_expired($show_expired = false) |
|
343 | - { |
|
344 | - return ! $show_expired |
|
345 | - ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" ' |
|
346 | - : ''; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * posts_where_sql_for_event_category_slug |
|
352 | - * |
|
353 | - * @access public |
|
354 | - * @param boolean $event_category_slug |
|
355 | - * @return string |
|
356 | - */ |
|
357 | - public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
358 | - { |
|
359 | - global $wpdb; |
|
360 | - return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : ''; |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * posts_where_sql_for_event_list_month |
|
365 | - * |
|
366 | - * @access public |
|
367 | - * @param boolean $month |
|
368 | - * @return string |
|
369 | - */ |
|
370 | - public static function posts_where_sql_for_event_list_month($month = null) |
|
371 | - { |
|
372 | - $SQL = ''; |
|
373 | - if (! empty($month)) { |
|
374 | - // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
|
375 | - $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start'; |
|
376 | - $SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"'; |
|
377 | - // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
|
378 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end'; |
|
379 | - $SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" '; |
|
380 | - } |
|
381 | - return $SQL; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * posts_orderby |
|
387 | - * |
|
388 | - * @access public |
|
389 | - * @return void |
|
390 | - */ |
|
391 | - public function posts_orderby($SQL, WP_Query $wp_query) |
|
392 | - { |
|
393 | - if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') { |
|
394 | - $SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date')); |
|
395 | - } |
|
396 | - return $SQL; |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * posts_orderby_sql |
|
402 | - * |
|
403 | - * possible parameters: |
|
404 | - * ID |
|
405 | - * start_date |
|
406 | - * end_date |
|
407 | - * event_name |
|
408 | - * category_slug |
|
409 | - * ticket_start |
|
410 | - * ticket_end |
|
411 | - * venue_title |
|
412 | - * city |
|
413 | - * state |
|
414 | - * |
|
415 | - * **IMPORTANT** |
|
416 | - * make sure to also send the $orderby_params array to the posts_join_for_orderby() method |
|
417 | - * or else some of the table references below will result in MySQL errors |
|
418 | - * |
|
419 | - * @access public |
|
420 | - * @param boolean $orderby_params |
|
421 | - * @return string |
|
422 | - */ |
|
423 | - public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
424 | - { |
|
425 | - global $wpdb; |
|
426 | - $SQL = ''; |
|
427 | - $cntr = 1; |
|
428 | - $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params); |
|
429 | - foreach ($orderby_params as $orderby) { |
|
430 | - $glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', '; |
|
431 | - switch ($orderby) { |
|
432 | - case 'id': |
|
433 | - case 'ID': |
|
434 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
435 | - break; |
|
436 | - |
|
437 | - case 'start_date': |
|
438 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort; |
|
439 | - break; |
|
440 | - |
|
441 | - case 'end_date': |
|
442 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
443 | - break; |
|
444 | - |
|
445 | - case 'event_name': |
|
446 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
447 | - break; |
|
448 | - |
|
449 | - case 'category_slug': |
|
450 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
451 | - break; |
|
452 | - |
|
453 | - case 'ticket_start': |
|
454 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
455 | - break; |
|
456 | - |
|
457 | - case 'ticket_end': |
|
458 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
459 | - break; |
|
460 | - |
|
461 | - case 'venue_title': |
|
462 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
463 | - break; |
|
464 | - |
|
465 | - case 'city': |
|
466 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
467 | - break; |
|
468 | - |
|
469 | - case 'state': |
|
470 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
471 | - break; |
|
472 | - } |
|
473 | - $cntr++; |
|
474 | - } |
|
475 | - // echo '<h4>$SQL : ' . $SQL . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
476 | - return $SQL; |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * template_redirect |
|
482 | - * |
|
483 | - * @access public |
|
484 | - * @return void |
|
485 | - */ |
|
486 | - public function template_redirect() |
|
487 | - { |
|
488 | - // add event list filters |
|
489 | - add_action('loop_start', array($this, 'event_list_template_filters')); |
|
490 | - // and pagination |
|
491 | - add_action('loop_start', array($this, 'event_list_pagination')); |
|
492 | - add_action('loop_end', array($this, 'event_list_pagination')); |
|
493 | - // if NOT a custom template |
|
494 | - if ( |
|
495 | - EE_Registry::instance() |
|
496 | - ->load_core('Front_Controller', array(), false, true) |
|
497 | - ->get_selected_template() != 'archive-espresso_events.php' |
|
498 | - ) { |
|
499 | - // don't know if theme uses the_excerpt |
|
500 | - add_filter('the_excerpt', array($this, 'event_details'), 100); |
|
501 | - add_filter('the_excerpt', array($this, 'event_tickets'), 110); |
|
502 | - add_filter('the_excerpt', array($this, 'event_datetimes'), 120); |
|
503 | - add_filter('the_excerpt', array($this, 'event_venues'), 130); |
|
504 | - // or the_content |
|
505 | - add_filter('the_content', array($this, 'event_details'), 100); |
|
506 | - add_filter('the_content', array($this, 'event_tickets'), 110); |
|
507 | - add_filter('the_content', array($this, 'event_datetimes'), 120); |
|
508 | - add_filter('the_content', array($this, 'event_venues'), 130); |
|
509 | - } else { |
|
510 | - remove_all_filters('excerpt_length'); |
|
511 | - add_filter('excerpt_length', array($this, 'excerpt_length'), 10); |
|
512 | - add_filter('excerpt_more', array($this, 'excerpt_more'), 10); |
|
513 | - } |
|
514 | - } |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * event_list_pagination |
|
519 | - * |
|
520 | - * @access public |
|
521 | - * @return void |
|
522 | - */ |
|
523 | - public function event_list_pagination() |
|
524 | - { |
|
525 | - echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>'; |
|
526 | - } |
|
527 | - |
|
528 | - |
|
529 | - /** |
|
530 | - * event_details |
|
531 | - * |
|
532 | - * @access public |
|
533 | - * @param string $content |
|
534 | - * @return void |
|
535 | - */ |
|
536 | - public function event_details($content) |
|
537 | - { |
|
538 | - return EEH_Template::display_template( |
|
539 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-details.php', |
|
540 | - array('the_content' => $content), |
|
541 | - true |
|
542 | - ); |
|
543 | - } |
|
544 | - |
|
545 | - |
|
546 | - /** |
|
547 | - * event_tickets |
|
548 | - * |
|
549 | - * @access public |
|
550 | - * @param string $content |
|
551 | - * @return void |
|
552 | - */ |
|
553 | - public function event_tickets($content) |
|
554 | - { |
|
555 | - return $content |
|
556 | - . EEH_Template::display_template( |
|
557 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-tickets.php', |
|
558 | - array(), |
|
559 | - true |
|
560 | - ); |
|
561 | - } |
|
562 | - |
|
563 | - /** |
|
564 | - * event_datetimes |
|
565 | - * |
|
566 | - * @access public |
|
567 | - * @param string $content |
|
568 | - * @return void |
|
569 | - */ |
|
570 | - public function event_datetimes($content) |
|
571 | - { |
|
572 | - return $content |
|
573 | - . EEH_Template::display_template( |
|
574 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-datetimes.php', |
|
575 | - array(), |
|
576 | - true |
|
577 | - ); |
|
578 | - } |
|
579 | - |
|
580 | - /** |
|
581 | - * event_venues |
|
582 | - * |
|
583 | - * @access public |
|
584 | - * @param string $content |
|
585 | - * @return void |
|
586 | - */ |
|
587 | - public function event_venues($content) |
|
588 | - { |
|
589 | - return $content |
|
590 | - . EEH_Template::display_template( |
|
591 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-venues.php', |
|
592 | - array(), |
|
593 | - true |
|
594 | - ); |
|
595 | - } |
|
596 | - |
|
597 | - |
|
598 | - /** |
|
599 | - * _initial_setup |
|
600 | - * |
|
601 | - * @access public |
|
602 | - * @return void |
|
603 | - */ |
|
604 | - private function _load_assests() |
|
605 | - { |
|
606 | - do_action('AHEE__EED_Events_Archive_Filters__before_load_assests'); |
|
607 | - wp_enqueue_style('espresso_default'); |
|
608 | - wp_enqueue_style('espresso_custom_css'); |
|
609 | - add_filter('FHEE_load_EE_Session', '__return_true'); |
|
610 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
611 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
612 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
613 | - } |
|
614 | - // add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 ); |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * _get_template |
|
620 | - * |
|
621 | - * @access private |
|
622 | - * @return string |
|
623 | - */ |
|
624 | - private function _get_template($which = 'part') |
|
625 | - { |
|
626 | - return EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php'; |
|
627 | - } |
|
628 | - |
|
629 | - |
|
630 | - /** |
|
631 | - * excerpt_length |
|
632 | - * |
|
633 | - * @access public |
|
634 | - * @return void |
|
635 | - */ |
|
636 | - public function excerpt_length($length) |
|
637 | - { |
|
638 | - |
|
639 | - if (self::$_type == 'grid') { |
|
640 | - return 36; |
|
641 | - } |
|
642 | - |
|
643 | - switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) { |
|
644 | - case 'tiny': |
|
645 | - return 12; |
|
646 | - break; |
|
647 | - case 'small': |
|
648 | - return 24; |
|
649 | - break; |
|
650 | - case 'large': |
|
651 | - return 48; |
|
652 | - break; |
|
653 | - case 'medium': |
|
654 | - default: |
|
655 | - return 36; |
|
656 | - } |
|
657 | - } |
|
658 | - |
|
659 | - |
|
660 | - /** |
|
661 | - * excerpt_more |
|
662 | - * |
|
663 | - * @access public |
|
664 | - * @return void |
|
665 | - */ |
|
666 | - public function excerpt_more($more) |
|
667 | - { |
|
668 | - return '…'; |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - |
|
673 | - |
|
674 | - /** |
|
675 | - * wp_enqueue_scripts |
|
676 | - * |
|
677 | - * @access public |
|
678 | - * @return void |
|
679 | - */ |
|
680 | - public function wp_enqueue_scripts() |
|
681 | - { |
|
682 | - // get some style |
|
683 | - if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
684 | - // first check uploads folder |
|
685 | - if ( |
|
686 | - is_readable( |
|
687 | - get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.css' |
|
688 | - ) |
|
689 | - ) { |
|
690 | - wp_register_style( |
|
691 | - 'archive-espresso_events', |
|
692 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme( |
|
693 | - ) . '/archive-espresso_events.css', |
|
694 | - array('dashicons', 'espresso_default') |
|
695 | - ); |
|
696 | - } else { |
|
697 | - wp_register_style( |
|
698 | - 'archive-espresso_events', |
|
699 | - EE_TEMPLATES_URL . EE_Config::get_current_theme() . '/archive-espresso_events.css', |
|
700 | - array('dashicons', 'espresso_default') |
|
701 | - ); |
|
702 | - } |
|
703 | - if ( |
|
704 | - is_readable( |
|
705 | - get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.js' |
|
706 | - ) |
|
707 | - ) { |
|
708 | - wp_register_script( |
|
709 | - 'archive-espresso_events', |
|
710 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme() . '/archive-espresso_events.js', |
|
711 | - array('jquery-masonry'), |
|
712 | - '1.0', |
|
713 | - true |
|
714 | - ); |
|
715 | - } else { |
|
716 | - wp_register_script( |
|
717 | - 'archive-espresso_events', |
|
718 | - EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js', |
|
719 | - array('jquery-masonry'), |
|
720 | - '1.0', |
|
721 | - true |
|
722 | - ); |
|
723 | - } |
|
724 | - wp_enqueue_style('archive-espresso_events'); |
|
725 | - wp_enqueue_script('jquery-masonry'); |
|
726 | - wp_enqueue_script('archive-espresso_events'); |
|
727 | - add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1); |
|
728 | - } |
|
729 | - } |
|
730 | - |
|
731 | - |
|
732 | - /** |
|
733 | - * template_settings_form |
|
734 | - * |
|
735 | - * @access public |
|
736 | - * @static |
|
737 | - * @return void |
|
738 | - */ |
|
739 | - public static function localize_grid_event_lists() |
|
740 | - { |
|
741 | - wp_localize_script( |
|
742 | - 'archive-espresso_events', |
|
743 | - 'espresso_grid_event_lists', |
|
744 | - EED_Events_Archive_Filters::$espresso_grid_event_lists |
|
745 | - ); |
|
746 | - } |
|
747 | - |
|
748 | - |
|
749 | - /** |
|
750 | - * template_settings_form |
|
751 | - * |
|
752 | - * @access public |
|
753 | - * @static |
|
754 | - * @return void |
|
755 | - */ |
|
756 | - public static function template_settings_form() |
|
757 | - { |
|
758 | - $EE = EE_Registry::instance(); |
|
759 | - $EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters) |
|
760 | - ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config(); |
|
761 | - $EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters( |
|
762 | - 'FHEE__Event_List__template_settings_form__event_list_config', |
|
763 | - $EE->CFG->template_settings->EED_Events_Archive_Filters |
|
764 | - ); |
|
765 | - EEH_Template::display_template( |
|
766 | - EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
767 | - $EE->CFG->template_settings->EED_Events_Archive_Filters |
|
768 | - ); |
|
769 | - } |
|
770 | - |
|
771 | - |
|
772 | - /** |
|
773 | - * set_default_settings |
|
774 | - * |
|
775 | - * @access public |
|
776 | - * @static |
|
777 | - * @return void |
|
778 | - */ |
|
779 | - public static function set_default_settings($CFG) |
|
780 | - { |
|
781 | - // EEH_Debug_Tools::printr( $CFG, '$CFG <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
782 | - $CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description) |
|
783 | - ? $CFG->display_description : 1; |
|
784 | - $CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address |
|
785 | - : true; |
|
786 | - $CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details) |
|
787 | - ? $CFG->display_venue_details : true; |
|
788 | - $CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events) |
|
789 | - ? $CFG->display_expired_events : false; |
|
790 | - $CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid'; |
|
791 | - $CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size) |
|
792 | - ? $CFG->event_list_grid_size : 'medium'; |
|
793 | - $CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full']) |
|
794 | - ? $CFG->templates['full'] |
|
795 | - : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php'; |
|
796 | - $CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part']) |
|
797 | - ? $CFG->templates['part'] |
|
798 | - : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-grid-view.php'; |
|
799 | - return $CFG; |
|
800 | - } |
|
801 | - |
|
802 | - |
|
803 | - /** |
|
804 | - * filter_config |
|
805 | - * |
|
806 | - * @access public |
|
807 | - * @return void |
|
808 | - */ |
|
809 | - public function filter_config($CFG) |
|
810 | - { |
|
811 | - return $CFG; |
|
812 | - } |
|
813 | - |
|
814 | - |
|
815 | - /** |
|
816 | - * filter_config |
|
817 | - * |
|
818 | - * @access public |
|
819 | - * @return void |
|
820 | - */ |
|
821 | - public static function update_template_settings($CFG, $REQ) |
|
822 | - { |
|
823 | - // $CFG->template_settings->EED_Events_Archive_Filters = new stdClass(); |
|
824 | - $CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list']) |
|
825 | - ? absint($REQ['display_description_in_event_list']) : 1; |
|
826 | - $CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint( |
|
827 | - $REQ['display_address_in_event_list'] |
|
828 | - ) : true; |
|
829 | - $CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list']) |
|
830 | - ? absint($REQ['display_venue_details_in_event_list']) : true; |
|
831 | - $CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint( |
|
832 | - $REQ['display_expired_events'] |
|
833 | - ) : false; |
|
834 | - $CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field( |
|
835 | - $REQ['default_type'] |
|
836 | - ) : 'grid'; |
|
837 | - $CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size']) |
|
838 | - ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium'; |
|
839 | - $CFG->EED_Events_Archive_Filters->templates = array( |
|
840 | - 'full' => EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php', |
|
841 | - ); |
|
842 | - |
|
843 | - switch ($CFG->EED_Events_Archive_Filters->default_type) { |
|
844 | - case 'dates': |
|
845 | - $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
846 | - . '/archive-espresso_events-dates-view.php'; |
|
847 | - break; |
|
848 | - case 'text': |
|
849 | - $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
850 | - . '/archive-espresso_events-text-view.php'; |
|
851 | - break; |
|
852 | - default: |
|
853 | - $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
854 | - . '/archive-espresso_events-grid-view.php'; |
|
855 | - } |
|
856 | - |
|
857 | - $CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings']) |
|
858 | - && absint($REQ['reset_event_list_settings']) == 1 |
|
859 | - ? new EE_Events_Archive_Config() |
|
860 | - : $CFG->EED_Events_Archive_Filters; |
|
861 | - return $CFG; |
|
862 | - } |
|
863 | - |
|
864 | - |
|
865 | - /** |
|
866 | - * get_template_part |
|
867 | - * |
|
868 | - * @access public |
|
869 | - * @return void |
|
870 | - */ |
|
871 | - public static function get_template_part() |
|
872 | - { |
|
873 | - switch (self::$_type) { |
|
874 | - case 'dates': |
|
875 | - return 'archive-espresso_events-dates-view.php'; |
|
876 | - break; |
|
877 | - case 'text': |
|
878 | - return 'archive-espresso_events-text-view.php'; |
|
879 | - break; |
|
880 | - default: |
|
881 | - return 'archive-espresso_events-grid-view.php'; |
|
882 | - } |
|
883 | - } |
|
884 | - |
|
885 | - |
|
886 | - /** |
|
887 | - * event_list_template_filters |
|
888 | - * |
|
889 | - * @access public |
|
890 | - * @return void |
|
891 | - */ |
|
892 | - public function event_list_template_filters() |
|
893 | - { |
|
894 | - $args = array( |
|
895 | - 'form_url' => get_post_type_archive_link('espresso_events'), |
|
896 | - // add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ), |
|
897 | - 'elf_month' => EED_Events_Archive_Filters::_display_month(), |
|
898 | - 'elf_category' => EED_Events_Archive_Filters::_event_category_slug(), |
|
899 | - 'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(), |
|
900 | - 'elf_type' => self::$_type, |
|
901 | - ); |
|
902 | - EEH_Template::display_template( |
|
903 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-filters.php', |
|
904 | - $args |
|
905 | - ); |
|
906 | - } |
|
907 | - |
|
908 | - |
|
909 | - /** |
|
910 | - * event_list_css |
|
911 | - * |
|
912 | - * @access public |
|
913 | - * @return void |
|
914 | - */ |
|
915 | - public static function event_list_css($extra_class = '') |
|
916 | - { |
|
917 | - $EE = EE_Registry::instance(); |
|
918 | - $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
919 | - $event_list_css[] = 'espresso-event-list-event'; |
|
920 | - if (self::$_type == 'grid') { |
|
921 | - $event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) |
|
922 | - ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium'; |
|
923 | - $event_list_css[] = $event_list_grid_size . '-event-list-grid'; |
|
924 | - } |
|
925 | - $event_list_css = apply_filters( |
|
926 | - 'EED_Events_Archive_Filters__event_list_css__event_list_css_array', |
|
927 | - $event_list_css |
|
928 | - ); |
|
929 | - return implode(' ', $event_list_css); |
|
930 | - } |
|
931 | - |
|
932 | - |
|
933 | - /** |
|
934 | - * event_categories |
|
935 | - * |
|
936 | - * @access public |
|
937 | - * @return void |
|
938 | - */ |
|
939 | - public static function event_categories() |
|
940 | - { |
|
941 | - return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
942 | - } |
|
943 | - |
|
944 | - |
|
945 | - /** |
|
946 | - * display_description |
|
947 | - * |
|
948 | - * @access public |
|
949 | - * @return void |
|
950 | - */ |
|
951 | - public static function display_description($value) |
|
952 | - { |
|
953 | - $EE = EE_Registry::instance(); |
|
954 | - $display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description) |
|
955 | - ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1; |
|
956 | - return $display_description === $value ? true : false; |
|
957 | - } |
|
958 | - |
|
959 | - |
|
960 | - /** |
|
961 | - * display_venue_details |
|
962 | - * |
|
963 | - * @access public |
|
964 | - * @return void |
|
965 | - */ |
|
966 | - public static function display_venue_details() |
|
967 | - { |
|
968 | - $EE = EE_Registry::instance(); |
|
969 | - $display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details) |
|
970 | - ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : true; |
|
971 | - $venue_name = EEH_Venue_View::venue_name(); |
|
972 | - return $display_venue_details && ! empty($venue_name) ? true : false; |
|
973 | - } |
|
974 | - |
|
975 | - |
|
976 | - /** |
|
977 | - * display_address |
|
978 | - * |
|
979 | - * @access public |
|
980 | - * @return void |
|
981 | - */ |
|
982 | - public static function display_address() |
|
983 | - { |
|
984 | - $EE = EE_Registry::instance(); |
|
985 | - $display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address) |
|
986 | - ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : false; |
|
987 | - $venue_name = EEH_Venue_View::venue_name(); |
|
988 | - return $display_address && ! empty($venue_name) ? true : false; |
|
989 | - } |
|
990 | - |
|
991 | - |
|
992 | - /** |
|
993 | - * pagination |
|
994 | - * |
|
995 | - * @access public |
|
996 | - * @return void |
|
997 | - */ |
|
998 | - public static function pagination() |
|
999 | - { |
|
1000 | - global $wp_query; |
|
1001 | - $big = 999999999; // need an unlikely integer |
|
1002 | - $pagination = paginate_links( |
|
1003 | - array( |
|
1004 | - 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
1005 | - 'format' => '?paged=%#%', |
|
1006 | - 'current' => max(1, get_query_var('paged')), |
|
1007 | - 'total' => $wp_query->max_num_pages, |
|
1008 | - 'show_all' => true, |
|
1009 | - 'end_size' => 10, |
|
1010 | - 'mid_size' => 6, |
|
1011 | - 'prev_next' => true, |
|
1012 | - 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
1013 | - 'next_text' => __('NEXT ›', 'event_espresso'), |
|
1014 | - 'type' => 'plain', |
|
1015 | - 'add_args' => false, |
|
1016 | - 'add_fragment' => '', |
|
1017 | - ) |
|
1018 | - ); |
|
1019 | - return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
1020 | - } |
|
1021 | - |
|
1022 | - |
|
1023 | - /** |
|
1024 | - * event_list_title |
|
1025 | - * |
|
1026 | - * @access public |
|
1027 | - * @return void |
|
1028 | - */ |
|
1029 | - public static function event_list_title() |
|
1030 | - { |
|
1031 | - return apply_filters( |
|
1032 | - 'EED_Events_Archive_Filters__event_list_title__event_list_title', |
|
1033 | - __('Upcoming Events', 'event_espresso') |
|
1034 | - ); |
|
1035 | - } |
|
16 | + /** |
|
17 | + * @return EED_Events_Archive_Filters |
|
18 | + */ |
|
19 | + public static function instance() |
|
20 | + { |
|
21 | + return parent::get_instance(__CLASS__); |
|
22 | + } |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Start Date |
|
27 | + * |
|
28 | + * @var $_elf_month |
|
29 | + * @access protected |
|
30 | + */ |
|
31 | + protected $_elf_month = null; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Category |
|
36 | + * |
|
37 | + * @var $_elf_category |
|
38 | + * @access protected |
|
39 | + */ |
|
40 | + protected $_elf_category = null; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * whether to display expired events in the event list |
|
45 | + * |
|
46 | + * @var $_show_expired |
|
47 | + * @access protected |
|
48 | + */ |
|
49 | + protected $_show_expired = null; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * whether to display the event list as a grid or list |
|
54 | + * |
|
55 | + * @var $_type |
|
56 | + * @access protected |
|
57 | + */ |
|
58 | + protected static $_type = null; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * array of existing event list views |
|
63 | + * |
|
64 | + * @var $_types |
|
65 | + * @access protected |
|
66 | + */ |
|
67 | + protected static $_types = array('grid', 'text', 'dates'); |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
73 | + * |
|
74 | + * @access public |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + public static function set_hooks() |
|
78 | + { |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
83 | + * |
|
84 | + * @access public |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public static function set_hooks_admin() |
|
88 | + { |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * set_definitions |
|
94 | + * |
|
95 | + * @access public |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public static function set_definitions() |
|
99 | + { |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * run - initial module setup |
|
105 | + * |
|
106 | + * @access public |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function run($WP) |
|
110 | + { |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * event_list |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @return void |
|
119 | + */ |
|
120 | + public function event_list() |
|
121 | + { |
|
122 | + // load other required components |
|
123 | + $this->_load_assests(); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * _filter_query_parts |
|
129 | + * |
|
130 | + * @access public |
|
131 | + * @return void |
|
132 | + */ |
|
133 | + private function _filter_query_parts() |
|
134 | + { |
|
135 | + // build event list query |
|
136 | + add_filter('posts_join', array($this, 'posts_join'), 1, 2); |
|
137 | + add_filter('posts_where', array($this, 'posts_where'), 1, 2); |
|
138 | + add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * _type - the type of event list : grid, text, dates |
|
143 | + * |
|
144 | + * @access public |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public static function set_type() |
|
148 | + { |
|
149 | + do_action('AHEE__EED_Events_Archive_Filters__before_set_type'); |
|
150 | + EED_Events_Archive_Filters::$_types = apply_filters( |
|
151 | + 'EED_Events_Archive_Filters__set_type__types', |
|
152 | + EED_Events_Archive_Filters::$_types |
|
153 | + ); |
|
154 | + $view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance( |
|
155 | + )->CFG->EED_Events_Archive_Filters['default_type'] : 'grid'; |
|
156 | + $elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field( |
|
157 | + EE_Registry::instance()->REQ->get('elf_type') |
|
158 | + ) : ''; |
|
159 | + $view = ! empty($elf_type) ? $elf_type : $view; |
|
160 | + $view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view); |
|
161 | + if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) { |
|
162 | + self::$_type = $view; |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * _show_expired |
|
168 | + * |
|
169 | + * @access private |
|
170 | + * @param boolean $req_only if TRUE, then ignore defaults and only return $_POST value |
|
171 | + * @return boolean |
|
172 | + */ |
|
173 | + private static function _show_expired($req_only = false) |
|
174 | + { |
|
175 | + // get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings |
|
176 | + $show_expired = ! $req_only && isset( |
|
177 | + EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] |
|
178 | + ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : false; |
|
179 | + // override default expired option if set via filter |
|
180 | + $show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint( |
|
181 | + EE_Registry::instance()->REQ->get('elf_expired_chk') |
|
182 | + ) : $show_expired; |
|
183 | + return $show_expired ? true : false; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * _event_category_slug |
|
188 | + * |
|
189 | + * @access private |
|
190 | + * @return string |
|
191 | + */ |
|
192 | + private static function _event_category_slug() |
|
193 | + { |
|
194 | + return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field( |
|
195 | + EE_Registry::instance()->REQ->get('elf_category_dd') |
|
196 | + ) : ''; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * _display_month - what month should the event list display events for? |
|
201 | + * |
|
202 | + * @access private |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + private static function _display_month() |
|
206 | + { |
|
207 | + return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field( |
|
208 | + EE_Registry::instance()->REQ->get('elf_month_dd') |
|
209 | + ) : ''; |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * get_post_data |
|
215 | + * |
|
216 | + * @access public |
|
217 | + * @return void |
|
218 | + */ |
|
219 | + public function get_post_data() |
|
220 | + { |
|
221 | + $this->_elf_month = EED_Events_Archive_Filters::_display_month(); |
|
222 | + $this->_elf_category = EED_Events_Archive_Filters::_event_category_slug(); |
|
223 | + $this->_show_expired = EED_Events_Archive_Filters::_show_expired(true); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * posts_join |
|
229 | + * |
|
230 | + * @access public |
|
231 | + * @return void |
|
232 | + */ |
|
233 | + public function posts_join($SQL, WP_Query $wp_query) |
|
234 | + { |
|
235 | + if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') { |
|
236 | + // Category |
|
237 | + $SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms( |
|
238 | + EED_Events_Archive_Filters::_event_category_slug() |
|
239 | + ); |
|
240 | + } |
|
241 | + return $SQL; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * posts_join_sql_for_terms |
|
247 | + * |
|
248 | + * @access public |
|
249 | + * @param mixed boolean|string $join_terms pass TRUE or term string, doesn't really matter since this value |
|
250 | + * doesn't really get used for anything yet |
|
251 | + * @return string |
|
252 | + */ |
|
253 | + public static function posts_join_sql_for_terms($join_terms = null) |
|
254 | + { |
|
255 | + $SQL = ''; |
|
256 | + if (! empty($join_terms)) { |
|
257 | + global $wpdb; |
|
258 | + $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
|
259 | + $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
|
260 | + $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) "; |
|
261 | + } |
|
262 | + return $SQL; |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * usage: $SQL .= EED_Events_Archive_Filters::posts_join_for_orderby( $orderby_params ); |
|
268 | + * |
|
269 | + * @param array $orderby_params |
|
270 | + * @return string |
|
271 | + * @throws EE_Error |
|
272 | + * @throws ReflectionException |
|
273 | + */ |
|
274 | + public static function posts_join_for_orderby(array $orderby_params = array()): string |
|
275 | + { |
|
276 | + global $wpdb; |
|
277 | + $SQL = ''; |
|
278 | + $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params); |
|
279 | + foreach ($orderby_params as $orderby) { |
|
280 | + switch ($orderby) { |
|
281 | + case 'ticket_start': |
|
282 | + case 'ticket_end': |
|
283 | + $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON (' |
|
284 | + . EEM_Datetime::instance()->table() . '.DTT_ID = ' |
|
285 | + . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )'; |
|
286 | + $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' |
|
287 | + . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = ' |
|
288 | + . EEM_Ticket::instance()->table() . '.TKT_ID )'; |
|
289 | + break; |
|
290 | + |
|
291 | + case 'city': |
|
292 | + case 'state': |
|
293 | + case 'venue_title': |
|
294 | + // grab wp_posts (event), venue, and event_meta table names |
|
295 | + $wp_posts = $wpdb->posts; |
|
296 | + $venue = EEM_Venue::instance()->table(); |
|
297 | + $event_meta = EEM_Event::instance()->second_table(); |
|
298 | + $SQL .= " LEFT JOIN $event_meta ON ( $wp_posts.ID = $event_meta.EVT_ID )"; |
|
299 | + $SQL .= " LEFT JOIN $venue ON ( $event_meta.VNU_ID = $venue.VNU_ID )"; |
|
300 | + break; |
|
301 | + } |
|
302 | + } |
|
303 | + return $SQL; |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * posts_where |
|
309 | + * |
|
310 | + * @access public |
|
311 | + * @return void |
|
312 | + */ |
|
313 | + public function posts_where($SQL, WP_Query $wp_query) |
|
314 | + { |
|
315 | + if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') { |
|
316 | + // Show Expired ? |
|
317 | + $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired( |
|
318 | + EED_Events_Archive_Filters::_show_expired() |
|
319 | + ); |
|
320 | + // Category |
|
321 | + // $elf_category = EED_Events_Archive_Filters::_event_category_slug(); |
|
322 | + $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug( |
|
323 | + EED_Events_Archive_Filters::_event_category_slug() |
|
324 | + ); |
|
325 | + // Start Date |
|
326 | + // $elf_month = EED_Events_Archive_Filters::_display_month(); |
|
327 | + $SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month( |
|
328 | + EED_Events_Archive_Filters::_display_month() |
|
329 | + ); |
|
330 | + } |
|
331 | + return $SQL; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * posts_where_sql_for_show_expired |
|
337 | + * |
|
338 | + * @access public |
|
339 | + * @param boolean $show_expired if TRUE, then displayed past events |
|
340 | + * @return string |
|
341 | + */ |
|
342 | + public static function posts_where_sql_for_show_expired($show_expired = false) |
|
343 | + { |
|
344 | + return ! $show_expired |
|
345 | + ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" ' |
|
346 | + : ''; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * posts_where_sql_for_event_category_slug |
|
352 | + * |
|
353 | + * @access public |
|
354 | + * @param boolean $event_category_slug |
|
355 | + * @return string |
|
356 | + */ |
|
357 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
358 | + { |
|
359 | + global $wpdb; |
|
360 | + return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : ''; |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * posts_where_sql_for_event_list_month |
|
365 | + * |
|
366 | + * @access public |
|
367 | + * @param boolean $month |
|
368 | + * @return string |
|
369 | + */ |
|
370 | + public static function posts_where_sql_for_event_list_month($month = null) |
|
371 | + { |
|
372 | + $SQL = ''; |
|
373 | + if (! empty($month)) { |
|
374 | + // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
|
375 | + $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start'; |
|
376 | + $SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"'; |
|
377 | + // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
|
378 | + $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end'; |
|
379 | + $SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" '; |
|
380 | + } |
|
381 | + return $SQL; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * posts_orderby |
|
387 | + * |
|
388 | + * @access public |
|
389 | + * @return void |
|
390 | + */ |
|
391 | + public function posts_orderby($SQL, WP_Query $wp_query) |
|
392 | + { |
|
393 | + if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') { |
|
394 | + $SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date')); |
|
395 | + } |
|
396 | + return $SQL; |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * posts_orderby_sql |
|
402 | + * |
|
403 | + * possible parameters: |
|
404 | + * ID |
|
405 | + * start_date |
|
406 | + * end_date |
|
407 | + * event_name |
|
408 | + * category_slug |
|
409 | + * ticket_start |
|
410 | + * ticket_end |
|
411 | + * venue_title |
|
412 | + * city |
|
413 | + * state |
|
414 | + * |
|
415 | + * **IMPORTANT** |
|
416 | + * make sure to also send the $orderby_params array to the posts_join_for_orderby() method |
|
417 | + * or else some of the table references below will result in MySQL errors |
|
418 | + * |
|
419 | + * @access public |
|
420 | + * @param boolean $orderby_params |
|
421 | + * @return string |
|
422 | + */ |
|
423 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
424 | + { |
|
425 | + global $wpdb; |
|
426 | + $SQL = ''; |
|
427 | + $cntr = 1; |
|
428 | + $orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params); |
|
429 | + foreach ($orderby_params as $orderby) { |
|
430 | + $glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', '; |
|
431 | + switch ($orderby) { |
|
432 | + case 'id': |
|
433 | + case 'ID': |
|
434 | + $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
435 | + break; |
|
436 | + |
|
437 | + case 'start_date': |
|
438 | + $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort; |
|
439 | + break; |
|
440 | + |
|
441 | + case 'end_date': |
|
442 | + $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
443 | + break; |
|
444 | + |
|
445 | + case 'event_name': |
|
446 | + $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
447 | + break; |
|
448 | + |
|
449 | + case 'category_slug': |
|
450 | + $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
451 | + break; |
|
452 | + |
|
453 | + case 'ticket_start': |
|
454 | + $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
455 | + break; |
|
456 | + |
|
457 | + case 'ticket_end': |
|
458 | + $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
459 | + break; |
|
460 | + |
|
461 | + case 'venue_title': |
|
462 | + $SQL .= $glue . 'venue_title ' . $sort; |
|
463 | + break; |
|
464 | + |
|
465 | + case 'city': |
|
466 | + $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
467 | + break; |
|
468 | + |
|
469 | + case 'state': |
|
470 | + $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
471 | + break; |
|
472 | + } |
|
473 | + $cntr++; |
|
474 | + } |
|
475 | + // echo '<h4>$SQL : ' . $SQL . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
476 | + return $SQL; |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * template_redirect |
|
482 | + * |
|
483 | + * @access public |
|
484 | + * @return void |
|
485 | + */ |
|
486 | + public function template_redirect() |
|
487 | + { |
|
488 | + // add event list filters |
|
489 | + add_action('loop_start', array($this, 'event_list_template_filters')); |
|
490 | + // and pagination |
|
491 | + add_action('loop_start', array($this, 'event_list_pagination')); |
|
492 | + add_action('loop_end', array($this, 'event_list_pagination')); |
|
493 | + // if NOT a custom template |
|
494 | + if ( |
|
495 | + EE_Registry::instance() |
|
496 | + ->load_core('Front_Controller', array(), false, true) |
|
497 | + ->get_selected_template() != 'archive-espresso_events.php' |
|
498 | + ) { |
|
499 | + // don't know if theme uses the_excerpt |
|
500 | + add_filter('the_excerpt', array($this, 'event_details'), 100); |
|
501 | + add_filter('the_excerpt', array($this, 'event_tickets'), 110); |
|
502 | + add_filter('the_excerpt', array($this, 'event_datetimes'), 120); |
|
503 | + add_filter('the_excerpt', array($this, 'event_venues'), 130); |
|
504 | + // or the_content |
|
505 | + add_filter('the_content', array($this, 'event_details'), 100); |
|
506 | + add_filter('the_content', array($this, 'event_tickets'), 110); |
|
507 | + add_filter('the_content', array($this, 'event_datetimes'), 120); |
|
508 | + add_filter('the_content', array($this, 'event_venues'), 130); |
|
509 | + } else { |
|
510 | + remove_all_filters('excerpt_length'); |
|
511 | + add_filter('excerpt_length', array($this, 'excerpt_length'), 10); |
|
512 | + add_filter('excerpt_more', array($this, 'excerpt_more'), 10); |
|
513 | + } |
|
514 | + } |
|
515 | + |
|
516 | + |
|
517 | + /** |
|
518 | + * event_list_pagination |
|
519 | + * |
|
520 | + * @access public |
|
521 | + * @return void |
|
522 | + */ |
|
523 | + public function event_list_pagination() |
|
524 | + { |
|
525 | + echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>'; |
|
526 | + } |
|
527 | + |
|
528 | + |
|
529 | + /** |
|
530 | + * event_details |
|
531 | + * |
|
532 | + * @access public |
|
533 | + * @param string $content |
|
534 | + * @return void |
|
535 | + */ |
|
536 | + public function event_details($content) |
|
537 | + { |
|
538 | + return EEH_Template::display_template( |
|
539 | + EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-details.php', |
|
540 | + array('the_content' => $content), |
|
541 | + true |
|
542 | + ); |
|
543 | + } |
|
544 | + |
|
545 | + |
|
546 | + /** |
|
547 | + * event_tickets |
|
548 | + * |
|
549 | + * @access public |
|
550 | + * @param string $content |
|
551 | + * @return void |
|
552 | + */ |
|
553 | + public function event_tickets($content) |
|
554 | + { |
|
555 | + return $content |
|
556 | + . EEH_Template::display_template( |
|
557 | + EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-tickets.php', |
|
558 | + array(), |
|
559 | + true |
|
560 | + ); |
|
561 | + } |
|
562 | + |
|
563 | + /** |
|
564 | + * event_datetimes |
|
565 | + * |
|
566 | + * @access public |
|
567 | + * @param string $content |
|
568 | + * @return void |
|
569 | + */ |
|
570 | + public function event_datetimes($content) |
|
571 | + { |
|
572 | + return $content |
|
573 | + . EEH_Template::display_template( |
|
574 | + EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-datetimes.php', |
|
575 | + array(), |
|
576 | + true |
|
577 | + ); |
|
578 | + } |
|
579 | + |
|
580 | + /** |
|
581 | + * event_venues |
|
582 | + * |
|
583 | + * @access public |
|
584 | + * @param string $content |
|
585 | + * @return void |
|
586 | + */ |
|
587 | + public function event_venues($content) |
|
588 | + { |
|
589 | + return $content |
|
590 | + . EEH_Template::display_template( |
|
591 | + EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-venues.php', |
|
592 | + array(), |
|
593 | + true |
|
594 | + ); |
|
595 | + } |
|
596 | + |
|
597 | + |
|
598 | + /** |
|
599 | + * _initial_setup |
|
600 | + * |
|
601 | + * @access public |
|
602 | + * @return void |
|
603 | + */ |
|
604 | + private function _load_assests() |
|
605 | + { |
|
606 | + do_action('AHEE__EED_Events_Archive_Filters__before_load_assests'); |
|
607 | + wp_enqueue_style('espresso_default'); |
|
608 | + wp_enqueue_style('espresso_custom_css'); |
|
609 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
610 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
611 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
612 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
613 | + } |
|
614 | + // add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 ); |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * _get_template |
|
620 | + * |
|
621 | + * @access private |
|
622 | + * @return string |
|
623 | + */ |
|
624 | + private function _get_template($which = 'part') |
|
625 | + { |
|
626 | + return EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php'; |
|
627 | + } |
|
628 | + |
|
629 | + |
|
630 | + /** |
|
631 | + * excerpt_length |
|
632 | + * |
|
633 | + * @access public |
|
634 | + * @return void |
|
635 | + */ |
|
636 | + public function excerpt_length($length) |
|
637 | + { |
|
638 | + |
|
639 | + if (self::$_type == 'grid') { |
|
640 | + return 36; |
|
641 | + } |
|
642 | + |
|
643 | + switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) { |
|
644 | + case 'tiny': |
|
645 | + return 12; |
|
646 | + break; |
|
647 | + case 'small': |
|
648 | + return 24; |
|
649 | + break; |
|
650 | + case 'large': |
|
651 | + return 48; |
|
652 | + break; |
|
653 | + case 'medium': |
|
654 | + default: |
|
655 | + return 36; |
|
656 | + } |
|
657 | + } |
|
658 | + |
|
659 | + |
|
660 | + /** |
|
661 | + * excerpt_more |
|
662 | + * |
|
663 | + * @access public |
|
664 | + * @return void |
|
665 | + */ |
|
666 | + public function excerpt_more($more) |
|
667 | + { |
|
668 | + return '…'; |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + |
|
673 | + |
|
674 | + /** |
|
675 | + * wp_enqueue_scripts |
|
676 | + * |
|
677 | + * @access public |
|
678 | + * @return void |
|
679 | + */ |
|
680 | + public function wp_enqueue_scripts() |
|
681 | + { |
|
682 | + // get some style |
|
683 | + if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
684 | + // first check uploads folder |
|
685 | + if ( |
|
686 | + is_readable( |
|
687 | + get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.css' |
|
688 | + ) |
|
689 | + ) { |
|
690 | + wp_register_style( |
|
691 | + 'archive-espresso_events', |
|
692 | + get_stylesheet_directory_uri() . EE_Config::get_current_theme( |
|
693 | + ) . '/archive-espresso_events.css', |
|
694 | + array('dashicons', 'espresso_default') |
|
695 | + ); |
|
696 | + } else { |
|
697 | + wp_register_style( |
|
698 | + 'archive-espresso_events', |
|
699 | + EE_TEMPLATES_URL . EE_Config::get_current_theme() . '/archive-espresso_events.css', |
|
700 | + array('dashicons', 'espresso_default') |
|
701 | + ); |
|
702 | + } |
|
703 | + if ( |
|
704 | + is_readable( |
|
705 | + get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.js' |
|
706 | + ) |
|
707 | + ) { |
|
708 | + wp_register_script( |
|
709 | + 'archive-espresso_events', |
|
710 | + get_stylesheet_directory_uri() . EE_Config::get_current_theme() . '/archive-espresso_events.js', |
|
711 | + array('jquery-masonry'), |
|
712 | + '1.0', |
|
713 | + true |
|
714 | + ); |
|
715 | + } else { |
|
716 | + wp_register_script( |
|
717 | + 'archive-espresso_events', |
|
718 | + EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js', |
|
719 | + array('jquery-masonry'), |
|
720 | + '1.0', |
|
721 | + true |
|
722 | + ); |
|
723 | + } |
|
724 | + wp_enqueue_style('archive-espresso_events'); |
|
725 | + wp_enqueue_script('jquery-masonry'); |
|
726 | + wp_enqueue_script('archive-espresso_events'); |
|
727 | + add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1); |
|
728 | + } |
|
729 | + } |
|
730 | + |
|
731 | + |
|
732 | + /** |
|
733 | + * template_settings_form |
|
734 | + * |
|
735 | + * @access public |
|
736 | + * @static |
|
737 | + * @return void |
|
738 | + */ |
|
739 | + public static function localize_grid_event_lists() |
|
740 | + { |
|
741 | + wp_localize_script( |
|
742 | + 'archive-espresso_events', |
|
743 | + 'espresso_grid_event_lists', |
|
744 | + EED_Events_Archive_Filters::$espresso_grid_event_lists |
|
745 | + ); |
|
746 | + } |
|
747 | + |
|
748 | + |
|
749 | + /** |
|
750 | + * template_settings_form |
|
751 | + * |
|
752 | + * @access public |
|
753 | + * @static |
|
754 | + * @return void |
|
755 | + */ |
|
756 | + public static function template_settings_form() |
|
757 | + { |
|
758 | + $EE = EE_Registry::instance(); |
|
759 | + $EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters) |
|
760 | + ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config(); |
|
761 | + $EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters( |
|
762 | + 'FHEE__Event_List__template_settings_form__event_list_config', |
|
763 | + $EE->CFG->template_settings->EED_Events_Archive_Filters |
|
764 | + ); |
|
765 | + EEH_Template::display_template( |
|
766 | + EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
767 | + $EE->CFG->template_settings->EED_Events_Archive_Filters |
|
768 | + ); |
|
769 | + } |
|
770 | + |
|
771 | + |
|
772 | + /** |
|
773 | + * set_default_settings |
|
774 | + * |
|
775 | + * @access public |
|
776 | + * @static |
|
777 | + * @return void |
|
778 | + */ |
|
779 | + public static function set_default_settings($CFG) |
|
780 | + { |
|
781 | + // EEH_Debug_Tools::printr( $CFG, '$CFG <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
782 | + $CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description) |
|
783 | + ? $CFG->display_description : 1; |
|
784 | + $CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address |
|
785 | + : true; |
|
786 | + $CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details) |
|
787 | + ? $CFG->display_venue_details : true; |
|
788 | + $CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events) |
|
789 | + ? $CFG->display_expired_events : false; |
|
790 | + $CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid'; |
|
791 | + $CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size) |
|
792 | + ? $CFG->event_list_grid_size : 'medium'; |
|
793 | + $CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full']) |
|
794 | + ? $CFG->templates['full'] |
|
795 | + : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php'; |
|
796 | + $CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part']) |
|
797 | + ? $CFG->templates['part'] |
|
798 | + : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-grid-view.php'; |
|
799 | + return $CFG; |
|
800 | + } |
|
801 | + |
|
802 | + |
|
803 | + /** |
|
804 | + * filter_config |
|
805 | + * |
|
806 | + * @access public |
|
807 | + * @return void |
|
808 | + */ |
|
809 | + public function filter_config($CFG) |
|
810 | + { |
|
811 | + return $CFG; |
|
812 | + } |
|
813 | + |
|
814 | + |
|
815 | + /** |
|
816 | + * filter_config |
|
817 | + * |
|
818 | + * @access public |
|
819 | + * @return void |
|
820 | + */ |
|
821 | + public static function update_template_settings($CFG, $REQ) |
|
822 | + { |
|
823 | + // $CFG->template_settings->EED_Events_Archive_Filters = new stdClass(); |
|
824 | + $CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list']) |
|
825 | + ? absint($REQ['display_description_in_event_list']) : 1; |
|
826 | + $CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint( |
|
827 | + $REQ['display_address_in_event_list'] |
|
828 | + ) : true; |
|
829 | + $CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list']) |
|
830 | + ? absint($REQ['display_venue_details_in_event_list']) : true; |
|
831 | + $CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint( |
|
832 | + $REQ['display_expired_events'] |
|
833 | + ) : false; |
|
834 | + $CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field( |
|
835 | + $REQ['default_type'] |
|
836 | + ) : 'grid'; |
|
837 | + $CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size']) |
|
838 | + ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium'; |
|
839 | + $CFG->EED_Events_Archive_Filters->templates = array( |
|
840 | + 'full' => EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php', |
|
841 | + ); |
|
842 | + |
|
843 | + switch ($CFG->EED_Events_Archive_Filters->default_type) { |
|
844 | + case 'dates': |
|
845 | + $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
846 | + . '/archive-espresso_events-dates-view.php'; |
|
847 | + break; |
|
848 | + case 'text': |
|
849 | + $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
850 | + . '/archive-espresso_events-text-view.php'; |
|
851 | + break; |
|
852 | + default: |
|
853 | + $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
854 | + . '/archive-espresso_events-grid-view.php'; |
|
855 | + } |
|
856 | + |
|
857 | + $CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings']) |
|
858 | + && absint($REQ['reset_event_list_settings']) == 1 |
|
859 | + ? new EE_Events_Archive_Config() |
|
860 | + : $CFG->EED_Events_Archive_Filters; |
|
861 | + return $CFG; |
|
862 | + } |
|
863 | + |
|
864 | + |
|
865 | + /** |
|
866 | + * get_template_part |
|
867 | + * |
|
868 | + * @access public |
|
869 | + * @return void |
|
870 | + */ |
|
871 | + public static function get_template_part() |
|
872 | + { |
|
873 | + switch (self::$_type) { |
|
874 | + case 'dates': |
|
875 | + return 'archive-espresso_events-dates-view.php'; |
|
876 | + break; |
|
877 | + case 'text': |
|
878 | + return 'archive-espresso_events-text-view.php'; |
|
879 | + break; |
|
880 | + default: |
|
881 | + return 'archive-espresso_events-grid-view.php'; |
|
882 | + } |
|
883 | + } |
|
884 | + |
|
885 | + |
|
886 | + /** |
|
887 | + * event_list_template_filters |
|
888 | + * |
|
889 | + * @access public |
|
890 | + * @return void |
|
891 | + */ |
|
892 | + public function event_list_template_filters() |
|
893 | + { |
|
894 | + $args = array( |
|
895 | + 'form_url' => get_post_type_archive_link('espresso_events'), |
|
896 | + // add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ), |
|
897 | + 'elf_month' => EED_Events_Archive_Filters::_display_month(), |
|
898 | + 'elf_category' => EED_Events_Archive_Filters::_event_category_slug(), |
|
899 | + 'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(), |
|
900 | + 'elf_type' => self::$_type, |
|
901 | + ); |
|
902 | + EEH_Template::display_template( |
|
903 | + EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-filters.php', |
|
904 | + $args |
|
905 | + ); |
|
906 | + } |
|
907 | + |
|
908 | + |
|
909 | + /** |
|
910 | + * event_list_css |
|
911 | + * |
|
912 | + * @access public |
|
913 | + * @return void |
|
914 | + */ |
|
915 | + public static function event_list_css($extra_class = '') |
|
916 | + { |
|
917 | + $EE = EE_Registry::instance(); |
|
918 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
919 | + $event_list_css[] = 'espresso-event-list-event'; |
|
920 | + if (self::$_type == 'grid') { |
|
921 | + $event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) |
|
922 | + ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium'; |
|
923 | + $event_list_css[] = $event_list_grid_size . '-event-list-grid'; |
|
924 | + } |
|
925 | + $event_list_css = apply_filters( |
|
926 | + 'EED_Events_Archive_Filters__event_list_css__event_list_css_array', |
|
927 | + $event_list_css |
|
928 | + ); |
|
929 | + return implode(' ', $event_list_css); |
|
930 | + } |
|
931 | + |
|
932 | + |
|
933 | + /** |
|
934 | + * event_categories |
|
935 | + * |
|
936 | + * @access public |
|
937 | + * @return void |
|
938 | + */ |
|
939 | + public static function event_categories() |
|
940 | + { |
|
941 | + return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
942 | + } |
|
943 | + |
|
944 | + |
|
945 | + /** |
|
946 | + * display_description |
|
947 | + * |
|
948 | + * @access public |
|
949 | + * @return void |
|
950 | + */ |
|
951 | + public static function display_description($value) |
|
952 | + { |
|
953 | + $EE = EE_Registry::instance(); |
|
954 | + $display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description) |
|
955 | + ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1; |
|
956 | + return $display_description === $value ? true : false; |
|
957 | + } |
|
958 | + |
|
959 | + |
|
960 | + /** |
|
961 | + * display_venue_details |
|
962 | + * |
|
963 | + * @access public |
|
964 | + * @return void |
|
965 | + */ |
|
966 | + public static function display_venue_details() |
|
967 | + { |
|
968 | + $EE = EE_Registry::instance(); |
|
969 | + $display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details) |
|
970 | + ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : true; |
|
971 | + $venue_name = EEH_Venue_View::venue_name(); |
|
972 | + return $display_venue_details && ! empty($venue_name) ? true : false; |
|
973 | + } |
|
974 | + |
|
975 | + |
|
976 | + /** |
|
977 | + * display_address |
|
978 | + * |
|
979 | + * @access public |
|
980 | + * @return void |
|
981 | + */ |
|
982 | + public static function display_address() |
|
983 | + { |
|
984 | + $EE = EE_Registry::instance(); |
|
985 | + $display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address) |
|
986 | + ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : false; |
|
987 | + $venue_name = EEH_Venue_View::venue_name(); |
|
988 | + return $display_address && ! empty($venue_name) ? true : false; |
|
989 | + } |
|
990 | + |
|
991 | + |
|
992 | + /** |
|
993 | + * pagination |
|
994 | + * |
|
995 | + * @access public |
|
996 | + * @return void |
|
997 | + */ |
|
998 | + public static function pagination() |
|
999 | + { |
|
1000 | + global $wp_query; |
|
1001 | + $big = 999999999; // need an unlikely integer |
|
1002 | + $pagination = paginate_links( |
|
1003 | + array( |
|
1004 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
1005 | + 'format' => '?paged=%#%', |
|
1006 | + 'current' => max(1, get_query_var('paged')), |
|
1007 | + 'total' => $wp_query->max_num_pages, |
|
1008 | + 'show_all' => true, |
|
1009 | + 'end_size' => 10, |
|
1010 | + 'mid_size' => 6, |
|
1011 | + 'prev_next' => true, |
|
1012 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
1013 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
1014 | + 'type' => 'plain', |
|
1015 | + 'add_args' => false, |
|
1016 | + 'add_fragment' => '', |
|
1017 | + ) |
|
1018 | + ); |
|
1019 | + return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
1020 | + } |
|
1021 | + |
|
1022 | + |
|
1023 | + /** |
|
1024 | + * event_list_title |
|
1025 | + * |
|
1026 | + * @access public |
|
1027 | + * @return void |
|
1028 | + */ |
|
1029 | + public static function event_list_title() |
|
1030 | + { |
|
1031 | + return apply_filters( |
|
1032 | + 'EED_Events_Archive_Filters__event_list_title__event_list_title', |
|
1033 | + __('Upcoming Events', 'event_espresso') |
|
1034 | + ); |
|
1035 | + } |
|
1036 | 1036 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | ) : ''; |
159 | 159 | $view = ! empty($elf_type) ? $elf_type : $view; |
160 | 160 | $view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view); |
161 | - if (! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) { |
|
161 | + if ( ! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) { |
|
162 | 162 | self::$_type = $view; |
163 | 163 | } |
164 | 164 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | public static function posts_join_sql_for_terms($join_terms = null) |
254 | 254 | { |
255 | 255 | $SQL = ''; |
256 | - if (! empty($join_terms)) { |
|
256 | + if ( ! empty($join_terms)) { |
|
257 | 257 | global $wpdb; |
258 | 258 | $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
259 | 259 | $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | switch ($orderby) { |
281 | 281 | case 'ticket_start': |
282 | 282 | case 'ticket_end': |
283 | - $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON (' |
|
284 | - . EEM_Datetime::instance()->table() . '.DTT_ID = ' |
|
285 | - . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )'; |
|
286 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' |
|
287 | - . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = ' |
|
288 | - . EEM_Ticket::instance()->table() . '.TKT_ID )'; |
|
283 | + $SQL .= ' LEFT JOIN '.EEM_Datetime_Ticket::instance()->table().' ON (' |
|
284 | + . EEM_Datetime::instance()->table().'.DTT_ID = ' |
|
285 | + . EEM_Datetime_Ticket::instance()->table().'.DTT_ID )'; |
|
286 | + $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON (' |
|
287 | + . EEM_Datetime_Ticket::instance()->table().'.TKT_ID = ' |
|
288 | + . EEM_Ticket::instance()->table().'.TKT_ID )'; |
|
289 | 289 | break; |
290 | 290 | |
291 | 291 | case 'city': |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | public static function posts_where_sql_for_show_expired($show_expired = false) |
343 | 343 | { |
344 | 344 | return ! $show_expired |
345 | - ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" ' |
|
345 | + ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.date('Y-m-d H:s:i').'" ' |
|
346 | 346 | : ''; |
347 | 347 | } |
348 | 348 | |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
358 | 358 | { |
359 | 359 | global $wpdb; |
360 | - return ! empty($event_category_slug) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : ''; |
|
360 | + return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : ''; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | public static function posts_where_sql_for_event_list_month($month = null) |
371 | 371 | { |
372 | 372 | $SQL = ''; |
373 | - if (! empty($month)) { |
|
373 | + if ( ! empty($month)) { |
|
374 | 374 | // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
375 | - $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start'; |
|
376 | - $SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"'; |
|
375 | + $SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start'; |
|
376 | + $SQL .= ' <= "'.date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)).'"'; |
|
377 | 377 | // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
378 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end'; |
|
379 | - $SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" '; |
|
378 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end'; |
|
379 | + $SQL .= ' >= "'.date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)).'" '; |
|
380 | 380 | } |
381 | 381 | return $SQL; |
382 | 382 | } |
@@ -431,43 +431,43 @@ discard block |
||
431 | 431 | switch ($orderby) { |
432 | 432 | case 'id': |
433 | 433 | case 'ID': |
434 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
434 | + $SQL .= $glue.$wpdb->posts.'.ID '.$sort; |
|
435 | 435 | break; |
436 | 436 | |
437 | 437 | case 'start_date': |
438 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort; |
|
438 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort; |
|
439 | 439 | break; |
440 | 440 | |
441 | 441 | case 'end_date': |
442 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
442 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort; |
|
443 | 443 | break; |
444 | 444 | |
445 | 445 | case 'event_name': |
446 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
446 | + $SQL .= $glue.$wpdb->posts.'.post_title '.$sort; |
|
447 | 447 | break; |
448 | 448 | |
449 | 449 | case 'category_slug': |
450 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
450 | + $SQL .= $glue.$wpdb->terms.'.slug '.$sort; |
|
451 | 451 | break; |
452 | 452 | |
453 | 453 | case 'ticket_start': |
454 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
454 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort; |
|
455 | 455 | break; |
456 | 456 | |
457 | 457 | case 'ticket_end': |
458 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
458 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort; |
|
459 | 459 | break; |
460 | 460 | |
461 | 461 | case 'venue_title': |
462 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
462 | + $SQL .= $glue.'venue_title '.$sort; |
|
463 | 463 | break; |
464 | 464 | |
465 | 465 | case 'city': |
466 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
466 | + $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort; |
|
467 | 467 | break; |
468 | 468 | |
469 | 469 | case 'state': |
470 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
470 | + $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort; |
|
471 | 471 | break; |
472 | 472 | } |
473 | 473 | $cntr++; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function event_list_pagination() |
524 | 524 | { |
525 | - echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>'; |
|
525 | + echo '<div class="ee-pagination-dv ee-clear-float">'.espresso_event_list_pagination().'</div>'; |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | public function event_details($content) |
537 | 537 | { |
538 | 538 | return EEH_Template::display_template( |
539 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-details.php', |
|
539 | + EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-details.php', |
|
540 | 540 | array('the_content' => $content), |
541 | 541 | true |
542 | 542 | ); |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | { |
555 | 555 | return $content |
556 | 556 | . EEH_Template::display_template( |
557 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-tickets.php', |
|
557 | + EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-tickets.php', |
|
558 | 558 | array(), |
559 | 559 | true |
560 | 560 | ); |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | { |
572 | 572 | return $content |
573 | 573 | . EEH_Template::display_template( |
574 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-datetimes.php', |
|
574 | + EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-datetimes.php', |
|
575 | 575 | array(), |
576 | 576 | true |
577 | 577 | ); |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | { |
589 | 589 | return $content |
590 | 590 | . EEH_Template::display_template( |
591 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/content-espresso_events-venues.php', |
|
591 | + EE_TEMPLATES.EE_Config::get_current_theme().'/content-espresso_events-venues.php', |
|
592 | 592 | array(), |
593 | 593 | true |
594 | 594 | ); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | */ |
624 | 624 | private function _get_template($which = 'part') |
625 | 625 | { |
626 | - return EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php'; |
|
626 | + return EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events.php'; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -684,30 +684,30 @@ discard block |
||
684 | 684 | // first check uploads folder |
685 | 685 | if ( |
686 | 686 | is_readable( |
687 | - get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.css' |
|
687 | + get_stylesheet_directory().EE_Config::get_current_theme().'/archive-espresso_events.css' |
|
688 | 688 | ) |
689 | 689 | ) { |
690 | 690 | wp_register_style( |
691 | 691 | 'archive-espresso_events', |
692 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme( |
|
693 | - ) . '/archive-espresso_events.css', |
|
692 | + get_stylesheet_directory_uri().EE_Config::get_current_theme( |
|
693 | + ).'/archive-espresso_events.css', |
|
694 | 694 | array('dashicons', 'espresso_default') |
695 | 695 | ); |
696 | 696 | } else { |
697 | 697 | wp_register_style( |
698 | 698 | 'archive-espresso_events', |
699 | - EE_TEMPLATES_URL . EE_Config::get_current_theme() . '/archive-espresso_events.css', |
|
699 | + EE_TEMPLATES_URL.EE_Config::get_current_theme().'/archive-espresso_events.css', |
|
700 | 700 | array('dashicons', 'espresso_default') |
701 | 701 | ); |
702 | 702 | } |
703 | 703 | if ( |
704 | 704 | is_readable( |
705 | - get_stylesheet_directory() . EE_Config::get_current_theme() . '/archive-espresso_events.js' |
|
705 | + get_stylesheet_directory().EE_Config::get_current_theme().'/archive-espresso_events.js' |
|
706 | 706 | ) |
707 | 707 | ) { |
708 | 708 | wp_register_script( |
709 | 709 | 'archive-espresso_events', |
710 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme() . '/archive-espresso_events.js', |
|
710 | + get_stylesheet_directory_uri().EE_Config::get_current_theme().'/archive-espresso_events.js', |
|
711 | 711 | array('jquery-masonry'), |
712 | 712 | '1.0', |
713 | 713 | true |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | } else { |
716 | 716 | wp_register_script( |
717 | 717 | 'archive-espresso_events', |
718 | - EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js', |
|
718 | + EVENTS_ARCHIVE_ASSETS_URL.'archive-espresso_events.js', |
|
719 | 719 | array('jquery-masonry'), |
720 | 720 | '1.0', |
721 | 721 | true |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | $EE->CFG->template_settings->EED_Events_Archive_Filters |
764 | 764 | ); |
765 | 765 | EEH_Template::display_template( |
766 | - EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
766 | + EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', |
|
767 | 767 | $EE->CFG->template_settings->EED_Events_Archive_Filters |
768 | 768 | ); |
769 | 769 | } |
@@ -792,10 +792,10 @@ discard block |
||
792 | 792 | ? $CFG->event_list_grid_size : 'medium'; |
793 | 793 | $CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full']) |
794 | 794 | ? $CFG->templates['full'] |
795 | - : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php'; |
|
795 | + : EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events.php'; |
|
796 | 796 | $CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part']) |
797 | 797 | ? $CFG->templates['part'] |
798 | - : EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-grid-view.php'; |
|
798 | + : EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events-grid-view.php'; |
|
799 | 799 | return $CFG; |
800 | 800 | } |
801 | 801 | |
@@ -837,20 +837,20 @@ discard block |
||
837 | 837 | $CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size']) |
838 | 838 | ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium'; |
839 | 839 | $CFG->EED_Events_Archive_Filters->templates = array( |
840 | - 'full' => EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events.php', |
|
840 | + 'full' => EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events.php', |
|
841 | 841 | ); |
842 | 842 | |
843 | 843 | switch ($CFG->EED_Events_Archive_Filters->default_type) { |
844 | 844 | case 'dates': |
845 | - $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
845 | + $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme() |
|
846 | 846 | . '/archive-espresso_events-dates-view.php'; |
847 | 847 | break; |
848 | 848 | case 'text': |
849 | - $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
849 | + $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme() |
|
850 | 850 | . '/archive-espresso_events-text-view.php'; |
851 | 851 | break; |
852 | 852 | default: |
853 | - $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() |
|
853 | + $CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme() |
|
854 | 854 | . '/archive-espresso_events-grid-view.php'; |
855 | 855 | } |
856 | 856 | |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | 'elf_type' => self::$_type, |
901 | 901 | ); |
902 | 902 | EEH_Template::display_template( |
903 | - EE_TEMPLATES . EE_Config::get_current_theme() . '/archive-espresso_events-filters.php', |
|
903 | + EE_TEMPLATES.EE_Config::get_current_theme().'/archive-espresso_events-filters.php', |
|
904 | 904 | $args |
905 | 905 | ); |
906 | 906 | } |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | if (self::$_type == 'grid') { |
921 | 921 | $event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) |
922 | 922 | ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium'; |
923 | - $event_list_css[] = $event_list_grid_size . '-event-list-grid'; |
|
923 | + $event_list_css[] = $event_list_grid_size.'-event-list-grid'; |
|
924 | 924 | } |
925 | 925 | $event_list_css = apply_filters( |
926 | 926 | 'EED_Events_Archive_Filters__event_list_css__event_list_css_array', |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | 'add_fragment' => '', |
1017 | 1017 | ) |
1018 | 1018 | ); |
1019 | - return ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
1019 | + return ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 |
@@ -10,145 +10,145 @@ |
||
10 | 10 | class EE_Country extends EE_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $props_n_values |
|
15 | - * @return EE_Country|mixed |
|
16 | - */ |
|
17 | - public static function new_instance($props_n_values = array()) |
|
18 | - { |
|
19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | - return $has_object ? $has_object : new self($props_n_values); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param array $props_n_values |
|
26 | - * @return EE_Country |
|
27 | - */ |
|
28 | - public static function new_instance_from_db($props_n_values = array()) |
|
29 | - { |
|
30 | - return new self($props_n_values, true); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Gets the country name |
|
36 | - * |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public function name() |
|
40 | - { |
|
41 | - return $this->get('CNT_name'); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Whether the country is active/enabled |
|
47 | - * |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - public function is_active(): bool |
|
51 | - { |
|
52 | - return $this->get('CNT_active'); |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * Gets the country ISO3 |
|
58 | - * |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function ISO3(): string |
|
62 | - { |
|
63 | - return $this->get('CNT_ISO3'); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * gets the country's currency code |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function currency_code() |
|
73 | - { |
|
74 | - return $this->get('CNT_cur_code'); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * gets the country's currency sign/symbol |
|
80 | - * |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function currency_sign() |
|
84 | - { |
|
85 | - $CNT_cur_sign = $this->get('CNT_cur_sign'); |
|
86 | - return $CNT_cur_sign ? $CNT_cur_sign : ''; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * Currency name singular |
|
92 | - * |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function currency_name_single() |
|
96 | - { |
|
97 | - return $this->get('CNT_cur_single'); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * Currency name plural |
|
103 | - * |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - public function currency_name_plural() |
|
107 | - { |
|
108 | - return $this->get('CNT_cur_plural'); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * currency_sign_before - ie: $TRUE or FALSE$ |
|
114 | - * |
|
115 | - * @return boolean |
|
116 | - */ |
|
117 | - public function currency_sign_before() |
|
118 | - { |
|
119 | - return $this->get('CNT_cur_sign_b4'); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * currency_decimal_places : 2 = 0.00 3 = 0.000 |
|
125 | - * |
|
126 | - * @return integer |
|
127 | - */ |
|
128 | - public function currency_decimal_places() |
|
129 | - { |
|
130 | - return $this->get('CNT_cur_dec_plc'); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * currency_decimal_mark : (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
136 | - * |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - public function currency_decimal_mark() |
|
140 | - { |
|
141 | - return $this->get('CNT_cur_dec_mrk'); |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * currency thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
147 | - * |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - public function currency_thousands_separator() |
|
151 | - { |
|
152 | - return $this->get('CNT_cur_thsnds'); |
|
153 | - } |
|
13 | + /** |
|
14 | + * @param array $props_n_values |
|
15 | + * @return EE_Country|mixed |
|
16 | + */ |
|
17 | + public static function new_instance($props_n_values = array()) |
|
18 | + { |
|
19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | + return $has_object ? $has_object : new self($props_n_values); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param array $props_n_values |
|
26 | + * @return EE_Country |
|
27 | + */ |
|
28 | + public static function new_instance_from_db($props_n_values = array()) |
|
29 | + { |
|
30 | + return new self($props_n_values, true); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Gets the country name |
|
36 | + * |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public function name() |
|
40 | + { |
|
41 | + return $this->get('CNT_name'); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Whether the country is active/enabled |
|
47 | + * |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + public function is_active(): bool |
|
51 | + { |
|
52 | + return $this->get('CNT_active'); |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * Gets the country ISO3 |
|
58 | + * |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function ISO3(): string |
|
62 | + { |
|
63 | + return $this->get('CNT_ISO3'); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * gets the country's currency code |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function currency_code() |
|
73 | + { |
|
74 | + return $this->get('CNT_cur_code'); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * gets the country's currency sign/symbol |
|
80 | + * |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function currency_sign() |
|
84 | + { |
|
85 | + $CNT_cur_sign = $this->get('CNT_cur_sign'); |
|
86 | + return $CNT_cur_sign ? $CNT_cur_sign : ''; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * Currency name singular |
|
92 | + * |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function currency_name_single() |
|
96 | + { |
|
97 | + return $this->get('CNT_cur_single'); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * Currency name plural |
|
103 | + * |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + public function currency_name_plural() |
|
107 | + { |
|
108 | + return $this->get('CNT_cur_plural'); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * currency_sign_before - ie: $TRUE or FALSE$ |
|
114 | + * |
|
115 | + * @return boolean |
|
116 | + */ |
|
117 | + public function currency_sign_before() |
|
118 | + { |
|
119 | + return $this->get('CNT_cur_sign_b4'); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * currency_decimal_places : 2 = 0.00 3 = 0.000 |
|
125 | + * |
|
126 | + * @return integer |
|
127 | + */ |
|
128 | + public function currency_decimal_places() |
|
129 | + { |
|
130 | + return $this->get('CNT_cur_dec_plc'); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * currency_decimal_mark : (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
136 | + * |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + public function currency_decimal_mark() |
|
140 | + { |
|
141 | + return $this->get('CNT_cur_dec_mrk'); |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * currency thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
147 | + * |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + public function currency_thousands_separator() |
|
151 | + { |
|
152 | + return $this->get('CNT_cur_thsnds'); |
|
153 | + } |
|
154 | 154 | } |
@@ -20,95 +20,95 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * StateConnection constructor. |
|
25 | - * |
|
26 | - * @param EEM_State $model |
|
27 | - */ |
|
28 | - public function __construct(EEM_State $model) |
|
29 | - { |
|
30 | - parent::__construct($model); |
|
31 | - } |
|
23 | + /** |
|
24 | + * StateConnection constructor. |
|
25 | + * |
|
26 | + * @param EEM_State $model |
|
27 | + */ |
|
28 | + public function __construct(EEM_State $model) |
|
29 | + { |
|
30 | + parent::__construct($model); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function config(): array |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'fromType' => 'RootQuery', |
|
41 | - 'toType' => $this->namespace . 'State', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'States', |
|
43 | - 'connectionTypeName' => "{$this->namespace}RootQueryStatesConnection", |
|
44 | - 'connectionArgs' => self::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - ]; |
|
47 | - } |
|
34 | + /** |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function config(): array |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => 'RootQuery', |
|
41 | + 'toType' => $this->namespace . 'State', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace) . 'States', |
|
43 | + 'connectionTypeName' => "{$this->namespace}RootQueryStatesConnection", |
|
44 | + 'connectionArgs' => self::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + ]; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $entity |
|
52 | - * @param $args |
|
53 | - * @param $context |
|
54 | - * @param $info |
|
55 | - * @return StateConnectionResolver |
|
56 | - * @throws Exception |
|
57 | - */ |
|
58 | - public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | - { |
|
60 | - return new StateConnectionResolver($entity, $args, $context, $info); |
|
61 | - } |
|
50 | + /** |
|
51 | + * @param $entity |
|
52 | + * @param $args |
|
53 | + * @param $context |
|
54 | + * @param $info |
|
55 | + * @return StateConnectionResolver |
|
56 | + * @throws Exception |
|
57 | + */ |
|
58 | + public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | + { |
|
60 | + return new StateConnectionResolver($entity, $args, $context, $info); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Given an optional array of args, this returns the args to be used in the connection |
|
65 | - * |
|
66 | - * @param array $args The args to modify the defaults |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
70 | - public static function get_connection_args(array $args = []): array |
|
71 | - { |
|
72 | - $newArgs = [ |
|
73 | - 'orderby' => [ |
|
74 | - 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
75 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
76 | - ], |
|
77 | - 'in' => [ |
|
78 | - 'type' => ['list_of' => 'ID'], |
|
79 | - 'description' => esc_html__( |
|
80 | - 'Limit the result to the set of given state IDs.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - ], |
|
84 | - 'countryIsoIn' => [ |
|
85 | - 'type' => ['list_of' => 'String'], |
|
86 | - 'description' => esc_html__( |
|
87 | - 'Limit the result to the set of given country ISOs.', |
|
88 | - 'event_espresso' |
|
89 | - ), |
|
90 | - ], |
|
91 | - 'search' => [ |
|
92 | - 'type' => 'String', |
|
93 | - 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
94 | - ], |
|
95 | - 'activeOnly' => [ |
|
96 | - 'type' => 'Boolean', |
|
97 | - 'description' => esc_html__( |
|
98 | - 'Limit the result to the active states.', |
|
99 | - 'event_espresso' |
|
100 | - ), |
|
101 | - ], |
|
102 | - ]; |
|
63 | + /** |
|
64 | + * Given an optional array of args, this returns the args to be used in the connection |
|
65 | + * |
|
66 | + * @param array $args The args to modify the defaults |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
70 | + public static function get_connection_args(array $args = []): array |
|
71 | + { |
|
72 | + $newArgs = [ |
|
73 | + 'orderby' => [ |
|
74 | + 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
75 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
76 | + ], |
|
77 | + 'in' => [ |
|
78 | + 'type' => ['list_of' => 'ID'], |
|
79 | + 'description' => esc_html__( |
|
80 | + 'Limit the result to the set of given state IDs.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + ], |
|
84 | + 'countryIsoIn' => [ |
|
85 | + 'type' => ['list_of' => 'String'], |
|
86 | + 'description' => esc_html__( |
|
87 | + 'Limit the result to the set of given country ISOs.', |
|
88 | + 'event_espresso' |
|
89 | + ), |
|
90 | + ], |
|
91 | + 'search' => [ |
|
92 | + 'type' => 'String', |
|
93 | + 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
94 | + ], |
|
95 | + 'activeOnly' => [ |
|
96 | + 'type' => 'Boolean', |
|
97 | + 'description' => esc_html__( |
|
98 | + 'Limit the result to the active states.', |
|
99 | + 'event_espresso' |
|
100 | + ), |
|
101 | + ], |
|
102 | + ]; |
|
103 | 103 | |
104 | - $newArgs = apply_filters( |
|
105 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__state_args', |
|
106 | - $newArgs, |
|
107 | - $args |
|
108 | - ); |
|
109 | - return array_merge( |
|
110 | - $newArgs, |
|
111 | - $args |
|
112 | - ); |
|
113 | - } |
|
104 | + $newArgs = apply_filters( |
|
105 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__state_args', |
|
106 | + $newArgs, |
|
107 | + $args |
|
108 | + ); |
|
109 | + return array_merge( |
|
110 | + $newArgs, |
|
111 | + $args |
|
112 | + ); |
|
113 | + } |
|
114 | 114 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | { |
39 | 39 | return [ |
40 | 40 | 'fromType' => 'RootQuery', |
41 | - 'toType' => $this->namespace . 'State', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'States', |
|
41 | + 'toType' => $this->namespace.'State', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace).'States', |
|
43 | 43 | 'connectionTypeName' => "{$this->namespace}RootQueryStatesConnection", |
44 | 44 | 'connectionArgs' => self::get_connection_args(), |
45 | 45 | 'resolve' => [$this, 'resolveConnection'], |
@@ -20,105 +20,105 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * CountryConnection constructor. |
|
25 | - * |
|
26 | - * @param EEM_Country $model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Country $model) |
|
29 | - { |
|
30 | - parent::__construct($model); |
|
31 | - } |
|
23 | + /** |
|
24 | + * CountryConnection constructor. |
|
25 | + * |
|
26 | + * @param EEM_Country $model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Country $model) |
|
29 | + { |
|
30 | + parent::__construct($model); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public function config(): array |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'fromType' => 'RootQuery', |
|
41 | - 'toType' => $this->namespace . 'Country', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace . 'Countries'), |
|
43 | - 'connectionTypeName' => "{$this->namespace}RootQueryCountriesConnection", |
|
44 | - 'connectionArgs' => RootQueryCountriesConnection::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - ]; |
|
47 | - } |
|
34 | + /** |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public function config(): array |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => 'RootQuery', |
|
41 | + 'toType' => $this->namespace . 'Country', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace . 'Countries'), |
|
43 | + 'connectionTypeName' => "{$this->namespace}RootQueryCountriesConnection", |
|
44 | + 'connectionArgs' => RootQueryCountriesConnection::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + ]; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $entity |
|
52 | - * @param $args |
|
53 | - * @param $context |
|
54 | - * @param $info |
|
55 | - * @return CountryConnectionResolver |
|
56 | - * @throws Exception |
|
57 | - */ |
|
58 | - public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | - { |
|
60 | - return new CountryConnectionResolver($entity, $args, $context, $info); |
|
61 | - } |
|
50 | + /** |
|
51 | + * @param $entity |
|
52 | + * @param $args |
|
53 | + * @param $context |
|
54 | + * @param $info |
|
55 | + * @return CountryConnectionResolver |
|
56 | + * @throws Exception |
|
57 | + */ |
|
58 | + public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
59 | + { |
|
60 | + return new CountryConnectionResolver($entity, $args, $context, $info); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Given an optional array of args, this returns the args to be used in the connection |
|
65 | - * |
|
66 | - * @param array $args The args to modify the defaults |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
70 | - public static function get_connection_args(array $args = []): array |
|
71 | - { |
|
72 | - $newArgs = [ |
|
73 | - 'orderby' => [ |
|
74 | - 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
75 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
76 | - ], |
|
77 | - 'in' => [ |
|
78 | - 'type' => ['list_of' => 'ID'], |
|
79 | - 'description' => esc_html__( |
|
80 | - 'Limit the result to the set of given country IDs.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - ], |
|
84 | - 'isoIn' => [ |
|
85 | - 'type' => ['list_of' => 'String'], |
|
86 | - 'description' => esc_html__( |
|
87 | - 'Limit the result to the set of given country ISOs.', |
|
88 | - 'event_espresso' |
|
89 | - ), |
|
90 | - ], |
|
91 | - 'iso3In' => [ |
|
92 | - 'type' => ['list_of' => 'String'], |
|
93 | - 'description' => esc_html__( |
|
94 | - 'Limit the result to the set of given country ISO3s.', |
|
95 | - 'event_espresso' |
|
96 | - ), |
|
97 | - ], |
|
98 | - 'search' => [ |
|
99 | - 'type' => 'String', |
|
100 | - 'description' => esc_html__( |
|
101 | - 'Limit the result to the given search query.', |
|
102 | - 'event_espresso' |
|
103 | - ), |
|
104 | - ], |
|
105 | - 'activeOnly' => [ |
|
106 | - 'type' => 'Boolean', |
|
107 | - 'description' => esc_html__( |
|
108 | - 'Limit the result to the active countries.', |
|
109 | - 'event_espresso' |
|
110 | - ), |
|
111 | - ], |
|
112 | - ]; |
|
63 | + /** |
|
64 | + * Given an optional array of args, this returns the args to be used in the connection |
|
65 | + * |
|
66 | + * @param array $args The args to modify the defaults |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
70 | + public static function get_connection_args(array $args = []): array |
|
71 | + { |
|
72 | + $newArgs = [ |
|
73 | + 'orderby' => [ |
|
74 | + 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
75 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
76 | + ], |
|
77 | + 'in' => [ |
|
78 | + 'type' => ['list_of' => 'ID'], |
|
79 | + 'description' => esc_html__( |
|
80 | + 'Limit the result to the set of given country IDs.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + ], |
|
84 | + 'isoIn' => [ |
|
85 | + 'type' => ['list_of' => 'String'], |
|
86 | + 'description' => esc_html__( |
|
87 | + 'Limit the result to the set of given country ISOs.', |
|
88 | + 'event_espresso' |
|
89 | + ), |
|
90 | + ], |
|
91 | + 'iso3In' => [ |
|
92 | + 'type' => ['list_of' => 'String'], |
|
93 | + 'description' => esc_html__( |
|
94 | + 'Limit the result to the set of given country ISO3s.', |
|
95 | + 'event_espresso' |
|
96 | + ), |
|
97 | + ], |
|
98 | + 'search' => [ |
|
99 | + 'type' => 'String', |
|
100 | + 'description' => esc_html__( |
|
101 | + 'Limit the result to the given search query.', |
|
102 | + 'event_espresso' |
|
103 | + ), |
|
104 | + ], |
|
105 | + 'activeOnly' => [ |
|
106 | + 'type' => 'Boolean', |
|
107 | + 'description' => esc_html__( |
|
108 | + 'Limit the result to the active countries.', |
|
109 | + 'event_espresso' |
|
110 | + ), |
|
111 | + ], |
|
112 | + ]; |
|
113 | 113 | |
114 | - $newArgs = apply_filters( |
|
115 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__country_args', |
|
116 | - $newArgs, |
|
117 | - $args |
|
118 | - ); |
|
119 | - return array_merge( |
|
120 | - $newArgs, |
|
121 | - $args |
|
122 | - ); |
|
123 | - } |
|
114 | + $newArgs = apply_filters( |
|
115 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__country_args', |
|
116 | + $newArgs, |
|
117 | + $args |
|
118 | + ); |
|
119 | + return array_merge( |
|
120 | + $newArgs, |
|
121 | + $args |
|
122 | + ); |
|
123 | + } |
|
124 | 124 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | { |
39 | 39 | return [ |
40 | 40 | 'fromType' => 'RootQuery', |
41 | - 'toType' => $this->namespace . 'Country', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace . 'Countries'), |
|
41 | + 'toType' => $this->namespace.'Country', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace.'Countries'), |
|
43 | 43 | 'connectionTypeName' => "{$this->namespace}RootQueryCountriesConnection", |
44 | 44 | 'connectionArgs' => RootQueryCountriesConnection::get_connection_args(), |
45 | 45 | 'resolve' => [$this, 'resolveConnection'], |
@@ -17,31 +17,31 @@ |
||
17 | 17 | class StatesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * StatesConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'StatesConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * StatesConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'StatesConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'StatesConnectionOrderbyInput'); |
|
25 | + $this->setName($this->namespace.'StatesConnectionOrderbyInput'); |
|
26 | 26 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | return [ |
37 | 37 | new GraphQLField( |
38 | 38 | 'field', |
39 | - ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum'] |
|
39 | + ['non_null' => $this->namespace.'StatesConnectionOrderbyEnum'] |
|
40 | 40 | ), |
41 | 41 | new GraphQLField( |
42 | 42 | 'order', |
@@ -17,31 +17,31 @@ |
||
17 | 17 | class CountriesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * CountriesConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'CountriesConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * CountriesConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'CountriesConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'CountriesConnectionOrderbyInput'); |
|
25 | + $this->setName($this->namespace.'CountriesConnectionOrderbyInput'); |
|
26 | 26 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | return [ |
37 | 37 | new GraphQLField( |
38 | 38 | 'field', |
39 | - ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum'] |
|
39 | + ['non_null' => $this->namespace.'CountriesConnectionOrderbyEnum'] |
|
40 | 40 | ), |
41 | 41 | new GraphQLField( |
42 | 42 | 'order', |