@@ -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 |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | function espresso_ticket_selector( $event = NULL ) { |
207 | 207 | if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
208 | 208 | espresso_load_ticket_selector(); |
209 | - \EED_Ticket_Selector::set_definitions(); |
|
209 | + \EED_Ticket_Selector::set_definitions(); |
|
210 | 210 | echo EED_Ticket_Selector::display_ticket_selector( $event ); |
211 | 211 | } |
212 | 212 | } |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | * @return string |
461 | 461 | */ |
462 | 462 | function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
463 | - $arguments = apply_filters( |
|
464 | - 'FHEE__espresso_list_of_event_dates__arguments', |
|
465 | - [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ] |
|
466 | - ); |
|
467 | - [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit] = $arguments; |
|
468 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
463 | + $arguments = apply_filters( |
|
464 | + 'FHEE__espresso_list_of_event_dates__arguments', |
|
465 | + [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ] |
|
466 | + ); |
|
467 | + [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit] = $arguments; |
|
468 | + $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
469 | 469 | $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
470 | 470 | $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
471 | 471 | $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
@@ -481,51 +481,51 @@ discard block |
||
481 | 481 | $html = '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="'. $ul_class.'">'; |
482 | 482 | foreach ( $datetimes as $datetime ) { |
483 | 483 | if ( $datetime instanceof EE_Datetime ) { |
484 | - $datetime_name = $datetime->name(); |
|
485 | - $datetime_description = $datetime->description(); |
|
486 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
487 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
488 | - $inner_html = ''; |
|
489 | - if (! empty( $datetime_name )) { |
|
490 | - $inner_html .= '<strong>' . $datetime_name . '</strong>'; |
|
491 | - $inner_html .= $add_breaks ? '<br />' : ''; |
|
492 | - } |
|
493 | - // add date |
|
494 | - $inner_html .= '<span class="ee-event-datetimes-li-daterange">'; |
|
495 | - $inner_html .= '<span class="dashicons dashicons-calendar"></span> '; |
|
496 | - $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>'; |
|
497 | - // add time |
|
498 | - $inner_html .= '<span class="ee-event-datetimes-li-timerange">'; |
|
499 | - $inner_html .= '<span class="dashicons dashicons-clock"></span> '; |
|
500 | - $inner_html .= $datetime->time_range( $time_format ) . '</span>'; |
|
501 | - |
|
502 | - $venue = $datetime->venue(); |
|
503 | - if ($venue instanceof EE_Venue) { |
|
504 | - $inner_html .= '<br /><span class="ee-event-datetimes-li-venue">'; |
|
505 | - $inner_html .= '<span class="dashicons dashicons-admin-home"></span> '; |
|
506 | - $inner_html .= '<a href="'. $venue->get_permalink() .'" '; |
|
507 | - $inner_html .= 'alt="'. $venue->name() .'" target="_blank">'; |
|
508 | - $inner_html .= $venue->name() . '</a></span>'; |
|
509 | - } |
|
510 | - if (! empty( $datetime_description )) { |
|
511 | - $inner_html .= $add_breaks ? '<br />' : ''; |
|
512 | - $inner_html .= $datetime_description; |
|
513 | - } |
|
514 | - $inner_html = apply_filters( |
|
515 | - 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
516 | - $inner_html, |
|
517 | - $datetime, |
|
518 | - $arguments |
|
519 | - ); |
|
520 | - $html .= $inner_html . '</li>'; |
|
484 | + $datetime_name = $datetime->name(); |
|
485 | + $datetime_description = $datetime->description(); |
|
486 | + $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
487 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
488 | + $inner_html = ''; |
|
489 | + if (! empty( $datetime_name )) { |
|
490 | + $inner_html .= '<strong>' . $datetime_name . '</strong>'; |
|
491 | + $inner_html .= $add_breaks ? '<br />' : ''; |
|
492 | + } |
|
493 | + // add date |
|
494 | + $inner_html .= '<span class="ee-event-datetimes-li-daterange">'; |
|
495 | + $inner_html .= '<span class="dashicons dashicons-calendar"></span> '; |
|
496 | + $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>'; |
|
497 | + // add time |
|
498 | + $inner_html .= '<span class="ee-event-datetimes-li-timerange">'; |
|
499 | + $inner_html .= '<span class="dashicons dashicons-clock"></span> '; |
|
500 | + $inner_html .= $datetime->time_range( $time_format ) . '</span>'; |
|
501 | + |
|
502 | + $venue = $datetime->venue(); |
|
503 | + if ($venue instanceof EE_Venue) { |
|
504 | + $inner_html .= '<br /><span class="ee-event-datetimes-li-venue">'; |
|
505 | + $inner_html .= '<span class="dashicons dashicons-admin-home"></span> '; |
|
506 | + $inner_html .= '<a href="'. $venue->get_permalink() .'" '; |
|
507 | + $inner_html .= 'alt="'. $venue->name() .'" target="_blank">'; |
|
508 | + $inner_html .= $venue->name() . '</a></span>'; |
|
509 | + } |
|
510 | + if (! empty( $datetime_description )) { |
|
511 | + $inner_html .= $add_breaks ? '<br />' : ''; |
|
512 | + $inner_html .= $datetime_description; |
|
513 | + } |
|
514 | + $inner_html = apply_filters( |
|
515 | + 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
516 | + $inner_html, |
|
517 | + $datetime, |
|
518 | + $arguments |
|
519 | + ); |
|
520 | + $html .= $inner_html . '</li>'; |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | $html .= '</ul>'; |
524 | - $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
|
524 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
|
525 | 525 | } else { |
526 | - $html = '<p><span class="dashicons dashicons-marker pink-text"></span>'; |
|
527 | - $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' ); |
|
528 | - $html .= '</p><br/>'; |
|
526 | + $html = '<p><span class="dashicons dashicons-marker pink-text"></span>'; |
|
527 | + $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' ); |
|
528 | + $html .= '</p><br/>'; |
|
529 | 529 | } |
530 | 530 | if ( $echo ) { |
531 | 531 | echo $html; |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param int | \EE_Event $event |
15 | 15 | * @return bool |
16 | 16 | */ |
17 | -function is_espresso_event( $event = NULL ) { |
|
18 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
17 | +function is_espresso_event($event = NULL) { |
|
18 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
19 | 19 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
20 | - $event = EEH_Event_View::get_event( $event ); |
|
20 | + $event = EEH_Event_View::get_event($event); |
|
21 | 21 | // do we have a valid event ? |
22 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
22 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
23 | 23 | } |
24 | 24 | return FALSE; |
25 | 25 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return bool |
32 | 32 | */ |
33 | 33 | function is_espresso_event_single() { |
34 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
34 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
35 | 35 | global $wp_query; |
36 | 36 | // return conditionals set by CPTs |
37 | 37 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return bool |
47 | 47 | */ |
48 | 48 | function is_espresso_event_archive() { |
49 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
49 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
50 | 50 | global $wp_query; |
51 | 51 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
52 | 52 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | function is_espresso_event_taxonomy() { |
63 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
63 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
64 | 64 | global $wp_query; |
65 | 65 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
66 | 66 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @param int | \EE_Venue $venue |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | -function is_espresso_venue( $venue = NULL ) { |
|
78 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
77 | +function is_espresso_venue($venue = NULL) { |
|
78 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
79 | 79 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
80 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
80 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
81 | 81 | // do we have a valid event ? |
82 | 82 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
83 | 83 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return bool |
92 | 92 | */ |
93 | 93 | function is_espresso_venue_single() { |
94 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
94 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
95 | 95 | global $wp_query; |
96 | 96 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return bool |
106 | 106 | */ |
107 | 107 | function is_espresso_venue_archive() { |
108 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
108 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
109 | 109 | global $wp_query; |
110 | 110 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
111 | 111 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return bool |
120 | 120 | */ |
121 | 121 | function is_espresso_venue_taxonomy() { |
122 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
122 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
123 | 123 | global $wp_query; |
124 | 124 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
125 | 125 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * @param $conditional_tag |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
137 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
136 | +function can_use_espresso_conditionals($conditional_tag) { |
|
137 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
138 | 138 | EE_Error::doing_it_wrong( |
139 | 139 | __FUNCTION__, |
140 | 140 | sprintf( |
141 | - esc_html__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'), |
|
141 | + esc_html__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), |
|
142 | 142 | $conditional_tag |
143 | 143 | ), |
144 | 144 | '4.4.0' |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | |
154 | 154 | /*************************** Event Queries ***************************/ |
155 | 155 | |
156 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
156 | +if ( ! function_exists('espresso_get_events')) { |
|
157 | 157 | /** |
158 | 158 | * espresso_get_events |
159 | 159 | * @param array $params |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - function espresso_get_events( $params = array() ) { |
|
162 | + function espresso_get_events($params = array()) { |
|
163 | 163 | //set default params |
164 | 164 | $default_espresso_events_params = array( |
165 | 165 | 'limit' => 10, |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | 'sort' => 'ASC' |
171 | 171 | ); |
172 | 172 | // allow the defaults to be filtered |
173 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
173 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
174 | 174 | // grab params and merge with defaults, then extract |
175 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
175 | + $params = array_merge($default_espresso_events_params, $params); |
|
176 | 176 | // run the query |
177 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params ); |
|
177 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
178 | 178 | // assign results to a variable so we can return it |
179 | 179 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
180 | 180 | // but first reset the query and postdata |
181 | 181 | wp_reset_query(); |
182 | 182 | wp_reset_postdata(); |
183 | 183 | EED_Events_Archive::remove_all_events_archive_filters(); |
184 | - unset( $events_query ); |
|
184 | + unset($events_query); |
|
185 | 185 | return $events; |
186 | 186 | } |
187 | 187 | } |
@@ -195,33 +195,33 @@ discard block |
||
195 | 195 | * espresso_load_ticket_selector |
196 | 196 | */ |
197 | 197 | function espresso_load_ticket_selector() { |
198 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
198 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
199 | 199 | } |
200 | 200 | |
201 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
201 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
202 | 202 | /** |
203 | 203 | * espresso_ticket_selector |
204 | 204 | * @param null $event |
205 | 205 | */ |
206 | - function espresso_ticket_selector( $event = NULL ) { |
|
207 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
206 | + function espresso_ticket_selector($event = NULL) { |
|
207 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
208 | 208 | espresso_load_ticket_selector(); |
209 | 209 | \EED_Ticket_Selector::set_definitions(); |
210 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
210 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | 215 | |
216 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
216 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
217 | 217 | /** |
218 | 218 | * espresso_view_details_btn |
219 | 219 | * @param null $event |
220 | 220 | */ |
221 | - function espresso_view_details_btn( $event = NULL ) { |
|
222 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
221 | + function espresso_view_details_btn($event = NULL) { |
|
222 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
223 | 223 | espresso_load_ticket_selector(); |
224 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
224 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | /*************************** EEH_Event_View ***************************/ |
233 | 233 | |
234 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
234 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
235 | 235 | /** |
236 | 236 | * espresso_load_event_list_assets |
237 | 237 | * ensures that event list styles and scripts are loaded |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function espresso_load_event_list_assets() { |
242 | 242 | $event_list = EED_Events_Archive::instance(); |
243 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
244 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
243 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
244 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
249 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
250 | 250 | /** |
251 | 251 | * espresso_event_reg_button |
252 | 252 | * returns the "Register Now" button if event is active, |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | * @param bool $EVT_ID |
259 | 259 | * @return string |
260 | 260 | */ |
261 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
262 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
263 | - if ( ! $event instanceof EE_Event ) { |
|
261 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
262 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
263 | + if ( ! $event instanceof EE_Event) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | $event_status = $event->get_active_status(); |
267 | - switch ( $event_status ) { |
|
267 | + switch ($event_status) { |
|
268 | 268 | case EE_Datetime::sold_out : |
269 | 269 | $btn_text = esc_html__('Sold Out', 'event_espresso'); |
270 | 270 | $class = 'ee-pink'; |
@@ -284,15 +284,15 @@ discard block |
||
284 | 284 | case EE_Datetime::upcoming : |
285 | 285 | case EE_Datetime::active : |
286 | 286 | default : |
287 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : esc_html__( 'Register Now', 'event_espresso' ); |
|
287 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : esc_html__('Register Now', 'event_espresso'); |
|
288 | 288 | $class = 'ee-green'; |
289 | 289 | } |
290 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
290 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
291 | 291 | $btn_text = $btn_text_if_inactive; |
292 | 292 | $class = 'ee-grey'; |
293 | 293 | } |
294 | 294 | ?> |
295 | - <a class="ee-button ee-register-button <?php echo $class; ?>" href="<?php espresso_event_link_url( $EVT_ID ); ?>"<?php echo \EED_Events_Archive::link_target(); ?>> |
|
295 | + <a class="ee-button ee-register-button <?php echo $class; ?>" href="<?php espresso_event_link_url($EVT_ID); ?>"<?php echo \EED_Events_Archive::link_target(); ?>> |
|
296 | 296 | <?php echo $btn_text; ?> |
297 | 297 | </a> |
298 | 298 | <?php |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | |
303 | 303 | |
304 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
304 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
305 | 305 | /** |
306 | 306 | * espresso_display_ticket_selector |
307 | 307 | * whether or not to display the Ticket Selector for an event |
@@ -309,14 +309,14 @@ discard block |
||
309 | 309 | * @param bool $EVT_ID |
310 | 310 | * @return boolean |
311 | 311 | */ |
312 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
313 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
312 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
313 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | 317 | |
318 | 318 | |
319 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
319 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
320 | 320 | /** |
321 | 321 | * espresso_event_status |
322 | 322 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | * @param bool $EVT_ID |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
328 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
327 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
328 | + return EEH_Event_View::event_status($EVT_ID); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
333 | +if ( ! function_exists('espresso_event_status')) { |
|
334 | 334 | /** |
335 | 335 | * espresso_event_status |
336 | 336 | * returns the event status if it is sold out, expired, or inactive |
@@ -339,13 +339,13 @@ discard block |
||
339 | 339 | * @param bool $echo |
340 | 340 | * @return string |
341 | 341 | */ |
342 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
343 | - return EEH_Event_View::event_active_status( $EVT_ID, $echo ); |
|
342 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
343 | + return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | |
348 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
348 | +if ( ! function_exists('espresso_event_categories')) { |
|
349 | 349 | /** |
350 | 350 | * espresso_event_categories |
351 | 351 | * returns the terms associated with an event |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * @param bool $echo |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
359 | - if ( $echo ) { |
|
360 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
358 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
359 | + if ($echo) { |
|
360 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
361 | 361 | return ''; |
362 | 362 | } |
363 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
363 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
368 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
369 | 369 | /** |
370 | 370 | * espresso_event_tickets_available |
371 | 371 | * returns the ticket types available for purchase for an event |
@@ -375,26 +375,26 @@ discard block |
||
375 | 375 | * @param bool $format |
376 | 376 | * @return string |
377 | 377 | */ |
378 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
379 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
380 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
378 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
379 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
380 | + if (is_array($tickets) && ! empty($tickets)) { |
|
381 | 381 | // if formatting then $html will be a string, else it will be an array of ticket objects |
382 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
383 | - foreach ( $tickets as $ticket ) { |
|
384 | - if ( $ticket instanceof EE_Ticket ) { |
|
385 | - if ( $format ) { |
|
386 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
387 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
382 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
383 | + foreach ($tickets as $ticket) { |
|
384 | + if ($ticket instanceof EE_Ticket) { |
|
385 | + if ($format) { |
|
386 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
387 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
388 | 388 | $html .= '</li>'; |
389 | 389 | } else { |
390 | 390 | $html[] = $ticket; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
394 | - if ( $format ) { |
|
394 | + if ($format) { |
|
395 | 395 | $html .= '</ul>'; |
396 | 396 | } |
397 | - if ( $echo && $format ) { |
|
397 | + if ($echo && $format) { |
|
398 | 398 | echo $html; |
399 | 399 | return ''; |
400 | 400 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
407 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
408 | 408 | /** |
409 | 409 | * espresso_event_date_obj |
410 | 410 | * returns the primary date object for an event |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | * @param bool $EVT_ID |
413 | 413 | * @return object |
414 | 414 | */ |
415 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
416 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
415 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
416 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
420 | 420 | |
421 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
421 | +if ( ! function_exists('espresso_event_date')) { |
|
422 | 422 | /** |
423 | 423 | * espresso_event_date |
424 | 424 | * returns the primary date for an event |
@@ -429,22 +429,22 @@ discard block |
||
429 | 429 | * @param bool $echo |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
433 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
434 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
435 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
436 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
437 | - if($echo){ |
|
438 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
432 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
433 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
434 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
435 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
436 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
437 | + if ($echo) { |
|
438 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
439 | 439 | return ''; |
440 | 440 | } |
441 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
441 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
442 | 442 | |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | 446 | |
447 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
447 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
448 | 448 | /** |
449 | 449 | * espresso_list_of_event_dates |
450 | 450 | * returns a unordered list of dates for an event |
@@ -459,55 +459,55 @@ discard block |
||
459 | 459 | * @param null $limit |
460 | 460 | * @return string |
461 | 461 | */ |
462 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
462 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
463 | 463 | $arguments = apply_filters( |
464 | 464 | 'FHEE__espresso_list_of_event_dates__arguments', |
465 | - [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ] |
|
465 | + [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit] |
|
466 | 466 | ); |
467 | 467 | [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit] = $arguments; |
468 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
469 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
470 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
471 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
472 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
473 | - if ( ! $format ) { |
|
474 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
468 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
469 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
470 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
471 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
472 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
473 | + if ( ! $format) { |
|
474 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
475 | 475 | } |
476 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
476 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
477 | 477 | global $post; |
478 | 478 | $cols = count($datetimes); |
479 | 479 | $cols = $cols >= 3 ? 'big' : 'small'; |
480 | 480 | $ul_class = "ee-event-datetimes-ul ee-event-datetimes-ul--{$cols}"; |
481 | - $html = '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="'. $ul_class.'">'; |
|
482 | - foreach ( $datetimes as $datetime ) { |
|
483 | - if ( $datetime instanceof EE_Datetime ) { |
|
481 | + $html = '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="'.$ul_class.'">'; |
|
482 | + foreach ($datetimes as $datetime) { |
|
483 | + if ($datetime instanceof EE_Datetime) { |
|
484 | 484 | $datetime_name = $datetime->name(); |
485 | 485 | $datetime_description = $datetime->description(); |
486 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
487 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
486 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
487 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
488 | 488 | $inner_html = ''; |
489 | - if (! empty( $datetime_name )) { |
|
490 | - $inner_html .= '<strong>' . $datetime_name . '</strong>'; |
|
489 | + if ( ! empty($datetime_name)) { |
|
490 | + $inner_html .= '<strong>'.$datetime_name.'</strong>'; |
|
491 | 491 | $inner_html .= $add_breaks ? '<br />' : ''; |
492 | 492 | } |
493 | 493 | // add date |
494 | 494 | $inner_html .= '<span class="ee-event-datetimes-li-daterange">'; |
495 | 495 | $inner_html .= '<span class="dashicons dashicons-calendar"></span> '; |
496 | - $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>'; |
|
496 | + $inner_html .= $datetime->date_range($date_format).'</span><br/>'; |
|
497 | 497 | // add time |
498 | 498 | $inner_html .= '<span class="ee-event-datetimes-li-timerange">'; |
499 | 499 | $inner_html .= '<span class="dashicons dashicons-clock"></span> '; |
500 | - $inner_html .= $datetime->time_range( $time_format ) . '</span>'; |
|
500 | + $inner_html .= $datetime->time_range($time_format).'</span>'; |
|
501 | 501 | |
502 | 502 | $venue = $datetime->venue(); |
503 | 503 | if ($venue instanceof EE_Venue) { |
504 | 504 | $inner_html .= '<br /><span class="ee-event-datetimes-li-venue">'; |
505 | 505 | $inner_html .= '<span class="dashicons dashicons-admin-home"></span> '; |
506 | - $inner_html .= '<a href="'. $venue->get_permalink() .'" '; |
|
507 | - $inner_html .= 'alt="'. $venue->name() .'" target="_blank">'; |
|
508 | - $inner_html .= $venue->name() . '</a></span>'; |
|
506 | + $inner_html .= '<a href="'.$venue->get_permalink().'" '; |
|
507 | + $inner_html .= 'alt="'.$venue->name().'" target="_blank">'; |
|
508 | + $inner_html .= $venue->name().'</a></span>'; |
|
509 | 509 | } |
510 | - if (! empty( $datetime_description )) { |
|
510 | + if ( ! empty($datetime_description)) { |
|
511 | 511 | $inner_html .= $add_breaks ? '<br />' : ''; |
512 | 512 | $inner_html .= $datetime_description; |
513 | 513 | } |
@@ -517,17 +517,17 @@ discard block |
||
517 | 517 | $datetime, |
518 | 518 | $arguments |
519 | 519 | ); |
520 | - $html .= $inner_html . '</li>'; |
|
520 | + $html .= $inner_html.'</li>'; |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | $html .= '</ul>'; |
524 | 524 | $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
525 | 525 | } else { |
526 | 526 | $html = '<p><span class="dashicons dashicons-marker pink-text"></span>'; |
527 | - $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' ); |
|
527 | + $html .= esc_html__('There are no upcoming dates for this event.', 'event_espresso'); |
|
528 | 528 | $html .= '</p><br/>'; |
529 | 529 | } |
530 | - if ( $echo ) { |
|
530 | + if ($echo) { |
|
531 | 531 | echo $html; |
532 | 532 | return ''; |
533 | 533 | } |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | } |
537 | 537 | |
538 | 538 | |
539 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
539 | +if ( ! function_exists('espresso_event_end_date')) { |
|
540 | 540 | /** |
541 | 541 | * espresso_event_end_date |
542 | 542 | * returns the last date for an event |
@@ -547,20 +547,20 @@ discard block |
||
547 | 547 | * @param bool $echo |
548 | 548 | * @return string |
549 | 549 | */ |
550 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
551 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
552 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
553 | - $date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format ); |
|
554 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
555 | - if($echo){ |
|
556 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
550 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
551 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
552 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
553 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
554 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
555 | + if ($echo) { |
|
556 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
557 | 557 | return ''; |
558 | 558 | } |
559 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
559 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | |
563 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
563 | +if ( ! function_exists('espresso_event_date_range')) { |
|
564 | 564 | /** |
565 | 565 | * espresso_event_date_range |
566 | 566 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -573,32 +573,32 @@ discard block |
||
573 | 573 | * @param bool $echo |
574 | 574 | * @return string |
575 | 575 | */ |
576 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
576 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
577 | 577 | // set and filter date and time formats when a range is returned |
578 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
579 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
578 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
579 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
580 | 580 | // get the start and end date with NO time portion |
581 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
582 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
581 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
582 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
583 | 583 | // now we can determine if date range spans more than one day |
584 | - if ( $the_event_date != $the_event_end_date ) { |
|
585 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
586 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
584 | + if ($the_event_date != $the_event_end_date) { |
|
585 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
586 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
587 | 587 | $html = sprintf( |
588 | 588 | /* translators: 1: first event date, 2: last event date */ |
589 | - esc_html__( '%1$s - %2$s', 'event_espresso' ), |
|
590 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
591 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
589 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
590 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
591 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
592 | 592 | ); |
593 | 593 | } else { |
594 | 594 | // set and filter date and time formats when only a single datetime is returned |
595 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
596 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
597 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
598 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
599 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
595 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
596 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
597 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
598 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
599 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
600 | 600 | } |
601 | - if ( $echo ) { |
|
601 | + if ($echo) { |
|
602 | 602 | echo $html; |
603 | 603 | return ''; |
604 | 604 | } |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
609 | -if ( ! function_exists( 'espresso_next_upcoming_datetime_obj' )) { |
|
609 | +if ( ! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
610 | 610 | /** |
611 | 611 | * espresso_next_upcoming_datetime_obj |
612 | 612 | * returns the next upcoming datetime object for an event |
@@ -614,12 +614,12 @@ discard block |
||
614 | 614 | * @param int $EVT_ID |
615 | 615 | * @return EE_Datetime|null |
616 | 616 | */ |
617 | - function espresso_next_upcoming_datetime_obj( $EVT_ID = 0 ) { |
|
618 | - return EEH_Event_View::get_next_upcoming_date_obj( $EVT_ID ); |
|
617 | + function espresso_next_upcoming_datetime_obj($EVT_ID = 0) { |
|
618 | + return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
622 | -if ( ! function_exists( 'espresso_next_upcoming_datetime' ) ) { |
|
622 | +if ( ! function_exists('espresso_next_upcoming_datetime')) { |
|
623 | 623 | /** |
624 | 624 | * espresso_next_upcoming_datetime |
625 | 625 | * returns the start date and time for the next upcoming event. |
@@ -630,30 +630,30 @@ discard block |
||
630 | 630 | * @param bool $echo |
631 | 631 | * @return string |
632 | 632 | */ |
633 | - function espresso_next_upcoming_datetime( $date_format = '', $time_format = '', $EVT_ID = 0, $echo = true ) { |
|
633 | + function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) { |
|
634 | 634 | |
635 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
636 | - $date_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__date_format', $date_format ); |
|
635 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
636 | + $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
637 | 637 | |
638 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
639 | - $time_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__time_format', $time_format ); |
|
638 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
639 | + $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
640 | 640 | |
641 | - $datetime_format = trim( $date_format . ' ' . $time_format); |
|
641 | + $datetime_format = trim($date_format.' '.$time_format); |
|
642 | 642 | |
643 | - $datetime = espresso_next_upcoming_datetime_obj( $EVT_ID ); |
|
643 | + $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
644 | 644 | |
645 | - if( ! $datetime instanceof EE_Datetime ) { |
|
645 | + if ( ! $datetime instanceof EE_Datetime) { |
|
646 | 646 | return ''; |
647 | 647 | } |
648 | - if ( $echo ){ |
|
649 | - echo $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format ); |
|
648 | + if ($echo) { |
|
649 | + echo $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
650 | 650 | return ''; |
651 | 651 | } |
652 | - return $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format ); |
|
652 | + return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | |
656 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
656 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
657 | 657 | /** |
658 | 658 | * espresso_event_date_as_calendar_page |
659 | 659 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -661,15 +661,15 @@ discard block |
||
661 | 661 | * @param bool $EVT_ID |
662 | 662 | * @return string |
663 | 663 | */ |
664 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
665 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
664 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
665 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
669 | 669 | |
670 | 670 | |
671 | 671 | |
672 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
672 | +if ( ! function_exists('espresso_event_link_url')) { |
|
673 | 673 | /** |
674 | 674 | * espresso_event_link_url |
675 | 675 | * |
@@ -677,18 +677,18 @@ discard block |
||
677 | 677 | * @param bool $echo |
678 | 678 | * @return string |
679 | 679 | */ |
680 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
681 | - if ( $echo ) { |
|
682 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
680 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
681 | + if ($echo) { |
|
682 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
683 | 683 | return ''; |
684 | 684 | } |
685 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
685 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
686 | 686 | } |
687 | 687 | } |
688 | 688 | |
689 | 689 | |
690 | 690 | |
691 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
691 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
692 | 692 | /** |
693 | 693 | * espresso_event_has_content_or_excerpt |
694 | 694 | * |
@@ -696,15 +696,15 @@ discard block |
||
696 | 696 | * @param bool $EVT_ID |
697 | 697 | * @return boolean |
698 | 698 | */ |
699 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
700 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
699 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
700 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
701 | 701 | } |
702 | 702 | } |
703 | 703 | |
704 | 704 | |
705 | 705 | |
706 | 706 | |
707 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
707 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
708 | 708 | /** |
709 | 709 | * espresso_event_content_or_excerpt |
710 | 710 | * |
@@ -713,18 +713,18 @@ discard block |
||
713 | 713 | * @param bool $echo |
714 | 714 | * @return string |
715 | 715 | */ |
716 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
717 | - if ( $echo ) { |
|
718 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
716 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
717 | + if ($echo) { |
|
718 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
719 | 719 | return ''; |
720 | 720 | } |
721 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
721 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | |
726 | 726 | |
727 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
727 | +if ( ! function_exists('espresso_event_phone')) { |
|
728 | 728 | /** |
729 | 729 | * espresso_event_phone |
730 | 730 | * |
@@ -732,18 +732,18 @@ discard block |
||
732 | 732 | * @param bool $echo |
733 | 733 | * @return string |
734 | 734 | */ |
735 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
736 | - if ( $echo ) { |
|
737 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
735 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
736 | + if ($echo) { |
|
737 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
738 | 738 | return ''; |
739 | 739 | } |
740 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
740 | + return EEH_Event_View::event_phone($EVT_ID); |
|
741 | 741 | } |
742 | 742 | } |
743 | 743 | |
744 | 744 | |
745 | 745 | |
746 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
746 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
747 | 747 | /** |
748 | 748 | * espresso_edit_event_link |
749 | 749 | * returns a link to edit an event |
@@ -752,39 +752,39 @@ discard block |
||
752 | 752 | * @param bool $echo |
753 | 753 | * @return string |
754 | 754 | */ |
755 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
756 | - if ( $echo ) { |
|
757 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
755 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
756 | + if ($echo) { |
|
757 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
758 | 758 | return ''; |
759 | 759 | } |
760 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
760 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | |
764 | 764 | |
765 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
765 | +if ( ! function_exists('espresso_organization_name')) { |
|
766 | 766 | /** |
767 | 767 | * espresso_organization_name |
768 | 768 | * @param bool $echo |
769 | 769 | * @return string |
770 | 770 | */ |
771 | 771 | function espresso_organization_name($echo = TRUE) { |
772 | - if($echo){ |
|
773 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
772 | + if ($echo) { |
|
773 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
774 | 774 | return ''; |
775 | 775 | } |
776 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
776 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | |
780 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
780 | +if ( ! function_exists('espresso_organization_address')) { |
|
781 | 781 | /** |
782 | 782 | * espresso_organization_address |
783 | 783 | * @param string $type |
784 | 784 | * @return string |
785 | 785 | */ |
786 | - function espresso_organization_address( $type = 'inline' ) { |
|
787 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
786 | + function espresso_organization_address($type = 'inline') { |
|
787 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
788 | 788 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
789 | 789 | EE_Registry::instance()->CFG->organization->address_1, |
790 | 790 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -793,129 +793,129 @@ discard block |
||
793 | 793 | EE_Registry::instance()->CFG->organization->zip, |
794 | 794 | EE_Registry::instance()->CFG->organization->CNT_ISO |
795 | 795 | ); |
796 | - return EEH_Address::format( $address, $type ); |
|
796 | + return EEH_Address::format($address, $type); |
|
797 | 797 | } |
798 | 798 | return ''; |
799 | 799 | } |
800 | 800 | } |
801 | 801 | |
802 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
802 | +if ( ! function_exists('espresso_organization_email')) { |
|
803 | 803 | /** |
804 | 804 | * espresso_organization_email |
805 | 805 | * @param bool $echo |
806 | 806 | * @return string |
807 | 807 | */ |
808 | - function espresso_organization_email( $echo = TRUE ) { |
|
809 | - if($echo){ |
|
810 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
808 | + function espresso_organization_email($echo = TRUE) { |
|
809 | + if ($echo) { |
|
810 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
811 | 811 | return ''; |
812 | 812 | } |
813 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
813 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
817 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
818 | 818 | /** |
819 | 819 | * espresso_organization_logo_url |
820 | 820 | * @param bool $echo |
821 | 821 | * @return string |
822 | 822 | */ |
823 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
824 | - if($echo){ |
|
825 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
823 | + function espresso_organization_logo_url($echo = TRUE) { |
|
824 | + if ($echo) { |
|
825 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
826 | 826 | return ''; |
827 | 827 | } |
828 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
828 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
829 | 829 | } |
830 | 830 | } |
831 | 831 | |
832 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
832 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
833 | 833 | /** |
834 | 834 | * espresso_organization_facebook |
835 | 835 | * @param bool $echo |
836 | 836 | * @return string |
837 | 837 | */ |
838 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
839 | - if($echo){ |
|
840 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
838 | + function espresso_organization_facebook($echo = TRUE) { |
|
839 | + if ($echo) { |
|
840 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
841 | 841 | return ''; |
842 | 842 | } |
843 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
843 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
847 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
847 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
848 | 848 | /** |
849 | 849 | * espresso_organization_twitter |
850 | 850 | * @param bool $echo |
851 | 851 | * @return string |
852 | 852 | */ |
853 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
854 | - if($echo){ |
|
855 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
853 | + function espresso_organization_twitter($echo = TRUE) { |
|
854 | + if ($echo) { |
|
855 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
856 | 856 | return ''; |
857 | 857 | } |
858 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
858 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | |
862 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
862 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
863 | 863 | /** |
864 | 864 | * espresso_organization_linkedin |
865 | 865 | * @param bool $echo |
866 | 866 | * @return string |
867 | 867 | */ |
868 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
869 | - if($echo){ |
|
870 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
868 | + function espresso_organization_linkedin($echo = TRUE) { |
|
869 | + if ($echo) { |
|
870 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
871 | 871 | return ''; |
872 | 872 | } |
873 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
873 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
874 | 874 | } |
875 | 875 | } |
876 | 876 | |
877 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
877 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
878 | 878 | /** |
879 | 879 | * espresso_organization_pinterest |
880 | 880 | * @param bool $echo |
881 | 881 | * @return string |
882 | 882 | */ |
883 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
884 | - if($echo){ |
|
885 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
883 | + function espresso_organization_pinterest($echo = TRUE) { |
|
884 | + if ($echo) { |
|
885 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
886 | 886 | return ''; |
887 | 887 | } |
888 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
888 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
889 | 889 | } |
890 | 890 | } |
891 | 891 | |
892 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
892 | +if ( ! function_exists('espresso_organization_google')) { |
|
893 | 893 | /** |
894 | 894 | * espresso_organization_google |
895 | 895 | * @param bool $echo |
896 | 896 | * @return string |
897 | 897 | */ |
898 | - function espresso_organization_google( $echo = TRUE ) { |
|
899 | - if($echo){ |
|
900 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
898 | + function espresso_organization_google($echo = TRUE) { |
|
899 | + if ($echo) { |
|
900 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
901 | 901 | return ''; |
902 | 902 | } |
903 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
903 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
904 | 904 | } |
905 | 905 | } |
906 | 906 | |
907 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
907 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
908 | 908 | /** |
909 | 909 | * espresso_organization_instagram |
910 | 910 | * @param bool $echo |
911 | 911 | * @return string |
912 | 912 | */ |
913 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
914 | - if($echo){ |
|
915 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
913 | + function espresso_organization_instagram($echo = TRUE) { |
|
914 | + if ($echo) { |
|
915 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
916 | 916 | return ''; |
917 | 917 | } |
918 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
918 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | |
926 | 926 | |
927 | 927 | |
928 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
928 | +if ( ! function_exists('espresso_event_venues')) { |
|
929 | 929 | /** |
930 | 930 | * espresso_event_venues |
931 | 931 | * |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | |
940 | 940 | |
941 | 941 | |
942 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
942 | +if ( ! function_exists('espresso_venue_id')) { |
|
943 | 943 | /** |
944 | 944 | * espresso_venue_name |
945 | 945 | * |
@@ -947,15 +947,15 @@ discard block |
||
947 | 947 | * @param int $EVT_ID |
948 | 948 | * @return string |
949 | 949 | */ |
950 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
951 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
950 | + function espresso_venue_id($EVT_ID = 0) { |
|
951 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
952 | 952 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
953 | 953 | } |
954 | 954 | } |
955 | 955 | |
956 | 956 | |
957 | 957 | |
958 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
958 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
959 | 959 | /** |
960 | 960 | * Return whether a venue is private or not. |
961 | 961 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -964,45 +964,45 @@ discard block |
||
964 | 964 | * |
965 | 965 | * @return bool | null |
966 | 966 | */ |
967 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
968 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
967 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
968 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
972 | 972 | |
973 | 973 | |
974 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
974 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
975 | 975 | /** |
976 | 976 | * returns true or false if a venue is password protected or not |
977 | 977 | * |
978 | 978 | * @param int $VNU_ID optional, the venue id to check. |
979 | 979 | * @return string |
980 | 980 | */ |
981 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
982 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
983 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
981 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
982 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
983 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
984 | 984 | } |
985 | 985 | } |
986 | 986 | |
987 | 987 | |
988 | 988 | |
989 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
989 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
990 | 990 | /** |
991 | 991 | * Returns a password form if venue is password protected. |
992 | 992 | * |
993 | 993 | * @param int $VNU_ID optional, the venue id to check. |
994 | 994 | * @return string |
995 | 995 | */ |
996 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
997 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
998 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
996 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
997 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
998 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
1003 | 1003 | |
1004 | 1004 | |
1005 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
1005 | +if ( ! function_exists('espresso_venue_name')) { |
|
1006 | 1006 | /** |
1007 | 1007 | * espresso_venue_name |
1008 | 1008 | * |
@@ -1012,19 +1012,19 @@ discard block |
||
1012 | 1012 | * @param bool $echo |
1013 | 1013 | * @return string |
1014 | 1014 | */ |
1015 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
1016 | - if($echo){ |
|
1017 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
1015 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
1016 | + if ($echo) { |
|
1017 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1018 | 1018 | return ''; |
1019 | 1019 | } |
1020 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
1020 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | |
1025 | 1025 | |
1026 | 1026 | |
1027 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
1027 | +if ( ! function_exists('espresso_venue_link')) { |
|
1028 | 1028 | /** |
1029 | 1029 | * espresso_venue_link |
1030 | 1030 | * |
@@ -1033,14 +1033,14 @@ discard block |
||
1033 | 1033 | * @param string $text |
1034 | 1034 | * @return string |
1035 | 1035 | */ |
1036 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
1037 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
1036 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
1037 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1038 | 1038 | } |
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | |
1043 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
1043 | +if ( ! function_exists('espresso_venue_description')) { |
|
1044 | 1044 | /** |
1045 | 1045 | * espresso_venue_description |
1046 | 1046 | * |
@@ -1049,17 +1049,17 @@ discard block |
||
1049 | 1049 | * @param bool $echo |
1050 | 1050 | * @return string |
1051 | 1051 | */ |
1052 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
1053 | - if($echo){ |
|
1054 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
1052 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
1053 | + if ($echo) { |
|
1054 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
1055 | 1055 | return ''; |
1056 | 1056 | } |
1057 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
1057 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
1058 | 1058 | } |
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | |
1062 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
1062 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
1063 | 1063 | /** |
1064 | 1064 | * espresso_venue_excerpt |
1065 | 1065 | * |
@@ -1068,18 +1068,18 @@ discard block |
||
1068 | 1068 | * @param bool $echo |
1069 | 1069 | * @return string |
1070 | 1070 | */ |
1071 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
1072 | - if ( $echo ) { |
|
1073 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
1071 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
1072 | + if ($echo) { |
|
1073 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1074 | 1074 | return ''; |
1075 | 1075 | } |
1076 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
1076 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1077 | 1077 | } |
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | |
1081 | 1081 | |
1082 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
1082 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1083 | 1083 | /** |
1084 | 1084 | * espresso_venue_categories |
1085 | 1085 | * returns the terms associated with a venue |
@@ -1089,17 +1089,17 @@ discard block |
||
1089 | 1089 | * @param bool $echo |
1090 | 1090 | * @return string |
1091 | 1091 | */ |
1092 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
1093 | - if ( $echo ) { |
|
1094 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1092 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
1093 | + if ($echo) { |
|
1094 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1095 | 1095 | return ''; |
1096 | 1096 | } |
1097 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1097 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1098 | 1098 | } |
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | |
1102 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
1102 | +if ( ! function_exists('espresso_venue_address')) { |
|
1103 | 1103 | /** |
1104 | 1104 | * espresso_venue_address |
1105 | 1105 | * returns a formatted block of html for displaying a venue's address |
@@ -1109,17 +1109,17 @@ discard block |
||
1109 | 1109 | * @param bool $echo |
1110 | 1110 | * @return string |
1111 | 1111 | */ |
1112 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1113 | - if ( $echo ) { |
|
1114 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1112 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1113 | + if ($echo) { |
|
1114 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1115 | 1115 | return ''; |
1116 | 1116 | } |
1117 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1117 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1118 | 1118 | } |
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | |
1122 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
1122 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1123 | 1123 | /** |
1124 | 1124 | * espresso_venue_address |
1125 | 1125 | * returns an UN-formatted string containing a venue's address |
@@ -1129,17 +1129,17 @@ discard block |
||
1129 | 1129 | * @param bool $echo |
1130 | 1130 | * @return string |
1131 | 1131 | */ |
1132 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1133 | - if ( $echo ) { |
|
1134 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1132 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1133 | + if ($echo) { |
|
1134 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1135 | 1135 | return ''; |
1136 | 1136 | } |
1137 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1137 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1138 | 1138 | } |
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | |
1142 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
1142 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1143 | 1143 | /** |
1144 | 1144 | * espresso_venue_has_address |
1145 | 1145 | * returns TRUE or FALSE if a Venue has address information |
@@ -1147,13 +1147,13 @@ discard block |
||
1147 | 1147 | * @param int $VNU_ID |
1148 | 1148 | * @return bool |
1149 | 1149 | */ |
1150 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
1151 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
1150 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
1151 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1152 | 1152 | } |
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | |
1156 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
1156 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1157 | 1157 | /** |
1158 | 1158 | * espresso_venue_gmap |
1159 | 1159 | * returns a google map for the venue address |
@@ -1164,17 +1164,17 @@ discard block |
||
1164 | 1164 | * @param bool $echo |
1165 | 1165 | * @return string |
1166 | 1166 | */ |
1167 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
1168 | - if ( $echo ) { |
|
1169 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1167 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
1168 | + if ($echo) { |
|
1169 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1170 | 1170 | return ''; |
1171 | 1171 | } |
1172 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1172 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1173 | 1173 | } |
1174 | 1174 | } |
1175 | 1175 | |
1176 | 1176 | |
1177 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
1177 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1178 | 1178 | /** |
1179 | 1179 | * espresso_venue_phone |
1180 | 1180 | * |
@@ -1182,18 +1182,18 @@ discard block |
||
1182 | 1182 | * @param bool $echo |
1183 | 1183 | * @return string |
1184 | 1184 | */ |
1185 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
1186 | - if ( $echo ) { |
|
1187 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1185 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
1186 | + if ($echo) { |
|
1187 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
1188 | 1188 | return ''; |
1189 | 1189 | } |
1190 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1190 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1191 | 1191 | } |
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | |
1195 | 1195 | |
1196 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
1196 | +if ( ! function_exists('espresso_venue_website')) { |
|
1197 | 1197 | /** |
1198 | 1198 | * espresso_venue_website |
1199 | 1199 | * |
@@ -1201,18 +1201,18 @@ discard block |
||
1201 | 1201 | * @param bool $echo |
1202 | 1202 | * @return string |
1203 | 1203 | */ |
1204 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
1205 | - if ( $echo ) { |
|
1206 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1204 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
1205 | + if ($echo) { |
|
1206 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
1207 | 1207 | return ''; |
1208 | 1208 | } |
1209 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1209 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1210 | 1210 | } |
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | |
1214 | 1214 | |
1215 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
1215 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1216 | 1216 | /** |
1217 | 1217 | * espresso_edit_venue_link |
1218 | 1218 | * |
@@ -1220,12 +1220,12 @@ discard block |
||
1220 | 1220 | * @param bool $echo |
1221 | 1221 | * @return string |
1222 | 1222 | */ |
1223 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
1224 | - if($echo){ |
|
1225 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1223 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
1224 | + if ($echo) { |
|
1225 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1226 | 1226 | return ''; |
1227 | 1227 | } |
1228 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1228 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1229 | 1229 | } |
1230 | 1230 | } |
1231 | 1231 |
@@ -15,69 +15,69 @@ |
||
15 | 15 | class DatetimeUpdate extends EntityMutator |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Defines the mutation data modification closure. |
|
20 | - * |
|
21 | - * @param EEM_Datetime $model |
|
22 | - * @param Datetime $type |
|
23 | - * @return callable |
|
24 | - */ |
|
25 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
26 | - { |
|
27 | - /** |
|
28 | - * Updates an entity. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | - try { |
|
39 | - /** @var EE_Datetime $entity */ |
|
40 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
18 | + /** |
|
19 | + * Defines the mutation data modification closure. |
|
20 | + * |
|
21 | + * @param EEM_Datetime $model |
|
22 | + * @param Datetime $type |
|
23 | + * @return callable |
|
24 | + */ |
|
25 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
26 | + { |
|
27 | + /** |
|
28 | + * Updates an entity. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | + try { |
|
39 | + /** @var EE_Datetime $entity */ |
|
40 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | 41 | |
42 | - $tickets = []; |
|
43 | - $args = DatetimeMutation::prepareFields($input); |
|
42 | + $tickets = []; |
|
43 | + $args = DatetimeMutation::prepareFields($input); |
|
44 | 44 | |
45 | - if (isset($args['tickets'])) { |
|
46 | - $tickets = $args['tickets']; |
|
47 | - unset($args['tickets']); |
|
48 | - } |
|
45 | + if (isset($args['tickets'])) { |
|
46 | + $tickets = $args['tickets']; |
|
47 | + unset($args['tickets']); |
|
48 | + } |
|
49 | 49 | |
50 | - $venue = 'NO_VENUE_SET'; |
|
51 | - if (array_key_exists('venue', $args)) { |
|
52 | - $venue = $args['venue']; |
|
53 | - unset($args['venue']); |
|
54 | - } |
|
50 | + $venue = 'NO_VENUE_SET'; |
|
51 | + if (array_key_exists('venue', $args)) { |
|
52 | + $venue = $args['venue']; |
|
53 | + unset($args['venue']); |
|
54 | + } |
|
55 | 55 | |
56 | - // Update the entity |
|
57 | - $entity->save($args); |
|
56 | + // Update the entity |
|
57 | + $entity->save($args); |
|
58 | 58 | |
59 | - if (! empty($tickets)) { |
|
60 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
61 | - } |
|
59 | + if (! empty($tickets)) { |
|
60 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
61 | + } |
|
62 | 62 | |
63 | - if ($venue !== 'NO_VENUE_SET') { |
|
64 | - DatetimeMutation::setVenue($entity, $venue); |
|
65 | - } |
|
63 | + if ($venue !== 'NO_VENUE_SET') { |
|
64 | + DatetimeMutation::setVenue($entity, $venue); |
|
65 | + } |
|
66 | 66 | |
67 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
68 | - } catch (Exception $exception) { |
|
69 | - EntityMutator::handleExceptions( |
|
70 | - $exception, |
|
71 | - esc_html__( |
|
72 | - 'The datetime could not be updated because of the following error(s)', |
|
73 | - 'event_espresso' |
|
74 | - ) |
|
75 | - ); |
|
76 | - } |
|
67 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
68 | + } catch (Exception $exception) { |
|
69 | + EntityMutator::handleExceptions( |
|
70 | + $exception, |
|
71 | + esc_html__( |
|
72 | + 'The datetime could not be updated because of the following error(s)', |
|
73 | + 'event_espresso' |
|
74 | + ) |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - return [ |
|
79 | - 'id' => $entity->ID(), |
|
80 | - ]; |
|
81 | - }; |
|
82 | - } |
|
78 | + return [ |
|
79 | + 'id' => $entity->ID(), |
|
80 | + ]; |
|
81 | + }; |
|
82 | + } |
|
83 | 83 | } |
@@ -14,73 +14,73 @@ |
||
14 | 14 | class EventUpdate extends EntityMutator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Defines the mutation data modification closure. |
|
19 | - * |
|
20 | - * @param EEM_Event $model |
|
21 | - * @param Event $type |
|
22 | - * @return callable |
|
23 | - */ |
|
24 | - public static function mutateFields(EEM_Event $model, Event $type) |
|
25 | - { |
|
26 | - /** |
|
27 | - * Update additional data related to the entity. |
|
28 | - * |
|
29 | - * @param int $id The ID of the postObject being mutated |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
32 | - * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
33 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - return static function ( |
|
38 | - int $id, |
|
39 | - array $input, |
|
40 | - WP_Post_Type $post_type_object, |
|
41 | - string $mutation_name, |
|
42 | - AppContext $context, |
|
43 | - ResolveInfo $info |
|
44 | - ) use ( |
|
45 | - $model, |
|
46 | - $type |
|
47 | - ) { |
|
48 | - try { |
|
49 | - // Make sure we are dealing with the right entity. |
|
50 | - if ( |
|
51 | - ! property_exists($post_type_object, 'graphql_single_name') |
|
52 | - || $post_type_object->graphql_single_name !== $type->name() |
|
53 | - ) { |
|
54 | - return; |
|
55 | - } |
|
17 | + /** |
|
18 | + * Defines the mutation data modification closure. |
|
19 | + * |
|
20 | + * @param EEM_Event $model |
|
21 | + * @param Event $type |
|
22 | + * @return callable |
|
23 | + */ |
|
24 | + public static function mutateFields(EEM_Event $model, Event $type) |
|
25 | + { |
|
26 | + /** |
|
27 | + * Update additional data related to the entity. |
|
28 | + * |
|
29 | + * @param int $id The ID of the postObject being mutated |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
32 | + * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
33 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + return static function ( |
|
38 | + int $id, |
|
39 | + array $input, |
|
40 | + WP_Post_Type $post_type_object, |
|
41 | + string $mutation_name, |
|
42 | + AppContext $context, |
|
43 | + ResolveInfo $info |
|
44 | + ) use ( |
|
45 | + $model, |
|
46 | + $type |
|
47 | + ) { |
|
48 | + try { |
|
49 | + // Make sure we are dealing with the right entity. |
|
50 | + if ( |
|
51 | + ! property_exists($post_type_object, 'graphql_single_name') |
|
52 | + || $post_type_object->graphql_single_name !== $type->name() |
|
53 | + ) { |
|
54 | + return; |
|
55 | + } |
|
56 | 56 | |
57 | - /** @var EE_Event $entity */ |
|
58 | - $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | - $args = EventMutation::prepareFields($input); |
|
57 | + /** @var EE_Event $entity */ |
|
58 | + $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | + $args = EventMutation::prepareFields($input); |
|
60 | 60 | |
61 | - $venue = 'NO_VENUE_SET'; |
|
62 | - if (array_key_exists('venue', $args)) { |
|
63 | - $venue = $args['venue']; |
|
64 | - unset($args['venue']); |
|
65 | - } |
|
61 | + $venue = 'NO_VENUE_SET'; |
|
62 | + if (array_key_exists('venue', $args)) { |
|
63 | + $venue = $args['venue']; |
|
64 | + unset($args['venue']); |
|
65 | + } |
|
66 | 66 | |
67 | - // Update the entity |
|
68 | - $entity->save($args); |
|
67 | + // Update the entity |
|
68 | + $entity->save($args); |
|
69 | 69 | |
70 | - if ($venue !== 'NO_VENUE_SET') { |
|
71 | - EventMutation::setEventVenue($entity, $venue); |
|
72 | - } |
|
70 | + if ($venue !== 'NO_VENUE_SET') { |
|
71 | + EventMutation::setEventVenue($entity, $venue); |
|
72 | + } |
|
73 | 73 | |
74 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
75 | - } catch (Exception $exception) { |
|
76 | - EntityMutator::handleExceptions( |
|
77 | - $exception, |
|
78 | - esc_html__( |
|
79 | - 'The event could not be updated because of the following error(s)', |
|
80 | - 'event_espresso' |
|
81 | - ) |
|
82 | - ); |
|
83 | - } |
|
84 | - }; |
|
85 | - } |
|
74 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
75 | + } catch (Exception $exception) { |
|
76 | + EntityMutator::handleExceptions( |
|
77 | + $exception, |
|
78 | + esc_html__( |
|
79 | + 'The event could not be updated because of the following error(s)', |
|
80 | + 'event_espresso' |
|
81 | + ) |
|
82 | + ); |
|
83 | + } |
|
84 | + }; |
|
85 | + } |
|
86 | 86 | } |
@@ -13,67 +13,67 @@ |
||
13 | 13 | class DatetimeCreate extends EntityMutator |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Defines the mutation data modification closure. |
|
18 | - * |
|
19 | - * @param EEM_Datetime $model |
|
20 | - * @param Datetime $type |
|
21 | - * @return callable |
|
22 | - */ |
|
23 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
24 | - { |
|
25 | - /** |
|
26 | - * Creates an entity. |
|
27 | - * |
|
28 | - * @param array $input The input for the mutation |
|
29 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | - $id = null; |
|
35 | - try { |
|
36 | - EntityMutator::checkPermissions($model); |
|
16 | + /** |
|
17 | + * Defines the mutation data modification closure. |
|
18 | + * |
|
19 | + * @param EEM_Datetime $model |
|
20 | + * @param Datetime $type |
|
21 | + * @return callable |
|
22 | + */ |
|
23 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
24 | + { |
|
25 | + /** |
|
26 | + * Creates an entity. |
|
27 | + * |
|
28 | + * @param array $input The input for the mutation |
|
29 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | + $id = null; |
|
35 | + try { |
|
36 | + EntityMutator::checkPermissions($model); |
|
37 | 37 | |
38 | - $tickets = []; |
|
39 | - $args = DatetimeMutation::prepareFields($input); |
|
38 | + $tickets = []; |
|
39 | + $args = DatetimeMutation::prepareFields($input); |
|
40 | 40 | |
41 | - if (isset($args['tickets'])) { |
|
42 | - $tickets = $args['tickets']; |
|
43 | - unset($args['tickets']); |
|
44 | - } |
|
41 | + if (isset($args['tickets'])) { |
|
42 | + $tickets = $args['tickets']; |
|
43 | + unset($args['tickets']); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - $venue = 'NO_VENUE_SET'; |
|
48 | - if (array_key_exists('venue', $args)) { |
|
49 | - $venue = $args['venue']; |
|
50 | - unset($args['venue']); |
|
51 | - } |
|
47 | + $venue = 'NO_VENUE_SET'; |
|
48 | + if (array_key_exists('venue', $args)) { |
|
49 | + $venue = $args['venue']; |
|
50 | + unset($args['venue']); |
|
51 | + } |
|
52 | 52 | |
53 | - $entity = EE_Datetime::new_instance($args); |
|
54 | - $id = $entity->save(); |
|
55 | - EntityMutator::validateResults($id); |
|
53 | + $entity = EE_Datetime::new_instance($args); |
|
54 | + $id = $entity->save(); |
|
55 | + EntityMutator::validateResults($id); |
|
56 | 56 | |
57 | - if (! empty($tickets)) { |
|
58 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
59 | - } |
|
57 | + if (! empty($tickets)) { |
|
58 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
59 | + } |
|
60 | 60 | |
61 | - if ($venue !== 'NO_VENUE_SET') { |
|
62 | - DatetimeMutation::setVenue($entity, $venue); |
|
63 | - } |
|
61 | + if ($venue !== 'NO_VENUE_SET') { |
|
62 | + DatetimeMutation::setVenue($entity, $venue); |
|
63 | + } |
|
64 | 64 | |
65 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input); |
|
66 | - } catch (Exception $exception) { |
|
67 | - EntityMutator::handleExceptions( |
|
68 | - $exception, |
|
69 | - esc_html__( |
|
70 | - 'The datetime could not be created because of the following error(s)', |
|
71 | - 'event_espresso' |
|
72 | - ) |
|
73 | - ); |
|
74 | - } |
|
65 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_create', $entity, $input); |
|
66 | + } catch (Exception $exception) { |
|
67 | + EntityMutator::handleExceptions( |
|
68 | + $exception, |
|
69 | + esc_html__( |
|
70 | + 'The datetime could not be created because of the following error(s)', |
|
71 | + 'event_espresso' |
|
72 | + ) |
|
73 | + ); |
|
74 | + } |
|
75 | 75 | |
76 | - return $id ? [ 'id' => $id ] : []; |
|
77 | - }; |
|
78 | - } |
|
76 | + return $id ? [ 'id' => $id ] : []; |
|
77 | + }; |
|
78 | + } |
|
79 | 79 | } |
@@ -38,423 +38,423 @@ |
||
38 | 38 | class Datetime extends TypeBase |
39 | 39 | { |
40 | 40 | |
41 | - /** |
|
42 | - * EventDate constructor. |
|
43 | - * |
|
44 | - * @param EEM_Datetime $datetime_model |
|
45 | - */ |
|
46 | - public function __construct(EEM_Datetime $datetime_model) |
|
47 | - { |
|
48 | - $this->setName($this->namespace . 'Datetime'); |
|
49 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
50 | - $this->setIsCustomPostType(false); |
|
51 | - parent::__construct($datetime_model); |
|
52 | - } |
|
41 | + /** |
|
42 | + * EventDate constructor. |
|
43 | + * |
|
44 | + * @param EEM_Datetime $datetime_model |
|
45 | + */ |
|
46 | + public function __construct(EEM_Datetime $datetime_model) |
|
47 | + { |
|
48 | + $this->setName($this->namespace . 'Datetime'); |
|
49 | + $this->setDescription(__('An event date', 'event_espresso')); |
|
50 | + $this->setIsCustomPostType(false); |
|
51 | + parent::__construct($datetime_model); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @return GraphQLFieldInterface[] |
|
57 | - */ |
|
58 | - public function getFields(): array |
|
59 | - { |
|
60 | - $fields = [ |
|
61 | - new GraphQLField( |
|
62 | - 'id', |
|
63 | - ['non_null' => 'ID'], |
|
64 | - null, |
|
65 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
66 | - ), |
|
67 | - new GraphQLOutputField( |
|
68 | - 'dbId', |
|
69 | - ['non_null' => 'Int'], |
|
70 | - 'ID', |
|
71 | - esc_html__('The datetime ID.', 'event_espresso') |
|
72 | - ), |
|
73 | - new GraphQLOutputField( |
|
74 | - 'cacheId', |
|
75 | - ['non_null' => 'String'], |
|
76 | - null, |
|
77 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
78 | - ), |
|
79 | - new GraphQLField( |
|
80 | - 'capacity', |
|
81 | - 'Int', |
|
82 | - 'reg_limit', |
|
83 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
84 | - [$this, 'parseInfiniteValue'] |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'description', |
|
88 | - 'String', |
|
89 | - 'description', |
|
90 | - esc_html__('Description for Datetime', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLField( |
|
93 | - 'endDate', |
|
94 | - 'String', |
|
95 | - 'end_date_and_time', |
|
96 | - esc_html__('End date and time of the Event', 'event_espresso'), |
|
97 | - [$this, 'formatDatetime'] |
|
98 | - ), |
|
99 | - new GraphQLOutputField( |
|
100 | - 'event', |
|
101 | - $this->namespace . 'Event', |
|
102 | - null, |
|
103 | - esc_html__('Event of the datetime.', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLInputField( |
|
106 | - 'event', |
|
107 | - 'ID', |
|
108 | - null, |
|
109 | - esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLInputField( |
|
112 | - 'eventId', |
|
113 | - 'Int', |
|
114 | - null, |
|
115 | - esc_html__('Event ID of the datetime.', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLOutputField( |
|
118 | - 'isActive', |
|
119 | - 'Boolean', |
|
120 | - 'is_active', |
|
121 | - esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLOutputField( |
|
124 | - 'isExpired', |
|
125 | - 'Boolean', |
|
126 | - 'is_expired', |
|
127 | - esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLField( |
|
130 | - 'isPrimary', |
|
131 | - 'Boolean', |
|
132 | - 'is_primary', |
|
133 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLOutputField( |
|
136 | - 'isSoldOut', |
|
137 | - 'Boolean', |
|
138 | - 'sold_out', |
|
139 | - esc_html__( |
|
140 | - 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
141 | - 'event_espresso' |
|
142 | - ) |
|
143 | - ), |
|
144 | - new GraphQLField( |
|
145 | - 'isTrashed', |
|
146 | - 'Boolean', |
|
147 | - null, |
|
148 | - esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
149 | - null, |
|
150 | - [$this, 'getIsTrashed'] |
|
151 | - ), |
|
152 | - new GraphQLOutputField( |
|
153 | - 'isUpcoming', |
|
154 | - 'Boolean', |
|
155 | - 'is_upcoming', |
|
156 | - esc_html__('Whether the date is upcoming', 'event_espresso') |
|
157 | - ), |
|
158 | - new GraphQLOutputField( |
|
159 | - 'length', |
|
160 | - 'Int', |
|
161 | - 'length', |
|
162 | - esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
163 | - ), |
|
164 | - new GraphQLField( |
|
165 | - 'name', |
|
166 | - 'String', |
|
167 | - 'name', |
|
168 | - esc_html__('Datetime Name', 'event_espresso') |
|
169 | - ), |
|
170 | - new GraphQLField( |
|
171 | - 'order', |
|
172 | - 'Int', |
|
173 | - 'order', |
|
174 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
175 | - ), |
|
176 | - new GraphQLOutputField( |
|
177 | - 'parent', |
|
178 | - $this->name(), |
|
179 | - null, |
|
180 | - esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
181 | - ), |
|
182 | - new GraphQLInputField( |
|
183 | - 'parent', |
|
184 | - 'ID', |
|
185 | - null, |
|
186 | - esc_html__('The parent datetime ID', 'event_espresso') |
|
187 | - ), |
|
188 | - new GraphQLField( |
|
189 | - 'reserved', |
|
190 | - 'Int', |
|
191 | - 'reserved', |
|
192 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
193 | - ), |
|
194 | - new GraphQLField( |
|
195 | - 'startDate', |
|
196 | - 'String', |
|
197 | - 'start_date_and_time', |
|
198 | - esc_html__('Start date and time of the Event', 'event_espresso'), |
|
199 | - [$this, 'formatDatetime'] |
|
200 | - ), |
|
201 | - new GraphQLField( |
|
202 | - 'sold', |
|
203 | - 'Int', |
|
204 | - 'sold', |
|
205 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
206 | - ), |
|
207 | - new GraphQLOutputField( |
|
208 | - 'status', |
|
209 | - $this->namespace . 'DatetimeStatusEnum', |
|
210 | - 'get_active_status', |
|
211 | - esc_html__('Datetime status', 'event_espresso') |
|
212 | - ), |
|
213 | - new GraphQLInputField( |
|
214 | - 'tickets', |
|
215 | - ['list_of' => 'ID'], |
|
216 | - null, |
|
217 | - sprintf( |
|
218 | - '%1$s %2$s', |
|
219 | - esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
220 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
221 | - ) |
|
222 | - ), |
|
223 | - new GraphQLField( |
|
224 | - 'venue', |
|
225 | - 'String', |
|
226 | - null, |
|
227 | - esc_html__('Datetime venue ID', 'event_espresso'), |
|
228 | - null, |
|
229 | - function (EE_Datetime $source) { |
|
230 | - $venue_ID = $source->venue_ID(); |
|
231 | - return $venue_ID |
|
232 | - // Since venue is a CPT, $type will be 'post' |
|
233 | - ? Relay::toGlobalId('post', $venue_ID) |
|
234 | - : null; |
|
235 | - } |
|
236 | - ), |
|
237 | - ]; |
|
55 | + /** |
|
56 | + * @return GraphQLFieldInterface[] |
|
57 | + */ |
|
58 | + public function getFields(): array |
|
59 | + { |
|
60 | + $fields = [ |
|
61 | + new GraphQLField( |
|
62 | + 'id', |
|
63 | + ['non_null' => 'ID'], |
|
64 | + null, |
|
65 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
66 | + ), |
|
67 | + new GraphQLOutputField( |
|
68 | + 'dbId', |
|
69 | + ['non_null' => 'Int'], |
|
70 | + 'ID', |
|
71 | + esc_html__('The datetime ID.', 'event_espresso') |
|
72 | + ), |
|
73 | + new GraphQLOutputField( |
|
74 | + 'cacheId', |
|
75 | + ['non_null' => 'String'], |
|
76 | + null, |
|
77 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
78 | + ), |
|
79 | + new GraphQLField( |
|
80 | + 'capacity', |
|
81 | + 'Int', |
|
82 | + 'reg_limit', |
|
83 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
84 | + [$this, 'parseInfiniteValue'] |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'description', |
|
88 | + 'String', |
|
89 | + 'description', |
|
90 | + esc_html__('Description for Datetime', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLField( |
|
93 | + 'endDate', |
|
94 | + 'String', |
|
95 | + 'end_date_and_time', |
|
96 | + esc_html__('End date and time of the Event', 'event_espresso'), |
|
97 | + [$this, 'formatDatetime'] |
|
98 | + ), |
|
99 | + new GraphQLOutputField( |
|
100 | + 'event', |
|
101 | + $this->namespace . 'Event', |
|
102 | + null, |
|
103 | + esc_html__('Event of the datetime.', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLInputField( |
|
106 | + 'event', |
|
107 | + 'ID', |
|
108 | + null, |
|
109 | + esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLInputField( |
|
112 | + 'eventId', |
|
113 | + 'Int', |
|
114 | + null, |
|
115 | + esc_html__('Event ID of the datetime.', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLOutputField( |
|
118 | + 'isActive', |
|
119 | + 'Boolean', |
|
120 | + 'is_active', |
|
121 | + esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLOutputField( |
|
124 | + 'isExpired', |
|
125 | + 'Boolean', |
|
126 | + 'is_expired', |
|
127 | + esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLField( |
|
130 | + 'isPrimary', |
|
131 | + 'Boolean', |
|
132 | + 'is_primary', |
|
133 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLOutputField( |
|
136 | + 'isSoldOut', |
|
137 | + 'Boolean', |
|
138 | + 'sold_out', |
|
139 | + esc_html__( |
|
140 | + 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
141 | + 'event_espresso' |
|
142 | + ) |
|
143 | + ), |
|
144 | + new GraphQLField( |
|
145 | + 'isTrashed', |
|
146 | + 'Boolean', |
|
147 | + null, |
|
148 | + esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
149 | + null, |
|
150 | + [$this, 'getIsTrashed'] |
|
151 | + ), |
|
152 | + new GraphQLOutputField( |
|
153 | + 'isUpcoming', |
|
154 | + 'Boolean', |
|
155 | + 'is_upcoming', |
|
156 | + esc_html__('Whether the date is upcoming', 'event_espresso') |
|
157 | + ), |
|
158 | + new GraphQLOutputField( |
|
159 | + 'length', |
|
160 | + 'Int', |
|
161 | + 'length', |
|
162 | + esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
163 | + ), |
|
164 | + new GraphQLField( |
|
165 | + 'name', |
|
166 | + 'String', |
|
167 | + 'name', |
|
168 | + esc_html__('Datetime Name', 'event_espresso') |
|
169 | + ), |
|
170 | + new GraphQLField( |
|
171 | + 'order', |
|
172 | + 'Int', |
|
173 | + 'order', |
|
174 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
175 | + ), |
|
176 | + new GraphQLOutputField( |
|
177 | + 'parent', |
|
178 | + $this->name(), |
|
179 | + null, |
|
180 | + esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
181 | + ), |
|
182 | + new GraphQLInputField( |
|
183 | + 'parent', |
|
184 | + 'ID', |
|
185 | + null, |
|
186 | + esc_html__('The parent datetime ID', 'event_espresso') |
|
187 | + ), |
|
188 | + new GraphQLField( |
|
189 | + 'reserved', |
|
190 | + 'Int', |
|
191 | + 'reserved', |
|
192 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
193 | + ), |
|
194 | + new GraphQLField( |
|
195 | + 'startDate', |
|
196 | + 'String', |
|
197 | + 'start_date_and_time', |
|
198 | + esc_html__('Start date and time of the Event', 'event_espresso'), |
|
199 | + [$this, 'formatDatetime'] |
|
200 | + ), |
|
201 | + new GraphQLField( |
|
202 | + 'sold', |
|
203 | + 'Int', |
|
204 | + 'sold', |
|
205 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
206 | + ), |
|
207 | + new GraphQLOutputField( |
|
208 | + 'status', |
|
209 | + $this->namespace . 'DatetimeStatusEnum', |
|
210 | + 'get_active_status', |
|
211 | + esc_html__('Datetime status', 'event_espresso') |
|
212 | + ), |
|
213 | + new GraphQLInputField( |
|
214 | + 'tickets', |
|
215 | + ['list_of' => 'ID'], |
|
216 | + null, |
|
217 | + sprintf( |
|
218 | + '%1$s %2$s', |
|
219 | + esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
220 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
221 | + ) |
|
222 | + ), |
|
223 | + new GraphQLField( |
|
224 | + 'venue', |
|
225 | + 'String', |
|
226 | + null, |
|
227 | + esc_html__('Datetime venue ID', 'event_espresso'), |
|
228 | + null, |
|
229 | + function (EE_Datetime $source) { |
|
230 | + $venue_ID = $source->venue_ID(); |
|
231 | + return $venue_ID |
|
232 | + // Since venue is a CPT, $type will be 'post' |
|
233 | + ? Relay::toGlobalId('post', $venue_ID) |
|
234 | + : null; |
|
235 | + } |
|
236 | + ), |
|
237 | + ]; |
|
238 | 238 | |
239 | - return apply_filters( |
|
240 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__datetime_fields', |
|
241 | - $fields, |
|
242 | - $this->name, |
|
243 | - $this->model |
|
244 | - ); |
|
245 | - } |
|
239 | + return apply_filters( |
|
240 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__datetime_fields', |
|
241 | + $fields, |
|
242 | + $this->name, |
|
243 | + $this->model |
|
244 | + ); |
|
245 | + } |
|
246 | 246 | |
247 | 247 | |
248 | - /** |
|
249 | - * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
250 | - * @param array $args The inputArgs on the field |
|
251 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
252 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
253 | - * @return bool |
|
254 | - * @throws Exception |
|
255 | - * @throws InvalidArgumentException |
|
256 | - * @throws InvalidDataTypeException |
|
257 | - * @throws InvalidInterfaceException |
|
258 | - * @throws ReflectionException |
|
259 | - * @throws UserError |
|
260 | - * @throws UnexpectedEntityException |
|
261 | - */ |
|
262 | - public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
263 | - { |
|
264 | - return (bool) $source->get('DTT_deleted'); |
|
265 | - } |
|
248 | + /** |
|
249 | + * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
250 | + * @param array $args The inputArgs on the field |
|
251 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
252 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
253 | + * @return bool |
|
254 | + * @throws Exception |
|
255 | + * @throws InvalidArgumentException |
|
256 | + * @throws InvalidDataTypeException |
|
257 | + * @throws InvalidInterfaceException |
|
258 | + * @throws ReflectionException |
|
259 | + * @throws UserError |
|
260 | + * @throws UnexpectedEntityException |
|
261 | + */ |
|
262 | + public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
263 | + { |
|
264 | + return (bool) $source->get('DTT_deleted'); |
|
265 | + } |
|
266 | 266 | |
267 | - /** |
|
268 | - * Return the base mutation config for bulk update. |
|
269 | - * |
|
270 | - * @param string $base_input |
|
271 | - * @return array |
|
272 | - */ |
|
273 | - public static function bulkUpdateBaseConfig(string $base_input): array |
|
274 | - { |
|
275 | - return [ |
|
276 | - 'inputFields' => [ |
|
277 | - /** |
|
278 | - * represents the input that is unique for each entity |
|
279 | - * e.g. dates may be unique for datetimes and tickets |
|
280 | - */ |
|
281 | - 'uniqueInputs' => [ |
|
282 | - 'type' => [ |
|
283 | - 'non_null' => ['list_of' => $base_input], |
|
284 | - ], |
|
285 | - 'description' => esc_html__( |
|
286 | - 'List of unique inputs for each entity in bulk update', |
|
287 | - 'event_espresso' |
|
288 | - ), |
|
289 | - ], |
|
290 | - /** |
|
291 | - * represents the common input for all entities |
|
292 | - * e.g. capacity or quantity may be same for all dates/tickets |
|
293 | - */ |
|
294 | - 'sharedInput' => [ |
|
295 | - 'type' => $base_input, |
|
296 | - 'description' => esc_html__( |
|
297 | - 'Shared input for all entities in bulk update', |
|
298 | - 'event_espresso' |
|
299 | - ), |
|
300 | - ], |
|
301 | - ], |
|
302 | - 'outputFields' => [ |
|
303 | - 'updated' => [ |
|
304 | - 'type' => ['list_of' => 'ID'], |
|
305 | - ], |
|
306 | - 'failed' => [ |
|
307 | - 'type' => ['list_of' => 'ID'], |
|
308 | - ], |
|
309 | - ], |
|
310 | - ]; |
|
311 | - } |
|
267 | + /** |
|
268 | + * Return the base mutation config for bulk update. |
|
269 | + * |
|
270 | + * @param string $base_input |
|
271 | + * @return array |
|
272 | + */ |
|
273 | + public static function bulkUpdateBaseConfig(string $base_input): array |
|
274 | + { |
|
275 | + return [ |
|
276 | + 'inputFields' => [ |
|
277 | + /** |
|
278 | + * represents the input that is unique for each entity |
|
279 | + * e.g. dates may be unique for datetimes and tickets |
|
280 | + */ |
|
281 | + 'uniqueInputs' => [ |
|
282 | + 'type' => [ |
|
283 | + 'non_null' => ['list_of' => $base_input], |
|
284 | + ], |
|
285 | + 'description' => esc_html__( |
|
286 | + 'List of unique inputs for each entity in bulk update', |
|
287 | + 'event_espresso' |
|
288 | + ), |
|
289 | + ], |
|
290 | + /** |
|
291 | + * represents the common input for all entities |
|
292 | + * e.g. capacity or quantity may be same for all dates/tickets |
|
293 | + */ |
|
294 | + 'sharedInput' => [ |
|
295 | + 'type' => $base_input, |
|
296 | + 'description' => esc_html__( |
|
297 | + 'Shared input for all entities in bulk update', |
|
298 | + 'event_espresso' |
|
299 | + ), |
|
300 | + ], |
|
301 | + ], |
|
302 | + 'outputFields' => [ |
|
303 | + 'updated' => [ |
|
304 | + 'type' => ['list_of' => 'ID'], |
|
305 | + ], |
|
306 | + 'failed' => [ |
|
307 | + 'type' => ['list_of' => 'ID'], |
|
308 | + ], |
|
309 | + ], |
|
310 | + ]; |
|
311 | + } |
|
312 | 312 | |
313 | 313 | |
314 | - /** |
|
315 | - * @param array $inputFields The mutation input fields. |
|
316 | - * @throws InvalidArgumentException |
|
317 | - * @throws ReflectionException |
|
318 | - * @throws Exception |
|
319 | - */ |
|
320 | - public function registerMutations(array $inputFields) |
|
321 | - { |
|
322 | - register_graphql_input_type( |
|
323 | - 'Update' . $this->name() . 'BaseInput', |
|
324 | - [ |
|
325 | - 'fields' => $inputFields, |
|
326 | - ] |
|
327 | - ); |
|
328 | - // Register mutation to update an entity. |
|
329 | - register_graphql_mutation( |
|
330 | - 'update' . $this->name(), |
|
331 | - [ |
|
332 | - 'inputFields' => $inputFields, |
|
333 | - 'outputFields' => [ |
|
334 | - lcfirst($this->name()) => [ |
|
335 | - 'type' => $this->name(), |
|
336 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
337 | - ], |
|
338 | - ], |
|
339 | - 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
340 | - ] |
|
341 | - ); |
|
342 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
343 | - // Register mutation to update an entity. |
|
344 | - register_graphql_mutation( |
|
345 | - 'bulkUpdate' . $this->name(), |
|
346 | - array_merge( |
|
347 | - Datetime::bulkUpdateBaseConfig($base_input), |
|
348 | - [ |
|
349 | - 'mutateAndGetPayload' => DatetimeBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
350 | - ] |
|
351 | - ) |
|
352 | - ); |
|
314 | + /** |
|
315 | + * @param array $inputFields The mutation input fields. |
|
316 | + * @throws InvalidArgumentException |
|
317 | + * @throws ReflectionException |
|
318 | + * @throws Exception |
|
319 | + */ |
|
320 | + public function registerMutations(array $inputFields) |
|
321 | + { |
|
322 | + register_graphql_input_type( |
|
323 | + 'Update' . $this->name() . 'BaseInput', |
|
324 | + [ |
|
325 | + 'fields' => $inputFields, |
|
326 | + ] |
|
327 | + ); |
|
328 | + // Register mutation to update an entity. |
|
329 | + register_graphql_mutation( |
|
330 | + 'update' . $this->name(), |
|
331 | + [ |
|
332 | + 'inputFields' => $inputFields, |
|
333 | + 'outputFields' => [ |
|
334 | + lcfirst($this->name()) => [ |
|
335 | + 'type' => $this->name(), |
|
336 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
337 | + ], |
|
338 | + ], |
|
339 | + 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
340 | + ] |
|
341 | + ); |
|
342 | + $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
343 | + // Register mutation to update an entity. |
|
344 | + register_graphql_mutation( |
|
345 | + 'bulkUpdate' . $this->name(), |
|
346 | + array_merge( |
|
347 | + Datetime::bulkUpdateBaseConfig($base_input), |
|
348 | + [ |
|
349 | + 'mutateAndGetPayload' => DatetimeBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
350 | + ] |
|
351 | + ) |
|
352 | + ); |
|
353 | 353 | |
354 | - // Register mutation to update an entity. |
|
355 | - register_graphql_mutation( |
|
356 | - 'bulkDelete' . $this->namespace . 'Entities', |
|
357 | - [ |
|
358 | - 'inputFields' => [ |
|
359 | - 'entityIds' => [ |
|
360 | - 'type' => [ |
|
361 | - 'non_null' => ['list_of' => 'ID'], |
|
362 | - ], |
|
363 | - 'description' => esc_html__('The list of GUIDs of the entities to be deleted.', 'event_espresso'), |
|
364 | - ], |
|
365 | - 'entityType' => [ |
|
366 | - 'type' => [ |
|
367 | - 'non_null' => $this->namespace . 'ModelNameEnum', |
|
368 | - ], |
|
369 | - 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
|
370 | - ], |
|
371 | - 'deletePermanently' => [ |
|
372 | - 'type' => 'Boolean', |
|
373 | - 'description' => esc_html__('Whether to delete the entities permanently.', 'event_espresso'), |
|
374 | - ], |
|
375 | - ], |
|
376 | - 'outputFields' => [ |
|
377 | - 'deleted' => [ |
|
378 | - 'type' => ['list_of' => 'ID'], |
|
379 | - ], |
|
380 | - 'failed' => [ |
|
381 | - 'type' => ['list_of' => 'ID'], |
|
382 | - ], |
|
383 | - ], |
|
384 | - 'mutateAndGetPayload' => BulkEntityDelete::mutateAndGetPayload(), |
|
385 | - ] |
|
386 | - ); |
|
387 | - // Register mutation to delete an entity. |
|
388 | - register_graphql_mutation( |
|
389 | - 'delete' . $this->name(), |
|
390 | - [ |
|
391 | - 'inputFields' => [ |
|
392 | - 'id' => $inputFields['id'], |
|
393 | - 'deletePermanently' => [ |
|
394 | - 'type' => 'Boolean', |
|
395 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
396 | - ], |
|
397 | - ], |
|
398 | - 'outputFields' => [ |
|
399 | - lcfirst($this->name()) => [ |
|
400 | - 'type' => $this->name(), |
|
401 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
402 | - 'resolve' => static function ($payload) { |
|
403 | - $deleted = (object) $payload['deleted']; |
|
354 | + // Register mutation to update an entity. |
|
355 | + register_graphql_mutation( |
|
356 | + 'bulkDelete' . $this->namespace . 'Entities', |
|
357 | + [ |
|
358 | + 'inputFields' => [ |
|
359 | + 'entityIds' => [ |
|
360 | + 'type' => [ |
|
361 | + 'non_null' => ['list_of' => 'ID'], |
|
362 | + ], |
|
363 | + 'description' => esc_html__('The list of GUIDs of the entities to be deleted.', 'event_espresso'), |
|
364 | + ], |
|
365 | + 'entityType' => [ |
|
366 | + 'type' => [ |
|
367 | + 'non_null' => $this->namespace . 'ModelNameEnum', |
|
368 | + ], |
|
369 | + 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
|
370 | + ], |
|
371 | + 'deletePermanently' => [ |
|
372 | + 'type' => 'Boolean', |
|
373 | + 'description' => esc_html__('Whether to delete the entities permanently.', 'event_espresso'), |
|
374 | + ], |
|
375 | + ], |
|
376 | + 'outputFields' => [ |
|
377 | + 'deleted' => [ |
|
378 | + 'type' => ['list_of' => 'ID'], |
|
379 | + ], |
|
380 | + 'failed' => [ |
|
381 | + 'type' => ['list_of' => 'ID'], |
|
382 | + ], |
|
383 | + ], |
|
384 | + 'mutateAndGetPayload' => BulkEntityDelete::mutateAndGetPayload(), |
|
385 | + ] |
|
386 | + ); |
|
387 | + // Register mutation to delete an entity. |
|
388 | + register_graphql_mutation( |
|
389 | + 'delete' . $this->name(), |
|
390 | + [ |
|
391 | + 'inputFields' => [ |
|
392 | + 'id' => $inputFields['id'], |
|
393 | + 'deletePermanently' => [ |
|
394 | + 'type' => 'Boolean', |
|
395 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
396 | + ], |
|
397 | + ], |
|
398 | + 'outputFields' => [ |
|
399 | + lcfirst($this->name()) => [ |
|
400 | + 'type' => $this->name(), |
|
401 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
402 | + 'resolve' => static function ($payload) { |
|
403 | + $deleted = (object) $payload['deleted']; |
|
404 | 404 | |
405 | - return ! empty($deleted) ? $deleted : null; |
|
406 | - }, |
|
407 | - ], |
|
408 | - ], |
|
409 | - 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
410 | - ] |
|
411 | - ); |
|
405 | + return ! empty($deleted) ? $deleted : null; |
|
406 | + }, |
|
407 | + ], |
|
408 | + ], |
|
409 | + 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
410 | + ] |
|
411 | + ); |
|
412 | 412 | |
413 | - // remove primary key from input. |
|
414 | - unset($inputFields['id']); |
|
415 | - // Register mutation to update an entity. |
|
416 | - register_graphql_mutation( |
|
417 | - 'create' . $this->name(), |
|
418 | - [ |
|
419 | - 'inputFields' => $inputFields, |
|
420 | - 'outputFields' => [ |
|
421 | - lcfirst($this->name()) => [ |
|
422 | - 'type' => $this->name(), |
|
423 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
424 | - ], |
|
425 | - ], |
|
426 | - 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
427 | - ] |
|
428 | - ); |
|
413 | + // remove primary key from input. |
|
414 | + unset($inputFields['id']); |
|
415 | + // Register mutation to update an entity. |
|
416 | + register_graphql_mutation( |
|
417 | + 'create' . $this->name(), |
|
418 | + [ |
|
419 | + 'inputFields' => $inputFields, |
|
420 | + 'outputFields' => [ |
|
421 | + lcfirst($this->name()) => [ |
|
422 | + 'type' => $this->name(), |
|
423 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
424 | + ], |
|
425 | + ], |
|
426 | + 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
427 | + ] |
|
428 | + ); |
|
429 | 429 | |
430 | - // Register mutation to update an entity. |
|
431 | - register_graphql_mutation( |
|
432 | - 'reorder' . $this->namespace . 'Entities', |
|
433 | - [ |
|
434 | - 'inputFields' => [ |
|
435 | - 'entityIds' => [ |
|
436 | - 'type' => [ |
|
437 | - 'non_null' => ['list_of' => 'ID'], |
|
438 | - ], |
|
439 | - 'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'), |
|
440 | - ], |
|
441 | - 'entityType' => [ |
|
442 | - 'type' => [ |
|
443 | - 'non_null' => $this->namespace . 'ModelNameEnum', |
|
444 | - ], |
|
445 | - 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
|
446 | - ], |
|
447 | - ], |
|
448 | - 'outputFields' => [ |
|
449 | - 'ok' => [ |
|
450 | - 'type' => 'Boolean', |
|
451 | - 'resolve' => function ($payload) { |
|
452 | - return (bool) $payload['ok']; |
|
453 | - }, |
|
454 | - ], |
|
455 | - ], |
|
456 | - 'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(), |
|
457 | - ] |
|
458 | - ); |
|
459 | - } |
|
430 | + // Register mutation to update an entity. |
|
431 | + register_graphql_mutation( |
|
432 | + 'reorder' . $this->namespace . 'Entities', |
|
433 | + [ |
|
434 | + 'inputFields' => [ |
|
435 | + 'entityIds' => [ |
|
436 | + 'type' => [ |
|
437 | + 'non_null' => ['list_of' => 'ID'], |
|
438 | + ], |
|
439 | + 'description' => esc_html__('The reordered list of entity GUIDs.', 'event_espresso'), |
|
440 | + ], |
|
441 | + 'entityType' => [ |
|
442 | + 'type' => [ |
|
443 | + 'non_null' => $this->namespace . 'ModelNameEnum', |
|
444 | + ], |
|
445 | + 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
|
446 | + ], |
|
447 | + ], |
|
448 | + 'outputFields' => [ |
|
449 | + 'ok' => [ |
|
450 | + 'type' => 'Boolean', |
|
451 | + 'resolve' => function ($payload) { |
|
452 | + return (bool) $payload['ok']; |
|
453 | + }, |
|
454 | + ], |
|
455 | + ], |
|
456 | + 'mutateAndGetPayload' => EntityReorder::mutateAndGetPayload(), |
|
457 | + ] |
|
458 | + ); |
|
459 | + } |
|
460 | 460 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function __construct(EEM_Datetime $datetime_model) |
47 | 47 | { |
48 | - $this->setName($this->namespace . 'Datetime'); |
|
48 | + $this->setName($this->namespace.'Datetime'); |
|
49 | 49 | $this->setDescription(__('An event date', 'event_espresso')); |
50 | 50 | $this->setIsCustomPostType(false); |
51 | 51 | parent::__construct($datetime_model); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | ), |
99 | 99 | new GraphQLOutputField( |
100 | 100 | 'event', |
101 | - $this->namespace . 'Event', |
|
101 | + $this->namespace.'Event', |
|
102 | 102 | null, |
103 | 103 | esc_html__('Event of the datetime.', 'event_espresso') |
104 | 104 | ), |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | ), |
207 | 207 | new GraphQLOutputField( |
208 | 208 | 'status', |
209 | - $this->namespace . 'DatetimeStatusEnum', |
|
209 | + $this->namespace.'DatetimeStatusEnum', |
|
210 | 210 | 'get_active_status', |
211 | 211 | esc_html__('Datetime status', 'event_espresso') |
212 | 212 | ), |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | null, |
227 | 227 | esc_html__('Datetime venue ID', 'event_espresso'), |
228 | 228 | null, |
229 | - function (EE_Datetime $source) { |
|
229 | + function(EE_Datetime $source) { |
|
230 | 230 | $venue_ID = $source->venue_ID(); |
231 | 231 | return $venue_ID |
232 | 232 | // Since venue is a CPT, $type will be 'post' |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | public function registerMutations(array $inputFields) |
321 | 321 | { |
322 | 322 | register_graphql_input_type( |
323 | - 'Update' . $this->name() . 'BaseInput', |
|
323 | + 'Update'.$this->name().'BaseInput', |
|
324 | 324 | [ |
325 | 325 | 'fields' => $inputFields, |
326 | 326 | ] |
327 | 327 | ); |
328 | 328 | // Register mutation to update an entity. |
329 | 329 | register_graphql_mutation( |
330 | - 'update' . $this->name(), |
|
330 | + 'update'.$this->name(), |
|
331 | 331 | [ |
332 | 332 | 'inputFields' => $inputFields, |
333 | 333 | 'outputFields' => [ |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
340 | 340 | ] |
341 | 341 | ); |
342 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
342 | + $base_input = 'Update'.$this->name().'BaseInput'; |
|
343 | 343 | // Register mutation to update an entity. |
344 | 344 | register_graphql_mutation( |
345 | - 'bulkUpdate' . $this->name(), |
|
345 | + 'bulkUpdate'.$this->name(), |
|
346 | 346 | array_merge( |
347 | 347 | Datetime::bulkUpdateBaseConfig($base_input), |
348 | 348 | [ |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | |
354 | 354 | // Register mutation to update an entity. |
355 | 355 | register_graphql_mutation( |
356 | - 'bulkDelete' . $this->namespace . 'Entities', |
|
356 | + 'bulkDelete'.$this->namespace.'Entities', |
|
357 | 357 | [ |
358 | 358 | 'inputFields' => [ |
359 | 359 | 'entityIds' => [ |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ], |
365 | 365 | 'entityType' => [ |
366 | 366 | 'type' => [ |
367 | - 'non_null' => $this->namespace . 'ModelNameEnum', |
|
367 | + 'non_null' => $this->namespace.'ModelNameEnum', |
|
368 | 368 | ], |
369 | 369 | 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
370 | 370 | ], |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | ); |
387 | 387 | // Register mutation to delete an entity. |
388 | 388 | register_graphql_mutation( |
389 | - 'delete' . $this->name(), |
|
389 | + 'delete'.$this->name(), |
|
390 | 390 | [ |
391 | 391 | 'inputFields' => [ |
392 | 392 | 'id' => $inputFields['id'], |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | lcfirst($this->name()) => [ |
400 | 400 | 'type' => $this->name(), |
401 | 401 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
402 | - 'resolve' => static function ($payload) { |
|
402 | + 'resolve' => static function($payload) { |
|
403 | 403 | $deleted = (object) $payload['deleted']; |
404 | 404 | |
405 | 405 | return ! empty($deleted) ? $deleted : null; |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | unset($inputFields['id']); |
415 | 415 | // Register mutation to update an entity. |
416 | 416 | register_graphql_mutation( |
417 | - 'create' . $this->name(), |
|
417 | + 'create'.$this->name(), |
|
418 | 418 | [ |
419 | 419 | 'inputFields' => $inputFields, |
420 | 420 | 'outputFields' => [ |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | |
430 | 430 | // Register mutation to update an entity. |
431 | 431 | register_graphql_mutation( |
432 | - 'reorder' . $this->namespace . 'Entities', |
|
432 | + 'reorder'.$this->namespace.'Entities', |
|
433 | 433 | [ |
434 | 434 | 'inputFields' => [ |
435 | 435 | 'entityIds' => [ |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | ], |
441 | 441 | 'entityType' => [ |
442 | 442 | 'type' => [ |
443 | - 'non_null' => $this->namespace . 'ModelNameEnum', |
|
443 | + 'non_null' => $this->namespace.'ModelNameEnum', |
|
444 | 444 | ], |
445 | 445 | 'description' => esc_html__('The entity type for the IDs', 'event_espresso'), |
446 | 446 | ], |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | 'outputFields' => [ |
449 | 449 | 'ok' => [ |
450 | 450 | 'type' => 'Boolean', |
451 | - 'resolve' => function ($payload) { |
|
451 | + 'resolve' => function($payload) { |
|
452 | 452 | return (bool) $payload['ok']; |
453 | 453 | }, |
454 | 454 | ], |
@@ -21,133 +21,133 @@ |
||
21 | 21 | class DatetimeMutation |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Maps the GraphQL input to a format that the model functions can use |
|
26 | - * |
|
27 | - * @param array $input Data coming from the GraphQL mutation query input |
|
28 | - * @return array |
|
29 | - * @throws Exception |
|
30 | - */ |
|
31 | - public static function prepareFields(array $input): array |
|
32 | - { |
|
33 | - $args = []; |
|
34 | - |
|
35 | - if (array_key_exists('capacity', $input)) { |
|
36 | - $args['DTT_reg_limit'] = (int) $input['capacity']; |
|
37 | - } |
|
38 | - |
|
39 | - if (isset($input['description'])) { |
|
40 | - $args['DTT_description'] = wp_kses_post($input['description']); |
|
41 | - } |
|
42 | - |
|
43 | - if (! empty($input['endDate'])) { |
|
44 | - $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
45 | - } |
|
46 | - |
|
47 | - if (! empty($input['eventId'])) { |
|
48 | - $args['EVT_ID'] = absint($input['eventId']); |
|
49 | - } elseif (! empty($input['event'])) { |
|
50 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['event'])); |
|
51 | - $args['EVT_ID'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
52 | - } |
|
53 | - |
|
54 | - if (array_key_exists('isPrimary', $input)) { |
|
55 | - $args['DTT_is_primary'] = (bool) $input['isPrimary']; |
|
56 | - } |
|
57 | - |
|
58 | - if (array_key_exists('isTrashed', $input)) { |
|
59 | - $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
60 | - } |
|
61 | - |
|
62 | - if (isset($input['name'])) { |
|
63 | - $args['DTT_name'] = sanitize_text_field($input['name']); |
|
64 | - } |
|
65 | - |
|
66 | - if (array_key_exists('order', $input)) { |
|
67 | - $args['DTT_order'] = (int) $input['order']; |
|
68 | - } |
|
69 | - |
|
70 | - if (! empty($input['parent'])) { |
|
71 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
72 | - $args['DTT_parent'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
73 | - } |
|
74 | - |
|
75 | - if (array_key_exists('reserved', $input)) { |
|
76 | - $args['DTT_reserved'] = (int) $input['reserved']; |
|
77 | - } |
|
78 | - |
|
79 | - if (array_key_exists('sold', $input)) { |
|
80 | - $args['DTT_sold'] = (int) $input['sold']; |
|
81 | - } |
|
82 | - |
|
83 | - if (! empty($input['startDate'])) { |
|
84 | - $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
85 | - } |
|
86 | - |
|
87 | - if (! empty($input['tickets'])) { |
|
88 | - $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
89 | - } |
|
90 | - |
|
91 | - if (array_key_exists('venue', $input)) { |
|
92 | - $venue_id = sanitize_text_field($input['venue']); |
|
93 | - $parts = Relay::fromGlobalId($venue_id); |
|
94 | - $args['venue'] = ! empty($parts['id']) ? $parts['id'] : $venue_id; |
|
95 | - } |
|
96 | - |
|
97 | - return apply_filters( |
|
98 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__datetime_args', |
|
99 | - $args, |
|
100 | - $input |
|
101 | - ); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * Sets the related tickets for the given datetime. |
|
107 | - * |
|
108 | - * @param EE_Datetime $entity The datetime instance. |
|
109 | - * @param array $tickets Array of ticket IDs to relate. |
|
110 | - * @throws EE_Error |
|
111 | - * @throws InvalidDataTypeException |
|
112 | - * @throws InvalidInterfaceException |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws ReflectionException |
|
115 | - */ |
|
116 | - public static function setRelatedTickets(EE_Datetime $entity, array $tickets) |
|
117 | - { |
|
118 | - $relationName = 'Ticket'; |
|
119 | - // Remove all the existing related tickets |
|
120 | - $entity->_remove_relations($relationName); |
|
121 | - |
|
122 | - foreach ($tickets as $ID) { |
|
123 | - $parts = Relay::fromGlobalId($ID); |
|
124 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
125 | - $entity->_add_relation_to( |
|
126 | - $parts['id'], |
|
127 | - $relationName |
|
128 | - ); |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * Sets the venue for the datetime. |
|
136 | - * |
|
137 | - * @param EE_Datetime $entity The datetime instance. |
|
138 | - * @param int $venue The venue ID |
|
139 | - * @throws EE_Error |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidInterfaceException |
|
142 | - * @throws InvalidArgumentException |
|
143 | - * @throws ReflectionException |
|
144 | - */ |
|
145 | - public static function setVenue(EE_Datetime $entity, int $venue) |
|
146 | - { |
|
147 | - if (empty($venue)) { |
|
148 | - $entity->remove_venue($venue); |
|
149 | - } else { |
|
150 | - $entity->add_venue($venue); |
|
151 | - } |
|
152 | - } |
|
24 | + /** |
|
25 | + * Maps the GraphQL input to a format that the model functions can use |
|
26 | + * |
|
27 | + * @param array $input Data coming from the GraphQL mutation query input |
|
28 | + * @return array |
|
29 | + * @throws Exception |
|
30 | + */ |
|
31 | + public static function prepareFields(array $input): array |
|
32 | + { |
|
33 | + $args = []; |
|
34 | + |
|
35 | + if (array_key_exists('capacity', $input)) { |
|
36 | + $args['DTT_reg_limit'] = (int) $input['capacity']; |
|
37 | + } |
|
38 | + |
|
39 | + if (isset($input['description'])) { |
|
40 | + $args['DTT_description'] = wp_kses_post($input['description']); |
|
41 | + } |
|
42 | + |
|
43 | + if (! empty($input['endDate'])) { |
|
44 | + $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
45 | + } |
|
46 | + |
|
47 | + if (! empty($input['eventId'])) { |
|
48 | + $args['EVT_ID'] = absint($input['eventId']); |
|
49 | + } elseif (! empty($input['event'])) { |
|
50 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['event'])); |
|
51 | + $args['EVT_ID'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
52 | + } |
|
53 | + |
|
54 | + if (array_key_exists('isPrimary', $input)) { |
|
55 | + $args['DTT_is_primary'] = (bool) $input['isPrimary']; |
|
56 | + } |
|
57 | + |
|
58 | + if (array_key_exists('isTrashed', $input)) { |
|
59 | + $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
60 | + } |
|
61 | + |
|
62 | + if (isset($input['name'])) { |
|
63 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
64 | + } |
|
65 | + |
|
66 | + if (array_key_exists('order', $input)) { |
|
67 | + $args['DTT_order'] = (int) $input['order']; |
|
68 | + } |
|
69 | + |
|
70 | + if (! empty($input['parent'])) { |
|
71 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
72 | + $args['DTT_parent'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
73 | + } |
|
74 | + |
|
75 | + if (array_key_exists('reserved', $input)) { |
|
76 | + $args['DTT_reserved'] = (int) $input['reserved']; |
|
77 | + } |
|
78 | + |
|
79 | + if (array_key_exists('sold', $input)) { |
|
80 | + $args['DTT_sold'] = (int) $input['sold']; |
|
81 | + } |
|
82 | + |
|
83 | + if (! empty($input['startDate'])) { |
|
84 | + $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
85 | + } |
|
86 | + |
|
87 | + if (! empty($input['tickets'])) { |
|
88 | + $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
89 | + } |
|
90 | + |
|
91 | + if (array_key_exists('venue', $input)) { |
|
92 | + $venue_id = sanitize_text_field($input['venue']); |
|
93 | + $parts = Relay::fromGlobalId($venue_id); |
|
94 | + $args['venue'] = ! empty($parts['id']) ? $parts['id'] : $venue_id; |
|
95 | + } |
|
96 | + |
|
97 | + return apply_filters( |
|
98 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__datetime_args', |
|
99 | + $args, |
|
100 | + $input |
|
101 | + ); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * Sets the related tickets for the given datetime. |
|
107 | + * |
|
108 | + * @param EE_Datetime $entity The datetime instance. |
|
109 | + * @param array $tickets Array of ticket IDs to relate. |
|
110 | + * @throws EE_Error |
|
111 | + * @throws InvalidDataTypeException |
|
112 | + * @throws InvalidInterfaceException |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws ReflectionException |
|
115 | + */ |
|
116 | + public static function setRelatedTickets(EE_Datetime $entity, array $tickets) |
|
117 | + { |
|
118 | + $relationName = 'Ticket'; |
|
119 | + // Remove all the existing related tickets |
|
120 | + $entity->_remove_relations($relationName); |
|
121 | + |
|
122 | + foreach ($tickets as $ID) { |
|
123 | + $parts = Relay::fromGlobalId($ID); |
|
124 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
125 | + $entity->_add_relation_to( |
|
126 | + $parts['id'], |
|
127 | + $relationName |
|
128 | + ); |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * Sets the venue for the datetime. |
|
136 | + * |
|
137 | + * @param EE_Datetime $entity The datetime instance. |
|
138 | + * @param int $venue The venue ID |
|
139 | + * @throws EE_Error |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidInterfaceException |
|
142 | + * @throws InvalidArgumentException |
|
143 | + * @throws ReflectionException |
|
144 | + */ |
|
145 | + public static function setVenue(EE_Datetime $entity, int $venue) |
|
146 | + { |
|
147 | + if (empty($venue)) { |
|
148 | + $entity->remove_venue($venue); |
|
149 | + } else { |
|
150 | + $entity->add_venue($venue); |
|
151 | + } |
|
152 | + } |
|
153 | 153 | } |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | $args['DTT_description'] = wp_kses_post($input['description']); |
41 | 41 | } |
42 | 42 | |
43 | - if (! empty($input['endDate'])) { |
|
43 | + if ( ! empty($input['endDate'])) { |
|
44 | 44 | $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
45 | 45 | } |
46 | 46 | |
47 | - if (! empty($input['eventId'])) { |
|
47 | + if ( ! empty($input['eventId'])) { |
|
48 | 48 | $args['EVT_ID'] = absint($input['eventId']); |
49 | - } elseif (! empty($input['event'])) { |
|
49 | + } elseif ( ! empty($input['event'])) { |
|
50 | 50 | $parts = Relay::fromGlobalId(sanitize_text_field($input['event'])); |
51 | 51 | $args['EVT_ID'] = ! empty($parts['id']) ? $parts['id'] : null; |
52 | 52 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $args['DTT_order'] = (int) $input['order']; |
68 | 68 | } |
69 | 69 | |
70 | - if (! empty($input['parent'])) { |
|
70 | + if ( ! empty($input['parent'])) { |
|
71 | 71 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
72 | 72 | $args['DTT_parent'] = ! empty($parts['id']) ? $parts['id'] : null; |
73 | 73 | } |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | $args['DTT_sold'] = (int) $input['sold']; |
81 | 81 | } |
82 | 82 | |
83 | - if (! empty($input['startDate'])) { |
|
83 | + if ( ! empty($input['startDate'])) { |
|
84 | 84 | $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
85 | 85 | } |
86 | 86 | |
87 | - if (! empty($input['tickets'])) { |
|
87 | + if ( ! empty($input['tickets'])) { |
|
88 | 88 | $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
89 | 89 | } |
90 | 90 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | foreach ($tickets as $ID) { |
123 | 123 | $parts = Relay::fromGlobalId($ID); |
124 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
124 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
125 | 125 | $entity->_add_relation_to( |
126 | 126 | $parts['id'], |
127 | 127 | $relationName |
@@ -21,113 +21,113 @@ |
||
21 | 21 | class EventMutation |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Maps the GraphQL input to a format that the model functions can use |
|
26 | - * |
|
27 | - * @param array $input Data coming from the GraphQL mutation query input |
|
28 | - * @return array |
|
29 | - * @throws Exception |
|
30 | - */ |
|
31 | - public static function prepareFields(array $input): array |
|
32 | - { |
|
33 | - $args = []; |
|
34 | - |
|
35 | - if (array_key_exists('allowDonations', $input)) { |
|
36 | - $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
37 | - } |
|
38 | - |
|
39 | - if (array_key_exists('allowOverflow', $input)) { |
|
40 | - $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
41 | - } |
|
42 | - |
|
43 | - if (array_key_exists('altRegPage', $input)) { |
|
44 | - $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
45 | - } |
|
46 | - |
|
47 | - if (! empty($input['defaultRegStatus'])) { |
|
48 | - $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
49 | - } |
|
50 | - |
|
51 | - if (! empty($input['description'])) { |
|
52 | - $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
|
53 | - } |
|
54 | - |
|
55 | - if (array_key_exists('displayDescription', $input)) { |
|
56 | - $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
57 | - } |
|
58 | - |
|
59 | - if (array_key_exists('displayTicketSelector', $input)) { |
|
60 | - $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
61 | - } |
|
62 | - |
|
63 | - if (! empty($input['maxRegistrations'])) { |
|
64 | - $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
65 | - } |
|
66 | - |
|
67 | - if (array_key_exists('memberOnly', $input)) { |
|
68 | - $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
69 | - } |
|
70 | - |
|
71 | - if (! empty($input['name'])) { |
|
72 | - $args['EVT_name'] = sanitize_text_field($input['name']); |
|
73 | - } |
|
74 | - |
|
75 | - if (array_key_exists('order', $input)) { |
|
76 | - $args['EVT_order'] = absint($input['order']); |
|
77 | - } |
|
78 | - |
|
79 | - if (array_key_exists('phoneNumber', $input)) { |
|
80 | - $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
81 | - } |
|
82 | - |
|
83 | - if (array_key_exists('shortDescription', $input)) { |
|
84 | - $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, 'db'); |
|
85 | - } |
|
86 | - |
|
87 | - if (array_key_exists('timezoneString', $input)) { |
|
88 | - $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
89 | - } |
|
90 | - |
|
91 | - if (! empty($input['visibleOn'])) { |
|
92 | - $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
93 | - } |
|
94 | - |
|
95 | - if (! empty($input['manager'])) { |
|
96 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
97 | - $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
98 | - } |
|
99 | - |
|
100 | - if (array_key_exists('venue', $input)) { |
|
101 | - $venue_id = sanitize_text_field($input['venue']); |
|
102 | - $parts = Relay::fromGlobalId($venue_id); |
|
103 | - $args['venue'] = ! empty($parts['id']) ? $parts['id'] : $venue_id; |
|
104 | - } |
|
105 | - |
|
106 | - return apply_filters( |
|
107 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
108 | - $args, |
|
109 | - $input |
|
110 | - ); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Sets the venue for the event. |
|
116 | - * |
|
117 | - * @param EE_Event $entity The event instance. |
|
118 | - * @param int $venue The venue ID |
|
119 | - * @throws EE_Error |
|
120 | - * @throws InvalidDataTypeException |
|
121 | - * @throws InvalidInterfaceException |
|
122 | - * @throws InvalidArgumentException |
|
123 | - * @throws ReflectionException |
|
124 | - */ |
|
125 | - public static function setEventVenue(EE_Event $entity, int $venue) |
|
126 | - { |
|
127 | - if (empty($venue)) { |
|
128 | - $entity->remove_venue($venue); |
|
129 | - } else { |
|
130 | - $entity->add_venue($venue); |
|
131 | - } |
|
132 | - } |
|
24 | + /** |
|
25 | + * Maps the GraphQL input to a format that the model functions can use |
|
26 | + * |
|
27 | + * @param array $input Data coming from the GraphQL mutation query input |
|
28 | + * @return array |
|
29 | + * @throws Exception |
|
30 | + */ |
|
31 | + public static function prepareFields(array $input): array |
|
32 | + { |
|
33 | + $args = []; |
|
34 | + |
|
35 | + if (array_key_exists('allowDonations', $input)) { |
|
36 | + $args['EVT_donations'] = filter_var($input['allowDonations'], FILTER_VALIDATE_BOOLEAN); |
|
37 | + } |
|
38 | + |
|
39 | + if (array_key_exists('allowOverflow', $input)) { |
|
40 | + $args['EVT_allow_overflow'] = filter_var($input['allowOverflow'], FILTER_VALIDATE_BOOLEAN); |
|
41 | + } |
|
42 | + |
|
43 | + if (array_key_exists('altRegPage', $input)) { |
|
44 | + $args['EVT_external_URL'] = sanitize_text_field($input['altRegPage']); |
|
45 | + } |
|
46 | + |
|
47 | + if (! empty($input['defaultRegStatus'])) { |
|
48 | + $args['EVT_default_registration_status'] = sanitize_text_field($input['defaultRegStatus']); |
|
49 | + } |
|
50 | + |
|
51 | + if (! empty($input['description'])) { |
|
52 | + $args['EVT_desc'] = sanitize_post_field('post_content', $input['description'], null, 'db'); |
|
53 | + } |
|
54 | + |
|
55 | + if (array_key_exists('displayDescription', $input)) { |
|
56 | + $args['EVT_display_desc'] = filter_var($input['displayDescription'], FILTER_VALIDATE_BOOLEAN); |
|
57 | + } |
|
58 | + |
|
59 | + if (array_key_exists('displayTicketSelector', $input)) { |
|
60 | + $args['EVT_display_ticket_selector'] = filter_var($input['displayTicketSelector'], FILTER_VALIDATE_BOOLEAN); |
|
61 | + } |
|
62 | + |
|
63 | + if (! empty($input['maxRegistrations'])) { |
|
64 | + $args['EVT_additional_limit'] = absint($input['maxRegistrations']); |
|
65 | + } |
|
66 | + |
|
67 | + if (array_key_exists('memberOnly', $input)) { |
|
68 | + $args['EVT_member_only'] = filter_var($input['memberOnly'], FILTER_VALIDATE_BOOLEAN); |
|
69 | + } |
|
70 | + |
|
71 | + if (! empty($input['name'])) { |
|
72 | + $args['EVT_name'] = sanitize_text_field($input['name']); |
|
73 | + } |
|
74 | + |
|
75 | + if (array_key_exists('order', $input)) { |
|
76 | + $args['EVT_order'] = absint($input['order']); |
|
77 | + } |
|
78 | + |
|
79 | + if (array_key_exists('phoneNumber', $input)) { |
|
80 | + $args['EVT_phone'] = sanitize_text_field($input['phoneNumber']); |
|
81 | + } |
|
82 | + |
|
83 | + if (array_key_exists('shortDescription', $input)) { |
|
84 | + $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDescription'], null, 'db'); |
|
85 | + } |
|
86 | + |
|
87 | + if (array_key_exists('timezoneString', $input)) { |
|
88 | + $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
89 | + } |
|
90 | + |
|
91 | + if (! empty($input['visibleOn'])) { |
|
92 | + $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
93 | + } |
|
94 | + |
|
95 | + if (! empty($input['manager'])) { |
|
96 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['manager'])); |
|
97 | + $args['EVT_wp_user'] = ! empty($parts['id']) ? $parts['id'] : null; |
|
98 | + } |
|
99 | + |
|
100 | + if (array_key_exists('venue', $input)) { |
|
101 | + $venue_id = sanitize_text_field($input['venue']); |
|
102 | + $parts = Relay::fromGlobalId($venue_id); |
|
103 | + $args['venue'] = ! empty($parts['id']) ? $parts['id'] : $venue_id; |
|
104 | + } |
|
105 | + |
|
106 | + return apply_filters( |
|
107 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__event_args', |
|
108 | + $args, |
|
109 | + $input |
|
110 | + ); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Sets the venue for the event. |
|
116 | + * |
|
117 | + * @param EE_Event $entity The event instance. |
|
118 | + * @param int $venue The venue ID |
|
119 | + * @throws EE_Error |
|
120 | + * @throws InvalidDataTypeException |
|
121 | + * @throws InvalidInterfaceException |
|
122 | + * @throws InvalidArgumentException |
|
123 | + * @throws ReflectionException |
|
124 | + */ |
|
125 | + public static function setEventVenue(EE_Event $entity, int $venue) |
|
126 | + { |
|
127 | + if (empty($venue)) { |
|
128 | + $entity->remove_venue($venue); |
|
129 | + } else { |
|
130 | + $entity->add_venue($venue); |
|
131 | + } |
|
132 | + } |
|
133 | 133 | } |
@@ -13,1472 +13,1472 @@ |
||
13 | 13 | class EE_Datetime extends EE_Soft_Delete_Base_Class |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * constant used by get_active_status, indicates datetime has no more available spaces |
|
18 | - */ |
|
19 | - const sold_out = 'DTS'; |
|
20 | - |
|
21 | - /** |
|
22 | - * constant used by get_active_status, indicating datetime is still active (even is not over, can be registered-for) |
|
23 | - */ |
|
24 | - const active = 'DTA'; |
|
25 | - |
|
26 | - /** |
|
27 | - * constant used by get_active_status, indicating the datetime cannot be used for registrations yet, but has not |
|
28 | - * expired |
|
29 | - */ |
|
30 | - const upcoming = 'DTU'; |
|
31 | - |
|
32 | - /** |
|
33 | - * Datetime is postponed |
|
34 | - */ |
|
35 | - const postponed = 'DTP'; |
|
36 | - |
|
37 | - /** |
|
38 | - * Datetime is cancelled |
|
39 | - */ |
|
40 | - const cancelled = 'DTC'; |
|
41 | - |
|
42 | - /** |
|
43 | - * constant used by get_active_status, indicates datetime has expired (event is over) |
|
44 | - */ |
|
45 | - const expired = 'DTE'; |
|
46 | - |
|
47 | - /** |
|
48 | - * constant used in various places indicating that an event is INACTIVE (not yet ready to be published) |
|
49 | - */ |
|
50 | - const inactive = 'DTI'; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @param array $props_n_values incoming values |
|
55 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be used.) |
|
56 | - * @param array $date_formats incoming date_formats in an array where the first value is the date_format |
|
57 | - * and the second value is the time format |
|
58 | - * @return EE_Datetime |
|
59 | - * @throws ReflectionException |
|
60 | - * @throws InvalidArgumentException |
|
61 | - * @throws InvalidInterfaceException |
|
62 | - * @throws InvalidDataTypeException |
|
63 | - * @throws EE_Error |
|
64 | - */ |
|
65 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
66 | - { |
|
67 | - $has_object = parent::_check_for_object( |
|
68 | - $props_n_values, |
|
69 | - __CLASS__, |
|
70 | - $timezone, |
|
71 | - $date_formats |
|
72 | - ); |
|
73 | - return $has_object |
|
74 | - ? $has_object |
|
75 | - : new self($props_n_values, false, $timezone, $date_formats); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param array $props_n_values incoming values from the database |
|
81 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
82 | - * the website will be used. |
|
83 | - * @return EE_Datetime |
|
84 | - * @throws ReflectionException |
|
85 | - * @throws InvalidArgumentException |
|
86 | - * @throws InvalidInterfaceException |
|
87 | - * @throws InvalidDataTypeException |
|
88 | - * @throws EE_Error |
|
89 | - */ |
|
90 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
91 | - { |
|
92 | - return new self($props_n_values, true, $timezone); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @param $name |
|
98 | - * @throws ReflectionException |
|
99 | - * @throws InvalidArgumentException |
|
100 | - * @throws InvalidInterfaceException |
|
101 | - * @throws InvalidDataTypeException |
|
102 | - * @throws EE_Error |
|
103 | - */ |
|
104 | - public function set_name($name) |
|
105 | - { |
|
106 | - $this->set('DTT_name', $name); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @param $description |
|
112 | - * @throws ReflectionException |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws InvalidInterfaceException |
|
115 | - * @throws InvalidDataTypeException |
|
116 | - * @throws EE_Error |
|
117 | - */ |
|
118 | - public function set_description($description) |
|
119 | - { |
|
120 | - $this->set('DTT_description', $description); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * Set event start date |
|
126 | - * set the start date for an event |
|
127 | - * |
|
128 | - * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
|
129 | - * @throws ReflectionException |
|
130 | - * @throws InvalidArgumentException |
|
131 | - * @throws InvalidInterfaceException |
|
132 | - * @throws InvalidDataTypeException |
|
133 | - * @throws EE_Error |
|
134 | - */ |
|
135 | - public function set_start_date($date) |
|
136 | - { |
|
137 | - $this->_set_date_for($date, 'DTT_EVT_start'); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Set event start time |
|
143 | - * set the start time for an event |
|
144 | - * |
|
145 | - * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
|
146 | - * @throws ReflectionException |
|
147 | - * @throws InvalidArgumentException |
|
148 | - * @throws InvalidInterfaceException |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws EE_Error |
|
151 | - */ |
|
152 | - public function set_start_time($time) |
|
153 | - { |
|
154 | - $this->_set_time_for($time, 'DTT_EVT_start'); |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Set event end date |
|
160 | - * set the end date for an event |
|
161 | - * |
|
162 | - * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
|
163 | - * @throws ReflectionException |
|
164 | - * @throws InvalidArgumentException |
|
165 | - * @throws InvalidInterfaceException |
|
166 | - * @throws InvalidDataTypeException |
|
167 | - * @throws EE_Error |
|
168 | - */ |
|
169 | - public function set_end_date($date) |
|
170 | - { |
|
171 | - $this->_set_date_for($date, 'DTT_EVT_end'); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * Set event end time |
|
177 | - * set the end time for an event |
|
178 | - * |
|
179 | - * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
|
180 | - * @throws ReflectionException |
|
181 | - * @throws InvalidArgumentException |
|
182 | - * @throws InvalidInterfaceException |
|
183 | - * @throws InvalidDataTypeException |
|
184 | - * @throws EE_Error |
|
185 | - */ |
|
186 | - public function set_end_time($time) |
|
187 | - { |
|
188 | - $this->_set_time_for($time, 'DTT_EVT_end'); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * Set registration limit |
|
194 | - * set the maximum number of attendees that can be registered for this datetime slot |
|
195 | - * |
|
196 | - * @param int $reg_limit |
|
197 | - * @throws ReflectionException |
|
198 | - * @throws InvalidArgumentException |
|
199 | - * @throws InvalidInterfaceException |
|
200 | - * @throws InvalidDataTypeException |
|
201 | - * @throws EE_Error |
|
202 | - */ |
|
203 | - public function set_reg_limit($reg_limit) |
|
204 | - { |
|
205 | - $this->set('DTT_reg_limit', $reg_limit); |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * get the number of tickets sold for this datetime slot |
|
211 | - * |
|
212 | - * @return mixed int on success, FALSE on fail |
|
213 | - * @throws ReflectionException |
|
214 | - * @throws InvalidArgumentException |
|
215 | - * @throws InvalidInterfaceException |
|
216 | - * @throws InvalidDataTypeException |
|
217 | - * @throws EE_Error |
|
218 | - */ |
|
219 | - public function sold() |
|
220 | - { |
|
221 | - return $this->get_raw('DTT_sold'); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * @param int $sold |
|
227 | - * @throws ReflectionException |
|
228 | - * @throws InvalidArgumentException |
|
229 | - * @throws InvalidInterfaceException |
|
230 | - * @throws InvalidDataTypeException |
|
231 | - * @throws EE_Error |
|
232 | - */ |
|
233 | - public function set_sold($sold) |
|
234 | - { |
|
235 | - // sold can not go below zero |
|
236 | - $sold = max(0, $sold); |
|
237 | - $this->set('DTT_sold', $sold); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * Increments sold by amount passed by $qty, and persists it immediately to the database. |
|
243 | - * Simultaneously decreases the reserved count, unless $also_decrease_reserved is false. |
|
244 | - * |
|
245 | - * @param int $qty |
|
246 | - * @param boolean $also_decrease_reserved |
|
247 | - * @return boolean indicating success |
|
248 | - * @throws ReflectionException |
|
249 | - * @throws InvalidArgumentException |
|
250 | - * @throws InvalidInterfaceException |
|
251 | - * @throws InvalidDataTypeException |
|
252 | - * @throws EE_Error |
|
253 | - */ |
|
254 | - public function increaseSold($qty = 1, $also_decrease_reserved = true) |
|
255 | - { |
|
256 | - $qty = absint($qty); |
|
257 | - if ($also_decrease_reserved) { |
|
258 | - $success = $this->adjustNumericFieldsInDb( |
|
259 | - [ |
|
260 | - 'DTT_reserved' => $qty * -1, |
|
261 | - 'DTT_sold' => $qty |
|
262 | - ] |
|
263 | - ); |
|
264 | - } else { |
|
265 | - $success = $this->adjustNumericFieldsInDb( |
|
266 | - [ |
|
267 | - 'DTT_sold' => $qty |
|
268 | - ] |
|
269 | - ); |
|
270 | - } |
|
271 | - |
|
272 | - do_action( |
|
273 | - 'AHEE__EE_Datetime__increase_sold', |
|
274 | - $this, |
|
275 | - $qty, |
|
276 | - $this->sold(), |
|
277 | - $success |
|
278 | - ); |
|
279 | - return $success; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need |
|
285 | - * to save afterwards.) |
|
286 | - * |
|
287 | - * @param int $qty |
|
288 | - * @return boolean indicating success |
|
289 | - * @throws ReflectionException |
|
290 | - * @throws InvalidArgumentException |
|
291 | - * @throws InvalidInterfaceException |
|
292 | - * @throws InvalidDataTypeException |
|
293 | - * @throws EE_Error |
|
294 | - */ |
|
295 | - public function decreaseSold($qty = 1) |
|
296 | - { |
|
297 | - $qty = absint($qty); |
|
298 | - $success = $this->adjustNumericFieldsInDb( |
|
299 | - [ |
|
300 | - 'DTT_sold' => $qty * -1 |
|
301 | - ] |
|
302 | - ); |
|
303 | - do_action( |
|
304 | - 'AHEE__EE_Datetime__decrease_sold', |
|
305 | - $this, |
|
306 | - $qty, |
|
307 | - $this->sold(), |
|
308 | - $success |
|
309 | - ); |
|
310 | - return $success; |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * Gets qty of reserved tickets for this datetime |
|
316 | - * |
|
317 | - * @return int |
|
318 | - * @throws ReflectionException |
|
319 | - * @throws InvalidArgumentException |
|
320 | - * @throws InvalidInterfaceException |
|
321 | - * @throws InvalidDataTypeException |
|
322 | - * @throws EE_Error |
|
323 | - */ |
|
324 | - public function reserved() |
|
325 | - { |
|
326 | - return $this->get_raw('DTT_reserved'); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * Sets qty of reserved tickets for this datetime |
|
332 | - * |
|
333 | - * @param int $reserved |
|
334 | - * @throws ReflectionException |
|
335 | - * @throws InvalidArgumentException |
|
336 | - * @throws InvalidInterfaceException |
|
337 | - * @throws InvalidDataTypeException |
|
338 | - * @throws EE_Error |
|
339 | - */ |
|
340 | - public function set_reserved($reserved) |
|
341 | - { |
|
342 | - // reserved can not go below zero |
|
343 | - $reserved = max(0, (int) $reserved); |
|
344 | - $this->set('DTT_reserved', $reserved); |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - /** |
|
349 | - * Increments reserved by amount passed by $qty, and persists it immediately to the database. |
|
350 | - * |
|
351 | - * @param int $qty |
|
352 | - * @return boolean indicating success |
|
353 | - * @throws ReflectionException |
|
354 | - * @throws InvalidArgumentException |
|
355 | - * @throws InvalidInterfaceException |
|
356 | - * @throws InvalidDataTypeException |
|
357 | - * @throws EE_Error |
|
358 | - */ |
|
359 | - public function increaseReserved($qty = 1) |
|
360 | - { |
|
361 | - $qty = absint($qty); |
|
362 | - $success = $this->incrementFieldConditionallyInDb( |
|
363 | - 'DTT_reserved', |
|
364 | - 'DTT_sold', |
|
365 | - 'DTT_reg_limit', |
|
366 | - $qty |
|
367 | - ); |
|
368 | - do_action( |
|
369 | - 'AHEE__EE_Datetime__increase_reserved', |
|
370 | - $this, |
|
371 | - $qty, |
|
372 | - $this->reserved(), |
|
373 | - $success |
|
374 | - ); |
|
375 | - return $success; |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database. |
|
381 | - * |
|
382 | - * @param int $qty |
|
383 | - * @return boolean indicating success |
|
384 | - * @throws ReflectionException |
|
385 | - * @throws InvalidArgumentException |
|
386 | - * @throws InvalidInterfaceException |
|
387 | - * @throws InvalidDataTypeException |
|
388 | - * @throws EE_Error |
|
389 | - */ |
|
390 | - public function decreaseReserved($qty = 1) |
|
391 | - { |
|
392 | - $qty = absint($qty); |
|
393 | - $success = $this->adjustNumericFieldsInDb( |
|
394 | - [ |
|
395 | - 'DTT_reserved' => $qty * -1 |
|
396 | - ] |
|
397 | - ); |
|
398 | - do_action( |
|
399 | - 'AHEE__EE_Datetime__decrease_reserved', |
|
400 | - $this, |
|
401 | - $qty, |
|
402 | - $this->reserved(), |
|
403 | - $success |
|
404 | - ); |
|
405 | - return $success; |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * total sold and reserved tickets |
|
411 | - * |
|
412 | - * @return int |
|
413 | - * @throws ReflectionException |
|
414 | - * @throws InvalidArgumentException |
|
415 | - * @throws InvalidInterfaceException |
|
416 | - * @throws InvalidDataTypeException |
|
417 | - * @throws EE_Error |
|
418 | - */ |
|
419 | - public function sold_and_reserved() |
|
420 | - { |
|
421 | - return $this->sold() + $this->reserved(); |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - /** |
|
426 | - * returns the datetime name |
|
427 | - * |
|
428 | - * @return string |
|
429 | - * @throws ReflectionException |
|
430 | - * @throws InvalidArgumentException |
|
431 | - * @throws InvalidInterfaceException |
|
432 | - * @throws InvalidDataTypeException |
|
433 | - * @throws EE_Error |
|
434 | - */ |
|
435 | - public function name() |
|
436 | - { |
|
437 | - return $this->get('DTT_name'); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * returns the datetime description |
|
443 | - * |
|
444 | - * @return string |
|
445 | - * @throws ReflectionException |
|
446 | - * @throws InvalidArgumentException |
|
447 | - * @throws InvalidInterfaceException |
|
448 | - * @throws InvalidDataTypeException |
|
449 | - * @throws EE_Error |
|
450 | - */ |
|
451 | - public function description() |
|
452 | - { |
|
453 | - return $this->get('DTT_description'); |
|
454 | - } |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * This helper simply returns whether the event_datetime for the current datetime is a primary datetime |
|
459 | - * |
|
460 | - * @return boolean TRUE if is primary, FALSE if not. |
|
461 | - * @throws ReflectionException |
|
462 | - * @throws InvalidArgumentException |
|
463 | - * @throws InvalidInterfaceException |
|
464 | - * @throws InvalidDataTypeException |
|
465 | - * @throws EE_Error |
|
466 | - */ |
|
467 | - public function is_primary() |
|
468 | - { |
|
469 | - return $this->get('DTT_is_primary'); |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * This helper simply returns the order for the datetime |
|
475 | - * |
|
476 | - * @return int The order of the datetime for this event. |
|
477 | - * @throws ReflectionException |
|
478 | - * @throws InvalidArgumentException |
|
479 | - * @throws InvalidInterfaceException |
|
480 | - * @throws InvalidDataTypeException |
|
481 | - * @throws EE_Error |
|
482 | - */ |
|
483 | - public function order() |
|
484 | - { |
|
485 | - return $this->get('DTT_order'); |
|
486 | - } |
|
487 | - |
|
488 | - |
|
489 | - /** |
|
490 | - * This helper simply returns the parent id for the datetime |
|
491 | - * |
|
492 | - * @return int |
|
493 | - * @throws ReflectionException |
|
494 | - * @throws InvalidArgumentException |
|
495 | - * @throws InvalidInterfaceException |
|
496 | - * @throws InvalidDataTypeException |
|
497 | - * @throws EE_Error |
|
498 | - */ |
|
499 | - public function parent() |
|
500 | - { |
|
501 | - return $this->get('DTT_parent'); |
|
502 | - } |
|
503 | - |
|
504 | - |
|
505 | - /** |
|
506 | - * show date and/or time |
|
507 | - * |
|
508 | - * @param string $date_or_time whether to display a date or time or both |
|
509 | - * @param string $start_or_end whether to display start or end datetimes |
|
510 | - * @param string $dt_frmt |
|
511 | - * @param string $tm_frmt |
|
512 | - * @param bool $echo whether we echo or return (note echoing uses "pretty" formats, |
|
513 | - * otherwise we use the standard formats) |
|
514 | - * @return string|bool string on success, FALSE on fail |
|
515 | - * @throws ReflectionException |
|
516 | - * @throws InvalidArgumentException |
|
517 | - * @throws InvalidInterfaceException |
|
518 | - * @throws InvalidDataTypeException |
|
519 | - * @throws EE_Error |
|
520 | - */ |
|
521 | - private function _show_datetime( |
|
522 | - $date_or_time = null, |
|
523 | - $start_or_end = 'start', |
|
524 | - $dt_frmt = '', |
|
525 | - $tm_frmt = '', |
|
526 | - $echo = false |
|
527 | - ) { |
|
528 | - $field_name = "DTT_EVT_{$start_or_end}"; |
|
529 | - $dtt = $this->_get_datetime( |
|
530 | - $field_name, |
|
531 | - $dt_frmt, |
|
532 | - $tm_frmt, |
|
533 | - $date_or_time, |
|
534 | - $echo |
|
535 | - ); |
|
536 | - if (! $echo) { |
|
537 | - return $dtt; |
|
538 | - } |
|
539 | - return ''; |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - /** |
|
544 | - * get event start date. Provide either the date format, or NULL to re-use the |
|
545 | - * last-used format, or '' to use the default date format |
|
546 | - * |
|
547 | - * @param string $dt_frmt string representation of date format defaults to 'F j, Y' |
|
548 | - * @return mixed string on success, FALSE on fail |
|
549 | - * @throws ReflectionException |
|
550 | - * @throws InvalidArgumentException |
|
551 | - * @throws InvalidInterfaceException |
|
552 | - * @throws InvalidDataTypeException |
|
553 | - * @throws EE_Error |
|
554 | - */ |
|
555 | - public function start_date($dt_frmt = '') |
|
556 | - { |
|
557 | - return $this->_show_datetime('D', 'start', $dt_frmt); |
|
558 | - } |
|
559 | - |
|
560 | - |
|
561 | - /** |
|
562 | - * Echoes start_date() |
|
563 | - * |
|
564 | - * @param string $dt_frmt |
|
565 | - * @throws ReflectionException |
|
566 | - * @throws InvalidArgumentException |
|
567 | - * @throws InvalidInterfaceException |
|
568 | - * @throws InvalidDataTypeException |
|
569 | - * @throws EE_Error |
|
570 | - */ |
|
571 | - public function e_start_date($dt_frmt = '') |
|
572 | - { |
|
573 | - $this->_show_datetime('D', 'start', $dt_frmt, null, true); |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * get end date. Provide either the date format, or NULL to re-use the |
|
579 | - * last-used format, or '' to use the default date format |
|
580 | - * |
|
581 | - * @param string $dt_frmt string representation of date format defaults to 'F j, Y' |
|
582 | - * @return mixed string on success, FALSE on fail |
|
583 | - * @throws ReflectionException |
|
584 | - * @throws InvalidArgumentException |
|
585 | - * @throws InvalidInterfaceException |
|
586 | - * @throws InvalidDataTypeException |
|
587 | - * @throws EE_Error |
|
588 | - */ |
|
589 | - public function end_date($dt_frmt = '') |
|
590 | - { |
|
591 | - return $this->_show_datetime('D', 'end', $dt_frmt); |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - /** |
|
596 | - * Echoes the end date. See end_date() |
|
597 | - * |
|
598 | - * @param string $dt_frmt |
|
599 | - * @throws ReflectionException |
|
600 | - * @throws InvalidArgumentException |
|
601 | - * @throws InvalidInterfaceException |
|
602 | - * @throws InvalidDataTypeException |
|
603 | - * @throws EE_Error |
|
604 | - */ |
|
605 | - public function e_end_date($dt_frmt = '') |
|
606 | - { |
|
607 | - $this->_show_datetime('D', 'end', $dt_frmt, null, true); |
|
608 | - } |
|
609 | - |
|
610 | - |
|
611 | - /** |
|
612 | - * get date_range - meaning the start AND end date |
|
613 | - * |
|
614 | - * @access public |
|
615 | - * @param string $dt_frmt string representation of date format defaults to WP settings |
|
616 | - * @param string $conjunction conjunction junction what's your function ? |
|
617 | - * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
618 | - * @return mixed string on success, FALSE on fail |
|
619 | - * @throws ReflectionException |
|
620 | - * @throws InvalidArgumentException |
|
621 | - * @throws InvalidInterfaceException |
|
622 | - * @throws InvalidDataTypeException |
|
623 | - * @throws EE_Error |
|
624 | - */ |
|
625 | - public function date_range($dt_frmt = '', $conjunction = ' - ') |
|
626 | - { |
|
627 | - $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
628 | - $start = str_replace( |
|
629 | - ' ', |
|
630 | - ' ', |
|
631 | - $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt) |
|
632 | - ); |
|
633 | - $end = str_replace( |
|
634 | - ' ', |
|
635 | - ' ', |
|
636 | - $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt) |
|
637 | - ); |
|
638 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
639 | - } |
|
640 | - |
|
641 | - |
|
642 | - /** |
|
643 | - * @param string $dt_frmt |
|
644 | - * @param string $conjunction |
|
645 | - * @throws ReflectionException |
|
646 | - * @throws InvalidArgumentException |
|
647 | - * @throws InvalidInterfaceException |
|
648 | - * @throws InvalidDataTypeException |
|
649 | - * @throws EE_Error |
|
650 | - */ |
|
651 | - public function e_date_range($dt_frmt = '', $conjunction = ' - ') |
|
652 | - { |
|
653 | - echo $this->date_range($dt_frmt, $conjunction); |
|
654 | - } |
|
655 | - |
|
656 | - |
|
657 | - /** |
|
658 | - * get start time |
|
659 | - * |
|
660 | - * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
661 | - * @return mixed string on success, FALSE on fail |
|
662 | - * @throws ReflectionException |
|
663 | - * @throws InvalidArgumentException |
|
664 | - * @throws InvalidInterfaceException |
|
665 | - * @throws InvalidDataTypeException |
|
666 | - * @throws EE_Error |
|
667 | - */ |
|
668 | - public function start_time($tm_format = '') |
|
669 | - { |
|
670 | - return $this->_show_datetime('T', 'start', null, $tm_format); |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - /** |
|
675 | - * @param string $tm_format |
|
676 | - * @throws ReflectionException |
|
677 | - * @throws InvalidArgumentException |
|
678 | - * @throws InvalidInterfaceException |
|
679 | - * @throws InvalidDataTypeException |
|
680 | - * @throws EE_Error |
|
681 | - */ |
|
682 | - public function e_start_time($tm_format = '') |
|
683 | - { |
|
684 | - $this->_show_datetime('T', 'start', null, $tm_format, true); |
|
685 | - } |
|
686 | - |
|
687 | - |
|
688 | - /** |
|
689 | - * get end time |
|
690 | - * |
|
691 | - * @param string $tm_format string representation of time format defaults to 'g:i a' |
|
692 | - * @return mixed string on success, FALSE on fail |
|
693 | - * @throws ReflectionException |
|
694 | - * @throws InvalidArgumentException |
|
695 | - * @throws InvalidInterfaceException |
|
696 | - * @throws InvalidDataTypeException |
|
697 | - * @throws EE_Error |
|
698 | - */ |
|
699 | - public function end_time($tm_format = '') |
|
700 | - { |
|
701 | - return $this->_show_datetime('T', 'end', null, $tm_format); |
|
702 | - } |
|
703 | - |
|
704 | - |
|
705 | - /** |
|
706 | - * @param string $tm_format |
|
707 | - * @throws ReflectionException |
|
708 | - * @throws InvalidArgumentException |
|
709 | - * @throws InvalidInterfaceException |
|
710 | - * @throws InvalidDataTypeException |
|
711 | - * @throws EE_Error |
|
712 | - */ |
|
713 | - public function e_end_time($tm_format = '') |
|
714 | - { |
|
715 | - $this->_show_datetime('T', 'end', null, $tm_format, true); |
|
716 | - } |
|
717 | - |
|
718 | - |
|
719 | - /** |
|
720 | - * get time_range |
|
721 | - * |
|
722 | - * @access public |
|
723 | - * @param string $tm_format string representation of time format defaults to 'g:i a' |
|
724 | - * @param string $conjunction conjunction junction what's your function ? |
|
725 | - * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
726 | - * @return mixed string on success, FALSE on fail |
|
727 | - * @throws ReflectionException |
|
728 | - * @throws InvalidArgumentException |
|
729 | - * @throws InvalidInterfaceException |
|
730 | - * @throws InvalidDataTypeException |
|
731 | - * @throws EE_Error |
|
732 | - */ |
|
733 | - public function time_range($tm_format = '', $conjunction = ' - ') |
|
734 | - { |
|
735 | - $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
736 | - $start = str_replace( |
|
737 | - ' ', |
|
738 | - ' ', |
|
739 | - $this->get_i18n_datetime('DTT_EVT_start', $tm_format) |
|
740 | - ); |
|
741 | - $end = str_replace( |
|
742 | - ' ', |
|
743 | - ' ', |
|
744 | - $this->get_i18n_datetime('DTT_EVT_end', $tm_format) |
|
745 | - ); |
|
746 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
747 | - } |
|
748 | - |
|
749 | - |
|
750 | - /** |
|
751 | - * @param string $tm_format |
|
752 | - * @param string $conjunction |
|
753 | - * @throws ReflectionException |
|
754 | - * @throws InvalidArgumentException |
|
755 | - * @throws InvalidInterfaceException |
|
756 | - * @throws InvalidDataTypeException |
|
757 | - * @throws EE_Error |
|
758 | - */ |
|
759 | - public function e_time_range($tm_format = '', $conjunction = ' - ') |
|
760 | - { |
|
761 | - echo $this->time_range($tm_format, $conjunction); |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - /** |
|
766 | - * This returns a range representation of the date and times. |
|
767 | - * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end. |
|
768 | - * Also, the return value is localized. |
|
769 | - * |
|
770 | - * @param string $dt_format |
|
771 | - * @param string $tm_format |
|
772 | - * @param string $conjunction used between two different dates or times. |
|
773 | - * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
774 | - * @param string $separator used between the date and time formats. |
|
775 | - * ex: Dec 1, 2016{$separator}2pm |
|
776 | - * @return string |
|
777 | - * @throws ReflectionException |
|
778 | - * @throws InvalidArgumentException |
|
779 | - * @throws InvalidInterfaceException |
|
780 | - * @throws InvalidDataTypeException |
|
781 | - * @throws EE_Error |
|
782 | - */ |
|
783 | - public function date_and_time_range( |
|
784 | - $dt_format = '', |
|
785 | - $tm_format = '', |
|
786 | - $conjunction = ' - ', |
|
787 | - $separator = ' ' |
|
788 | - ) { |
|
789 | - $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt; |
|
790 | - $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
791 | - $full_format = $dt_format . $separator . $tm_format; |
|
792 | - // the range output depends on various conditions |
|
793 | - switch (true) { |
|
794 | - // start date timestamp and end date timestamp are the same. |
|
795 | - case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')): |
|
796 | - $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
797 | - break; |
|
798 | - // start and end date are the same but times are different |
|
799 | - case ($this->start_date() === $this->end_date()): |
|
800 | - $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
801 | - . $conjunction |
|
802 | - . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
803 | - break; |
|
804 | - // all other conditions |
|
805 | - default: |
|
806 | - $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
807 | - . $conjunction |
|
808 | - . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
809 | - break; |
|
810 | - } |
|
811 | - return $output; |
|
812 | - } |
|
813 | - |
|
814 | - |
|
815 | - /** |
|
816 | - * This echos the results of date and time range. |
|
817 | - * |
|
818 | - * @see date_and_time_range() for more details on purpose. |
|
819 | - * @param string $dt_format |
|
820 | - * @param string $tm_format |
|
821 | - * @param string $conjunction |
|
822 | - * @return void |
|
823 | - * @throws ReflectionException |
|
824 | - * @throws InvalidArgumentException |
|
825 | - * @throws InvalidInterfaceException |
|
826 | - * @throws InvalidDataTypeException |
|
827 | - * @throws EE_Error |
|
828 | - */ |
|
829 | - public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') |
|
830 | - { |
|
831 | - echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
832 | - } |
|
833 | - |
|
834 | - |
|
835 | - /** |
|
836 | - * get start date and start time |
|
837 | - * |
|
838 | - * @param string $dt_format - string representation of date format defaults to 'F j, Y' |
|
839 | - * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
840 | - * @return mixed string on success, FALSE on fail |
|
841 | - * @throws ReflectionException |
|
842 | - * @throws InvalidArgumentException |
|
843 | - * @throws InvalidInterfaceException |
|
844 | - * @throws InvalidDataTypeException |
|
845 | - * @throws EE_Error |
|
846 | - */ |
|
847 | - public function start_date_and_time($dt_format = '', $tm_format = '') |
|
848 | - { |
|
849 | - return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
850 | - } |
|
851 | - |
|
852 | - |
|
853 | - /** |
|
854 | - * @param string $dt_frmt |
|
855 | - * @param string $tm_format |
|
856 | - * @throws ReflectionException |
|
857 | - * @throws InvalidArgumentException |
|
858 | - * @throws InvalidInterfaceException |
|
859 | - * @throws InvalidDataTypeException |
|
860 | - * @throws EE_Error |
|
861 | - */ |
|
862 | - public function e_start_date_and_time($dt_frmt = '', $tm_format = '') |
|
863 | - { |
|
864 | - $this->_show_datetime('', 'start', $dt_frmt, $tm_format, true); |
|
865 | - } |
|
866 | - |
|
867 | - |
|
868 | - /** |
|
869 | - * Shows the length of the event (start to end time). |
|
870 | - * Can be shown in 'seconds','minutes','hours', or 'days'. |
|
871 | - * By default, rounds up. (So if you use 'days', and then event |
|
872 | - * only occurs for 1 hour, it will return 1 day). |
|
873 | - * |
|
874 | - * @param string $units 'seconds','minutes','hours','days' |
|
875 | - * @param bool $round_up |
|
876 | - * @return float|int|mixed |
|
877 | - * @throws ReflectionException |
|
878 | - * @throws InvalidArgumentException |
|
879 | - * @throws InvalidInterfaceException |
|
880 | - * @throws InvalidDataTypeException |
|
881 | - * @throws EE_Error |
|
882 | - */ |
|
883 | - public function length($units = 'seconds', $round_up = false) |
|
884 | - { |
|
885 | - $start = $this->get_raw('DTT_EVT_start'); |
|
886 | - $end = $this->get_raw('DTT_EVT_end'); |
|
887 | - $length_in_units = $end - $start; |
|
888 | - switch ($units) { |
|
889 | - // NOTE: We purposefully don't use "break;" in order to chain the divisions |
|
890 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
891 | - // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment |
|
892 | - case 'days': |
|
893 | - $length_in_units /= 24; |
|
894 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
895 | - case 'hours': |
|
896 | - // fall through is intentional |
|
897 | - $length_in_units /= 60; |
|
898 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
899 | - case 'minutes': |
|
900 | - // fall through is intentional |
|
901 | - $length_in_units /= 60; |
|
902 | - case 'seconds': |
|
903 | - default: |
|
904 | - $length_in_units = ceil($length_in_units); |
|
905 | - } |
|
906 | - // phpcs:enable |
|
907 | - if ($round_up) { |
|
908 | - $length_in_units = max($length_in_units, 1); |
|
909 | - } |
|
910 | - return $length_in_units; |
|
911 | - } |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * get end date and time |
|
916 | - * |
|
917 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
918 | - * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
919 | - * @return mixed string on success, FALSE on fail |
|
920 | - * @throws ReflectionException |
|
921 | - * @throws InvalidArgumentException |
|
922 | - * @throws InvalidInterfaceException |
|
923 | - * @throws InvalidDataTypeException |
|
924 | - * @throws EE_Error |
|
925 | - */ |
|
926 | - public function end_date_and_time($dt_frmt = '', $tm_format = '') |
|
927 | - { |
|
928 | - return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
929 | - } |
|
930 | - |
|
931 | - |
|
932 | - /** |
|
933 | - * @param string $dt_frmt |
|
934 | - * @param string $tm_format |
|
935 | - * @throws ReflectionException |
|
936 | - * @throws InvalidArgumentException |
|
937 | - * @throws InvalidInterfaceException |
|
938 | - * @throws InvalidDataTypeException |
|
939 | - * @throws EE_Error |
|
940 | - */ |
|
941 | - public function e_end_date_and_time($dt_frmt = '', $tm_format = '') |
|
942 | - { |
|
943 | - $this->_show_datetime('', 'end', $dt_frmt, $tm_format, true); |
|
944 | - } |
|
945 | - |
|
946 | - |
|
947 | - /** |
|
948 | - * get start timestamp |
|
949 | - * |
|
950 | - * @return int |
|
951 | - * @throws ReflectionException |
|
952 | - * @throws InvalidArgumentException |
|
953 | - * @throws InvalidInterfaceException |
|
954 | - * @throws InvalidDataTypeException |
|
955 | - * @throws EE_Error |
|
956 | - */ |
|
957 | - public function start() |
|
958 | - { |
|
959 | - return $this->get_raw('DTT_EVT_start'); |
|
960 | - } |
|
961 | - |
|
962 | - |
|
963 | - /** |
|
964 | - * get end timestamp |
|
965 | - * |
|
966 | - * @return int |
|
967 | - * @throws ReflectionException |
|
968 | - * @throws InvalidArgumentException |
|
969 | - * @throws InvalidInterfaceException |
|
970 | - * @throws InvalidDataTypeException |
|
971 | - * @throws EE_Error |
|
972 | - */ |
|
973 | - public function end() |
|
974 | - { |
|
975 | - return $this->get_raw('DTT_EVT_end'); |
|
976 | - } |
|
977 | - |
|
978 | - |
|
979 | - /** |
|
980 | - * get the registration limit for this datetime slot |
|
981 | - * |
|
982 | - * @return mixed int on success, FALSE on fail |
|
983 | - * @throws ReflectionException |
|
984 | - * @throws InvalidArgumentException |
|
985 | - * @throws InvalidInterfaceException |
|
986 | - * @throws InvalidDataTypeException |
|
987 | - * @throws EE_Error |
|
988 | - */ |
|
989 | - public function reg_limit() |
|
990 | - { |
|
991 | - return $this->get_raw('DTT_reg_limit'); |
|
992 | - } |
|
993 | - |
|
994 | - |
|
995 | - /** |
|
996 | - * have the tickets sold for this datetime, met or exceed the registration limit ? |
|
997 | - * |
|
998 | - * @return boolean |
|
999 | - * @throws ReflectionException |
|
1000 | - * @throws InvalidArgumentException |
|
1001 | - * @throws InvalidInterfaceException |
|
1002 | - * @throws InvalidDataTypeException |
|
1003 | - * @throws EE_Error |
|
1004 | - */ |
|
1005 | - public function sold_out() |
|
1006 | - { |
|
1007 | - return $this->reg_limit() > 0 && $this->sold() >= $this->reg_limit(); |
|
1008 | - } |
|
1009 | - |
|
1010 | - |
|
1011 | - /** |
|
1012 | - * return the total number of spaces remaining at this venue. |
|
1013 | - * This only takes the venue's capacity into account, NOT the tickets available for sale |
|
1014 | - * |
|
1015 | - * @param bool $consider_tickets Whether to consider tickets remaining when determining if there are any spaces left |
|
1016 | - * Because if all tickets attached to this datetime have no spaces left, |
|
1017 | - * then this datetime IS effectively sold out. |
|
1018 | - * However, there are cases where we just want to know the spaces |
|
1019 | - * remaining for this particular datetime, hence the flag. |
|
1020 | - * @return int |
|
1021 | - * @throws ReflectionException |
|
1022 | - * @throws InvalidArgumentException |
|
1023 | - * @throws InvalidInterfaceException |
|
1024 | - * @throws InvalidDataTypeException |
|
1025 | - * @throws EE_Error |
|
1026 | - */ |
|
1027 | - public function spaces_remaining($consider_tickets = false) |
|
1028 | - { |
|
1029 | - // tickets remaining available for purchase |
|
1030 | - // no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
|
1031 | - $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved(); |
|
1032 | - if (! $consider_tickets) { |
|
1033 | - return $dtt_remaining; |
|
1034 | - } |
|
1035 | - $tickets_remaining = $this->tickets_remaining(); |
|
1036 | - return min($dtt_remaining, $tickets_remaining); |
|
1037 | - } |
|
1038 | - |
|
1039 | - |
|
1040 | - /** |
|
1041 | - * Counts the total tickets available |
|
1042 | - * (from all the different types of tickets which are available for this datetime). |
|
1043 | - * |
|
1044 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1045 | - * @return int |
|
1046 | - * @throws ReflectionException |
|
1047 | - * @throws InvalidArgumentException |
|
1048 | - * @throws InvalidInterfaceException |
|
1049 | - * @throws InvalidDataTypeException |
|
1050 | - * @throws EE_Error |
|
1051 | - */ |
|
1052 | - public function tickets_remaining($query_params = array()) |
|
1053 | - { |
|
1054 | - $sum = 0; |
|
1055 | - $tickets = $this->tickets($query_params); |
|
1056 | - if (! empty($tickets)) { |
|
1057 | - foreach ($tickets as $ticket) { |
|
1058 | - if ($ticket instanceof EE_Ticket) { |
|
1059 | - // get the actual amount of tickets that can be sold |
|
1060 | - $qty = $ticket->qty('saleable'); |
|
1061 | - if ($qty === EE_INF) { |
|
1062 | - return EE_INF; |
|
1063 | - } |
|
1064 | - // no negative ticket quantities plz |
|
1065 | - if ($qty > 0) { |
|
1066 | - $sum += $qty; |
|
1067 | - } |
|
1068 | - } |
|
1069 | - } |
|
1070 | - } |
|
1071 | - return $sum; |
|
1072 | - } |
|
1073 | - |
|
1074 | - |
|
1075 | - /** |
|
1076 | - * Gets the count of all the tickets available at this datetime (not ticket types) |
|
1077 | - * before any were sold |
|
1078 | - * |
|
1079 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1080 | - * @return int |
|
1081 | - * @throws ReflectionException |
|
1082 | - * @throws InvalidArgumentException |
|
1083 | - * @throws InvalidInterfaceException |
|
1084 | - * @throws InvalidDataTypeException |
|
1085 | - * @throws EE_Error |
|
1086 | - */ |
|
1087 | - public function sum_tickets_initially_available($query_params = array()) |
|
1088 | - { |
|
1089 | - return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
1090 | - } |
|
1091 | - |
|
1092 | - |
|
1093 | - /** |
|
1094 | - * Returns the lesser-of-the two: spaces remaining at this datetime, or |
|
1095 | - * the total tickets remaining (a sum of the tickets remaining for each ticket type |
|
1096 | - * that is available for this datetime). |
|
1097 | - * |
|
1098 | - * @return int |
|
1099 | - * @throws ReflectionException |
|
1100 | - * @throws InvalidArgumentException |
|
1101 | - * @throws InvalidInterfaceException |
|
1102 | - * @throws InvalidDataTypeException |
|
1103 | - * @throws EE_Error |
|
1104 | - */ |
|
1105 | - public function total_tickets_available_at_this_datetime() |
|
1106 | - { |
|
1107 | - return $this->spaces_remaining(true); |
|
1108 | - } |
|
1109 | - |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * This simply compares the internal dtt for the given string with NOW |
|
1113 | - * and determines if the date is upcoming or not. |
|
1114 | - * |
|
1115 | - * @access public |
|
1116 | - * @return boolean |
|
1117 | - * @throws ReflectionException |
|
1118 | - * @throws InvalidArgumentException |
|
1119 | - * @throws InvalidInterfaceException |
|
1120 | - * @throws InvalidDataTypeException |
|
1121 | - * @throws EE_Error |
|
1122 | - */ |
|
1123 | - public function is_upcoming() |
|
1124 | - { |
|
1125 | - return ($this->get_raw('DTT_EVT_start') > time()); |
|
1126 | - } |
|
1127 | - |
|
1128 | - |
|
1129 | - /** |
|
1130 | - * This simply compares the internal datetime for the given string with NOW |
|
1131 | - * and returns if the date is active (i.e. start and end time) |
|
1132 | - * |
|
1133 | - * @return boolean |
|
1134 | - * @throws ReflectionException |
|
1135 | - * @throws InvalidArgumentException |
|
1136 | - * @throws InvalidInterfaceException |
|
1137 | - * @throws InvalidDataTypeException |
|
1138 | - * @throws EE_Error |
|
1139 | - */ |
|
1140 | - public function is_active() |
|
1141 | - { |
|
1142 | - return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
1143 | - } |
|
1144 | - |
|
1145 | - |
|
1146 | - /** |
|
1147 | - * This simply compares the internal dtt for the given string with NOW |
|
1148 | - * and determines if the date is expired or not. |
|
1149 | - * |
|
1150 | - * @return boolean |
|
1151 | - * @throws ReflectionException |
|
1152 | - * @throws InvalidArgumentException |
|
1153 | - * @throws InvalidInterfaceException |
|
1154 | - * @throws InvalidDataTypeException |
|
1155 | - * @throws EE_Error |
|
1156 | - */ |
|
1157 | - public function is_expired() |
|
1158 | - { |
|
1159 | - return ($this->get_raw('DTT_EVT_end') < time()); |
|
1160 | - } |
|
1161 | - |
|
1162 | - |
|
1163 | - /** |
|
1164 | - * This returns the active status for whether an event is active, upcoming, or expired |
|
1165 | - * |
|
1166 | - * @return int return value will be one of the EE_Datetime status constants. |
|
1167 | - * @throws ReflectionException |
|
1168 | - * @throws InvalidArgumentException |
|
1169 | - * @throws InvalidInterfaceException |
|
1170 | - * @throws InvalidDataTypeException |
|
1171 | - * @throws EE_Error |
|
1172 | - */ |
|
1173 | - public function get_active_status() |
|
1174 | - { |
|
1175 | - $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
|
1176 | - if ($total_tickets_for_this_dtt !== false && $total_tickets_for_this_dtt < 1) { |
|
1177 | - return EE_Datetime::sold_out; |
|
1178 | - } |
|
1179 | - if ($this->is_expired()) { |
|
1180 | - return EE_Datetime::expired; |
|
1181 | - } |
|
1182 | - if ($this->is_upcoming()) { |
|
1183 | - return EE_Datetime::upcoming; |
|
1184 | - } |
|
1185 | - if ($this->is_active()) { |
|
1186 | - return EE_Datetime::active; |
|
1187 | - } |
|
1188 | - return null; |
|
1189 | - } |
|
1190 | - |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * This returns a nice display name for the datetime that is contingent on the span between the dates and times. |
|
1194 | - * |
|
1195 | - * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
|
1196 | - * @return string |
|
1197 | - * @throws ReflectionException |
|
1198 | - * @throws InvalidArgumentException |
|
1199 | - * @throws InvalidInterfaceException |
|
1200 | - * @throws InvalidDataTypeException |
|
1201 | - * @throws EE_Error |
|
1202 | - */ |
|
1203 | - public function get_dtt_display_name($use_dtt_name = false) |
|
1204 | - { |
|
1205 | - if ($use_dtt_name) { |
|
1206 | - $dtt_name = $this->name(); |
|
1207 | - if (! empty($dtt_name)) { |
|
1208 | - return $dtt_name; |
|
1209 | - } |
|
1210 | - } |
|
1211 | - // first condition is to see if the months are different |
|
1212 | - if ( |
|
1213 | - date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end')) |
|
1214 | - ) { |
|
1215 | - $display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a'); |
|
1216 | - // next condition is if its the same month but different day |
|
1217 | - } else { |
|
1218 | - if ( |
|
1219 | - date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end')) |
|
1220 | - && date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end')) |
|
1221 | - ) { |
|
1222 | - $display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y'); |
|
1223 | - } else { |
|
1224 | - $display_date = $this->start_date('F j\, Y') |
|
1225 | - . ' @ ' |
|
1226 | - . $this->start_date('g:i a') |
|
1227 | - . ' - ' |
|
1228 | - . $this->end_date('g:i a'); |
|
1229 | - } |
|
1230 | - } |
|
1231 | - return $display_date; |
|
1232 | - } |
|
1233 | - |
|
1234 | - |
|
1235 | - /** |
|
1236 | - * Gets all the tickets for this datetime |
|
1237 | - * |
|
1238 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1239 | - * @return EE_Base_Class[]|EE_Ticket[] |
|
1240 | - * @throws ReflectionException |
|
1241 | - * @throws InvalidArgumentException |
|
1242 | - * @throws InvalidInterfaceException |
|
1243 | - * @throws InvalidDataTypeException |
|
1244 | - * @throws EE_Error |
|
1245 | - */ |
|
1246 | - public function tickets($query_params = array()) |
|
1247 | - { |
|
1248 | - return $this->get_many_related('Ticket', $query_params); |
|
1249 | - } |
|
1250 | - |
|
1251 | - |
|
1252 | - /** |
|
1253 | - * Gets all the ticket types currently available for purchase |
|
1254 | - * |
|
1255 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1256 | - * @return EE_Ticket[] |
|
1257 | - * @throws ReflectionException |
|
1258 | - * @throws InvalidArgumentException |
|
1259 | - * @throws InvalidInterfaceException |
|
1260 | - * @throws InvalidDataTypeException |
|
1261 | - * @throws EE_Error |
|
1262 | - */ |
|
1263 | - public function ticket_types_available_for_purchase($query_params = array()) |
|
1264 | - { |
|
1265 | - // first check if datetime is valid |
|
1266 | - if ($this->sold_out() || ! ($this->is_upcoming() || $this->is_active())) { |
|
1267 | - return array(); |
|
1268 | - } |
|
1269 | - if (empty($query_params)) { |
|
1270 | - $query_params = array( |
|
1271 | - array( |
|
1272 | - 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
1273 | - 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
1274 | - 'TKT_deleted' => false, |
|
1275 | - ), |
|
1276 | - ); |
|
1277 | - } |
|
1278 | - return $this->tickets($query_params); |
|
1279 | - } |
|
1280 | - |
|
1281 | - |
|
1282 | - /** |
|
1283 | - * @return EE_Base_Class|EE_Event |
|
1284 | - * @throws ReflectionException |
|
1285 | - * @throws InvalidArgumentException |
|
1286 | - * @throws InvalidInterfaceException |
|
1287 | - * @throws InvalidDataTypeException |
|
1288 | - * @throws EE_Error |
|
1289 | - */ |
|
1290 | - public function event() |
|
1291 | - { |
|
1292 | - return $this->get_first_related('Event'); |
|
1293 | - } |
|
1294 | - |
|
1295 | - |
|
1296 | - /** |
|
1297 | - * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime |
|
1298 | - * (via the tickets). |
|
1299 | - * |
|
1300 | - * @return int |
|
1301 | - * @throws ReflectionException |
|
1302 | - * @throws InvalidArgumentException |
|
1303 | - * @throws InvalidInterfaceException |
|
1304 | - * @throws InvalidDataTypeException |
|
1305 | - * @throws EE_Error |
|
1306 | - */ |
|
1307 | - public function update_sold() |
|
1308 | - { |
|
1309 | - $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
|
1310 | - array( |
|
1311 | - array( |
|
1312 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
1313 | - 'REG_deleted' => 0, |
|
1314 | - 'Ticket.Datetime.DTT_ID' => $this->ID(), |
|
1315 | - ), |
|
1316 | - ) |
|
1317 | - ); |
|
1318 | - $this->set_sold($count_regs_for_this_datetime); |
|
1319 | - $this->save(); |
|
1320 | - return $count_regs_for_this_datetime; |
|
1321 | - } |
|
1322 | - |
|
1323 | - |
|
1324 | - /** |
|
1325 | - * Adds a venue to this event |
|
1326 | - * |
|
1327 | - * @param int|EE_Venue /int $venue_id_or_obj |
|
1328 | - * @return EE_Base_Class|EE_Venue |
|
1329 | - * @throws EE_Error |
|
1330 | - * @throws ReflectionException |
|
1331 | - */ |
|
1332 | - public function add_venue($venue_id_or_obj): EE_Venue |
|
1333 | - { |
|
1334 | - return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
1335 | - } |
|
1336 | - |
|
1337 | - |
|
1338 | - /** |
|
1339 | - * Removes a venue from the event |
|
1340 | - * |
|
1341 | - * @param EE_Venue /int $venue_id_or_obj |
|
1342 | - * @return EE_Base_Class|EE_Venue |
|
1343 | - * @throws EE_Error |
|
1344 | - * @throws ReflectionException |
|
1345 | - */ |
|
1346 | - public function remove_venue($venue_id_or_obj): EE_Venue |
|
1347 | - { |
|
1348 | - $venue_id_or_obj = ! empty($venue_id_or_obj) ? $venue_id_or_obj : $this->venue(); |
|
1349 | - return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
1350 | - } |
|
1351 | - |
|
1352 | - |
|
1353 | - /** |
|
1354 | - * Gets the venue related to the event. May provide additional $query_params if desired |
|
1355 | - * |
|
1356 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1357 | - * @return int |
|
1358 | - * @throws EE_Error |
|
1359 | - * @throws ReflectionException |
|
1360 | - */ |
|
1361 | - public function venue_ID(array $query_params = []): int |
|
1362 | - { |
|
1363 | - $venue = $this->get_first_related('Venue', $query_params); |
|
1364 | - return $venue instanceof EE_Venue |
|
1365 | - ? $venue->ID() |
|
1366 | - : 0; |
|
1367 | - } |
|
1368 | - |
|
1369 | - |
|
1370 | - /** |
|
1371 | - * Gets the venue related to the event. May provide additional $query_params if desired |
|
1372 | - * |
|
1373 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1374 | - * @return EE_Base_Class|EE_Venue |
|
1375 | - * @throws EE_Error |
|
1376 | - * @throws ReflectionException |
|
1377 | - */ |
|
1378 | - public function venue(array $query_params = []) |
|
1379 | - { |
|
1380 | - return $this->get_first_related('Venue', $query_params); |
|
1381 | - } |
|
1382 | - |
|
1383 | - |
|
1384 | - /******************************************************************* |
|
16 | + /** |
|
17 | + * constant used by get_active_status, indicates datetime has no more available spaces |
|
18 | + */ |
|
19 | + const sold_out = 'DTS'; |
|
20 | + |
|
21 | + /** |
|
22 | + * constant used by get_active_status, indicating datetime is still active (even is not over, can be registered-for) |
|
23 | + */ |
|
24 | + const active = 'DTA'; |
|
25 | + |
|
26 | + /** |
|
27 | + * constant used by get_active_status, indicating the datetime cannot be used for registrations yet, but has not |
|
28 | + * expired |
|
29 | + */ |
|
30 | + const upcoming = 'DTU'; |
|
31 | + |
|
32 | + /** |
|
33 | + * Datetime is postponed |
|
34 | + */ |
|
35 | + const postponed = 'DTP'; |
|
36 | + |
|
37 | + /** |
|
38 | + * Datetime is cancelled |
|
39 | + */ |
|
40 | + const cancelled = 'DTC'; |
|
41 | + |
|
42 | + /** |
|
43 | + * constant used by get_active_status, indicates datetime has expired (event is over) |
|
44 | + */ |
|
45 | + const expired = 'DTE'; |
|
46 | + |
|
47 | + /** |
|
48 | + * constant used in various places indicating that an event is INACTIVE (not yet ready to be published) |
|
49 | + */ |
|
50 | + const inactive = 'DTI'; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @param array $props_n_values incoming values |
|
55 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be used.) |
|
56 | + * @param array $date_formats incoming date_formats in an array where the first value is the date_format |
|
57 | + * and the second value is the time format |
|
58 | + * @return EE_Datetime |
|
59 | + * @throws ReflectionException |
|
60 | + * @throws InvalidArgumentException |
|
61 | + * @throws InvalidInterfaceException |
|
62 | + * @throws InvalidDataTypeException |
|
63 | + * @throws EE_Error |
|
64 | + */ |
|
65 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
66 | + { |
|
67 | + $has_object = parent::_check_for_object( |
|
68 | + $props_n_values, |
|
69 | + __CLASS__, |
|
70 | + $timezone, |
|
71 | + $date_formats |
|
72 | + ); |
|
73 | + return $has_object |
|
74 | + ? $has_object |
|
75 | + : new self($props_n_values, false, $timezone, $date_formats); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param array $props_n_values incoming values from the database |
|
81 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
82 | + * the website will be used. |
|
83 | + * @return EE_Datetime |
|
84 | + * @throws ReflectionException |
|
85 | + * @throws InvalidArgumentException |
|
86 | + * @throws InvalidInterfaceException |
|
87 | + * @throws InvalidDataTypeException |
|
88 | + * @throws EE_Error |
|
89 | + */ |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
91 | + { |
|
92 | + return new self($props_n_values, true, $timezone); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @param $name |
|
98 | + * @throws ReflectionException |
|
99 | + * @throws InvalidArgumentException |
|
100 | + * @throws InvalidInterfaceException |
|
101 | + * @throws InvalidDataTypeException |
|
102 | + * @throws EE_Error |
|
103 | + */ |
|
104 | + public function set_name($name) |
|
105 | + { |
|
106 | + $this->set('DTT_name', $name); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @param $description |
|
112 | + * @throws ReflectionException |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws InvalidInterfaceException |
|
115 | + * @throws InvalidDataTypeException |
|
116 | + * @throws EE_Error |
|
117 | + */ |
|
118 | + public function set_description($description) |
|
119 | + { |
|
120 | + $this->set('DTT_description', $description); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * Set event start date |
|
126 | + * set the start date for an event |
|
127 | + * |
|
128 | + * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
|
129 | + * @throws ReflectionException |
|
130 | + * @throws InvalidArgumentException |
|
131 | + * @throws InvalidInterfaceException |
|
132 | + * @throws InvalidDataTypeException |
|
133 | + * @throws EE_Error |
|
134 | + */ |
|
135 | + public function set_start_date($date) |
|
136 | + { |
|
137 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Set event start time |
|
143 | + * set the start time for an event |
|
144 | + * |
|
145 | + * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
|
146 | + * @throws ReflectionException |
|
147 | + * @throws InvalidArgumentException |
|
148 | + * @throws InvalidInterfaceException |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws EE_Error |
|
151 | + */ |
|
152 | + public function set_start_time($time) |
|
153 | + { |
|
154 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Set event end date |
|
160 | + * set the end date for an event |
|
161 | + * |
|
162 | + * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
|
163 | + * @throws ReflectionException |
|
164 | + * @throws InvalidArgumentException |
|
165 | + * @throws InvalidInterfaceException |
|
166 | + * @throws InvalidDataTypeException |
|
167 | + * @throws EE_Error |
|
168 | + */ |
|
169 | + public function set_end_date($date) |
|
170 | + { |
|
171 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * Set event end time |
|
177 | + * set the end time for an event |
|
178 | + * |
|
179 | + * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
|
180 | + * @throws ReflectionException |
|
181 | + * @throws InvalidArgumentException |
|
182 | + * @throws InvalidInterfaceException |
|
183 | + * @throws InvalidDataTypeException |
|
184 | + * @throws EE_Error |
|
185 | + */ |
|
186 | + public function set_end_time($time) |
|
187 | + { |
|
188 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * Set registration limit |
|
194 | + * set the maximum number of attendees that can be registered for this datetime slot |
|
195 | + * |
|
196 | + * @param int $reg_limit |
|
197 | + * @throws ReflectionException |
|
198 | + * @throws InvalidArgumentException |
|
199 | + * @throws InvalidInterfaceException |
|
200 | + * @throws InvalidDataTypeException |
|
201 | + * @throws EE_Error |
|
202 | + */ |
|
203 | + public function set_reg_limit($reg_limit) |
|
204 | + { |
|
205 | + $this->set('DTT_reg_limit', $reg_limit); |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * get the number of tickets sold for this datetime slot |
|
211 | + * |
|
212 | + * @return mixed int on success, FALSE on fail |
|
213 | + * @throws ReflectionException |
|
214 | + * @throws InvalidArgumentException |
|
215 | + * @throws InvalidInterfaceException |
|
216 | + * @throws InvalidDataTypeException |
|
217 | + * @throws EE_Error |
|
218 | + */ |
|
219 | + public function sold() |
|
220 | + { |
|
221 | + return $this->get_raw('DTT_sold'); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * @param int $sold |
|
227 | + * @throws ReflectionException |
|
228 | + * @throws InvalidArgumentException |
|
229 | + * @throws InvalidInterfaceException |
|
230 | + * @throws InvalidDataTypeException |
|
231 | + * @throws EE_Error |
|
232 | + */ |
|
233 | + public function set_sold($sold) |
|
234 | + { |
|
235 | + // sold can not go below zero |
|
236 | + $sold = max(0, $sold); |
|
237 | + $this->set('DTT_sold', $sold); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * Increments sold by amount passed by $qty, and persists it immediately to the database. |
|
243 | + * Simultaneously decreases the reserved count, unless $also_decrease_reserved is false. |
|
244 | + * |
|
245 | + * @param int $qty |
|
246 | + * @param boolean $also_decrease_reserved |
|
247 | + * @return boolean indicating success |
|
248 | + * @throws ReflectionException |
|
249 | + * @throws InvalidArgumentException |
|
250 | + * @throws InvalidInterfaceException |
|
251 | + * @throws InvalidDataTypeException |
|
252 | + * @throws EE_Error |
|
253 | + */ |
|
254 | + public function increaseSold($qty = 1, $also_decrease_reserved = true) |
|
255 | + { |
|
256 | + $qty = absint($qty); |
|
257 | + if ($also_decrease_reserved) { |
|
258 | + $success = $this->adjustNumericFieldsInDb( |
|
259 | + [ |
|
260 | + 'DTT_reserved' => $qty * -1, |
|
261 | + 'DTT_sold' => $qty |
|
262 | + ] |
|
263 | + ); |
|
264 | + } else { |
|
265 | + $success = $this->adjustNumericFieldsInDb( |
|
266 | + [ |
|
267 | + 'DTT_sold' => $qty |
|
268 | + ] |
|
269 | + ); |
|
270 | + } |
|
271 | + |
|
272 | + do_action( |
|
273 | + 'AHEE__EE_Datetime__increase_sold', |
|
274 | + $this, |
|
275 | + $qty, |
|
276 | + $this->sold(), |
|
277 | + $success |
|
278 | + ); |
|
279 | + return $success; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need |
|
285 | + * to save afterwards.) |
|
286 | + * |
|
287 | + * @param int $qty |
|
288 | + * @return boolean indicating success |
|
289 | + * @throws ReflectionException |
|
290 | + * @throws InvalidArgumentException |
|
291 | + * @throws InvalidInterfaceException |
|
292 | + * @throws InvalidDataTypeException |
|
293 | + * @throws EE_Error |
|
294 | + */ |
|
295 | + public function decreaseSold($qty = 1) |
|
296 | + { |
|
297 | + $qty = absint($qty); |
|
298 | + $success = $this->adjustNumericFieldsInDb( |
|
299 | + [ |
|
300 | + 'DTT_sold' => $qty * -1 |
|
301 | + ] |
|
302 | + ); |
|
303 | + do_action( |
|
304 | + 'AHEE__EE_Datetime__decrease_sold', |
|
305 | + $this, |
|
306 | + $qty, |
|
307 | + $this->sold(), |
|
308 | + $success |
|
309 | + ); |
|
310 | + return $success; |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * Gets qty of reserved tickets for this datetime |
|
316 | + * |
|
317 | + * @return int |
|
318 | + * @throws ReflectionException |
|
319 | + * @throws InvalidArgumentException |
|
320 | + * @throws InvalidInterfaceException |
|
321 | + * @throws InvalidDataTypeException |
|
322 | + * @throws EE_Error |
|
323 | + */ |
|
324 | + public function reserved() |
|
325 | + { |
|
326 | + return $this->get_raw('DTT_reserved'); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * Sets qty of reserved tickets for this datetime |
|
332 | + * |
|
333 | + * @param int $reserved |
|
334 | + * @throws ReflectionException |
|
335 | + * @throws InvalidArgumentException |
|
336 | + * @throws InvalidInterfaceException |
|
337 | + * @throws InvalidDataTypeException |
|
338 | + * @throws EE_Error |
|
339 | + */ |
|
340 | + public function set_reserved($reserved) |
|
341 | + { |
|
342 | + // reserved can not go below zero |
|
343 | + $reserved = max(0, (int) $reserved); |
|
344 | + $this->set('DTT_reserved', $reserved); |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + /** |
|
349 | + * Increments reserved by amount passed by $qty, and persists it immediately to the database. |
|
350 | + * |
|
351 | + * @param int $qty |
|
352 | + * @return boolean indicating success |
|
353 | + * @throws ReflectionException |
|
354 | + * @throws InvalidArgumentException |
|
355 | + * @throws InvalidInterfaceException |
|
356 | + * @throws InvalidDataTypeException |
|
357 | + * @throws EE_Error |
|
358 | + */ |
|
359 | + public function increaseReserved($qty = 1) |
|
360 | + { |
|
361 | + $qty = absint($qty); |
|
362 | + $success = $this->incrementFieldConditionallyInDb( |
|
363 | + 'DTT_reserved', |
|
364 | + 'DTT_sold', |
|
365 | + 'DTT_reg_limit', |
|
366 | + $qty |
|
367 | + ); |
|
368 | + do_action( |
|
369 | + 'AHEE__EE_Datetime__increase_reserved', |
|
370 | + $this, |
|
371 | + $qty, |
|
372 | + $this->reserved(), |
|
373 | + $success |
|
374 | + ); |
|
375 | + return $success; |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database. |
|
381 | + * |
|
382 | + * @param int $qty |
|
383 | + * @return boolean indicating success |
|
384 | + * @throws ReflectionException |
|
385 | + * @throws InvalidArgumentException |
|
386 | + * @throws InvalidInterfaceException |
|
387 | + * @throws InvalidDataTypeException |
|
388 | + * @throws EE_Error |
|
389 | + */ |
|
390 | + public function decreaseReserved($qty = 1) |
|
391 | + { |
|
392 | + $qty = absint($qty); |
|
393 | + $success = $this->adjustNumericFieldsInDb( |
|
394 | + [ |
|
395 | + 'DTT_reserved' => $qty * -1 |
|
396 | + ] |
|
397 | + ); |
|
398 | + do_action( |
|
399 | + 'AHEE__EE_Datetime__decrease_reserved', |
|
400 | + $this, |
|
401 | + $qty, |
|
402 | + $this->reserved(), |
|
403 | + $success |
|
404 | + ); |
|
405 | + return $success; |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * total sold and reserved tickets |
|
411 | + * |
|
412 | + * @return int |
|
413 | + * @throws ReflectionException |
|
414 | + * @throws InvalidArgumentException |
|
415 | + * @throws InvalidInterfaceException |
|
416 | + * @throws InvalidDataTypeException |
|
417 | + * @throws EE_Error |
|
418 | + */ |
|
419 | + public function sold_and_reserved() |
|
420 | + { |
|
421 | + return $this->sold() + $this->reserved(); |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + /** |
|
426 | + * returns the datetime name |
|
427 | + * |
|
428 | + * @return string |
|
429 | + * @throws ReflectionException |
|
430 | + * @throws InvalidArgumentException |
|
431 | + * @throws InvalidInterfaceException |
|
432 | + * @throws InvalidDataTypeException |
|
433 | + * @throws EE_Error |
|
434 | + */ |
|
435 | + public function name() |
|
436 | + { |
|
437 | + return $this->get('DTT_name'); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * returns the datetime description |
|
443 | + * |
|
444 | + * @return string |
|
445 | + * @throws ReflectionException |
|
446 | + * @throws InvalidArgumentException |
|
447 | + * @throws InvalidInterfaceException |
|
448 | + * @throws InvalidDataTypeException |
|
449 | + * @throws EE_Error |
|
450 | + */ |
|
451 | + public function description() |
|
452 | + { |
|
453 | + return $this->get('DTT_description'); |
|
454 | + } |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * This helper simply returns whether the event_datetime for the current datetime is a primary datetime |
|
459 | + * |
|
460 | + * @return boolean TRUE if is primary, FALSE if not. |
|
461 | + * @throws ReflectionException |
|
462 | + * @throws InvalidArgumentException |
|
463 | + * @throws InvalidInterfaceException |
|
464 | + * @throws InvalidDataTypeException |
|
465 | + * @throws EE_Error |
|
466 | + */ |
|
467 | + public function is_primary() |
|
468 | + { |
|
469 | + return $this->get('DTT_is_primary'); |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * This helper simply returns the order for the datetime |
|
475 | + * |
|
476 | + * @return int The order of the datetime for this event. |
|
477 | + * @throws ReflectionException |
|
478 | + * @throws InvalidArgumentException |
|
479 | + * @throws InvalidInterfaceException |
|
480 | + * @throws InvalidDataTypeException |
|
481 | + * @throws EE_Error |
|
482 | + */ |
|
483 | + public function order() |
|
484 | + { |
|
485 | + return $this->get('DTT_order'); |
|
486 | + } |
|
487 | + |
|
488 | + |
|
489 | + /** |
|
490 | + * This helper simply returns the parent id for the datetime |
|
491 | + * |
|
492 | + * @return int |
|
493 | + * @throws ReflectionException |
|
494 | + * @throws InvalidArgumentException |
|
495 | + * @throws InvalidInterfaceException |
|
496 | + * @throws InvalidDataTypeException |
|
497 | + * @throws EE_Error |
|
498 | + */ |
|
499 | + public function parent() |
|
500 | + { |
|
501 | + return $this->get('DTT_parent'); |
|
502 | + } |
|
503 | + |
|
504 | + |
|
505 | + /** |
|
506 | + * show date and/or time |
|
507 | + * |
|
508 | + * @param string $date_or_time whether to display a date or time or both |
|
509 | + * @param string $start_or_end whether to display start or end datetimes |
|
510 | + * @param string $dt_frmt |
|
511 | + * @param string $tm_frmt |
|
512 | + * @param bool $echo whether we echo or return (note echoing uses "pretty" formats, |
|
513 | + * otherwise we use the standard formats) |
|
514 | + * @return string|bool string on success, FALSE on fail |
|
515 | + * @throws ReflectionException |
|
516 | + * @throws InvalidArgumentException |
|
517 | + * @throws InvalidInterfaceException |
|
518 | + * @throws InvalidDataTypeException |
|
519 | + * @throws EE_Error |
|
520 | + */ |
|
521 | + private function _show_datetime( |
|
522 | + $date_or_time = null, |
|
523 | + $start_or_end = 'start', |
|
524 | + $dt_frmt = '', |
|
525 | + $tm_frmt = '', |
|
526 | + $echo = false |
|
527 | + ) { |
|
528 | + $field_name = "DTT_EVT_{$start_or_end}"; |
|
529 | + $dtt = $this->_get_datetime( |
|
530 | + $field_name, |
|
531 | + $dt_frmt, |
|
532 | + $tm_frmt, |
|
533 | + $date_or_time, |
|
534 | + $echo |
|
535 | + ); |
|
536 | + if (! $echo) { |
|
537 | + return $dtt; |
|
538 | + } |
|
539 | + return ''; |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + /** |
|
544 | + * get event start date. Provide either the date format, or NULL to re-use the |
|
545 | + * last-used format, or '' to use the default date format |
|
546 | + * |
|
547 | + * @param string $dt_frmt string representation of date format defaults to 'F j, Y' |
|
548 | + * @return mixed string on success, FALSE on fail |
|
549 | + * @throws ReflectionException |
|
550 | + * @throws InvalidArgumentException |
|
551 | + * @throws InvalidInterfaceException |
|
552 | + * @throws InvalidDataTypeException |
|
553 | + * @throws EE_Error |
|
554 | + */ |
|
555 | + public function start_date($dt_frmt = '') |
|
556 | + { |
|
557 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
558 | + } |
|
559 | + |
|
560 | + |
|
561 | + /** |
|
562 | + * Echoes start_date() |
|
563 | + * |
|
564 | + * @param string $dt_frmt |
|
565 | + * @throws ReflectionException |
|
566 | + * @throws InvalidArgumentException |
|
567 | + * @throws InvalidInterfaceException |
|
568 | + * @throws InvalidDataTypeException |
|
569 | + * @throws EE_Error |
|
570 | + */ |
|
571 | + public function e_start_date($dt_frmt = '') |
|
572 | + { |
|
573 | + $this->_show_datetime('D', 'start', $dt_frmt, null, true); |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * get end date. Provide either the date format, or NULL to re-use the |
|
579 | + * last-used format, or '' to use the default date format |
|
580 | + * |
|
581 | + * @param string $dt_frmt string representation of date format defaults to 'F j, Y' |
|
582 | + * @return mixed string on success, FALSE on fail |
|
583 | + * @throws ReflectionException |
|
584 | + * @throws InvalidArgumentException |
|
585 | + * @throws InvalidInterfaceException |
|
586 | + * @throws InvalidDataTypeException |
|
587 | + * @throws EE_Error |
|
588 | + */ |
|
589 | + public function end_date($dt_frmt = '') |
|
590 | + { |
|
591 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + /** |
|
596 | + * Echoes the end date. See end_date() |
|
597 | + * |
|
598 | + * @param string $dt_frmt |
|
599 | + * @throws ReflectionException |
|
600 | + * @throws InvalidArgumentException |
|
601 | + * @throws InvalidInterfaceException |
|
602 | + * @throws InvalidDataTypeException |
|
603 | + * @throws EE_Error |
|
604 | + */ |
|
605 | + public function e_end_date($dt_frmt = '') |
|
606 | + { |
|
607 | + $this->_show_datetime('D', 'end', $dt_frmt, null, true); |
|
608 | + } |
|
609 | + |
|
610 | + |
|
611 | + /** |
|
612 | + * get date_range - meaning the start AND end date |
|
613 | + * |
|
614 | + * @access public |
|
615 | + * @param string $dt_frmt string representation of date format defaults to WP settings |
|
616 | + * @param string $conjunction conjunction junction what's your function ? |
|
617 | + * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
618 | + * @return mixed string on success, FALSE on fail |
|
619 | + * @throws ReflectionException |
|
620 | + * @throws InvalidArgumentException |
|
621 | + * @throws InvalidInterfaceException |
|
622 | + * @throws InvalidDataTypeException |
|
623 | + * @throws EE_Error |
|
624 | + */ |
|
625 | + public function date_range($dt_frmt = '', $conjunction = ' - ') |
|
626 | + { |
|
627 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
628 | + $start = str_replace( |
|
629 | + ' ', |
|
630 | + ' ', |
|
631 | + $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt) |
|
632 | + ); |
|
633 | + $end = str_replace( |
|
634 | + ' ', |
|
635 | + ' ', |
|
636 | + $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt) |
|
637 | + ); |
|
638 | + return $start !== $end ? $start . $conjunction . $end : $start; |
|
639 | + } |
|
640 | + |
|
641 | + |
|
642 | + /** |
|
643 | + * @param string $dt_frmt |
|
644 | + * @param string $conjunction |
|
645 | + * @throws ReflectionException |
|
646 | + * @throws InvalidArgumentException |
|
647 | + * @throws InvalidInterfaceException |
|
648 | + * @throws InvalidDataTypeException |
|
649 | + * @throws EE_Error |
|
650 | + */ |
|
651 | + public function e_date_range($dt_frmt = '', $conjunction = ' - ') |
|
652 | + { |
|
653 | + echo $this->date_range($dt_frmt, $conjunction); |
|
654 | + } |
|
655 | + |
|
656 | + |
|
657 | + /** |
|
658 | + * get start time |
|
659 | + * |
|
660 | + * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
661 | + * @return mixed string on success, FALSE on fail |
|
662 | + * @throws ReflectionException |
|
663 | + * @throws InvalidArgumentException |
|
664 | + * @throws InvalidInterfaceException |
|
665 | + * @throws InvalidDataTypeException |
|
666 | + * @throws EE_Error |
|
667 | + */ |
|
668 | + public function start_time($tm_format = '') |
|
669 | + { |
|
670 | + return $this->_show_datetime('T', 'start', null, $tm_format); |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + /** |
|
675 | + * @param string $tm_format |
|
676 | + * @throws ReflectionException |
|
677 | + * @throws InvalidArgumentException |
|
678 | + * @throws InvalidInterfaceException |
|
679 | + * @throws InvalidDataTypeException |
|
680 | + * @throws EE_Error |
|
681 | + */ |
|
682 | + public function e_start_time($tm_format = '') |
|
683 | + { |
|
684 | + $this->_show_datetime('T', 'start', null, $tm_format, true); |
|
685 | + } |
|
686 | + |
|
687 | + |
|
688 | + /** |
|
689 | + * get end time |
|
690 | + * |
|
691 | + * @param string $tm_format string representation of time format defaults to 'g:i a' |
|
692 | + * @return mixed string on success, FALSE on fail |
|
693 | + * @throws ReflectionException |
|
694 | + * @throws InvalidArgumentException |
|
695 | + * @throws InvalidInterfaceException |
|
696 | + * @throws InvalidDataTypeException |
|
697 | + * @throws EE_Error |
|
698 | + */ |
|
699 | + public function end_time($tm_format = '') |
|
700 | + { |
|
701 | + return $this->_show_datetime('T', 'end', null, $tm_format); |
|
702 | + } |
|
703 | + |
|
704 | + |
|
705 | + /** |
|
706 | + * @param string $tm_format |
|
707 | + * @throws ReflectionException |
|
708 | + * @throws InvalidArgumentException |
|
709 | + * @throws InvalidInterfaceException |
|
710 | + * @throws InvalidDataTypeException |
|
711 | + * @throws EE_Error |
|
712 | + */ |
|
713 | + public function e_end_time($tm_format = '') |
|
714 | + { |
|
715 | + $this->_show_datetime('T', 'end', null, $tm_format, true); |
|
716 | + } |
|
717 | + |
|
718 | + |
|
719 | + /** |
|
720 | + * get time_range |
|
721 | + * |
|
722 | + * @access public |
|
723 | + * @param string $tm_format string representation of time format defaults to 'g:i a' |
|
724 | + * @param string $conjunction conjunction junction what's your function ? |
|
725 | + * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
|
726 | + * @return mixed string on success, FALSE on fail |
|
727 | + * @throws ReflectionException |
|
728 | + * @throws InvalidArgumentException |
|
729 | + * @throws InvalidInterfaceException |
|
730 | + * @throws InvalidDataTypeException |
|
731 | + * @throws EE_Error |
|
732 | + */ |
|
733 | + public function time_range($tm_format = '', $conjunction = ' - ') |
|
734 | + { |
|
735 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
736 | + $start = str_replace( |
|
737 | + ' ', |
|
738 | + ' ', |
|
739 | + $this->get_i18n_datetime('DTT_EVT_start', $tm_format) |
|
740 | + ); |
|
741 | + $end = str_replace( |
|
742 | + ' ', |
|
743 | + ' ', |
|
744 | + $this->get_i18n_datetime('DTT_EVT_end', $tm_format) |
|
745 | + ); |
|
746 | + return $start !== $end ? $start . $conjunction . $end : $start; |
|
747 | + } |
|
748 | + |
|
749 | + |
|
750 | + /** |
|
751 | + * @param string $tm_format |
|
752 | + * @param string $conjunction |
|
753 | + * @throws ReflectionException |
|
754 | + * @throws InvalidArgumentException |
|
755 | + * @throws InvalidInterfaceException |
|
756 | + * @throws InvalidDataTypeException |
|
757 | + * @throws EE_Error |
|
758 | + */ |
|
759 | + public function e_time_range($tm_format = '', $conjunction = ' - ') |
|
760 | + { |
|
761 | + echo $this->time_range($tm_format, $conjunction); |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + /** |
|
766 | + * This returns a range representation of the date and times. |
|
767 | + * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end. |
|
768 | + * Also, the return value is localized. |
|
769 | + * |
|
770 | + * @param string $dt_format |
|
771 | + * @param string $tm_format |
|
772 | + * @param string $conjunction used between two different dates or times. |
|
773 | + * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
774 | + * @param string $separator used between the date and time formats. |
|
775 | + * ex: Dec 1, 2016{$separator}2pm |
|
776 | + * @return string |
|
777 | + * @throws ReflectionException |
|
778 | + * @throws InvalidArgumentException |
|
779 | + * @throws InvalidInterfaceException |
|
780 | + * @throws InvalidDataTypeException |
|
781 | + * @throws EE_Error |
|
782 | + */ |
|
783 | + public function date_and_time_range( |
|
784 | + $dt_format = '', |
|
785 | + $tm_format = '', |
|
786 | + $conjunction = ' - ', |
|
787 | + $separator = ' ' |
|
788 | + ) { |
|
789 | + $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt; |
|
790 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
791 | + $full_format = $dt_format . $separator . $tm_format; |
|
792 | + // the range output depends on various conditions |
|
793 | + switch (true) { |
|
794 | + // start date timestamp and end date timestamp are the same. |
|
795 | + case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')): |
|
796 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
797 | + break; |
|
798 | + // start and end date are the same but times are different |
|
799 | + case ($this->start_date() === $this->end_date()): |
|
800 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
801 | + . $conjunction |
|
802 | + . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
803 | + break; |
|
804 | + // all other conditions |
|
805 | + default: |
|
806 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
807 | + . $conjunction |
|
808 | + . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
809 | + break; |
|
810 | + } |
|
811 | + return $output; |
|
812 | + } |
|
813 | + |
|
814 | + |
|
815 | + /** |
|
816 | + * This echos the results of date and time range. |
|
817 | + * |
|
818 | + * @see date_and_time_range() for more details on purpose. |
|
819 | + * @param string $dt_format |
|
820 | + * @param string $tm_format |
|
821 | + * @param string $conjunction |
|
822 | + * @return void |
|
823 | + * @throws ReflectionException |
|
824 | + * @throws InvalidArgumentException |
|
825 | + * @throws InvalidInterfaceException |
|
826 | + * @throws InvalidDataTypeException |
|
827 | + * @throws EE_Error |
|
828 | + */ |
|
829 | + public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') |
|
830 | + { |
|
831 | + echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
832 | + } |
|
833 | + |
|
834 | + |
|
835 | + /** |
|
836 | + * get start date and start time |
|
837 | + * |
|
838 | + * @param string $dt_format - string representation of date format defaults to 'F j, Y' |
|
839 | + * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
840 | + * @return mixed string on success, FALSE on fail |
|
841 | + * @throws ReflectionException |
|
842 | + * @throws InvalidArgumentException |
|
843 | + * @throws InvalidInterfaceException |
|
844 | + * @throws InvalidDataTypeException |
|
845 | + * @throws EE_Error |
|
846 | + */ |
|
847 | + public function start_date_and_time($dt_format = '', $tm_format = '') |
|
848 | + { |
|
849 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
850 | + } |
|
851 | + |
|
852 | + |
|
853 | + /** |
|
854 | + * @param string $dt_frmt |
|
855 | + * @param string $tm_format |
|
856 | + * @throws ReflectionException |
|
857 | + * @throws InvalidArgumentException |
|
858 | + * @throws InvalidInterfaceException |
|
859 | + * @throws InvalidDataTypeException |
|
860 | + * @throws EE_Error |
|
861 | + */ |
|
862 | + public function e_start_date_and_time($dt_frmt = '', $tm_format = '') |
|
863 | + { |
|
864 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, true); |
|
865 | + } |
|
866 | + |
|
867 | + |
|
868 | + /** |
|
869 | + * Shows the length of the event (start to end time). |
|
870 | + * Can be shown in 'seconds','minutes','hours', or 'days'. |
|
871 | + * By default, rounds up. (So if you use 'days', and then event |
|
872 | + * only occurs for 1 hour, it will return 1 day). |
|
873 | + * |
|
874 | + * @param string $units 'seconds','minutes','hours','days' |
|
875 | + * @param bool $round_up |
|
876 | + * @return float|int|mixed |
|
877 | + * @throws ReflectionException |
|
878 | + * @throws InvalidArgumentException |
|
879 | + * @throws InvalidInterfaceException |
|
880 | + * @throws InvalidDataTypeException |
|
881 | + * @throws EE_Error |
|
882 | + */ |
|
883 | + public function length($units = 'seconds', $round_up = false) |
|
884 | + { |
|
885 | + $start = $this->get_raw('DTT_EVT_start'); |
|
886 | + $end = $this->get_raw('DTT_EVT_end'); |
|
887 | + $length_in_units = $end - $start; |
|
888 | + switch ($units) { |
|
889 | + // NOTE: We purposefully don't use "break;" in order to chain the divisions |
|
890 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
891 | + // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment |
|
892 | + case 'days': |
|
893 | + $length_in_units /= 24; |
|
894 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
895 | + case 'hours': |
|
896 | + // fall through is intentional |
|
897 | + $length_in_units /= 60; |
|
898 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
899 | + case 'minutes': |
|
900 | + // fall through is intentional |
|
901 | + $length_in_units /= 60; |
|
902 | + case 'seconds': |
|
903 | + default: |
|
904 | + $length_in_units = ceil($length_in_units); |
|
905 | + } |
|
906 | + // phpcs:enable |
|
907 | + if ($round_up) { |
|
908 | + $length_in_units = max($length_in_units, 1); |
|
909 | + } |
|
910 | + return $length_in_units; |
|
911 | + } |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * get end date and time |
|
916 | + * |
|
917 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
918 | + * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
919 | + * @return mixed string on success, FALSE on fail |
|
920 | + * @throws ReflectionException |
|
921 | + * @throws InvalidArgumentException |
|
922 | + * @throws InvalidInterfaceException |
|
923 | + * @throws InvalidDataTypeException |
|
924 | + * @throws EE_Error |
|
925 | + */ |
|
926 | + public function end_date_and_time($dt_frmt = '', $tm_format = '') |
|
927 | + { |
|
928 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
929 | + } |
|
930 | + |
|
931 | + |
|
932 | + /** |
|
933 | + * @param string $dt_frmt |
|
934 | + * @param string $tm_format |
|
935 | + * @throws ReflectionException |
|
936 | + * @throws InvalidArgumentException |
|
937 | + * @throws InvalidInterfaceException |
|
938 | + * @throws InvalidDataTypeException |
|
939 | + * @throws EE_Error |
|
940 | + */ |
|
941 | + public function e_end_date_and_time($dt_frmt = '', $tm_format = '') |
|
942 | + { |
|
943 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, true); |
|
944 | + } |
|
945 | + |
|
946 | + |
|
947 | + /** |
|
948 | + * get start timestamp |
|
949 | + * |
|
950 | + * @return int |
|
951 | + * @throws ReflectionException |
|
952 | + * @throws InvalidArgumentException |
|
953 | + * @throws InvalidInterfaceException |
|
954 | + * @throws InvalidDataTypeException |
|
955 | + * @throws EE_Error |
|
956 | + */ |
|
957 | + public function start() |
|
958 | + { |
|
959 | + return $this->get_raw('DTT_EVT_start'); |
|
960 | + } |
|
961 | + |
|
962 | + |
|
963 | + /** |
|
964 | + * get end timestamp |
|
965 | + * |
|
966 | + * @return int |
|
967 | + * @throws ReflectionException |
|
968 | + * @throws InvalidArgumentException |
|
969 | + * @throws InvalidInterfaceException |
|
970 | + * @throws InvalidDataTypeException |
|
971 | + * @throws EE_Error |
|
972 | + */ |
|
973 | + public function end() |
|
974 | + { |
|
975 | + return $this->get_raw('DTT_EVT_end'); |
|
976 | + } |
|
977 | + |
|
978 | + |
|
979 | + /** |
|
980 | + * get the registration limit for this datetime slot |
|
981 | + * |
|
982 | + * @return mixed int on success, FALSE on fail |
|
983 | + * @throws ReflectionException |
|
984 | + * @throws InvalidArgumentException |
|
985 | + * @throws InvalidInterfaceException |
|
986 | + * @throws InvalidDataTypeException |
|
987 | + * @throws EE_Error |
|
988 | + */ |
|
989 | + public function reg_limit() |
|
990 | + { |
|
991 | + return $this->get_raw('DTT_reg_limit'); |
|
992 | + } |
|
993 | + |
|
994 | + |
|
995 | + /** |
|
996 | + * have the tickets sold for this datetime, met or exceed the registration limit ? |
|
997 | + * |
|
998 | + * @return boolean |
|
999 | + * @throws ReflectionException |
|
1000 | + * @throws InvalidArgumentException |
|
1001 | + * @throws InvalidInterfaceException |
|
1002 | + * @throws InvalidDataTypeException |
|
1003 | + * @throws EE_Error |
|
1004 | + */ |
|
1005 | + public function sold_out() |
|
1006 | + { |
|
1007 | + return $this->reg_limit() > 0 && $this->sold() >= $this->reg_limit(); |
|
1008 | + } |
|
1009 | + |
|
1010 | + |
|
1011 | + /** |
|
1012 | + * return the total number of spaces remaining at this venue. |
|
1013 | + * This only takes the venue's capacity into account, NOT the tickets available for sale |
|
1014 | + * |
|
1015 | + * @param bool $consider_tickets Whether to consider tickets remaining when determining if there are any spaces left |
|
1016 | + * Because if all tickets attached to this datetime have no spaces left, |
|
1017 | + * then this datetime IS effectively sold out. |
|
1018 | + * However, there are cases where we just want to know the spaces |
|
1019 | + * remaining for this particular datetime, hence the flag. |
|
1020 | + * @return int |
|
1021 | + * @throws ReflectionException |
|
1022 | + * @throws InvalidArgumentException |
|
1023 | + * @throws InvalidInterfaceException |
|
1024 | + * @throws InvalidDataTypeException |
|
1025 | + * @throws EE_Error |
|
1026 | + */ |
|
1027 | + public function spaces_remaining($consider_tickets = false) |
|
1028 | + { |
|
1029 | + // tickets remaining available for purchase |
|
1030 | + // no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
|
1031 | + $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved(); |
|
1032 | + if (! $consider_tickets) { |
|
1033 | + return $dtt_remaining; |
|
1034 | + } |
|
1035 | + $tickets_remaining = $this->tickets_remaining(); |
|
1036 | + return min($dtt_remaining, $tickets_remaining); |
|
1037 | + } |
|
1038 | + |
|
1039 | + |
|
1040 | + /** |
|
1041 | + * Counts the total tickets available |
|
1042 | + * (from all the different types of tickets which are available for this datetime). |
|
1043 | + * |
|
1044 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1045 | + * @return int |
|
1046 | + * @throws ReflectionException |
|
1047 | + * @throws InvalidArgumentException |
|
1048 | + * @throws InvalidInterfaceException |
|
1049 | + * @throws InvalidDataTypeException |
|
1050 | + * @throws EE_Error |
|
1051 | + */ |
|
1052 | + public function tickets_remaining($query_params = array()) |
|
1053 | + { |
|
1054 | + $sum = 0; |
|
1055 | + $tickets = $this->tickets($query_params); |
|
1056 | + if (! empty($tickets)) { |
|
1057 | + foreach ($tickets as $ticket) { |
|
1058 | + if ($ticket instanceof EE_Ticket) { |
|
1059 | + // get the actual amount of tickets that can be sold |
|
1060 | + $qty = $ticket->qty('saleable'); |
|
1061 | + if ($qty === EE_INF) { |
|
1062 | + return EE_INF; |
|
1063 | + } |
|
1064 | + // no negative ticket quantities plz |
|
1065 | + if ($qty > 0) { |
|
1066 | + $sum += $qty; |
|
1067 | + } |
|
1068 | + } |
|
1069 | + } |
|
1070 | + } |
|
1071 | + return $sum; |
|
1072 | + } |
|
1073 | + |
|
1074 | + |
|
1075 | + /** |
|
1076 | + * Gets the count of all the tickets available at this datetime (not ticket types) |
|
1077 | + * before any were sold |
|
1078 | + * |
|
1079 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1080 | + * @return int |
|
1081 | + * @throws ReflectionException |
|
1082 | + * @throws InvalidArgumentException |
|
1083 | + * @throws InvalidInterfaceException |
|
1084 | + * @throws InvalidDataTypeException |
|
1085 | + * @throws EE_Error |
|
1086 | + */ |
|
1087 | + public function sum_tickets_initially_available($query_params = array()) |
|
1088 | + { |
|
1089 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
1090 | + } |
|
1091 | + |
|
1092 | + |
|
1093 | + /** |
|
1094 | + * Returns the lesser-of-the two: spaces remaining at this datetime, or |
|
1095 | + * the total tickets remaining (a sum of the tickets remaining for each ticket type |
|
1096 | + * that is available for this datetime). |
|
1097 | + * |
|
1098 | + * @return int |
|
1099 | + * @throws ReflectionException |
|
1100 | + * @throws InvalidArgumentException |
|
1101 | + * @throws InvalidInterfaceException |
|
1102 | + * @throws InvalidDataTypeException |
|
1103 | + * @throws EE_Error |
|
1104 | + */ |
|
1105 | + public function total_tickets_available_at_this_datetime() |
|
1106 | + { |
|
1107 | + return $this->spaces_remaining(true); |
|
1108 | + } |
|
1109 | + |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * This simply compares the internal dtt for the given string with NOW |
|
1113 | + * and determines if the date is upcoming or not. |
|
1114 | + * |
|
1115 | + * @access public |
|
1116 | + * @return boolean |
|
1117 | + * @throws ReflectionException |
|
1118 | + * @throws InvalidArgumentException |
|
1119 | + * @throws InvalidInterfaceException |
|
1120 | + * @throws InvalidDataTypeException |
|
1121 | + * @throws EE_Error |
|
1122 | + */ |
|
1123 | + public function is_upcoming() |
|
1124 | + { |
|
1125 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
1126 | + } |
|
1127 | + |
|
1128 | + |
|
1129 | + /** |
|
1130 | + * This simply compares the internal datetime for the given string with NOW |
|
1131 | + * and returns if the date is active (i.e. start and end time) |
|
1132 | + * |
|
1133 | + * @return boolean |
|
1134 | + * @throws ReflectionException |
|
1135 | + * @throws InvalidArgumentException |
|
1136 | + * @throws InvalidInterfaceException |
|
1137 | + * @throws InvalidDataTypeException |
|
1138 | + * @throws EE_Error |
|
1139 | + */ |
|
1140 | + public function is_active() |
|
1141 | + { |
|
1142 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
1143 | + } |
|
1144 | + |
|
1145 | + |
|
1146 | + /** |
|
1147 | + * This simply compares the internal dtt for the given string with NOW |
|
1148 | + * and determines if the date is expired or not. |
|
1149 | + * |
|
1150 | + * @return boolean |
|
1151 | + * @throws ReflectionException |
|
1152 | + * @throws InvalidArgumentException |
|
1153 | + * @throws InvalidInterfaceException |
|
1154 | + * @throws InvalidDataTypeException |
|
1155 | + * @throws EE_Error |
|
1156 | + */ |
|
1157 | + public function is_expired() |
|
1158 | + { |
|
1159 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
1160 | + } |
|
1161 | + |
|
1162 | + |
|
1163 | + /** |
|
1164 | + * This returns the active status for whether an event is active, upcoming, or expired |
|
1165 | + * |
|
1166 | + * @return int return value will be one of the EE_Datetime status constants. |
|
1167 | + * @throws ReflectionException |
|
1168 | + * @throws InvalidArgumentException |
|
1169 | + * @throws InvalidInterfaceException |
|
1170 | + * @throws InvalidDataTypeException |
|
1171 | + * @throws EE_Error |
|
1172 | + */ |
|
1173 | + public function get_active_status() |
|
1174 | + { |
|
1175 | + $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
|
1176 | + if ($total_tickets_for_this_dtt !== false && $total_tickets_for_this_dtt < 1) { |
|
1177 | + return EE_Datetime::sold_out; |
|
1178 | + } |
|
1179 | + if ($this->is_expired()) { |
|
1180 | + return EE_Datetime::expired; |
|
1181 | + } |
|
1182 | + if ($this->is_upcoming()) { |
|
1183 | + return EE_Datetime::upcoming; |
|
1184 | + } |
|
1185 | + if ($this->is_active()) { |
|
1186 | + return EE_Datetime::active; |
|
1187 | + } |
|
1188 | + return null; |
|
1189 | + } |
|
1190 | + |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * This returns a nice display name for the datetime that is contingent on the span between the dates and times. |
|
1194 | + * |
|
1195 | + * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
|
1196 | + * @return string |
|
1197 | + * @throws ReflectionException |
|
1198 | + * @throws InvalidArgumentException |
|
1199 | + * @throws InvalidInterfaceException |
|
1200 | + * @throws InvalidDataTypeException |
|
1201 | + * @throws EE_Error |
|
1202 | + */ |
|
1203 | + public function get_dtt_display_name($use_dtt_name = false) |
|
1204 | + { |
|
1205 | + if ($use_dtt_name) { |
|
1206 | + $dtt_name = $this->name(); |
|
1207 | + if (! empty($dtt_name)) { |
|
1208 | + return $dtt_name; |
|
1209 | + } |
|
1210 | + } |
|
1211 | + // first condition is to see if the months are different |
|
1212 | + if ( |
|
1213 | + date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end')) |
|
1214 | + ) { |
|
1215 | + $display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a'); |
|
1216 | + // next condition is if its the same month but different day |
|
1217 | + } else { |
|
1218 | + if ( |
|
1219 | + date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end')) |
|
1220 | + && date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end')) |
|
1221 | + ) { |
|
1222 | + $display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y'); |
|
1223 | + } else { |
|
1224 | + $display_date = $this->start_date('F j\, Y') |
|
1225 | + . ' @ ' |
|
1226 | + . $this->start_date('g:i a') |
|
1227 | + . ' - ' |
|
1228 | + . $this->end_date('g:i a'); |
|
1229 | + } |
|
1230 | + } |
|
1231 | + return $display_date; |
|
1232 | + } |
|
1233 | + |
|
1234 | + |
|
1235 | + /** |
|
1236 | + * Gets all the tickets for this datetime |
|
1237 | + * |
|
1238 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1239 | + * @return EE_Base_Class[]|EE_Ticket[] |
|
1240 | + * @throws ReflectionException |
|
1241 | + * @throws InvalidArgumentException |
|
1242 | + * @throws InvalidInterfaceException |
|
1243 | + * @throws InvalidDataTypeException |
|
1244 | + * @throws EE_Error |
|
1245 | + */ |
|
1246 | + public function tickets($query_params = array()) |
|
1247 | + { |
|
1248 | + return $this->get_many_related('Ticket', $query_params); |
|
1249 | + } |
|
1250 | + |
|
1251 | + |
|
1252 | + /** |
|
1253 | + * Gets all the ticket types currently available for purchase |
|
1254 | + * |
|
1255 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1256 | + * @return EE_Ticket[] |
|
1257 | + * @throws ReflectionException |
|
1258 | + * @throws InvalidArgumentException |
|
1259 | + * @throws InvalidInterfaceException |
|
1260 | + * @throws InvalidDataTypeException |
|
1261 | + * @throws EE_Error |
|
1262 | + */ |
|
1263 | + public function ticket_types_available_for_purchase($query_params = array()) |
|
1264 | + { |
|
1265 | + // first check if datetime is valid |
|
1266 | + if ($this->sold_out() || ! ($this->is_upcoming() || $this->is_active())) { |
|
1267 | + return array(); |
|
1268 | + } |
|
1269 | + if (empty($query_params)) { |
|
1270 | + $query_params = array( |
|
1271 | + array( |
|
1272 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
1273 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
1274 | + 'TKT_deleted' => false, |
|
1275 | + ), |
|
1276 | + ); |
|
1277 | + } |
|
1278 | + return $this->tickets($query_params); |
|
1279 | + } |
|
1280 | + |
|
1281 | + |
|
1282 | + /** |
|
1283 | + * @return EE_Base_Class|EE_Event |
|
1284 | + * @throws ReflectionException |
|
1285 | + * @throws InvalidArgumentException |
|
1286 | + * @throws InvalidInterfaceException |
|
1287 | + * @throws InvalidDataTypeException |
|
1288 | + * @throws EE_Error |
|
1289 | + */ |
|
1290 | + public function event() |
|
1291 | + { |
|
1292 | + return $this->get_first_related('Event'); |
|
1293 | + } |
|
1294 | + |
|
1295 | + |
|
1296 | + /** |
|
1297 | + * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime |
|
1298 | + * (via the tickets). |
|
1299 | + * |
|
1300 | + * @return int |
|
1301 | + * @throws ReflectionException |
|
1302 | + * @throws InvalidArgumentException |
|
1303 | + * @throws InvalidInterfaceException |
|
1304 | + * @throws InvalidDataTypeException |
|
1305 | + * @throws EE_Error |
|
1306 | + */ |
|
1307 | + public function update_sold() |
|
1308 | + { |
|
1309 | + $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
|
1310 | + array( |
|
1311 | + array( |
|
1312 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
1313 | + 'REG_deleted' => 0, |
|
1314 | + 'Ticket.Datetime.DTT_ID' => $this->ID(), |
|
1315 | + ), |
|
1316 | + ) |
|
1317 | + ); |
|
1318 | + $this->set_sold($count_regs_for_this_datetime); |
|
1319 | + $this->save(); |
|
1320 | + return $count_regs_for_this_datetime; |
|
1321 | + } |
|
1322 | + |
|
1323 | + |
|
1324 | + /** |
|
1325 | + * Adds a venue to this event |
|
1326 | + * |
|
1327 | + * @param int|EE_Venue /int $venue_id_or_obj |
|
1328 | + * @return EE_Base_Class|EE_Venue |
|
1329 | + * @throws EE_Error |
|
1330 | + * @throws ReflectionException |
|
1331 | + */ |
|
1332 | + public function add_venue($venue_id_or_obj): EE_Venue |
|
1333 | + { |
|
1334 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
1335 | + } |
|
1336 | + |
|
1337 | + |
|
1338 | + /** |
|
1339 | + * Removes a venue from the event |
|
1340 | + * |
|
1341 | + * @param EE_Venue /int $venue_id_or_obj |
|
1342 | + * @return EE_Base_Class|EE_Venue |
|
1343 | + * @throws EE_Error |
|
1344 | + * @throws ReflectionException |
|
1345 | + */ |
|
1346 | + public function remove_venue($venue_id_or_obj): EE_Venue |
|
1347 | + { |
|
1348 | + $venue_id_or_obj = ! empty($venue_id_or_obj) ? $venue_id_or_obj : $this->venue(); |
|
1349 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
1350 | + } |
|
1351 | + |
|
1352 | + |
|
1353 | + /** |
|
1354 | + * Gets the venue related to the event. May provide additional $query_params if desired |
|
1355 | + * |
|
1356 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1357 | + * @return int |
|
1358 | + * @throws EE_Error |
|
1359 | + * @throws ReflectionException |
|
1360 | + */ |
|
1361 | + public function venue_ID(array $query_params = []): int |
|
1362 | + { |
|
1363 | + $venue = $this->get_first_related('Venue', $query_params); |
|
1364 | + return $venue instanceof EE_Venue |
|
1365 | + ? $venue->ID() |
|
1366 | + : 0; |
|
1367 | + } |
|
1368 | + |
|
1369 | + |
|
1370 | + /** |
|
1371 | + * Gets the venue related to the event. May provide additional $query_params if desired |
|
1372 | + * |
|
1373 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
1374 | + * @return EE_Base_Class|EE_Venue |
|
1375 | + * @throws EE_Error |
|
1376 | + * @throws ReflectionException |
|
1377 | + */ |
|
1378 | + public function venue(array $query_params = []) |
|
1379 | + { |
|
1380 | + return $this->get_first_related('Venue', $query_params); |
|
1381 | + } |
|
1382 | + |
|
1383 | + |
|
1384 | + /******************************************************************* |
|
1385 | 1385 | *********************** DEPRECATED METHODS ********************** |
1386 | 1386 | *******************************************************************/ |
1387 | 1387 | |
1388 | 1388 | |
1389 | - /** |
|
1390 | - * Increments sold by amount passed by $qty, and persists it immediately to the database. |
|
1391 | - * |
|
1392 | - * @deprecated 4.9.80.p |
|
1393 | - * @param int $qty |
|
1394 | - * @return boolean |
|
1395 | - * @throws ReflectionException |
|
1396 | - * @throws InvalidArgumentException |
|
1397 | - * @throws InvalidInterfaceException |
|
1398 | - * @throws InvalidDataTypeException |
|
1399 | - * @throws EE_Error |
|
1400 | - */ |
|
1401 | - public function increase_sold($qty = 1) |
|
1402 | - { |
|
1403 | - EE_Error::doing_it_wrong( |
|
1404 | - __FUNCTION__, |
|
1405 | - esc_html__('Please use EE_Datetime::increaseSold() instead', 'event_espresso'), |
|
1406 | - '4.9.80.p', |
|
1407 | - '5.0.0.p' |
|
1408 | - ); |
|
1409 | - return $this->increaseSold($qty); |
|
1410 | - } |
|
1411 | - |
|
1412 | - |
|
1413 | - /** |
|
1414 | - * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need |
|
1415 | - * to save afterwards.) |
|
1416 | - * |
|
1417 | - * @deprecated 4.9.80.p |
|
1418 | - * @param int $qty |
|
1419 | - * @return boolean |
|
1420 | - * @throws ReflectionException |
|
1421 | - * @throws InvalidArgumentException |
|
1422 | - * @throws InvalidInterfaceException |
|
1423 | - * @throws InvalidDataTypeException |
|
1424 | - * @throws EE_Error |
|
1425 | - */ |
|
1426 | - public function decrease_sold($qty = 1) |
|
1427 | - { |
|
1428 | - EE_Error::doing_it_wrong( |
|
1429 | - __FUNCTION__, |
|
1430 | - esc_html__('Please use EE_Datetime::decreaseSold() instead', 'event_espresso'), |
|
1431 | - '4.9.80.p', |
|
1432 | - '5.0.0.p' |
|
1433 | - ); |
|
1434 | - return $this->decreaseSold($qty); |
|
1435 | - } |
|
1436 | - |
|
1437 | - |
|
1438 | - /** |
|
1439 | - * Increments reserved by amount passed by $qty, and persists it immediately to the database. |
|
1440 | - * |
|
1441 | - * @deprecated 4.9.80.p |
|
1442 | - * @param int $qty |
|
1443 | - * @return boolean indicating success |
|
1444 | - * @throws ReflectionException |
|
1445 | - * @throws InvalidArgumentException |
|
1446 | - * @throws InvalidInterfaceException |
|
1447 | - * @throws InvalidDataTypeException |
|
1448 | - * @throws EE_Error |
|
1449 | - */ |
|
1450 | - public function increase_reserved($qty = 1) |
|
1451 | - { |
|
1452 | - EE_Error::doing_it_wrong( |
|
1453 | - __FUNCTION__, |
|
1454 | - esc_html__('Please use EE_Datetime::increaseReserved() instead', 'event_espresso'), |
|
1455 | - '4.9.80.p', |
|
1456 | - '5.0.0.p' |
|
1457 | - ); |
|
1458 | - return $this->increaseReserved($qty); |
|
1459 | - } |
|
1460 | - |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database. |
|
1464 | - * |
|
1465 | - * @deprecated 4.9.80.p |
|
1466 | - * @param int $qty |
|
1467 | - * @return boolean |
|
1468 | - * @throws ReflectionException |
|
1469 | - * @throws InvalidArgumentException |
|
1470 | - * @throws InvalidInterfaceException |
|
1471 | - * @throws InvalidDataTypeException |
|
1472 | - * @throws EE_Error |
|
1473 | - */ |
|
1474 | - public function decrease_reserved($qty = 1) |
|
1475 | - { |
|
1476 | - EE_Error::doing_it_wrong( |
|
1477 | - __FUNCTION__, |
|
1478 | - esc_html__('Please use EE_Datetime::decreaseReserved() instead', 'event_espresso'), |
|
1479 | - '4.9.80.p', |
|
1480 | - '5.0.0.p' |
|
1481 | - ); |
|
1482 | - return $this->decreaseReserved($qty); |
|
1483 | - } |
|
1389 | + /** |
|
1390 | + * Increments sold by amount passed by $qty, and persists it immediately to the database. |
|
1391 | + * |
|
1392 | + * @deprecated 4.9.80.p |
|
1393 | + * @param int $qty |
|
1394 | + * @return boolean |
|
1395 | + * @throws ReflectionException |
|
1396 | + * @throws InvalidArgumentException |
|
1397 | + * @throws InvalidInterfaceException |
|
1398 | + * @throws InvalidDataTypeException |
|
1399 | + * @throws EE_Error |
|
1400 | + */ |
|
1401 | + public function increase_sold($qty = 1) |
|
1402 | + { |
|
1403 | + EE_Error::doing_it_wrong( |
|
1404 | + __FUNCTION__, |
|
1405 | + esc_html__('Please use EE_Datetime::increaseSold() instead', 'event_espresso'), |
|
1406 | + '4.9.80.p', |
|
1407 | + '5.0.0.p' |
|
1408 | + ); |
|
1409 | + return $this->increaseSold($qty); |
|
1410 | + } |
|
1411 | + |
|
1412 | + |
|
1413 | + /** |
|
1414 | + * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need |
|
1415 | + * to save afterwards.) |
|
1416 | + * |
|
1417 | + * @deprecated 4.9.80.p |
|
1418 | + * @param int $qty |
|
1419 | + * @return boolean |
|
1420 | + * @throws ReflectionException |
|
1421 | + * @throws InvalidArgumentException |
|
1422 | + * @throws InvalidInterfaceException |
|
1423 | + * @throws InvalidDataTypeException |
|
1424 | + * @throws EE_Error |
|
1425 | + */ |
|
1426 | + public function decrease_sold($qty = 1) |
|
1427 | + { |
|
1428 | + EE_Error::doing_it_wrong( |
|
1429 | + __FUNCTION__, |
|
1430 | + esc_html__('Please use EE_Datetime::decreaseSold() instead', 'event_espresso'), |
|
1431 | + '4.9.80.p', |
|
1432 | + '5.0.0.p' |
|
1433 | + ); |
|
1434 | + return $this->decreaseSold($qty); |
|
1435 | + } |
|
1436 | + |
|
1437 | + |
|
1438 | + /** |
|
1439 | + * Increments reserved by amount passed by $qty, and persists it immediately to the database. |
|
1440 | + * |
|
1441 | + * @deprecated 4.9.80.p |
|
1442 | + * @param int $qty |
|
1443 | + * @return boolean indicating success |
|
1444 | + * @throws ReflectionException |
|
1445 | + * @throws InvalidArgumentException |
|
1446 | + * @throws InvalidInterfaceException |
|
1447 | + * @throws InvalidDataTypeException |
|
1448 | + * @throws EE_Error |
|
1449 | + */ |
|
1450 | + public function increase_reserved($qty = 1) |
|
1451 | + { |
|
1452 | + EE_Error::doing_it_wrong( |
|
1453 | + __FUNCTION__, |
|
1454 | + esc_html__('Please use EE_Datetime::increaseReserved() instead', 'event_espresso'), |
|
1455 | + '4.9.80.p', |
|
1456 | + '5.0.0.p' |
|
1457 | + ); |
|
1458 | + return $this->increaseReserved($qty); |
|
1459 | + } |
|
1460 | + |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database. |
|
1464 | + * |
|
1465 | + * @deprecated 4.9.80.p |
|
1466 | + * @param int $qty |
|
1467 | + * @return boolean |
|
1468 | + * @throws ReflectionException |
|
1469 | + * @throws InvalidArgumentException |
|
1470 | + * @throws InvalidInterfaceException |
|
1471 | + * @throws InvalidDataTypeException |
|
1472 | + * @throws EE_Error |
|
1473 | + */ |
|
1474 | + public function decrease_reserved($qty = 1) |
|
1475 | + { |
|
1476 | + EE_Error::doing_it_wrong( |
|
1477 | + __FUNCTION__, |
|
1478 | + esc_html__('Please use EE_Datetime::decreaseReserved() instead', 'event_espresso'), |
|
1479 | + '4.9.80.p', |
|
1480 | + '5.0.0.p' |
|
1481 | + ); |
|
1482 | + return $this->decreaseReserved($qty); |
|
1483 | + } |
|
1484 | 1484 | } |