1: <?php
2: /**
3: * Shortcuts for useful functions in templates
4: *
5: * @package event-post
6: * @version 6.0.1
7: * @since 5.0.0
8: */
9:
10: if ( ! defined( 'ABSPATH' ) ) exit;
11:
12: if(!function_exists('get_the_dates')){
13: /**
14: * Returns the HTML string of the given event's date range.
15: * If no post reference is given, the current post will be used
16: *
17: * @param mixte $post
18: *
19: * @global \EventPost $EventPost
20: *
21: * @return string
22: *
23: * @example:
24: * <pre>
25: * <div class="event_date" data-start="april 6 2017 12am" data-end="april 6 2017 1pm">
26: * <time itemprop="dtstart" datetime="2017-04-06T12:08:00+00:00">
27: * <span class="date date-single">april 6 2017, 8am</span>
28: * <span class="linking_word linking_word-from">from</span>
29: * <span class="time time-start">12h am</span>
30: * <span class="linking_word linking_word-to">to</span>
31: * <span class="time time-end">1h am</span>
32: * </time>
33: * </div>
34: * </pre>
35: */
36: function get_the_dates($_post=null){
37: global $EventPost, $post;
38: if(!$_post){
39: $_post = $post;
40: }
41: return $EventPost->print_date($_post);
42: }
43: }
44: if(!function_exists('the_dates')){
45: /**
46: * Outputs the HTML generated by `get_the_dates`
47: *
48: * @param mixte $post
49: */
50: function the_dates($post=null){
51: echo wp_kses(get_the_dates($post), EventPost()->kses_tags);
52: }
53: }
54:
55: if(!function_exists('get_the_date_start')){
56: /**
57: * Returns the HTML of the start date of an event
58: *
59: * @param type $post
60: *
61: * @global \EventPost $EventPost
62: *
63: * @return string
64: */
65: function get_the_date_start($post=null){
66: global $EventPost;
67: $event = $EventPost->retreive($post);
68: return $EventPost->human_date($event->time_start, $EventPost->settings['dateformat']);
69: }
70: }
71: if(!function_exists('the_date_start')){
72: /**
73: * Outputs the HTML of the start date of an event
74: *
75: * @param type $post
76: */
77: function the_date_start($post=null){
78: echo wp_kses(get_the_date_start($post), EventPost()->kses_tags);
79: }
80: }
81:
82: if(!function_exists('get_the_date_end')){
83: /**
84: * Returns the HTML of the end date of an event
85: *
86: * @param type $post
87: *
88: * @global \EventPost $EventPost
89: *
90: * @return string
91: */
92: function get_the_date_end($post=null){
93: global $EventPost;
94: $event = $EventPost->retreive($post);
95: return $EventPost->human_date($event->time_end, $EventPost->settings['dateformat']);
96: }
97: }
98: if(!function_exists('the_date_end')){
99: /**
100: * Outputs the HTML of the start date of an event
101: *
102: * @param type $post
103: *
104: * @global \EventPost $EventPost
105: *
106: * @return string
107: */
108: function the_date_end($post=null){
109: echo wp_kses(get_the_date_end($post), EventPost()->kses_tags);
110: }
111: }
112:
113: if(!function_exists('get_the_location')){
114: /**
115: * Returns the HTML of the location date of an event
116: *
117: * @param type $post
118: *
119: * @global \EventPost $EventPost
120: *
121: * @return string
122: */
123: function get_the_location($post=null){
124: global $EventPost;
125: return $EventPost->print_location($post);
126: }
127: }
128: if(!function_exists('the_location')){
129: /**
130: * Outputs the HTML of the location date of an event
131: *
132: * @param type $post
133: */
134: function the_location($post=null){
135: echo wp_kses(get_the_location($post), EventPost()->kses_tags);
136: }
137: }
138: