-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-scrum_episode.php
155 lines (139 loc) · 4.78 KB
/
single-scrum_episode.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
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package kanso-general
*/
$post_id = get_the_ID();
$scrum_chs = wp_get_post_terms( $post_id, 'scrum_channel' );
if ( count( $scrum_chs ) ) {
$scrum_ch = $scrum_chs[0];
$scrum_ch_id = $scrum_ch->term_id;
$scrum_ch_link = get_term_link( $scrum_ch );
$scrum_ch_fields = get_fields( $scrum_ch );
$args = array(
'hide_empty' => false,
'taxonomy' => 'scrum',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'updates_news_podcast',
'value' => $scrum_ch_id,
'compare' => '=',
),
array(
'key' => 'updates_archive_podcast',
'value' => $scrum_ch_id,
'compare' => '=',
),
),
);
$scrums = get_terms( $args );
if ( count( $scrums ) ) {
$scrum = $scrums[0];
$scrum_fields = get_fields( $scrum );
$scrum_url = get_term_link( $scrum );
$header_color = $scrum_fields['title_color'];
$header_bg_img = $scrum_fields['scrum_headerbg']['url'];
$scrum_url = get_term_link( $scrum );
} else {
wp_die( '所属する scrum がありません。指定してください。' );
}
} else {
wp_die( '所属する scrum_channel がありません。指定してください。' );
}
$fields = get_fields();
global $wcr_content;
$has_access = true;
if ( true === $scrum_ch_fields['restrict'] ) {
$has_access = $wcr_content->check_access( $scrum_ch_fields['restrict_product'] );
if ( is_super_admin() ) {
$has_access = true;
}
}
get_header(); ?>
<header>
<div class="uk-section-default">
<div class="uk-section <?php echo $header_color; ?> uk-background-cover" style="background-image: url(<?php echo $header_bg_img; ?>)">
<div class="uk-container">
<p>スクラム・ラーニング <?php echo $scrum->name; ?></p>
<h1 class="uk-margin-remove-bottom uk-margin-remove-top uk-h2"><?php echo $scrum_ch->name; ?></h1>
</div>
</div>
</div>
</header>
<div class="uk-container uk-container-small uk-background-default main-content">
<div class="kns-breadcrumb">
<ul itemscope itemtype="http://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="<?php echo esc_url( site_url() ); ?>" itemprop="item"><span itemprop="name">home</span><meta itemprop="position" content="1"></a>
</li>
<li class="bc-divider">></li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="<?php echo esc_url( $scrum_url ); ?>" itemprop="item"><span itemprop="name">スクラム : <?php echo $scrum->name; ?></span><meta itemprop="position" content="2"></a>
</li>
<li class="bc-divider">></li>
<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
<a href="<?php echo esc_url( $scrum_ch_link ); ?>" itemprop="item"><span itemprop="name">Podcast : <?php echo esc_html( $scrum_ch->name ); ?></span><meta itemprop="position" content="2"></a>
</li>
</ul>
</div>
<?php
while ( have_posts() ) :
the_post();
the_title( '<h1 class="main-title">', '</h1>' );
$src = get_field( 'enclosure' );
$media = get_field( 'media' );
if ( $has_access ) {
the_episode_player_plyr( $src, $media );
} else {
$restrict = get_field( 'restrict' );
if ( $restrict === true ) {
$restrict = 'restrict';
} else if ( $restrict === false ) {
$restrict = 'open';
}
switch ( $restrict ) {
case 'open':
the_episode_player_plyr( $src, $media );
break;
case 'free':
if ( $user_logged_in ) {
the_episode_player_plyr( $src, $media );
break;
}
default: /* restrict */
the_episode_player_dummy( $media );
break;
}
}
the_content();
?>
<hr class="uk-divider-small uk-text-center">
<?php if ( 'serial' === $scrum_ch_fields['episode_type'] ) : ?>
<ul class="uk-pagination">
<li><a href="#"><?php previous_post_link( '%link', 'Previous', true, ' ', 'scrum_channel' ); ?></li>
<li class="uk-margin-auto-left"><?php next_post_link( '%link', 'Next', true, ' ', 'scrum_channel' ); ?></li>
</ul>
<?php else : ?>
<ul class="uk-pagination">
<li class="uk-margin-auto-left"><?php next_post_link( '%link', 'Previous', true, ' ', 'scrum_channel' ); ?></li>
<li><a href="#"><?php previous_post_link( '%link', 'Next', true, ' ', 'scrum_channel' ); ?></li>
</ul>
<?php endif; ?>
<?php
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
?>
<hr class="uk-margin-large">
<?php
comments_template();
endif;
endwhile; // End of the loop.
?>
</div><!-- .main-content -->
<?php
get_sidebar();
get_footer();