-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-message.php
283 lines (265 loc) · 11 KB
/
single-message.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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package ROCKHARBOR_Church
*/
get_header();
?>
<?php while ( have_posts() ) : the_post();
$video = get_field('video');
$audio = get_field('audio');
$subtitle = get_field('subtitle');
$tags = get_the_term_list( $post->ID, 'tags', '<span>', ' ', '</span>' ) ;
$scripture = get_field('scripture');
$series = get_the_terms( $post->ID, 'series' )[0]->name;
$campus = get_the_terms( $post->ID, 'campuses' )[0]->name;
$campusSlug = get_the_terms( $post->ID, 'campuses' )[0]->slug;
$seriescover = get_field('thumbnail', 'series_'.get_the_terms( $post->ID, 'series' )[0]->term_id);
$duration = powerpress_get_enclosure_data( $post->ID )['duration'];
if (isset($duration) && !empty($duration)) {
$durationParts = explode(':', $duration);
$duration8601 = "PT" . $durationParts[0] . "H" . $durationParts[1] . "M" . $durationParts[2] . "S";
}
if ( has_post_thumbnail() ) {
$image = get_the_post_thumbnail_url( $post->id, 'large' );
} elseif($seriescover) {
$image = wp_get_attachment_image_url( $seriescover, 'large' );
} else {
$image = get_bloginfo('template_url').'/images/series-placeholder.png';
} ?>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"VideoObject","name":"<?php the_title(); ?>","description":"<?php echo str_replace('"', '\"', get_the_content()); ?>","thumbnailUrl":["<?php echo $image; ?>"],"uploadDate":"<?php echo get_the_date('c'); ?>",<?php if (isset($duration8601)) { echo "\"duration\":\"" . $duration8601 . "\","; } ?>"contentUrl":"<?php echo $video; ?>"}
</script>
<section class="sermon">
<div class="container">
<video poster="<?php echo $image; ?>" id="plyr" playsinline controls>
<?php if ($video) { ?>
<source src="<?php echo $video;?>" type="video/mp4">
<?php } else { ?>
<source src="<?php echo $audio;?>" type="audio/mp3">
<?php }
if ($subtitle) { ?>
<track kind="captions" label="English (United States) captions" src="<?php echo $subtitle; ?>" srclang="en" default />
<?php } ?>
</video>
<header>
<h1 class="heading"><?php the_title();?></h1>
<div class="meta">
<span class="date"><?php $date = get_the_date( 'F j, Y' ); echo $date;?></span> — <span class="teacher"><?php $terms_as_link = get_the_term_list( $post->ID, 'teacher', '<span>', ', ', '</span>' ) ; echo ($terms_as_link);?></span>
</div>
<div class="share">
<a href="https://www.facebook.com/sharer.php?u=<?php the_permalink();?>" target="_blank" rel="noopener noreferrer"><i class="fab fa-facebook-f"></i></a>
<a href="https://pinterest.com/pin/create/button/?url=<?php the_permalink();?>&media=<?php echo wp_get_attachment_image_url( $image, 'medium' ); ?>&description=<?php the_title();?>" target="_blank" rel="noopener noreferrer"><i class="fab fa-pinterest-p"></i></a>
<a href="https://twitter.com/intent/tweet?text=I want you guys to check out this article: <?php the_permalink();?>" class="icon-twitter" target="_blank" rel="noopener noreferrer"><i class="fab fa-twitter"></i></a>
</div>
</header>
<main>
<div class="description">
<?php the_content();?>
</div>
<?php if($scripture) { ?>
<div class="scripture"><strong>Scripture:</strong> <?php the_field('scripture');?></div>
<?php }?>
<?php if($tags) { ?>
<div class="tags"><strong>Tags:</strong> <?php echo ($tags); ?></div>
<?php }?>
<?php if($video && $audio) { ?>
<audio id="plyr-audio" controls>
<source src="<?php echo $audio;?>" type="audio/mp3">
</audio>
<?php } ?>
<div class="actions">
<div class="download">
<h5>Download <i class="fas fa-angle-down"></i></h5>
<ul>
<?php
$redirectKey = strtolower(get_field('redirect_key', 'option'));
if ($audio) {
$audioUrl = get_bloginfo('template_url') . "/force_download.php?file=" . urlencode($audio);
if ($redirectKey && !empty($redirectKey)) {
$hash = hash_hmac('sha256', urlencode($audio), $redirectKey);
$audioUrl .= "&key={$hash}";
}
?><li><a href="<?php echo $audioUrl; ?>" target="_blank"><i class="fas fa-volume-up"></i> Audio</a></li>
<?php
}
if ($video) {
$videoUrl = get_bloginfo('template_url') . "/force_download.php?file=" . urlencode($video);
if ($redirectKey && !empty($redirectKey)) {
$hash = hash_hmac('sha256', urlencode($video), $redirectKey);
$videoUrl .= "&key={$hash}";
}
?><li><a href="<?php echo $videoUrl; ?>" target="_blank"><i class="fas fa-video"></i> Video</a></li>
<?php
} ?>
</ul>
</div>
<?php
if ($campusSlug == 'costa-mesa') {
$podcastLink = 'https://itunes.apple.com/us/podcast/rockharbor-costa-mesa-podcast/id1094888066?mt=2';
} else if($campusSlug == 'mission-viejo') {
$podcastLink = 'https://itunes.apple.com/us/podcast/rockharbor-mission-viejo-podcast/id1095856839?mt=2';
} else if($campusSlug == 'charlotte') {
$podcastLink = 'https://itunes.apple.com/us/podcast/rockharbor-charlotte-podcast/id1095856746?mt=2';
}
?>
<?php if($podcastLink) { ?>
<span class="sep"></span>
<a href="<?php echo $podcastLink; ?>" class="link podcast">Podcast <i class="fas fa-podcast"></i></a>
<?php } ?>
<?php if($video && $audio) { ?>
<span class="sep"></span>
<a href="javascript:;" class="link listen">Listen <i class="fas fa-volume-up"></i></a>
<?php } ?>
</div>
</main>
</div>
</section>
<section class="section more-sermons">
<div class="container">
<h2 class="heading">More Messages in "<?php echo $series;?>"</h2>
<ul>
<?php
$m_args = array(
'post_type' => array( 'message' ),
'posts_per_page' => '4',
'order' => 'DESC',
'orderby' => 'date',
'post__not_in' => array($post->ID),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'series',
'field' => 'name',
'terms' => $series,
),
array(
'taxonomy' => 'campuses',
'field' => 'slug',
'terms' => $campus,
)
),
);
$m_query = new WP_Query( $m_args );
if ( $m_query->have_posts() ) {
while ( $m_query->have_posts() ) {
$m_query->the_post();
$seriescover = get_field('thumbnail', 'series_'.get_the_terms( $post->ID, 'series' )[0]->term_id);
if ( has_post_thumbnail() ) {
$imagesm = get_the_post_thumbnail_url( $post->id, 'thumb_uncropped' );
$image = get_the_post_thumbnail_url( $post->id, 'large' );
} elseif($seriescover) {
$imagesm = wp_get_attachment_image_url( $seriescover, 'thumb_uncropped' );
$image = wp_get_attachment_image_url( $seriescover, 'large' );
} else {
$imagesm = get_bloginfo('template_url').'/images/series-placeholder.png';
$image = $imagesm;
} ?>
<li>
<a href="<?php the_permalink();?>">
<div class="cover"><img src="<?php echo $imagesm; ?>" data-layzr="<?php echo $image; ?>" alt="<?php the_title();?>"></div>
<h3><?php the_title();?></h3>
<span class="date"><?php $date = get_the_date( 'F j, Y' ); echo $date;?></span>
</a>
</li>
<?php }
} wp_reset_postdata(); ?>
</ul>
</div>
</section>
<section class="section series-archive">
<div class="container">
<h2>Past Series</h2>
<?php
$args = array (
'taxonomy' => 'campuses',
'term' => $campusSlug,
'post_type' => array( 'message' ),
'posts_per_page' => 20,
'order' => 'DESC',
'orderby' => 'date',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) { ?>
<ul class="series">
<?php while ( $query->have_posts() ) { $query->the_post();
$seriescover = get_field('thumbnail', 'series_'.get_the_terms( $post->ID, 'series' )[0]->term_id); $placeholder = get_bloginfo('template_url').'/images/series-placeholder.png';
if ( has_post_thumbnail() ) {
$image = get_the_post_thumbnail_url( $post->id, 'thumb_uncropped' );
} elseif($seriescover) {
$image = wp_get_attachment_image_url( $seriescover, 'thumb_uncropped' );
} else {
$image = $placeholder;
}
?>
<?php
// Get series of post
$seriesID = get_the_terms( $post->ID, 'series' )[0]->term_id;
$seriesName = get_the_terms( $post->ID, 'series' )[0]->name;
$seriesSlug = get_the_terms( $post->ID, 'series' )[0]->slug;
?>
<?php
// if this series is not previous series
if (!isset($previousSeriesID)) {
$previousSeriesID = '';
}
if ($seriesID != $previousSeriesID) {
?>
<li data-series-id="<?php echo $seriesID ?>">
<a href="/series/<?php echo $seriesSlug?>">
<div class="cover"><img src="<?php echo $image ?>" alt="<?php echo $seriesName?>"></div>
<h3 class="series-name"><?php echo $seriesName?></h3>
<?php
// Get Series Date Range
$slug = get_the_terms( $post->ID, 'series' )[0]->slug;
$args = array(
'post_type'=>'message',
'posts_per_page' => -1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'series',
'field' => 'slug',
'terms' => $slug,
),
array(
'taxonomy' => 'campuses',
'field' => 'slug',
'terms' => $campusSlug,
),
),
);
$posts_array = get_posts( $args );
$first = $posts_array[0]->ID;
$last = $posts_array[count($posts_array) -1 ]->ID;
if(count($posts_array) == 1) {
//echo get_the_title( $first );
$date = get_the_date( 'M j, Y', $first );
} else {
//echo get_the_title( $first ) , ' - ' , echo get_the_title( $last );
$date = get_the_date( 'M j, Y', $last ) . ' - ' . get_the_date( 'M j, Y', $first );
}
?>
<span class="date"><?php echo $date ?></span>
</a>
</li>
<?php } ?>
<?php $previousSeriesID = get_the_terms( $post->ID, 'series' )[0]->term_id; ?>
<?php } ?>
</ul>
<?php } else { ?>
<div style="padding: 40px 0; text-align: center;">It looks like there are no messages available for <?php the_archive_title(); ?>.</div>
<?php }
wp_reset_postdata();?>
<a href="/messages/?c=<?php echo $campusSlug; ?>" class="button teal" style="margin: 0 auto; width: 241px; display: block;">View Messages Archive</a>
</div>
</section>
<script src="<?php bloginfo('template_url');?>/js/vendors/js.cookie.js"></script>
<?php endwhile; ?>
<?php
get_footer();