-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle.php
More file actions
executable file
·343 lines (307 loc) · 36.4 KB
/
single.php
File metadata and controls
executable file
·343 lines (307 loc) · 36.4 KB
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<?php
if (!defined('ABSPATH')) {
exit;
}
get_header();
if (have_posts()) :
while (have_posts()) :
the_post();
$content_plain = wp_strip_all_tags((string) get_post_field('post_content', get_the_ID()));
$cjk_count = preg_match_all('/[\x{4e00}-\x{9fff}\x{3400}-\x{4dbf}\x{f900}-\x{faff}]/u', $content_plain, $_cjk_m);
$latin_words = str_word_count((string) preg_replace('/[\x{4e00}-\x{9fff}\x{3400}-\x{4dbf}\x{f900}-\x{faff}]/u', ' ', $content_plain));
$word_count = (int) $cjk_count + $latin_words;
$reading_minutes = max(1, (int) ceil($word_count / 300));
// 存储/更新字数到 _word_count meta
$stored_wc = get_post_meta(get_the_ID(), '_word_count', true);
if ($stored_wc === '' || (int) $stored_wc !== $word_count) {
update_post_meta(get_the_ID(), '_word_count', $word_count);
}
$categories = get_the_category();
$first_cat = !empty($categories) ? $categories[0] : null;
$category_label = $first_cat ? $first_cat->name : __('Uncategorized', 'lared');
$category_icon_html = $first_cat ? lared_get_category_icon_html((int) $first_cat->term_id) : '';
$tags = get_the_tags();
$author_id = (int) get_the_author_meta('ID');
$author_url = $author_id > 0 ? get_author_posts_url($author_id) : '';
$previous_post = get_previous_post();
$next_post = get_next_post();
$article_content = apply_filters('the_content', (string) get_post_field('post_content', get_the_ID()));
$single_toc_items = [];
$single_used_ids = [];
$single_heading_index = 0;
$article_content = preg_replace_callback(
'/<h([23])([^>]*)>(.*?)<\/h\1>/is',
static function (array $matches) use (&$single_toc_items, &$single_used_ids, &$single_heading_index): string {
$level = (int) $matches[1];
$attributes = (string) $matches[2];
$inner_html = (string) $matches[3];
$heading_text = trim(wp_strip_all_tags($inner_html));
if ('' === $heading_text) {
return $matches[0];
}
$single_heading_index++;
$base_id = sanitize_title($heading_text);
if ('' === $base_id) {
$base_id = 'section-' . $single_heading_index;
}
$base_id = 'single-' . get_the_ID() . '-' . $base_id;
$heading_id = $base_id;
$suffix = 2;
while (in_array($heading_id, $single_used_ids, true)) {
$heading_id = $base_id . '-' . $suffix;
$suffix++;
}
$single_used_ids[] = $heading_id;
$attributes = preg_replace('/\sid=("|\')(.*?)\1/i', '', $attributes);
$attributes .= ' id="' . esc_attr($heading_id) . '"';
$single_toc_items[] = [
'id' => $heading_id,
'label' => $heading_text,
'level' => $level,
];
return '<h' . $level . $attributes . '>' . $inner_html . '</h' . $level . '>';
},
$article_content
);
$comment_count = (int) get_comments_number();
$post_views = function_exists('lared_get_post_views') ? lared_get_post_views(get_the_ID()) : 0;
$post_timestamp = (int) get_post_time('U', true, get_the_ID());
$post_month_short = lared_date_en('M', $post_timestamp);
$post_day_number = lared_date_en('j', $post_timestamp);
$post_time_full = lared_date_en('Y/m/d H:i', $post_timestamp);
$post_relative = human_time_diff($post_timestamp, time()) . '前';
?>
<main class="single-page-square main-shell mx-auto w-full max-w-[1400px] min-h-[calc(100vh-64px)] border-x border-[#d9d9d9] bg-[#fff] pb-[90px] max-[900px]:pb-16" data-post-id="<?php echo esc_attr((string) get_the_ID()); ?>">
<section class="w-full" aria-label="Article Banner">
<div class="single-top-banner">
<img
class="single-top-banner__image lazyload"
data-src="<?php
$banner_image = lared_get_post_image_url(get_the_ID(), 'large');
if ('' === $banner_image) {
$banner_image = lared_get_landscape_image_url((int) get_the_ID());
}
echo esc_url($banner_image);
?>"
alt="<?php esc_attr_e('文章 Banner 占位图', 'lared'); ?>">
<div class="single-top-banner__meta">
<div class="single-top-banner__meta-inner">
<div class="single-top-banner__meta-main">
<span class="home-article-time" tabindex="0" aria-label="<?php echo esc_attr($post_time_full); ?>">
<span class="home-article-time-month"><?php echo esc_html($post_month_short); ?></span>
<span class="home-article-time-day"><?php echo esc_html($post_day_number); ?></span>
<span class="home-article-time-tooltip"><?php echo esc_html($post_time_full); ?></span>
</span>
<span class="single-top-banner__cat-icon" tabindex="0" aria-label="<?php echo esc_attr($category_label); ?>">
<?php if ('' !== $category_icon_html) : ?>
<?php echo wp_kses_post($category_icon_html); ?>
<?php else : ?>
<i class="fa-solid fa-folder" aria-hidden="true"></i>
<?php endif; ?>
<span class="single-top-banner__tooltip"><?php echo esc_html($category_label); ?></span>
</span>
<span class="single-top-banner__title-box"><?php the_title(); ?></span>
</div>
<div class="single-top-banner__meta-side" aria-label="Article Stats">
<!-- 移动端日期卡片(桌面端隐藏) -->
<div class="single-top-banner__stat-box single-top-banner__stat-box--date" tabindex="0" aria-label="<?php echo esc_attr($post_time_full); ?>">
<i class="fa-regular fa-clock" aria-hidden="true"></i>
<span class="single-top-banner__stat-number"><?php echo esc_html($post_relative); ?></span>
<span class="single-top-banner__tooltip"><?php echo esc_html($post_time_full); ?></span>
</div>
<div class="single-top-banner__stat-box single-top-banner__stat-box--comment" tabindex="0" aria-label="<?php esc_attr_e('评论数量', 'lared'); ?>">
<i class="fa-regular fa-comment" aria-hidden="true"></i>
<span class="single-top-banner__stat-number"><?php echo esc_html(lared_format_number($comment_count)); ?></span>
<span class="single-top-banner__tooltip"><?php esc_html_e('评论数量', 'lared'); ?></span>
</div>
<div class="single-top-banner__stat-box single-top-banner__stat-box--heat" tabindex="0" aria-label="<?php esc_attr_e('文章热度', 'lared'); ?>">
<i class="fa-solid fa-fire" aria-hidden="true"></i>
<span class="single-top-banner__stat-number"><?php echo esc_html(lared_format_number($post_views)); ?></span>
<span class="single-top-banner__tooltip"><?php esc_html_e('阅读数量', 'lared'); ?></span>
</div>
<div class="single-top-banner__stat-box single-top-banner__stat-box--words" tabindex="0" aria-label="<?php esc_attr_e('文章字数', 'lared'); ?>">
<i class="fa-solid fa-font" aria-hidden="true"></i>
<span class="single-top-banner__stat-number"><?php echo esc_html(lared_format_number($word_count)); ?></span>
<span class="single-top-banner__tooltip"><?php esc_html_e('文章字数', 'lared'); ?></span>
</div>
<div class="single-top-banner__stat-box single-top-banner__stat-box--reading" tabindex="0" aria-label="<?php esc_attr_e('阅读时间', 'lared'); ?>">
<i class="fa-regular fa-clock" aria-hidden="true"></i>
<span class="single-top-banner__stat-number"><?php echo esc_html(number_format($reading_minutes)); ?></span>
<span class="single-top-banner__stat-label"><?php esc_html_e('min', 'lared'); ?></span>
<span class="single-top-banner__tooltip"><?php esc_html_e('阅读时间', 'lared'); ?></span>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="mx-auto w-full max-w-[1400px]">
<div class="single-content-wrap box-border pt-7 max-[900px]:pt-[22px]">
<?php if (!empty($single_toc_items)) : ?>
<aside class="single-side-toc" aria-label="<?php esc_attr_e('文章目录', 'lared'); ?>">
<nav class="single-side-toc__nav" aria-label="<?php esc_attr_e('文章目录导航', 'lared'); ?>">
<?php foreach ($single_toc_items as $index => $toc_item) : ?>
<a
class="single-side-toc__item level-<?php echo (int) $toc_item['level']; ?> <?php echo 0 === $index ? 'is-active' : ''; ?>"
href="#<?php echo esc_attr((string) $toc_item['id']); ?>"
data-single-toc-link>
<?php echo esc_html((string) $toc_item['label']); ?>
</a>
<?php endforeach; ?>
</nav>
</aside>
<!-- 移动端 TOC 面板 -->
<div class="mobile-toc-panel" data-mobile-toc-panel aria-hidden="true">
<div class="mobile-toc-panel__header">
<span><?php esc_html_e('文章目录', 'lared'); ?></span>
<button type="button" class="mobile-toc-panel__close" data-mobile-toc-close aria-label="<?php esc_attr_e('关闭', 'lared'); ?>">
<i class="fa-solid fa-xmark" aria-hidden="true"></i>
</button>
</div>
<nav class="mobile-toc-panel__nav" aria-label="<?php esc_attr_e('文章目录导航', 'lared'); ?>">
<?php foreach ($single_toc_items as $index => $toc_item) : ?>
<a
class="mobile-toc-panel__item level-<?php echo (int) $toc_item['level']; ?>"
href="#<?php echo esc_attr((string) $toc_item['id']); ?>"
data-mobile-toc-link>
<?php echo esc_html((string) $toc_item['label']); ?>
</a>
<?php endforeach; ?>
</nav>
</div>
<div class="mobile-toc-overlay" data-mobile-toc-overlay></div>
<?php endif; ?>
<article class="single-article-content page-content prose prose-neutral max-w-none min-w-0 mt-[6px] text-[var(--color-body)] [&_hr]:hidden">
<?php
$ai_summary = lared_get_ai_summary((int) get_the_ID());
if ('' !== $ai_summary) :
?>
<div class="single-ai-summary" aria-label="AI 摘要">
<div class="single-ai-summary__title">
<i class="fa-sharp fa-light fa-robot" style="flex-shrink:0;"></i>
<span><?php esc_html_e('AI 摘要', 'lared'); ?></span>
<?php
$ai_provider = lared_ai_get_provider();
if ('openai' === $ai_provider) : ?>
<i class="fa-brands fa-openai single-ai-summary__provider"></i>
<?php elseif ('deepseek' === $ai_provider) : ?>
<svg class="single-ai-summary__provider single-ai-summary__provider--deepseek" viewBox="0 0 6465 1024" xmlns="http://www.w3.org/2000/svg">
<path d="M1348.789884 85.951355c-14.399892-7.231946-20.671845 6.527951-29.055782 13.503899-2.879978 2.303983-5.37596 5.183961-7.807941 7.935941-21.119842 23.039827-45.759657 38.079714-77.951416 36.287727-47.103647-2.68798-87.295345 12.415907-122.879078 49.151632-7.487944-45.31166-32.639755-72.319458-70.847469-89.727327-20.03185-9.023932-40.191699-18.047865-54.207593-37.695718-9.727927-13.951895-12.415907-29.567778-17.279871-44.863663-3.135976-9.27993-6.207953-18.751859-16.639875-20.351847-11.391915-1.791987-15.807881 7.93594-20.287848 15.99988-17.727867 33.215751-24.639815 69.759477-23.93582 106.751199 1.535988 83.199376 35.96773 149.566878 104.319217 196.670525 7.807941 5.439959 9.855926 10.879918 7.359945 18.751859-4.607965 16.255878-10.239923 31.99976-15.103887 48.255638-3.071977 10.367922-7.679942 12.671905-18.62386 8.127939A314.109644 314.109644 0 0 1 887.161346 326.397552c-48.639635-47.99964-92.607305-101.055242-147.454894-142.526931-12.671905-9.599928-25.727807-18.68786-39.039707-27.327795-56.06358-55.487584 7.295945-101.055242 21.951835-106.495201 15.295885-5.631958 5.31196-24.959813-44.223668-24.767815-49.535628 0.191999-94.847289 17.151871-152.638855 39.679703a172.350707 172.350707 0 0 1-26.367802 7.871941 534.395992 534.395992 0 0 0-163.774772-5.823957c-107.071197 12.159909-192.574556 63.807521-255.422084 151.99886C4.671965 325.117562-13.119902 445.564658 8.639935 571.131717c22.847829 132.479006 89.087332 242.046185 190.846569 327.805541 105.471209 88.831334 227.006297 132.415007 365.629258 124.03107 84.159369-4.927963 177.918666-16.447877 283.645872-107.839191 26.6878 13.567898 54.65559 18.943858 101.119242 23.039827 35.711732 3.391975 70.143474-1.791987 96.831274-7.423945 41.727687-9.023932 38.847709-48.511636 23.743822-55.743582-122.367082-58.239563-95.487284-34.559741-119.935101-53.695597 62.207533-75.135436 155.902831-153.150851 192.638555-406.012955 2.879978-20.095849 0.383997-32.703755 0-48.959632-0.255998-9.919926 1.919986-13.759897 13.055902-14.911889a233.598248 233.598248 0 0 0 87.743342-27.519793c79.295405-44.159669 111.359165-116.799124 118.847109-203.902471 1.151991-13.3119-0.191999-27.071797-14.015895-34.047745zM657.723067 869.561478C539.131957 774.394192 481.596388 743.034427 457.788567 744.378417c-22.207833 1.34399-18.175864 27.327795-13.311901 44.223668 5.119962 16.639875 11.775912 28.159789 21.119842 42.879679 6.399952 9.663928 10.879918 24.127819-6.463951 34.943738-38.207713 24.127819-104.639215-8.127939-107.711193-9.727927-77.31142-46.399652-141.950935-107.775192-187.518593-191.678563A594.555541 594.555541 0 0 1 90.239323 405.116962c-1.151991-22.399832 5.31196-30.271773 27.071797-34.367743 28.607785-5.567958 57.983565-6.335952 86.847349-2.239983 121.087092 18.047865 224.190319 73.34345 310.58967 160.830794 49.27963 49.919626 86.591351 109.439179 125.055062 167.678742 40.895693 61.759537 84.863364 120.639095 140.798944 168.894734 19.839851 16.895873 35.583733 29.759777 50.68762 39.231705-45.567658 5.183961-121.535088 6.335952-173.502698-35.647732z m56.895573-373.3092c0-9.919926 7.743942-17.791867 17.535869-17.791866q3.327975 0 6.015955 1.087991a17.663868 17.663868 0 0 1 11.327915 16.703875 17.599868 17.599868 0 0 1-17.535869 17.855866 17.407869 17.407869 0 0 1-17.34387-17.855866zM891.193316 588.795584c-11.327915 4.735964-22.65583 8.831934-33.535748 9.27993a69.759477 69.759477 0 0 1-45.311661-14.719889c-15.551883-13.247901-26.6878-20.735844-31.359764-43.96767a102.207233 102.207233 0 0 1 0.895993-34.047745c4.03197-18.943858-0.447997-31.103767-13.503899-42.175684-10.68792-9.023932-24.255818-11.519914-39.103707-11.519913a31.231766 31.231766 0 0 1-14.463891-4.479967 14.783889 14.783889 0 0 1-6.399952-20.735844c1.535988-3.199976 9.087932-10.879918 10.879918-12.159909 20.223848-11.775912 43.519674-7.93594 65.087512 0.831994 19.96785 8.319938 35.071737 23.679822 56.831574 45.375659 22.207833 26.175804 26.239803 33.34375 38.847709 52.991603 10.047925 15.359885 19.199856 31.103767 25.343809 49.151631 3.839971 11.327915-1.087992 20.543846-14.207893 26.239804z m2806.570951 210.302423h-71.167466v-110.271173h71.167466c43.96767 0 88.511336-10.879918 117.375119-41.40769 28.863784-30.591771 39.423704-77.695417 39.423705-124.287067 0-46.527651-10.559921-93.439299-39.423705-123.967071-28.799784-30.591771-73.407449-41.407689-117.375119-41.407689-44.287668 0-88.575336 10.879918-117.439119 41.407689-29.119782 30.591771-39.423704 77.439419-39.423705 123.967071v453.372599h-124.799064V247.422144h124.799064v46.271653h22.847829c2.303983-2.559981 4.863964-5.119962 7.679942-7.679942 31.167766-28.607785 78.911408-38.591711 126.335053-38.591711 73.407449 0 147.390895 18.239863 195.646532 69.119482 47.99964 50.879618 65.471509 129.151031 65.471509 206.846449 0 77.439419-17.471869 155.710832-65.471509 206.526451-48.255638 51.199616-122.239083 69.119482-195.646532 69.119481zM1797.106522 266.558001h71.103466v110.271173H1797.106522c-44.03167 0-88.575336 10.879918-117.43912 41.727687-28.799784 30.527771-39.423704 77.439419-39.423704 123.96707 0 46.527651 10.559921 93.439299 39.423704 123.96707 28.863784 30.591771 73.407449 41.727687 117.43912 41.727687 44.287668 0 88.575336-11.135916 117.439119-41.727687 29.119782-30.527771 39.423704-77.439419 39.423704-123.96707v-453.116602h124.799064V818.553861h-124.799064v-46.591651h-22.847828a49.471629 49.471629 0 0 1-7.743942 7.679943c-31.167766 28.607785-78.847409 38.911708-126.271053 38.911708-73.407449 0-147.390895-18.303863-195.710532-69.439479C1553.39635 698.234763 1535.98848 620.219348 1535.98848 542.523931s17.407869-155.710832 65.40751-206.846449c48.319638-50.815619 122.239083-69.119482 195.710532-69.119481z m908.473186 266.238003v44.287668h-332.541506V488.508336h220.542346c-5.119962-32.255758-16.831874-62.271533-37.439719-83.96737-30.271773-31.743762-76.223428-43.135676-122.239083-43.135677-45.695657 0-92.03131 11.391915-121.983085 43.135677-30.015775 31.359765-40.895693 79.9994-40.895694 128.255038 0 48.319638 10.879918 96.831274 40.895694 128.575036 29.951775 31.679762 76.287428 42.879678 121.983085 42.879678 45.951655 0 91.96731-11.199916 122.239083-42.879678a142.078934 142.078934 0 0 0 11.455914-14.591891h123.391075c-10.559921 38.271713-27.96779 72.895453-53.695598 100.03125-50.303623 52.799604-127.103047 71.679462-203.390474 71.679462s-153.150851-18.879858-203.134477-71.679462c-50.303623-52.863604-68.287488-133.758997-68.287488-214.014395s17.983865-161.086792 68.287488-213.950395c49.983625-52.607605 126.847049-71.423464 203.134477-71.423465s153.086852 18.815859 203.390474 71.423465c50.303623 52.863604 68.287488 133.694997 68.287488 213.950395z m626.491301 0v44.287668h-332.541505V488.508336h220.798344c-5.119962-32.255758-16.831874-62.271533-37.695718-83.96737-29.951775-31.743762-75.96743-43.135676-121.983085-43.135677-45.695657 0-91.96731 11.391915-121.983085 43.135677-29.951775 31.359765-40.831694 79.9994-40.831694 128.255038 0 48.319638 10.879918 96.831274 40.831694 128.575036 30.015775 31.679762 76.287428 42.879678 121.983085 42.879678 46.079654 0 92.03131-11.199916 121.983085-42.879678 4.287968-4.607965 8.319938-9.407929 11.775912-14.591891h123.391075c-10.879918 38.271713-28.03179 72.895453-53.759597 100.03125-50.239623 52.799604-127.103047 71.679462-203.390475 71.679462-76.223428 0-153.086852-18.879858-203.390474-71.679462-49.983625-52.863604-67.96749-133.758997-67.967491-214.014395s17.983865-161.086792 67.967491-213.950395c50.303623-52.607605 127.167046-71.423464 203.390474-71.423465 76.287428 0 153.150851 18.815859 203.454474 71.423465 49.919626 52.863604 67.96749 133.694997 67.96749 213.950395z m982.200634 285.693857c76.287428 0 153.086852-11.135916 203.070477-42.239683 50.303623-31.167766 68.287488-78.911408 68.287488-126.335052 0-47.359645-17.983865-95.103287-68.287488-126.271053-49.919626-31.103767-126.783049-42.239683-203.070477-42.239684h2.559981c-32.639755 0-65.407509-4.287968-86.591351-16.639875a53.759597 53.759597 0 0 1-29.119781-48.831633c0-18.559861 7.679942-36.799724 29.119781-49.087632 21.119842-12.03191 54.015595-16.319878 86.591351-16.319878s65.407509 4.287968 86.847348 16.319878a53.759597 53.759597 0 0 1 28.799784 49.087632h127.167047c0-47.359645-16.255878-95.103287-61.43954-126.271053-45.439659-31.103767-114.815139-42.239683-183.93462-42.239684s-138.558961 11.135916-183.99862 42.239684c-45.439659 31.167766-61.695537 78.847409-61.695537 126.271053 0 47.423644 16.255878 95.167286 61.695537 126.271052 45.439659 31.167766 114.815139 42.303683 183.99862 42.303683 35.96773 0 75.135436 4.287968 98.815259 16.319878 23.679822 11.96791 31.99976 30.527771 31.99976 49.087632 0 18.303863-8.319938 36.863724-31.99976 48.895633-23.679822 11.96791-59.96755 16.511876-95.99928 16.511876-35.96773 0-72.319458-4.479966-95.679283-16.511876-23.679822-12.03191-32.255758-30.591771-32.255758-48.895633H4042.849679c0 47.423644 17.983865 95.167286 67.96749 126.271053 50.303623 31.167766 126.847049 42.239683 203.454474 42.239683z m897.913266-285.693857v44.287668h-332.605506V488.508336h220.862344c-5.119962-32.255758-16.831874-62.271533-37.759717-83.96737-29.951775-31.743762-75.96743-43.135676-121.919086-43.135677-45.695657 0-92.03131 11.391915-121.983085 43.135677-30.015775 31.359765-40.895693 79.9994-40.895693 128.255038 0 48.319638 10.879918 96.831274 40.895693 128.575036 29.951775 31.679762 76.287428 42.879678 121.983085 42.879678 45.951655 0 91.96731-11.199916 121.983085-42.879678a113.27915 113.27915 0 0 0 11.711913-14.591891h123.391074c-10.879918 38.271713-27.96779 72.895453-53.695597 100.03125-50.303623 52.799604-127.103047 71.679462-203.390475 71.679462s-153.150851-18.879858-203.390474-71.679462c-50.047625-52.863604-68.03149-133.758997-68.03149-214.014395s17.983865-161.086792 68.03149-213.950395c50.239623-52.607605 127.103047-71.423464 203.390474-71.423465s153.086852 18.815859 203.390475 71.423465c49.983625 52.863604 67.96749 133.694997 67.96749 213.950395z m626.747299 0v44.287668h-332.541506V488.508336h220.798344c-5.37596-32.255758-16.831874-62.271533-37.631718-83.96737-30.079774-31.743762-76.287428-43.135676-122.047084-43.135677-45.695657 0-91.96731 11.391915-121.983085 43.135677-30.271773 31.359765-40.831694 79.9994-40.831694 128.255038 0 48.319638 10.559921 96.831274 40.831694 128.575036 30.015775 31.679762 76.287428 42.879678 121.983085 42.879678 45.759657 0 92.03131-11.199916 122.047084-42.879678 4.223968-4.607965 7.93594-9.407929 11.647913-14.591891h123.455074c-10.879918 38.271713-28.03179 72.895453-54.015595 100.03125-49.983625 52.799604-126.847049 71.679462-203.134476 71.679462-76.223428 0-153.406849-18.879858-203.390475-71.679462-49.983625-52.863604-67.96749-133.758997-67.96749-214.014395s17.983865-161.086792 67.96749-213.950395c49.983625-52.607605 127.167046-71.423464 203.390475-71.423465 76.287428 0 153.150851 18.815859 203.134476 71.423465 50.303623 52.863604 68.287488 133.694997 68.287488 213.950395zM5922.963578 63.99952h124.863063v754.68234h-124.863063V63.99952z m337.917465 451.644613l204.862464 302.845728h-154.878838l-204.798464-302.845728 204.798464-242.814179h154.878838l-204.798464 242.814179z" />
</svg>
<?php elseif ('kimi' === $ai_provider) : ?>
<svg class="single-ai-summary__provider single-ai-summary__provider--kimi" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
<path d="M1024 0m0 186.197333l0 651.605334q0 186.197333-186.197333 186.197333l-651.605334 0q-186.197333 0-186.197333-186.197333l0-651.605334q0-186.197333 186.197333-186.197333l651.605334 0q186.197333 0 186.197333 186.197333Z" fill="#000000" />
<path d="M580.181333 459.946667c57.173333 1.322667 104.192 52.352 104.192 115.2v232.533333a2.090667 2.090667 0 0 1-2.133333 2.133333h-99.925333a2.090667 2.090667 0 0 1-2.133334-2.133333l-1.706666-294.016c0-1.28-2.218667-1.493333-2.56-0.298667-13.397333 43.946667-52.736 56.32-99.84 56.32H304.384a2.090667 2.090667 0 0 0-2.090667 2.090667v235.946667a2.090667 2.090667 0 0 1-2.090666 2.090666H194.858667a2.090667 2.090667 0 0 1-2.048-2.133333V241.578667c0-1.152 0.896-2.048 2.048-2.048h105.386666c1.109333 0 2.048 0.896 2.048 2.048v216.32c0 1.152 0.938667 2.133333 2.090667 2.133333h135.253333a2.133333 2.133333 0 0 0 1.877334-1.28l96.896-218.026667a2.090667 2.090667 0 0 1 1.92-1.194666h116.778666c1.493333 0 2.517333 1.578667 1.877334 2.944l-66.261334 142.293333c-19.754667 36.224-34.304 61.866667-67.242666 72.789333-1.194667 0.426667-0.938667 2.432 0.298666 2.432h54.4z" fill="#FFFFFF" />
<path d="M727.338667 227.968c-11.733333 9.856-19.413333 25.941333-19.413334 50.218667 0 22.741333 7.253333 40.405333 18.133334 50.986666-5.674667 9.386667-11.434667 15.957333-15.786667 19.498667-0.725333 0.554667-0.170667 2.218667 0.725333 2.133333l64.426667-4.693333c14.378667-1.066667 26.709333-6.485333 37.034667-15.744 12.373333-10.496 19.498667-28.544 19.498666-52.181333 0-24.277333-7.125333-40.362667-19.498666-50.218667-11.776-9.813333-26.112-14.762667-43.050667-14.762667-16.298667 0-30.293333 4.949333-42.069333 14.762667z" fill="#007AFF" />
</svg>
<?php elseif ('minimax' === $ai_provider) : ?>
<svg class="single-ai-summary__provider single-ai-summary__provider--minimax" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
<path d="M428.8 480.981333v282.666667c-19.072 95.701333-146.048 70.997333-146.602667 1.621333-0.597333-87.210667 0-173.866667 0-260.437333V404.437333c0-12.544-2.730667-22.485333-13.696-30.293333-21.418667-16.042667-47.061333 2.773333-47.616 25.856-1.194667 31.018667-0.597333 61.312-1.194666 91.904 0 24.106667 0 47.530667 0.554666 71.637333-15.786667 106.026667-144.213333 88.405333-147.2 0.597334v-73.514667c0-24.021333 47.061333-29.696 44.8 6.314667-1.578667 17.834667-0.597333 36.181333-1.194666 53.845333-0.554667 31.573333 47.658667 52.778667 59.050666 1.237333 0.512-42.538667 0.512-85.034667 0.512-127.914666 0-53.76 15.274667-97.536 72.277334-101.589334 24.661333-2.218667 41.088 8.106667 56.832 25.941334 5.973333 6.314667 20.266667 26.325333 20.821333 48.085333 0 20.053333 0.554667 40.064 0.554667 60.330667 0 40.064-0.554667 80.341333-0.554667 120.362666 0 25.941333 0.554667 51.626667 0.554667 76.970667 0 32.128 0 64.725333-0.554667 96.896-0.554667 41.856 50.346667 41.258667 58.538667-0.64 0-49.365333 0.554667-98.133333 0.554666-147.498667 0-121.6-0.554667-243.2-0.554666-364.8 0-12.586667-1.749333-47.573333 4.949333-60.330666 35.541333-86.613333 143.36-48.810667 144.341333 22.869333 2.133333 146.901333 0 295.466667 0.554667 442.709333 0 51.029333-41.472 40.106667-43.776 20.096 0-153.173333 0-306.986667 0.554667-459.989333-2.005333-38.4-58.965333-33.194667-62.293334-5.632-1.066667 31.573333-0.512 63.744-1.066666 95.274667v187.605333h0.554666l0.384 0.213333h-0.042666z" />
<path d="M595.541333 478.72v207.573333V196.437333c18.517333-96.384 145.493333-71.296 146.005334-1.877333 0.597333 86.613333 0 173.824 0.597333 260.394667 0 33.28 0 66.602667-0.554667 99.84 0 13.184 3.242667 22.442667 14.293334 30.890666 20.821333 15.616 46.421333-2.730667 47.573333-26.24 1.152-30.378667 0.554667-60.757333 0.554667-91.904v-71.253333c15.914667-105.984 144-88.405333 146.688-0.554667v266.026667c0 24.149333-46.506667 29.866667-44.416 6.272 1.28-18.346667 0-228.778667 0.64-247.210667 1.109333-30.976-47.701333-52.821333-59.008-0.64v127.232c0 54.528-15.317333 97.578667-72.789334 102.272-54.186667 1.28-75.946667-36.224-77.738666-74.069333v-257.28c0-32.725333 0-64.682667 0.554666-96.853333 0.554667-41.813333-50.346667-41.813333-59.008 0.597333v576c0 12.501333 1.706667 47.530667-4.48 60.330667-35.456 86.528-143.872 48.682667-144.853333-22.954667V754.773333c2.688-45.909333 41.472-34.986667 43.221333-15.573333v80.896c2.090667 38.528 59.050667 33.877333 61.738667 5.717333 1.152-31.573333 1.152-63.146667 1.152-95.317333V478.72h-0.170667v-0.042667z" />
</svg>
<?php endif; ?>
</div>
<div class="single-ai-summary__content">
<?php echo esc_html($ai_summary); ?>
</div>
</div>
<?php endif; ?>
<?php echo wp_kses_post($article_content); ?>
</article>
<div class="single-footer-meta" aria-label="Article Footer Meta">
<div class="single-footer-meta__left">
<span class="single-footer-meta__item">
<strong><?php esc_html_e('作者', 'lared'); ?></strong>
<?php if ('' !== $author_url) : ?>
<a class="single-footer-meta__author-link" href="<?php echo esc_url($author_url); ?>"><?php echo esc_html(get_the_author()); ?></a>
<?php else : ?>
<?php echo esc_html(get_the_author()); ?>
<?php endif; ?>
<?php esc_html_e('本文采用', 'lared'); ?>
<a class="single-footer-meta__license-link" href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" rel="noopener noreferrer"><i class="fa-brands fa-creative-commons single-footer-meta__cc-icon"></i>CC BY-NC-SA 4.0</a>
<?php esc_html_e('许可协议,转载请注明来源。', 'lared'); ?>
</span>
</div>
<div class="single-footer-meta__right">
<span class="single-footer-meta__keywords">
<?php if (!empty($tags)) : ?>
<?php foreach ($tags as $tag) : ?>
<a class="single-footer-meta__tag" href="<?php echo esc_url(get_tag_link($tag->term_id)); ?>"><span class="single-footer-meta__tag-text"><?php echo esc_html($tag->name); ?></span></a>
<?php endforeach; ?>
<?php else : ?>
<span class="single-footer-meta__tag is-empty"><?php esc_html_e('None', 'lared'); ?></span>
<?php endif; ?>
</span>
</div>
</div>
</div>
</section>
<nav class="single-post-nav" aria-label="Post Navigation">
<?php if ($previous_post instanceof WP_Post) : ?>
<a class="single-post-nav__item single-post-nav__item--prev" href="<?php echo esc_url(get_permalink($previous_post->ID)); ?>">
<span class="single-post-nav__arrow" aria-hidden="true"><i class="fa-solid fa-arrow-left"></i></span>
<span class="single-post-nav__body">
<span class="single-post-nav__label"><?php esc_html_e('上一篇', 'lared'); ?></span>
<span class="single-post-nav__title"><?php echo esc_html(wp_specialchars_decode(get_the_title($previous_post->ID), ENT_QUOTES)); ?></span>
</span>
</a>
<?php else : ?>
<span class="single-post-nav__item single-post-nav__item--prev is-empty">
<span class="single-post-nav__arrow" aria-hidden="true"><i class="fa-solid fa-arrow-left"></i></span>
<span class="single-post-nav__body">
<span class="single-post-nav__label"><?php esc_html_e('上一篇', 'lared'); ?></span>
<span class="single-post-nav__title"><?php esc_html_e('没有更多了', 'lared'); ?></span>
</span>
</span>
<?php endif; ?>
<?php if ($next_post instanceof WP_Post) : ?>
<a class="single-post-nav__item single-post-nav__item--next" href="<?php echo esc_url(get_permalink($next_post->ID)); ?>">
<span class="single-post-nav__body">
<span class="single-post-nav__label"><?php esc_html_e('下一篇', 'lared'); ?></span>
<span class="single-post-nav__title"><?php echo esc_html(wp_specialchars_decode(get_the_title($next_post->ID), ENT_QUOTES)); ?></span>
</span>
<span class="single-post-nav__arrow" aria-hidden="true"><i class="fa-solid fa-arrow-right"></i></span>
</a>
<?php else : ?>
<span class="single-post-nav__item single-post-nav__item--next is-empty">
<span class="single-post-nav__body">
<span class="single-post-nav__label"><?php esc_html_e('下一篇', 'lared'); ?></span>
<span class="single-post-nav__title"><?php esc_html_e('没有更多了', 'lared'); ?></span>
</span>
<span class="single-post-nav__arrow" aria-hidden="true"><i class="fa-solid fa-arrow-right"></i></span>
</span>
<?php endif; ?>
</nav>
<?php
// 评论区懒加载:仅输出轻量占位符,滚动到附近时 AJAX 加载完整评论
$lazy_comment_count = (int) get_comments_number();
?>
<section class="comments-shell comments-shell--lazy" id="comments"
data-lazy-comments
data-post-id="<?php echo (int) get_the_ID(); ?>">
<div class="comments-header" aria-label="Comments Header">
<div class="comments-header__left">
<span class="comments-title-icon" aria-hidden="true"><i class="fa-sharp fa-solid fa-message-smile"></i></span>
<span class="comments-header__title"><?php echo esc_html('《' . get_the_title() . '》'); ?></span>
</div>
<div class="comments-header__stats">
<?php if ($lazy_comment_count > 0) : ?>
<?php /* translators: %s: top-level comment (floor) count */ ?>
<span><?php printf(
esc_html__('施工队集合中… 共 %s 楼待验收 ↓', 'lared'),
'<span class="comments-header__num">' . esc_html(number_format_i18n($lazy_comment_count)) . '</span>'
); ?></span>
<?php else : ?>
<span><?php esc_html_e('地基还没挖,来开第一铲?', 'lared'); ?></span><a href="#respond" class="comments-header__gai"><?php esc_html_e('»»盖否?', 'lared'); ?></a>
<?php endif; ?>
</div>
</div>
<div class="comments-inner">
<div class="comments-lazy-spinner" aria-hidden="true"></div>
</div>
</section>
</main>
<?php
endwhile;
endif;
get_footer();