-
Notifications
You must be signed in to change notification settings - Fork 0
/
single.php
262 lines (261 loc) · 12.1 KB
/
single.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
<?php get_header(); ?>
<main>
<div class="content article single">
<?php if (has_post_thumbnail()): ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?>
<article>
<h2 class="title"><?php the_title(); ?></h2>
<time class="date"><i class="ori-time"></i>
<?php the_time(get_option("date_format")); ?>
</time>
<div class="post-categories">
<?php
$categories = get_the_category();
foreach ($categories as $category) {
echo '<li><a href="' .
get_category_link($category->term_id) .
'"><i class="ori-category"></i>' .
$category->name .
"</a></li>";
}
?>
</div>
<?php
if (
strpos(
get_theme_mod("or_sns_display_place"),
"article_top"
) !== false
): ?>
<div class="sns">
<?php
if (
strpos(get_theme_mod("or_sns_services"), "twitter") !==
false
): ?>
<a href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank" rel="noopener noreferrer"
title="Tweet" class="twitter">
<i class="ori-twitter text-lg mr-2"></i>
</a>
<?php endif;
if (
strpos(get_theme_mod("or_sns_services"), "facebook") !==
false
): ?>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" target="_blank" rel="noopener noreferrer"
title="Facebook" class="facebook">
<i class="ori-facebook text-lg mr-2"></i>
</a>
<?php endif;
if (
strpos(get_theme_mod("or_sns_services"), "hatena") !==
false
): ?>
<a href="https://b.hatena.ne.jp/add?mode=confirm&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" rel="noopener noreferrer"
title="hatena" class="hatena">
<i class="ori-hatena text-lg mr-2"></i>
</a>
<?php endif;
if (
strpos(get_theme_mod("or_sns_services"), "pocket") !==
false
): ?>
<a href="https://getpocket.com/edit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" title="pocket" rel="noopener noreferrer"
class="pocket">
<i class="ori-pocket text-lg mr-2"></i>
</a>
<?php endif;
if (
strpos(get_theme_mod("or_sns_services"), "line") !==
false
): ?>
<a href="https://timeline.line.me/social-plugin/share?url=<?php the_permalink(); ?>" class="line" target="_blank" title="line" rel="noopener noreferrer">
<i class="ori-line text-lg mr-2"></i>
</a>
<?php endif;
if (
strpos(get_theme_mod("or_sns_services"), "url") !==
false
): ?>
<a href="javascript:OnClickURL();" class="url" title="Copy to Clipboard"
data-clipboard-text="<?php the_title(); ?> <?php the_permalink(); ?>" id="url">
<i class="ori-url text-lg mr-2"></i>
</a>
<?php endif;
?>
</div>
<?php endif;
if (
strpos(
get_theme_mod("or_ads_display_place"),
"single_top"
) !== false
):
echo get_theme_mod("or_ads_display"); ?>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php
endif;
?>
<section class="article-body"><?php the_content(); ?></section>
<?php
if (
strpos(
get_theme_mod("or_ads_display_place"),
"single_bottom"
) !== false
):
echo get_theme_mod("or_ads_display"); ?>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php
endif;
if (
strpos(
get_theme_mod("or_sns_display_place"),
"article_bottom"
) !== false
): ?>
<div class="sns">
<a href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank" rel="noopener noreferrer"
title="Tweet" class="twitter">
<i class="ori-twitter text-lg mr-2"></i>
</a>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" target="_blank" rel="noopener noreferrer"
title="Facebook" class="facebook">
<i class="ori-facebook text-lg mr-2"></i>
</a>
<a href="https://b.hatena.ne.jp/add?mode=confirm&url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" rel="noopener noreferrer"
title="hatena" class="hatena">
<i class="ori-hatena text-lg mr-2"></i>
</a>
<a href="https://getpocket.com/edit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" title="pocket" rel="noopener noreferrer"
class="pocket">
<i class="ori-pocket text-lg mr-2"></i>
</a>
<a href="https://timeline.line.me/social-plugin/share?url=<?php the_permalink(); ?>" class="line" target="_blank" title="line" rel="noopener noreferrer">
<i class="ori-line text-lg mr-2"></i>
</a>
<a href="javascript:OnClickURL();" class="url" title="Copy to Clipboard"
data-clipboard-text="<?php the_title(); ?> <?php the_permalink(); ?>" id="url">
<i class="ori-url text-lg mr-2"></i>
</a>
</div>
<?php endif;
?>
</article>
<?php the_post(); ?>
<div class="author">
<div class="details">
<?php echo get_avatar(get_the_author_meta("ID")); ?>
<p>著者:<?php echo get_the_author(); ?></p>
<a class="posts" href="<?php echo get_author_posts_url(
get_the_author_meta("ID")
); ?>">記事一覧</a>
</div>
<p class="description"><?php echo get_the_author_meta(
"description"
); ?></p>
<div class="author-sns">
<?php
if (get_the_author_meta("user_url")) {
echo '<a rel="noopener noreferrer" class="sns-icon url" href="' .
esc_url(get_the_author_meta("user_url")) .
'"><i class="ori-url"></i></a>';
}
if (get_the_author_meta("facebook")) {
echo '<a rel="noopener noreferrer" class="sns-icon facebook" href="' .
esc_url(
"https://www.facebook.com/" .
get_the_author_meta("facebook")
) .
'"><i class="ori-facebook"></i></a>';
}
if (get_the_author_meta("twitter")) {
echo '<a rel="noopener noreferrer" class="sns-icon twitter" href="' .
esc_url(
"https://twitter.com/" .
get_the_author_meta("twitter")
) .
'"><i class="ori-twitter"></i></a>';
}
if (get_the_author_meta("youtube")) {
echo '<a rel="noopener noreferrer" class="sns-icon youtube" href="' .
esc_url(get_the_author_meta("youtube")) .
'"><i class="ori-youtube"></i></a>';
}
if (get_the_author_meta("github")) {
echo '<a rel="noopener noreferrer" class="sns-icon github" href="' .
esc_attr(get_the_author_meta("github")) .
'"><i class="ori-github"></i></a>';
}
?>
</div>
</div>
<?php if (!get_theme_mod("or_single_design_related")):
if (has_category()) {
$catlist = get_the_category();
$category = [];
foreach ($catlist as $cat) {
$category[] = $cat->term_id;
}
}
$args = [
"post_type" => "post",
"posts_per_page" => "5",
"post__not_in" => [$post->ID],
"category__in" => $category,
"orderby" => "rand",
];
$related_query = new WP_Query($args);
?>
<?php if ($related_query->have_posts()): ?>
<div class="related">
<h3>関連記事</h3>
<ul class="related_post_container">
<?php while ($related_query->have_posts()):
$related_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()):
the_post_thumbnail("medium");
else:
?>
<img src="<?php echo get_template_directory_uri(); ?>/img/default.jpg" />
<?php
endif; ?>
<div>
<h4><?php the_title(); ?></h4>
<time><i class="ori-time"></i><?php the_time(
get_option("date_format")
); ?></time>
<p><?php if (
get_theme_mod(
"or_main_design_excerpt_num"
) !== "0"
):
echo get_the_excerpt();
endif; ?></p>
</div>
</a>
</li>
<?php
endwhile; ?>
<?php wp_reset_postdata(); ?>
</ul>
</div>
<?php endif;
endif; ?>
<div class="comments">
<?php comments_template(); ?>
</div>
</div>
<?php if (!get_theme_mod("or_single_design_sidebar")):
get_sidebar();
endif; ?>
</main>
<?php get_footer(); ?>
<?php wp_footer(); ?>