-
Notifications
You must be signed in to change notification settings - Fork 1
/
page-classes.php
234 lines (198 loc) · 9.16 KB
/
page-classes.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
<?php
/**
*
* Template for the classes page
*/
get_header();
$container = get_theme_mod( 'understrap_container_type' );
$classes_category = 'Classes';
$class_cat_param = get_query_var('class_cat');
//called to check if category is active
function cat_active($cat) {
global $class_cat_param;
if ($cat == $class_cat_param) {
return " active";
} else return "";
}
// this needs to match explicitly with the categories created for My Calendar
if (!empty($class_cat_param)) {
switch ($class_cat_param) {
case 'screenprint':
$classes_category = 'Screenprint';
break;
case 'audio':
$classes_category = 'Audio Stage';
break;
}
}
$args = array(
'before' => 1,
'today' => 'yes',
'category' => $classes_category
);
$classes = mc_get_all_events($args);
$grouped_classes = array();
//iterate over all glasses, and group them accordingly based on title
foreach ($classes as $class) {
//grab a subheader if it exists
$subheader = get_post_meta( $class->event_post, '_mc_event_subheader', true );
if (trim($subheader) !== '') {
$class->custom_subheader = $subheader;
}
if (!isset($grouped_classes[$class->event_title])) {
$event_times = array();
$event_schedule = new stdClass();
$event_schedule->link = $class->event_link;
$event_schedule->time_start = calendar_date_parse($class->occur_begin);
$event_schedule->time_end = calendar_date_parse($class->occur_end);
array_push($event_times, $event_schedule);
$class->event_times = $event_times;
$grouped_classes[$class->event_title] = $class;
} else {
$repeating_event = $grouped_classes[$class->event_title];
$event_schedule = new stdClass();
$event_schedule->link = $class->event_link;
$event_schedule->time_start = calendar_date_parse($class->occur_begin);
$event_schedule->time_end = calendar_date_parse($class->occur_end);
//get and compare modified time for repeating events
$curr_modified_time = get_post_modified_time('U', false, $class->event_post);
$class->modified_time = $curr_modified_time;
if (!isset($repeating_event->modified_time)) {
$prev_modified_time = get_post_modified_time('U', false, $repeating_event->event_post);
$repeating_event->modified_time = $prev_modified_time;
}
//if repeating event has a more recently updated description + subheader, update
if ($class->modified_time > $repeating_event->modified_time) {
//copy over subheader into repeating event if it exists
if (isset($class->custom_subheader)) {
$repeating_event->custom_subheader = $class->custom_subheader;
}
//copy over description + last updated time
$repeating_event->event_desc = $class->event_desc;
$repeating_event->modified_time = $class->modified_time;
}
array_push($repeating_event->event_times, $event_schedule);
}
}
//takes in date in my calendar format, and converts to Date object
function calendar_date_parse($my_calendar_date) {
return DateTime::createFromFormat('Y-m-d H:i:s', $my_calendar_date);
}
?>
<div class="wrapper" id="full-width-page-wrapper">
<div class="<?php echo esc_attr( $container ); ?>" id="content">
<main class="site-main" id="main" role="main">
<article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<?php get_template_part('partial-templates/titlecard-fullwidth'); ?>
<div class="entry-content">
<section class="info text-center">
<div class="row header no-gutters">
<div class="col-md-12">
<h3><?php the_field('header'); ?></h3>
</div>
</div><!-- .header -->
<div class="row body no-gutters">
<div class="col-md-12">
<?/* the_content() wasn't working here?? */?>
<?= get_post(get_the_ID())->post_content; ?>
</div>
</div><!-- .body -->
</section><!-- .info -->
<section class="classes-section">
<div class="row body">
<div class="list-header m-auto">
<a class="filter-category<?= cat_active(""); ?>" href="./">All</a>
<a class="filter-category<?= cat_active("screenprint"); ?>" href="?class_cat=screenprint">Screenprint</a>
<a class="filter-category<?= cat_active("audio"); ?>" href="?class_cat=audio">Audio & Stage</a>
</div>
</div>
<div class="container">
<div class="row body class no-gutters">
<?php foreach ($grouped_classes as $class):
?>
<div class="col-sm-6 col-lg-3">
<div class="square-wrapper">
<div class="square-content class-title d-flex flex-column justify-content-between align-content-center">
<a data-toggle="modal" data-target="#modal-<?= $class->event_id ?>">
<?= stripslashes($class->event_title) ?>
</a>
<?php
if (trim($class->custom_subheader) !== '') {
echo "<h4>" . nl2br($class->custom_subheader) . "</h4>";
}
?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
</div><!-- .entry-content -->
</article><!-- #post-## -->
</main><!-- #main -->
</div><!-- Container end -->
</div><!-- Wrapper end -->
<?php get_footer(); ?>
<div class=modals>
<?php foreach ($grouped_classes as $class): ?>
<div class="modal fade" id="modal-<?= $class->event_id ?>" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<span class="modal-title"><?= stripslashes($class->event_title) ?></span>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body"><?= wpautop( stripslashes($class->event_desc) ) ?></div>
<?php
if (isset($class->event_times)) {
foreach($class->event_times as $event_time) {
//if event is in the past, skip
$current_time = new DateTime();
if ($current_time > $event_time->time_end) { continue; }
?>
<div class="modal-footer">
<div class="row w-100 mx-0 d-flex align-items-center">
<div class="col-sm-2 text-right time-label">
<h4><?= $event_time->time_start->format('l'); ?></h4>
</div>
<div class="col-sm-3 text-right time-label">
<h4 class="text-primary font-weight-bold"><?= $event_time->time_start->format('F j'); ?></h4>
</div>
<div class="col-sm-4 text-right time-label">
<?php
$start_time = $event_time->time_start->format('g:ia');
$end_time = $event_time->time_end->format('g:ia');
if ($start_time == '12:00am' && $end_time == '11:59pm') {
echo "<h4>All Day</h4>";
} else {
echo "<h4>" . $start_time . "-" . $end_time . "</h4>";
}
?>
</div>
<div class="col-sm-3">
<a href="<?= $event_time->link; ?>"
target="_blank"
class="btn bordered-button btn-outline-primary btn-override pull-right my-auto">Register</a>
</div>
</div>
</div>
<?php
}
} else if ( strlen(trim($class->event_link)) > 0 ) {
?>
<div class="modal-footer">
<a href="<?= $class->event_link ?>"
target="_blank"
class="btn bordered-button btn-outline-primary btn-override pull-right my-auto">Register</a>
</div>
<?php
}
?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>