-
Notifications
You must be signed in to change notification settings - Fork 8
/
page-events.php
executable file
·269 lines (225 loc) · 12.3 KB
/
page-events.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<?php
/**
* Template Name: Events Template
* Description: page template with a list of events
*
* @package WordPress
* @subpackage planningpress
*/
get_header(); ?>
<div id="primary">
<div id="content">
<?php the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content clearfix">
<?php the_content(); ?>
<?php edit_post_link( __( 'Edit', 'planningpress' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php rewind_posts(); ?>
<div class="events-list">
<h2 class="upcoming-events">Upcoming Events</h2>
<?php
$upcoming_events = get_upcoming_events();
if ($upcoming_events):
global $post;
foreach ($upcoming_events as $post):
setup_postdata($post);
$custom = get_post_custom(get_the_ID());
$sd = $custom["pprss_event_startdate"][0];
$ed = $custom["pprss_event_enddate"][0];
$allday = $custom["pprss_event_allday"][0];
$hidedate = $custom["pprss_event_hidedate"][0];
?>
<?php if ($hidedate != 'yes') { ?>
<article id="post-<?php the_ID(); ?>" <?php post_class("clearfix has-date"); ?> role="article">
<?php } else { ?>
<article id="post-<?php the_ID(); ?>" <?php post_class("clearfix"); ?> role="article">
<?php } ?>
<header class="event-header">
<h3 class="entry-title"><a href="<?php the_permalink(); ?>" class="permalink"><?php the_title(); ?></a></h3>
<div class="event-meta">
<?php
$terms = wp_get_object_terms($post->ID, 'pprss_event_tag');
if(!empty($terms)){
if(!is_wp_error( $terms )){
foreach($terms as $term){
echo '<span class="event-tag" style="background-color:' . $term->description . ';">';
echo '' . $term->name . '';
echo '<span class="hidden">:</span></span>';
}
}
} ?>
<?php if ($hidedate != 'yes'):?>
<span class="event-date-and-time">
<span class="event-date">
<?php
$startday = date("l, F jS, Y", $sd);
$endday = date("l, F jS, Y", $ed);
if ($startday != $endday) { // it's a multi-day event
// the days of the week range
$startdayofweek = date("l", $sd);
$enddayofweek = date("l", $ed);
$dayofweekrange = '<span class="dayofweek">' . $startdayofweek . '–' . $enddayofweek . ' </span>';
// the days of the month(s) range
$startmonth = date("F, Y", $sd);
$endmonth = date("F, Y", $ed);
if ($startmonth != $endmonth) { // it's a multi-month event
$startyear = date("Y", $sd);
$endyear = date("Y", $ed);
if ($startyear != $endyear) { // if the daterange spans multiple years...
// show both years
$startdayofmonth = date("F jS, Y", $sd);
} else {
// show only one year
$startdayofmonth = date("F jS", $sd);
}
$enddayofmonth = date("F jS, Y", $ed);
} else { // it's a single-month event
$startdayofmonth = date("F jS", $sd);
$enddayofmonth = date("jS, Y", $ed);
}
$dayofmonthrange = '<span class="dayofmonth"><span>' . $startdayofmonth . '–</span>' . $enddayofmonth . '</span>';
// set the date range for multi-day events
$date_range = $dayofweekrange . '<span class="hidden">,</span> ' . $dayofmonthrange;
} else { // it's a single-day event
$startdayofweek = date("l", $sd);
$startdayofmonth = date("F jS, Y", $sd);
$date_range = '<span class="dayofweek">' . $startdayofweek . ' </span>' . $startdayofmonth;
}
echo $date_range;
?></span><?php
if ($allday != 'yes') {
?><span class="hidden">,</span> <span class="event-time"><?php echo date("g:i A", $sd);
if ($ed != $sd) { ?><span class="ndash">–</span><?php echo date("g:i A", $ed); } ?></span><?php
} ?>
</span>
<?php endif;?>
</div>
</header>
<div class="entry-content clearfix">
<?php if ( has_excerpt() ) {
the_excerpt();
?>
<a href="<?php the_permalink(); ?>" class="permalink">More Details…</a>
<?php
} else {
the_content();
?>
<?php } ?>
<?php edit_post_link( __( 'Edit', 'planningpress' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php
endforeach;
else :
echo "<p>There are no upcoming events.</p>";
endif;
?>
<?php
$past_events = get_past_events();
if ($past_events):
?><h2 class="past-events">Past Events</h2><?php
global $post;
foreach ($past_events as $post):
setup_postdata($post);
$custom = get_post_custom(get_the_ID());
$sd = $custom["pprss_event_startdate"][0];
$ed = $custom["pprss_event_enddate"][0];
$allday = $custom["pprss_event_allday"][0];
$hidedate = $custom["pprss_event_hidedate"][0];
?>
<?php if ($hidedate != 'yes') { ?>
<article id="post-<?php the_ID(); ?>" <?php post_class("clearfix has-date"); ?> role="article">
<?php } else { ?>
<article id="post-<?php the_ID(); ?>" <?php post_class("clearfix"); ?> role="article">
<?php } ?>
<header class="event-header">
<h3 class="entry-title"><a href="<?php the_permalink(); ?>" class="permalink"><?php the_title(); ?></a></h3>
<div class="event-meta">
<?php
$terms = wp_get_object_terms($post->ID, 'pprss_event_tag');
if(!empty($terms)){
if(!is_wp_error( $terms )){
foreach($terms as $term){
echo '<span class="event-tag" style="background-color:' . $term->description . ';">';
echo '' . $term->name . '';
echo '<span class="hidden">:</span></span>';
}
}
} ?>
<?php if ($hidedate != 'yes'):?>
<span class="event-date-and-time">
<span class="event-date">
<?php
$startday = date("l, F jS, Y", $sd);
$endday = date("l, F jS, Y", $ed);
if ($startday != $endday) { // it's a multi-day event
// the days of the week range
$startdayofweek = date("l", $sd);
$enddayofweek = date("l", $ed);
$dayofweekrange = '<span class="dayofweek">' . $startdayofweek . '–' . $enddayofweek . ' </span>';
// the days of the month(s) range
$startmonth = date("F, Y", $sd);
$endmonth = date("F, Y", $ed);
if ($startmonth != $endmonth) { // it's a multi-month event
$startyear = date("Y", $sd);
$endyear = date("Y", $ed);
if ($startyear != $endyear) { // if the daterange spans multiple years...
// show both years
$startdayofmonth = date("F jS, Y", $sd);
} else {
// show only one year
$startdayofmonth = date("F jS", $sd);
}
$enddayofmonth = date("F jS, Y", $ed);
} else { // it's a single-month event
$startdayofmonth = date("F jS", $sd);
$enddayofmonth = date("jS, Y", $ed);
}
$dayofmonthrange = '<span class="dayofmonth"><span>' . $startdayofmonth . '–</span>' . $enddayofmonth . '</span>';
// set the date range for multi-day events
$date_range = $dayofweekrange . '<span class="hidden">,</span> ' . $dayofmonthrange;
} else { // it's a single-day event
$startdayofweek = date("l", $sd);
$startdayofmonth = date("F jS, Y", $sd);
$date_range = '<span class="dayofweek">' . $startdayofweek . ' </span>' . $startdayofmonth;
}
echo $date_range;
?></span><?php
if ($allday != 'yes') {
?><span class="hidden">,</span> <span class="event-time"><?php echo date("g:i A", $sd);
if ($ed != $sd) { ?><span class="ndash">–</span><?php echo date("g:i A", $ed); } ?></span><?php
}
?>
</span>
<?php endif;?>
</div>
</header>
<div class="entry-content clearfix">
<?php if ( has_excerpt() ) {
the_excerpt();
?>
<a href="<?php the_permalink(); ?>" class="permalink">More Details…</a>
<?php
} else {
the_content();
?>
<?php } ?>
<?php edit_post_link( __( 'Edit', 'planningpress' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php
endforeach;
else :
echo "<p>There are no past events.</p>";
endif;
?>
</div>
<?php comments_template( '', true ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>