This repository has been archived by the owner on Dec 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
taxonomy-shows.php
167 lines (141 loc) · 5.07 KB
/
taxonomy-shows.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
<?php
get_header();
$show = get_queried_object();
$show_id = $show->term_id;
$all_options = wp_load_alloptions();
$options = array();
foreach ($all_options as $key => $value) {
$key_start = 'show_' . $show_id . '_custom_option_';
if (preg_match('/^' . $key_start . '\w*$/', $key)) {
$options[str_replace($key_start, '', $key)] = $value;
}
}
$description = $show->description;
$name = $show->name;
$fullname = $show->name;
$name_prelude = $options['name_prelude'];
$fb_link = $options['fb_link'];
$tw_link = $options['tw_link'];
$ended = $options['ended'];
$hidden = $options['hidden'];
$category = $options['show_category'];
$image = $options['image'];
$slots = unserialize($options['slot']);
$slug = $show->slug;
$category_slug = strtolower($category);
$category_slug = str_replace(' ', '-', $category_slug);
if ($name_prelude !== "") {
$name = str_replace($name_prelude, '', $name);
}
$slot_strings = array();
$time = $slots[0]['from'];
foreach ($slots as $slot) {
if ($slot['from'] == $time) {
$slot_strings[] = $slot['day'] . 's, ';
}else {
$slot_strings[] = $slot['day'] . 's from ' . $time;
}
$time = $slot['from'];
}
$slot_strings[] = 'from ' . $slot['from'];
$term_objects = get_objects_in_term($show_id, 'shows');
$users = array();
foreach ($term_objects as $object_id) {
$userObject = get_user_by('id', $object_id);
$postObject = get_post($object_id);
if ($userObject) {
$user_id = $userObject->data->ID;
$user = array();
$user['name'] = $userObject->data->display_name;
$user['link'] = get_author_posts_url($user_id);
$user['image'] = get_avatar($id, 32);
$user['committee_role'] = esc_attr(get_the_author_meta('committee_role', $user_id));
$users[] = $user;
}
}
$postObjects = get_posts(array(
'tax_query' => array(
array(
'taxonomy' => 'shows',
'field' => 'term_id',
'terms' => $show_id
)
)
));
$posts = array();
foreach ($postObjects as $postObject) {
$post = array();
$post['title'] = $postObject->post_title;
$post['date'] = $postObject->post_date_gmt;
$post['excerpt'] = $postObject->post_excerpt;
$post['link'] = get_permalink($postObject->ID);
$posts[] = $post;
}
?>
<header class="show-page-header <?php echo $category_slug; ?>">
<div class="titles">
<h2 class="title-prelude"><?php echo $name_prelude; ?></h2>
<h1 class="title"><?php echo $name; ?></h1>
<h3 class="time"><?php echo implode(' ', $slot_strings) ?></h3>
</div>
</header>
<div class="main-content">
<div class="entry-content">
<div class="show-page-show-info">
<div class="show-page-members">
<img src="<?php echo $image; ?>" class="show-image" alt="<?php echo $name; ?>" />
<h1>Show Hosts</h1>
<ul>
<?php
if (count($users) < 1) {
echo 'This show has no hosts assigned.';
}
else {
foreach ($users as $user) {
$role = $user['committee_role'];
echo '<li class="host">';
echo '<a href="' . $user['link'] . '">';
echo $user['image'];
echo '<span class="name">' . $user['name'] . '</span>';
echo '</a>';
if ($role !== '') {
echo '<a href="/committee" title="Committee Member" class="committee-tag">' . $role . '</a>';
}
echo '</li>';
}
}
?>
</ul>
</div>
<p class="show-page-description"><?php echo $description; ?></p>
</div>
<h1>Recent shows</h1>
<div class="show-page-posts">
<?php
if (count($posts) < 1) {
echo 'This show has made no posts.';
}
else {
foreach ($posts as $post) {
echo '<article class="show-page-post panel">';
echo '<header><a href="' . $post['link'] . '">' . $post['title'] . '</a></header>';
echo '<div class="body">' . $post['excerpt'] . '</div>';
echo '<footer>' . $post['date'] .'</footer>';
echo '</article>';
}
}
?>
</div>
<ul class="show-page-external-links">
<?php
if ($fb_link !== '') {
echo '<li><a href="' . $fb_link . '" class="facebook">Facebook</a></li>';
}
if ($tw_link !== '') {
echo '<li><a href="' . $tw_link . '" class="twitter">Twitter</a></li>';
}
?>
</ul>
</div>
</div>
<?php get_footer(); ?>