This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
/
page_template-calendar.php
268 lines (253 loc) · 10 KB
/
page_template-calendar.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
<?php /* Template Name: Calendar */ ?>
<?php
$calendar_groups = array(
'past' => array(
'id' => 'past',
'title' => 'In the Past', // these posts should not display
'items' => array()
),
'ongoing' => array(
'id' => 'ongoing',
'title' => 'Ongoing',
'items' => array()
),
'today-tomorrow' => array(
'id' => 'today-tomorrow',
'title' => 'Today & Tomorrow',
'items' => array()
),
'this-week' => array(
'id' => 'this-week',
'title' => 'This Week',
'items' => array()
),
'next-week' => array(
'id' => 'next-week',
'title' => 'Next Week',
'items' => array()
),
'this-month' => array(
'id' => 'this-month',
'title' => 'Later in the Month of '.date('F'),
'items' => array()
),
'next-month' => array(
'id' => 'next-month',
'title' => 'Next Month in '.date('F', strtotime('+1 month')),
'items' => array()
),
'later' => array(
'id' => 'later',
'title' => 'In '.date('F', strtotime('+2 month')).' & Beyond',
'items' => array()
),
);
$today = getdate();
$opp_args = array(
'nopaging' => true,
'post_type' => 'opportunity',
'post_status' => 'publish',
'orderby' => 'post_date',
'order' => 'ASC',
'date_query' => array( array(
'after' => array(
'year' => $today['year'],
'month' => $today['mon'],
'day' => $today['mday'],
),
'inclusive' => true,
)),
'tax_query' => array( array(
'taxonomy' => 'webdisplay',
'field' => 'slug',
'terms' => get_option('sprout_webdisplay')
)),
);
global $post;
$target_calendar = $post->post_name;
if( $target_calendar == 'educators-innovators' ) {
$opp_args['meta_query'] = array( array(
'key' => 'audience_filter',
'value' => 'a:1:{i:0;s:8:"educator";}',
'compare' => '=',
));
} elseif( $target_calendar == 'youth-teens' ) {
$opp_args['meta_query'] = array( array(
'key' => 'audience_filter',
'value' => 'a:1:{i:0;s:4:"teen";}',
'compare' => '=',
));
} elseif( $target_calendar == 'children-families' ) {
$opp_args['meta_query'] = array( array(
'key' => 'audience_filter',
'value' => 'a:1:{i:0;s:5:"child";}',
'compare' => '=',
));
}
$opportunities = get_posts( $opp_args );
$opportunities_arr = array();
foreach( $opportunities as $opportunity ) {
$datetime_info = get_datetime_info( $opportunity->ID );
if( ($datetime_info[0]['date_status'] == 'today') || ($datetime_info[0]['date_status'] == 'tomorrow') ) {
$calendar_group = 'today-tomorrow';
} elseif( $datetime_info[0]['date_status'] != '' ) {
$calendar_group = $datetime_info[0]['date_status'];
} else {
$calendar_group = 'ongoing';
}
$opportunities_arr[] = array(
'post_id' => $opportunity->ID,
'db_datetime' => $opportunity->post_date,
'calendar_group' => $calendar_group,
'datetime_type' => $datetime_info[0]['type'],
'date_start' => $datetime_info[0]['date_start'],
'date_end' => $datetime_info[0]['date_end'],
'time_start' => $datetime_info[0]['time_start'],
'time_end' => $datetime_info[0]['time_end'],
'is_deadline' => ($datetime_info[0]['print']['context'] == 'Deadline: '),
'datetime_print' => $datetime_info[0]['print']['dates'],
'location_print' => opportunity_summary_get_location( $opportunity->ID ),
);
}
foreach ($opportunities_arr as $key => $row) {
$date_start[$key] = $row['date_start'];
$time_start[$key] = $row['time_start'];
}
array_multisort($date_start, SORT_ASC, $time_start, SORT_ASC, $opportunities_arr);
foreach ($opportunities_arr as $opportunity) {
$calendar_groups[$opportunity['calendar_group']]['items'][] = $opportunity;
}
echo '<!--';
print_r($calendar_groups);
echo '-->';
?>
<?php get_header(); ?>
<header id="header" class="row" role="banner">
<div class="site-header columns small-12">
<?php //get_template_part( 'header', 'breadcrumbs' ); ?>
<div class="header-info">
<p class="page-title" ><?php the_title(); ?><a target="_blank" class="button secondary small" style="float: right; margin-bottom: 2px;" href="/calendar/add-event/" title="Add an event or opportunity to the Remake Learning calendar">Add Event</a></p>
<?php the_excerpt(); ?>
</div><!-- /.header-info -->
</div><!-- .site-header -->
</header><!-- #header -->
<section class="container row" role="document">
<div id="content" class="columns" role="main">
<?php if( $target_calendar == 'calendar' ) : ?>
<section id="browse-by-audience">
<div class="row">
<div class="columns medium-4">
<div class="panel">
<h4><a href="/calendar/educators-innovators/"><span class="filter-link">Filter <i class="fa fa-filter"></i></span>For Educators & Innovators</a></h4>
<p class="body-text">Funding deadlines, local and national conferences, professional development, meet ups and more</p>
</div>
</div>
<div class="columns medium-4">
<div class="panel">
<h4><a href="/calendar/youth-teens/"><span class="filter-link">Filter <i class="fa fa-filter"></i></span>For Youth & Teens</a></h4>
<p class="body-text">Events, programs, drop-in learning activities, and workshops for youth and teens the Pittsburgh region</p>
</div>
</div>
<div class="columns medium-4">
<div class="panel">
<h4><a href="/calendar/children-families/"><span class="filter-link">Filter <i class="fa fa-filter"></i></span>For Children & Families</a></h4>
<p class="body-text">Events, activities, programs, and family things to do with kids in the Pittsburgh region</p>
</div>
</div>
</div>
</section>
<hr style="margin-left: -0.9375rem; margin-right: -0.9375rem;" />
<?php else : ?>
<section id="browse-by-audience">
<div class="row">
<div class="columns medium-4">
<?php if( $target_calendar == 'educators-innovators' ) : ?>
<div class="panel callout">
<h4><span class="filter-link">Showing Events <i class="fa fa-filter"></i></span>For Educators & Innovators</h4>
</div>
<?php else : ?>
<div class="panel">
<h4><a href="/calendar/educators-innovators/"><span class="filter-link">Filter <i class="fa fa-filter"></i></span>For Educators & Innovators</a></h4>
</div>
<?php endif; ?>
</div>
<div class="columns medium-4">
<?php if( $target_calendar == 'youth-teens' ) : ?>
<div class="panel callout">
<h4><span class="filter-link">Showing Events <i class="fa fa-filter"></i></span>For Youth & Teens</h4>
</div>
<?php else : ?>
<div class="panel">
<h4><a href="/calendar/youth-teens/"><span class="filter-link">Filter <i class="fa fa-filter"></i></span>For Youth & Teens</a></h4>
</div>
<?php endif; ?>
</div>
<div class="columns medium-4">
<?php if( $target_calendar == 'children-families' ) : ?>
<div class="panel callout">
<h4><span class="filter-link">Showing Events <i class="fa fa-filter"></i></span>For Children & Families</h4>
</div>
<?php else : ?>
<div class="panel">
<h4><a href="/calendar/children-families/"><span class="filter-link">Filter <i class="fa fa-filter"></i></span>For Children & Families</a></h4>
</div>
<?php endif; ?>
</div>
</div>
</section>
<hr style="margin-left: -0.9375rem; margin-right: -0.9375rem;" />
<?php endif; ?>
<section id="browse-all" class="<?php if( $target_calendar == 'calendar' ) { echo 'hide-for-small-only'; } ?>">
<?php foreach( $calendar_groups as $calendar_group ) : ?>
<?php if( !empty($calendar_group['items']) ) : ?>
<section id="<?php echo $calendar_group['id']; ?>">
<header>
<h3><?php echo $calendar_group['title']; ?></h3>
</header>
<div class="row">
<div class="columns">
<ul class="large-block-grid-5 medium-block-grid-4 small-block-grid-2 portfolio">
<?php foreach( $calendar_group['items'] as $calendar_item ) : $post_id = $calendar_item['post_id']; ?>
<?php
$the_title = get_the_title($post_id);
$the_permalink = get_permalink($post_id);
$the_title_attribute = esc_attr( strip_tags( get_the_title($post_id) ) );
$image_id = get_post_thumbnail_id($post_id);
if ( !empty($calendar_item['datetime_print']) && !empty($calendar_item['location_print']) ) {
$the_summary_stmt = $calendar_item['datetime_print'].'<br/>'.$calendar_item['location_print'];
} else {
$the_summary_stmt = $calendar_item['datetime_print'].$calendar_item['location_print'];
}
?>
<li id="post-<?php echo $post_id; ?>">
<header class="entry-header">
<?php if( $image_id ) : ?>
<figure>
<a href="<?php echo $the_permalink; ?>" title="<?php echo $the_title_attribute; ?>">
<div class="portfolio_image_container">
<div class="dummy"></div>
<div data-content="" class="portfolio_image">
<?php the_responsive_image( $image_id, $image_type = 'portfolio', $image_classes = 'wp-post-image', $show_caption = false, $wrap_figure = false ); ?>
</div>
</div>
</a>
</figure>
<?php endif; ?>
<p class="entry-title">
<a href="<?php echo $the_permalink; ?>" title="<?php echo $the_title_attribute; ?>"><?php echo $the_title; ?></a>
</p>
</header>
<div class="entry-summary"><?php echo $the_summary_stmt; ?></div>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</section>
<hr style="margin-left: -0.9375rem; margin-right: -0.9375rem;" />
<?php endif; ?>
<?php endforeach; ?>
</section>
</div><!-- #content -->
</section>
<?php get_footer(); ?>