500 lines
26 KiB
PHP
500 lines
26 KiB
PHP
<?php
|
|
/**
|
|
* Single post template.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
wp_reset_postdata();
|
|
|
|
get_header();
|
|
|
|
while (have_posts()) :
|
|
the_post();
|
|
|
|
$post_id = get_the_ID();
|
|
$single_settings = function_exists('aksrt_resolve_single_post_display_settings')
|
|
? aksrt_resolve_single_post_display_settings($post_id)
|
|
: [];
|
|
$show_toc = !empty($single_settings['toc_enabled']);
|
|
$show_cover = !empty($single_settings['show_cover']);
|
|
$cover_url = (string) ($single_settings['cover_url'] ?? '');
|
|
$views = function_exists('aksrt_get_post_views') ? (int) aksrt_get_post_views($post_id) : 0;
|
|
$comment_count = (int) get_comments_number();
|
|
$like_count = function_exists('aksrt_get_post_likes') ? (int) aksrt_get_post_likes($post_id) : 0;
|
|
$favorite_count = function_exists('aksrt_get_post_favorites') ? (int) aksrt_get_post_favorites($post_id) : 0;
|
|
$is_liked = function_exists('aksrt_is_post_liked') ? aksrt_is_post_liked($post_id) : false;
|
|
$is_favorited = function_exists('aksrt_is_post_favorited') ? aksrt_is_post_favorited($post_id) : false;
|
|
$word_count = function_exists('aksrt_post_word_count') && !empty($single_settings['word_count_enabled'])
|
|
? aksrt_post_word_count($post_id)
|
|
: 0;
|
|
$reading_minutes = function_exists('aksrt_reading_minutes') && !empty($single_settings['reading_time_enabled'])
|
|
? aksrt_reading_minutes($post_id)
|
|
: 0;
|
|
$author_meta_items = [];
|
|
if (empty($single_settings['hide_time'])) {
|
|
$author_meta_items[] = [
|
|
'icon' => 'far fa-calendar-alt',
|
|
'text' => get_the_date(),
|
|
];
|
|
}
|
|
$author_meta_items[] = [
|
|
'icon' => 'far fa-eye',
|
|
'text' => sprintf(__('浏览 %s', 'aksrt'), function_exists('aksrt_format_number') ? aksrt_format_number($views) : number_format_i18n($views)),
|
|
];
|
|
$author_meta_items[] = [
|
|
'icon' => 'far fa-comment-dots',
|
|
'text' => sprintf(__('评论 %s', 'aksrt'), number_format_i18n($comment_count)),
|
|
];
|
|
|
|
if ($word_count > 0) {
|
|
$author_meta_items[] = [
|
|
'icon' => 'far fa-file-word',
|
|
'text' => sprintf(__('约 %s 字', 'aksrt'), number_format_i18n($word_count)),
|
|
];
|
|
}
|
|
if ($reading_minutes > 0) {
|
|
$author_meta_items[] = [
|
|
'icon' => 'far fa-hourglass',
|
|
'text' => sprintf(_n('约 %d 分钟', '约 %d 分钟', $reading_minutes, 'aksrt'), $reading_minutes),
|
|
];
|
|
}
|
|
|
|
$copyright_text = trim((string) ($single_settings['copyright_text'] ?? ''));
|
|
if ($copyright_text === '') {
|
|
$copyright_text = sprintf(
|
|
__('本文由 %s 原创发布,转载请注明出处。', 'aksrt'),
|
|
get_the_author()
|
|
);
|
|
}
|
|
|
|
$show_action_card = !empty($single_settings['like_enabled'])
|
|
|| !empty($single_settings['favorite_enabled'])
|
|
|| !empty($single_settings['share_enabled'])
|
|
|| !empty($single_settings['print_enabled'])
|
|
|| !empty($single_settings['pdf_export_enabled']);
|
|
$has_sidebar_widgets = is_active_sidebar('sidebar-article');
|
|
$show_sidebar = $has_sidebar_widgets || $show_toc;
|
|
$cover_breadcrumbs_html = '';
|
|
if (!empty($single_settings['breadcrumbs']) && function_exists('aksrt_breadcrumbs')) {
|
|
ob_start();
|
|
aksrt_breadcrumbs($single_settings['breadcrumbs_home'] ?? '');
|
|
$cover_breadcrumbs_html = trim((string) ob_get_clean());
|
|
}
|
|
$post_front_content = (string) ($single_settings['front_content'] ?? '');
|
|
$post_after_content = (string) ($single_settings['after_content'] ?? '');
|
|
$content_maxheight = !empty($single_settings['maxheight_enabled']) ? max(0, (int) ($single_settings['maxheight'] ?? 0)) : 0;
|
|
$post_toc_title = __('文章目录', 'aksrt');
|
|
$post_toc_widget = '';
|
|
$post_toc_drawer = '';
|
|
$post_share_dropdown = '';
|
|
$post_reward_modal = '';
|
|
$post_sidebar_prepend = '';
|
|
$post_episode_count = max(0, (int) get_post_meta($post_id, '_aksrt_featured_video_episode', true));
|
|
$post_slide_images = array_values(array_filter((array) ($single_settings['slide_images'] ?? [])));
|
|
$author_card_html = '';
|
|
$has_download_capability = function_exists('aksrt_is_downloadable_content') && aksrt_is_downloadable_content($post_id);
|
|
$paid_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_paid_content_settings() : [];
|
|
$paid_display_settings = is_array($paid_settings['display'] ?? null) ? $paid_settings['display'] : [];
|
|
$paid_box_position = (string) ($paid_display_settings['box_position'] ?? 'top');
|
|
if ($paid_box_position === 'box_top') {
|
|
$paid_box_position = 'top';
|
|
} elseif ($paid_box_position === 'box_bottom') {
|
|
$paid_box_position = 'bottom';
|
|
}
|
|
if (!in_array($paid_box_position, ['top', 'bottom'], true)) {
|
|
$paid_box_position = 'top';
|
|
}
|
|
if (class_exists('AKSRT_Docs_Presenter')) {
|
|
$docs_presenter = AKSRT_Docs_Presenter::get_instance();
|
|
if ($docs_presenter->is_docs_page($post_id)) {
|
|
get_template_part('templates/pages/page-documentnav');
|
|
get_footer();
|
|
return;
|
|
}
|
|
}
|
|
if (!empty($single_settings['share_enabled'])) {
|
|
$post_share_dropdown = '<div class="share-dropdown" id="share-dropdown" aria-hidden="true"><div class="share-dropdown__grid">'
|
|
. '<button type="button" class="share-item" data-platform="qq"><i class="fab fa-qq"></i><span>QQ</span></button>'
|
|
. '<button type="button" class="share-item" data-platform="weibo"><i class="fab fa-weibo"></i><span>微博</span></button>'
|
|
. '<button type="button" class="share-item" data-platform="twitter"><i class="fab fa-x-twitter"></i><span>X</span></button>'
|
|
. '<button type="button" class="share-item" data-platform="wechat"><i class="fab fa-weixin"></i><span>微信</span></button>'
|
|
. '<button type="button" class="share-item" data-platform="copy"><i class="fas fa-link"></i><span>' . esc_html__('复制链接', 'aksrt') . '</span></button>'
|
|
. '</div><div id="share-qrcode-box" aria-hidden="true"><img id="share-qrcode-image" src="" alt="QR Code"></div></div>';
|
|
}
|
|
if (!empty($single_settings['rewards_enabled']) && !empty($single_settings['rewards_image'])) {
|
|
$post_reward_modal = '<div class="reward-modal" id="reward-modal" aria-hidden="true"><div class="reward-modal__overlay"></div><div class="reward-modal__dialog"><button type="button" class="reward-modal__close" aria-label="' . esc_attr__('关闭', 'aksrt') . '"><i class="fas fa-times" aria-hidden="true"></i></button><div class="reward-modal__content"><h3>' . esc_html($single_settings['rewards_text']) . '</h3><div class="reward-modal__qrcode"><img src="' . esc_url($single_settings['rewards_image']) . '" alt="' . esc_attr__('打赏二维码', 'aksrt') . '"></div></div></div></div>';
|
|
}
|
|
if ($show_toc) {
|
|
$post_toc_widget = '<div class="zib-widget toc-widget posts-nav-box" data-title="' . esc_attr($post_toc_title) . '"><h3>' . esc_html($post_toc_title) . '</h3><ol class="toc-list"></ol></div>';
|
|
$post_toc_drawer = '<button type="button" class="toc-float-btn" aria-label="' . esc_attr__('打开目录', 'aksrt') . '"><i class="fas fa-list-ul" aria-hidden="true"></i></button>'
|
|
. '<div class="toc-drawer-overlay"></div>'
|
|
. '<aside class="toc-drawer posts-nav-box" data-title="' . esc_attr($post_toc_title) . '" aria-label="' . esc_attr($post_toc_title) . '"><div class="toc-drawer__head"><h3>' . esc_html($post_toc_title) . '</h3><button type="button" class="toc-drawer__close" aria-label="' . esc_attr__('关闭目录', 'aksrt') . '"><i class="fas fa-times" aria-hidden="true"></i></button></div><ol class="toc-list"></ol></aside>';
|
|
}
|
|
if (function_exists('aksrt_get_user_dashboard_view')) {
|
|
$author_dashboard = aksrt_get_user_dashboard_view((int) get_the_author_meta('ID'), ['viewer_id' => get_current_user_id()]);
|
|
$author_recent_posts = is_array($author_dashboard['recent_posts'] ?? null) ? $author_dashboard['recent_posts'] : [];
|
|
$author_card_stats = [
|
|
['label' => __('文章', 'aksrt'), 'value' => (int) ($author_dashboard['post_count'] ?? 0)],
|
|
['label' => __('评论', 'aksrt'), 'value' => (int) ($author_dashboard['comment_count'] ?? 0)],
|
|
['label' => __('收藏', 'aksrt'), 'value' => (int) ($author_dashboard['favorite_count'] ?? 0)],
|
|
];
|
|
$author_card_html = '<div class="author author-box">'
|
|
. '<div class="author-box__header">'
|
|
. '<a href="' . esc_url(get_author_posts_url((int) get_the_author_meta('ID'))) . '" class="author-box__avatar">' . get_avatar((int) get_the_author_meta('ID'), 56, '', esc_attr(get_the_author())) . '</a>'
|
|
. '<div class="author-box__info"><a href="' . esc_url(get_author_posts_url((int) get_the_author_meta('ID'))) . '" class="author-box__name">' . esc_html(get_the_author()) . '</a>';
|
|
$author_bio = trim((string) get_the_author_meta('description'));
|
|
if ($author_bio !== '') {
|
|
$author_card_html .= '<p class="author-box__bio">' . esc_html($author_bio) . '</p>';
|
|
}
|
|
$author_card_html .= '<div class="author-box__stats">';
|
|
foreach ($author_card_stats as $stat) {
|
|
$author_card_html .= '<span><strong>' . esc_html((string) $stat['value']) . '</strong> ' . esc_html($stat['label']) . '</span>';
|
|
}
|
|
$author_card_html .= '</div></div></div>';
|
|
if (!empty($author_recent_posts)) {
|
|
$author_card_html .= '<div class="author-box__posts"><h3 class="author-box__posts-title">' . esc_html__('最新文章', 'aksrt') . '</h3><ul>';
|
|
foreach ($author_recent_posts as $author_recent_post) {
|
|
if ($author_recent_post instanceof WP_Post) {
|
|
$author_card_html .= '<li><a href="' . esc_url(get_permalink($author_recent_post)) . '">' . esc_html(get_the_title($author_recent_post)) . '</a></li>';
|
|
}
|
|
}
|
|
$author_card_html .= '</ul></div>';
|
|
}
|
|
$author_card_html .= '</div>';
|
|
}
|
|
$post_status_badge = '';
|
|
$post_status = get_post_status($post_id);
|
|
if ($post_status && $post_status !== 'publish') {
|
|
$status_map = [
|
|
'draft' => ['label' => __('草稿', 'aksrt'), 'class' => 'jb-yellow'],
|
|
'pending' => ['label' => __('待审核', 'aksrt'), 'class' => 'jb-red'],
|
|
'private' => ['label' => __('私密', 'aksrt'), 'class' => 'b-black opacity8'],
|
|
'future' => ['label' => __('定时发布', 'aksrt'), 'class' => 'c-blue'],
|
|
];
|
|
if (isset($status_map[$post_status])) {
|
|
$post_status_badge = '<badge class="img-badge right ' . esc_attr($status_map[$post_status]['class']) . '">' . esc_html($status_map[$post_status]['label']) . '</badge>';
|
|
}
|
|
}
|
|
?>
|
|
|
|
<?php if (!empty($single_settings['reading_progress'])) : ?>
|
|
<div id="reading-progress-global" class="reading-progress-bar" role="progressbar" aria-label="<?php esc_attr_e('阅读进度', 'aksrt'); ?>" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"></div>
|
|
<?php endif; ?>
|
|
|
|
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--single" tabindex="-1">
|
|
<div class="content-layout<?php echo $show_sidebar ? '' : ' content-layout--no-sidebar'; ?>">
|
|
<div class="content-layout__primary">
|
|
<div class="content-main content-main--single">
|
|
<?php if (!$show_cover && function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs($single_settings['breadcrumbs_home'] ?? ''); } ?>
|
|
|
|
<?php do_action('aksrt_single_before', $post); ?>
|
|
|
|
<article <?php post_class('article article-shell main-bg theme-box box-body radius8 main-shadow'); ?>>
|
|
<?php
|
|
$cover_type = (string) ($single_settings['cover_type'] ?? 'none');
|
|
$img_scale = (int) ($single_settings['article_image_cover_scale'] ?? 35);
|
|
$video_scale = (int) ($single_settings['article_video_cover_scale'] ?? 56);
|
|
if ($show_cover && $cover_url !== '') :
|
|
if ($cover_type === 'video') :
|
|
?>
|
|
<div class="single-head-cover single-cover single-cover--video graphic imgbox-container" style="padding-bottom:<?php echo esc_attr($video_scale); ?>%;">
|
|
<video src="<?php echo esc_url($cover_url); ?>" autoplay muted loop playsinline class="single-cover__video"></video>
|
|
<div class="single-cover__overlay"></div>
|
|
<div class="single-cover__content">
|
|
<?php if ($cover_breadcrumbs_html !== '') : ?>
|
|
<div class="post-breadcrumbs"><?php echo $cover_breadcrumbs_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
|
<?php endif; ?>
|
|
<h1 class="article-title title-h-left"><?php the_title(); ?></h1>
|
|
<?php if ($post_status_badge !== '') : ?>
|
|
<?php echo $post_status_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php endif; ?>
|
|
<div class="cover-meta abs-right">
|
|
<?php foreach ($author_meta_items as $meta_item) : ?>
|
|
<item class="meta-view"><?php echo esc_html($meta_item['text']); ?></item>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php if ($post_episode_count > 0) : ?>
|
|
<div class="featured-video-episode single-video"><?php printf(esc_html__('第 %d 集', 'aksrt'), $post_episode_count); ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php elseif ($cover_type === 'slide' && !empty($single_settings['slide_images'])) : ?>
|
|
<div class="single-head-cover single-cover single-cover--slide graphic imgbox-container" style="padding-bottom:<?php echo esc_attr($img_scale); ?>%;">
|
|
<div class="single-cover__slides">
|
|
<?php foreach ($single_settings['slide_images'] as $idx => $slide_url) : ?>
|
|
<div class="single-cover__slide<?php echo $idx === 0 ? ' is-active' : ''; ?>">
|
|
<img src="<?php echo esc_url($slide_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" class="fit-cover" loading="<?php echo $idx === 0 ? 'eager' : 'lazy'; ?>">
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="single-cover__overlay"></div>
|
|
<div class="single-cover__content">
|
|
<?php if ($cover_breadcrumbs_html !== '') : ?>
|
|
<div class="post-breadcrumbs"><?php echo $cover_breadcrumbs_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
|
<?php endif; ?>
|
|
<h1 class="article-title title-h-left"><?php the_title(); ?></h1>
|
|
<?php if ($post_status_badge !== '') : ?>
|
|
<?php echo $post_status_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php endif; ?>
|
|
<div class="cover-meta abs-right">
|
|
<?php foreach ($author_meta_items as $meta_item) : ?>
|
|
<item class="meta-view"><?php echo esc_html($meta_item['text']); ?></item>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php if (!empty($post_slide_images)) : ?>
|
|
<div class="single-cover__dots single-cover-slide" aria-hidden="true">
|
|
<?php foreach ($post_slide_images as $idx => $unused_slide) : ?>
|
|
<span class="single-cover__dot<?php echo $idx === 0 ? ' is-active' : ''; ?>"></span>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php else : ?>
|
|
<div class="single-head-cover single-cover graphic imgbox-container" style="padding-bottom:<?php echo esc_attr($img_scale); ?>%;">
|
|
<img src="<?php echo esc_url($cover_url); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" class="fit-cover" loading="eager">
|
|
<div class="single-cover__overlay"></div>
|
|
<div class="single-cover__content">
|
|
<?php if ($cover_breadcrumbs_html !== '') : ?>
|
|
<div class="post-breadcrumbs"><?php echo $cover_breadcrumbs_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
|
<?php endif; ?>
|
|
<h1 class="article-title title-h-left"><?php the_title(); ?></h1>
|
|
<?php if ($post_status_badge !== '') : ?>
|
|
<?php echo $post_status_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php endif; ?>
|
|
<div class="cover-meta abs-right">
|
|
<?php foreach ($author_meta_items as $meta_item) : ?>
|
|
<item class="meta-view"><?php echo esc_html($meta_item['text']); ?></item>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; endif; ?>
|
|
|
|
<?php if (!$show_cover) : ?>
|
|
<header class="article-header theme-box clearfix relative">
|
|
<h1 class="article-title"><?php the_title(); ?></h1>
|
|
<?php if ($post_status_badge !== '') : ?>
|
|
<?php echo $post_status_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php endif; ?>
|
|
</header>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($single_settings['authordesc'])) : ?>
|
|
<?php
|
|
set_query_var('aksrt_author_bar_actions', true);
|
|
set_query_var('aksrt_author_bar_meta_items', $author_meta_items);
|
|
?>
|
|
<div class="article-avatar">
|
|
<?php get_template_part('templates/parts/single-author-bar'); ?>
|
|
</div>
|
|
<?php
|
|
set_query_var('aksrt_author_bar_actions', false);
|
|
set_query_var('aksrt_author_bar_meta_items', []);
|
|
?>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($single_settings['yiyan_header'])) : ?>
|
|
<div class="article-yiyan yiyan-box aksrt-yiyan yiyan--header" data-aksrt-yiyan data-type="hitokoto"></div>
|
|
<?php endif; ?>
|
|
|
|
<?php do_action('aksrt_single_content_before', $post); ?>
|
|
|
|
<?php if ($has_download_capability && $paid_box_position === 'top') : ?>
|
|
<div class="aksrt-single-download-box aksrt-single-download-box--before">
|
|
<?php get_template_part('templates/parts/resource-download-box'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (is_active_sidebar('single_top_content')) : ?>
|
|
<div class="aksrt-single-widget-area aksrt-single-widget-area--top">
|
|
<?php dynamic_sidebar('single_top_content'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($post_front_content !== '') : ?>
|
|
<div class="post_front_content theme-box box-body"><?php echo wp_kses_post($post_front_content); ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div class="theme-box wp-posts-content entry-content<?php echo $content_maxheight > 0 ? ' limit-height' : ''; ?>"
|
|
data-nav="posts"
|
|
data-maxheight="<?php echo esc_attr((string) $content_maxheight); ?>"
|
|
data-aksrt-toc="<?php echo $show_toc ? '1' : '0'; ?>"
|
|
data-aksrt-toc-depth="<?php echo esc_attr((string) ((int) ($single_settings['toc_depth'] ?? 3))); ?>">
|
|
<?php the_content(); ?>
|
|
<?php
|
|
wp_link_pages([
|
|
'before' => '<p class="text-center post-nav-links radius8 padding-6">',
|
|
'after' => '</p>',
|
|
]);
|
|
?>
|
|
</div>
|
|
<?php if ($post_after_content !== '') : ?>
|
|
<div class="post_after_content theme-box box-body"><?php echo wp_kses_post($post_after_content); ?></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($has_download_capability && $paid_box_position === 'bottom') : ?>
|
|
<div class="aksrt-single-download-box aksrt-single-download-box--after">
|
|
<?php get_template_part('templates/parts/resource-download-box'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($author_card_html !== '') : ?>
|
|
<?php echo $author_card_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php endif; ?>
|
|
|
|
<div class="text-center muted-3-color box-body em09"><?php echo esc_html($single_settings['button_toptext'] ?? __('喜欢就支持一下吧', 'aksrt')); ?></div>
|
|
<div class="text-center post-actions">
|
|
<?php if (!empty($single_settings['like_enabled'])) : ?>
|
|
<button type="button" class="action action-like<?php echo $is_liked ? ' is-active' : ''; ?>" id="action-like" data-post-id="<?php echo esc_attr((string) $post_id); ?>" data-initial-active="<?php echo $is_liked ? '1' : '0'; ?>">
|
|
<i class="<?php echo $is_liked ? 'fas' : 'far'; ?> fa-heart" aria-hidden="true"></i>
|
|
<span class="action-btn__count" data-stat-count="likes" data-base-count="<?php echo esc_attr((string) $like_count); ?>"><?php echo esc_html((string) $like_count); ?></span>
|
|
</button>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($single_settings['rewards_enabled']) && !empty($single_settings['rewards_image'])) : ?>
|
|
<button type="button" class="action action-rewards" id="action-reward">
|
|
<i class="fas fa-gift" aria-hidden="true"></i>
|
|
<span class="action-btn__label"><?php echo esc_html($single_settings['rewards_btn_text'] ?? __('赞赏', 'aksrt')); ?></span>
|
|
</button>
|
|
<?php endif; ?>
|
|
<?php if (!empty($single_settings['share_enabled'])) : ?>
|
|
<button type="button" class="action action-share" id="action-share-trigger" aria-haspopup="true" aria-expanded="false">
|
|
<i class="fas fa-share-alt" aria-hidden="true"></i>
|
|
<span class="action-btn__label"><?php esc_html_e('分享', 'aksrt'); ?></span>
|
|
</button>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($single_settings['favorite_enabled'])) : ?>
|
|
<button type="button" class="action action-favorite<?php echo $is_favorited ? ' is-active' : ''; ?>" id="action-favorite" data-post-id="<?php echo esc_attr((string) $post_id); ?>" data-initial-active="<?php echo $is_favorited ? '1' : '0'; ?>">
|
|
<i class="<?php echo $is_favorited ? 'fas' : 'far'; ?> fa-star" aria-hidden="true"></i>
|
|
<span class="action-btn__count" data-stat-count="favorites" data-base-count="<?php echo esc_attr((string) $favorite_count); ?>"><?php echo esc_html((string) $favorite_count); ?></span>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php if ($post_share_dropdown !== '') : ?>
|
|
<?php echo $post_share_dropdown; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php endif; ?>
|
|
<?php if ($post_reward_modal !== '') : ?>
|
|
<?php echo $post_reward_modal; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($single_settings['yiyan_footer'])) : ?>
|
|
<div class="article-yiyan yiyan-box aksrt-yiyan yiyan--footer" data-aksrt-yiyan data-type="hitokoto"></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($single_settings['copyright_enabled'])) : ?>
|
|
<div class="em09 muted-3-color"><div><span>©</span> <?php esc_html_e('版权声明', 'aksrt'); ?></div><div class="posts-copyright"><?php echo esc_html($copyright_text); ?></div></div>
|
|
<?php endif; ?>
|
|
<div class="text-center theme-box muted-3-color box-body separator em09">THE END</div>
|
|
<div class="theme-box article-tags">
|
|
<?php foreach (get_the_category() ?: [] as $cat) : ?>
|
|
<a href="<?php echo esc_url(get_category_link($cat->term_id)); ?>" class="but"><i class="far fa-folder-open" aria-hidden="true"></i> <?php echo esc_html($cat->name); ?></a>
|
|
<?php endforeach; ?>
|
|
<?php $single_topics = taxonomy_exists('topics') ? wp_get_post_terms($post_id, 'topics') : []; ?>
|
|
<?php if (!is_wp_error($single_topics) && !empty($single_topics)) : ?>
|
|
<?php foreach (array_slice($single_topics, 0, 2) as $single_topic) : ?>
|
|
<a href="<?php echo esc_url(get_term_link($single_topic)); ?>" class="but"><i class="fas fa-cube" aria-hidden="true"></i> <?php echo esc_html($single_topic->name); ?></a>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
<br>
|
|
<?php foreach (get_the_tags() ?: [] as $tag) : ?>
|
|
<a href="<?php echo esc_url(get_tag_link($tag->term_id)); ?>" class="but">#<?php echo esc_html($tag->name); ?></a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php
|
|
$prev_post = get_previous_post();
|
|
$next_post = get_next_post();
|
|
if ($prev_post || $next_post) :
|
|
?>
|
|
<nav class="post-nav-box">
|
|
<?php if ($prev_post) : ?>
|
|
<a class="post-nav-box__item post-nav-box__item--prev" href="<?php echo esc_url(get_permalink($prev_post)); ?>">
|
|
<span class="post-nav-box__label"><?php esc_html_e('上一篇', 'aksrt'); ?></span>
|
|
<span class="post-nav-box__title"><?php echo esc_html(get_the_title($prev_post)); ?></span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php if ($next_post) : ?>
|
|
<a class="post-nav-box__item post-nav-box__item--next" href="<?php echo esc_url(get_permalink($next_post)); ?>">
|
|
<span class="post-nav-box__label"><?php esc_html_e('下一篇', 'aksrt'); ?></span>
|
|
<span class="post-nav-box__title"><?php echo esc_html(get_the_title($next_post)); ?></span>
|
|
</a>
|
|
<?php endif; ?>
|
|
</nav>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($single_settings['related_enabled'])) : ?>
|
|
<?php
|
|
$related_count = max(1, min(12, (int) ($single_settings['related_count'] ?? 6)));
|
|
$related_title = (string) ($single_settings['related_title'] ?? '');
|
|
$related_args = [
|
|
'post_type' => get_post_type($post_id),
|
|
'post_status' => 'publish',
|
|
'post__not_in' => [$post_id],
|
|
'posts_per_page' => $related_count,
|
|
'ignore_sticky_posts' => true,
|
|
];
|
|
if (($single_settings['related_type'] ?? 'category') === 'tag') {
|
|
$tag_ids = wp_get_post_terms($post_id, 'post_tag', ['fields' => 'ids']);
|
|
if (!empty($tag_ids) && !is_wp_error($tag_ids)) {
|
|
$related_args['tag__in'] = $tag_ids;
|
|
}
|
|
} else {
|
|
$cat_ids = wp_get_post_terms($post_id, 'category', ['fields' => 'ids']);
|
|
if (!empty($cat_ids) && !is_wp_error($cat_ids)) {
|
|
$related_args['category__in'] = $cat_ids;
|
|
}
|
|
}
|
|
$related_query = new WP_Query($related_args);
|
|
if ($related_query->have_posts()) :
|
|
?>
|
|
<div class="related-box theme-box box-body radius8 main-shadow">
|
|
<div class="related-box__header">
|
|
<h3><?php echo esc_html($related_title !== '' ? $related_title : __('相关文章', 'aksrt')); ?></h3>
|
|
</div>
|
|
<div class="related-box__list">
|
|
<?php aksrt_render_post_list($related_query, ['context' => 'related', 'mode' => 'card', 'card_style' => 'standard']); ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; wp_reset_postdata(); ?>
|
|
<?php endif; ?>
|
|
|
|
<?php if (is_active_sidebar('single_bottom_content')) : ?>
|
|
<div class="aksrt-single-widget-area aksrt-single-widget-area--bottom">
|
|
<?php dynamic_sidebar('single_bottom_content'); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</article>
|
|
|
|
<?php do_action('aksrt_single_article_after', $post); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($show_sidebar) : ?>
|
|
<?php
|
|
$post_sidebar_prepend = '';
|
|
if ($has_download_capability) {
|
|
ob_start();
|
|
get_template_part('templates/parts/resource-meta-box');
|
|
$post_sidebar_prepend .= (string) ob_get_clean();
|
|
}
|
|
if ($show_toc && $post_toc_widget !== '') {
|
|
$post_sidebar_prepend .= $post_toc_widget;
|
|
}
|
|
set_query_var('aksrt_sidebar_prepend_html', $post_sidebar_prepend);
|
|
get_sidebar();
|
|
set_query_var('aksrt_sidebar_prepend_html', '');
|
|
?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php endwhile; ?>
|
|
|
|
<?php get_footer(); ?>
|