forked from aspirepress/site-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content-talk.php
171 lines (148 loc) · 7.34 KB
/
content-talk.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
<article id="post-<?php the_ID(); ?>" <?php post_class('blog-post'); ?>>
<?php
$postId = get_the_ID();
$event = trim(get_post_meta($postId, 'talk_event', true));
$event_date = trim(get_post_meta($postId, 'talk_date', true));
$event_text = '';
if ($event) {
if ($event_date) {
$event .= ", $event_date";
}
$event = esc_html($event);
$event_text = "<small>Presented at $event</small>";
}
if (is_singular()) :
the_title(
'<h1 class="post-title page-header talk-title">',
"$event_text</h1>"
);
else :
the_title(
sprintf('<h2 class="post-title talk-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())),
"</a>$event_text</h2>"
);
endif;
?>
<div class="entry-summary">
<?php the_content(sprintf('Continue reading %s', the_title( '<span class="screen-reader-text">', '</span>', false))); ?>
</div>
<?php
global $akrabat_talk_type_fields, $akrabat_talk_type_textareas;
$links = [];
$notist_code = trim(get_post_meta($postId, 'talk_code_notist', true));
$notist_url = 'https://speaking.akrabat.com';
if ($notist_code) {
$links[] = '<a href="' . $notist_url . '/' . $notist_code . '">Notist</a>';
}
foreach ($akrabat_talk_type_fields as $key => $label) {
if (stripos($label, 'URL') == false) {
continue;
}
$label = str_replace(' URL', '', $label);
$value = trim(get_post_meta($postId, $key, true));
if (empty($value)) {
continue;
}
if (stripos($value, 'joind.in') !== false) {
$label = 'Joind.in';
}
$links[] = '<a href="' . $value .'">' . $label . '</a></li>';
}
if (!is_singular()) {
// displaying on a list page
// add link for Speakerdeck
$speakerdeck_url = trim(get_post_meta($postId, 'talk_url_speakerdeck', true));
if ($speakerdeck_url) {
$site = 'Slides';
if (stripos($speakerdeck_url, 'speakerdeck') !== false) {
$site = 'Speaker Deck';
} elseif (stripos($speakerdeck_url, 'noti.st') !== false) {
$site = 'Notist';
} elseif (stripos($speakerdeck_url, 'speaking.akrabat.com') !== false) {
$site = 'Notist';
}
$links[] = '<a href="' . $speakerdeck_url . '">' . $site . '</a>';
}
// add link for Youtube
$youtube_id = trim(get_post_meta($postId, 'talk_youtube_id', true));
if ($youtube_id) {
$links[] = '<a href="https://www.youtube.com/watch?v=' . $youtube_id . '">Video</a>';
}
}
$links = implode(" | ", $links);
?>
<div class="talk-links">
<p><?= $links ?></p>
</div>
<?php
if (is_singular()) {
$youtube_id = trim(get_post_meta($postId, 'talk_youtube_id', true));
if ($youtube_id) {
echo <<<HTML
<p>
<h4>Video</h4>
<div class="youtubevideowrap">
<div class="video-container">
<iframe width="853" height="480" src="https://www.youtube.com/embed/$youtube_id" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</p>
HTML;
}
// <iframe width="560" height="315" src="https://www.youtube.com/embed/$youtube_id" frameborder="0" allowfullscreen></iframe>
$video_embed = trim(get_post_meta($postId, 'talk_embed_video', true));
if ($video_embed) {
echo <<<HTML
<p>
<h4>Video</h4>
$video_embed
</p>
HTML;
}
// Embed notist slides if we have a Notist code
if ($notist_code) {
// $notist_code = 'JwEI4m';
$title = get_the_title($postId);
$notist_username = 'akrabat';
$notist_embed_html = get_post_meta($postId, 'talk_notist_embed_html', true);
$notist_embed_expires = get_post_meta($postId, 'talk_notist_embed_expires', true);
$notist_embed_aspect = get_post_meta($postId, 'talk_notist_embed_aspect', true);
if (empty($notist_embed_html) || time() > $notist_embed_expires) {
// No embed HTML or it's expired: get new embed HTML.
$info = get_notist_embed_html($notist_username, $notist_code);
list($notist_embed_html, $notist_embed_expires, $notist_embed_aspect) = $info;
if ($notist_embed_html) {
update_post_meta($postId, 'talk_notist_embed_html', $notist_embed_html);
update_post_meta($postId, 'talk_notist_embed_expires', $notist_embed_expires);
update_post_meta($postId, 'talk_notist_embed_aspect', $notist_embed_aspect);
}
}
if ($notist_embed_html) {
$notist_embed_html = htmlentities($notist_embed_html);
$percentage = 100.0 / $notist_embed_aspect;
echo <<<HTML
<h4>Slides</h4>
<div style="position: relative; overflow: hidden; padding-top: $percentage%;">
<iframe sandbox="allow-scripts" scrolling="no" frameborder="0"
style="position:absolute; top:0; left:0; width:100%; height:100%; border:0;"
srcdoc="$notist_embed_html"></iframe>
</div>
HTML;
}
} else {
$slides_embed = trim(get_post_meta($postId, 'talk_embed_slides', true));
if ($slides_embed) {
echo <<<HTML
<h4>Slides</h4>
$slides_embed
HTML;
}
}
}
?>
<?php if (is_singular()) : ?>
<p class="post-meta meta list-post-meta" style="margin-top: 20px;">
<?php edit_post_link('<span>Edit page</span>', '<span class="edit-link"> ', '</span>'); ?>
</p>
<?php endif; ?>
</article>