feat(frontend): deepen single post 1:1 parity with Zibll
Split related style/source settings, add subtitle/meta/allow-view helpers, align cover/author/tags/pay shell markup and CSS with Zibll single.
This commit is contained in:
+191
-151
@@ -33,32 +33,20 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
? aksrt_reading_minutes($post_id)
|
||||
: 0;
|
||||
|
||||
// Zibll primary meta = comment/views/likes via meta_box_html.
|
||||
$meta_items = [];
|
||||
if (empty($settings['hide_time'])) {
|
||||
$meta_items[] = [
|
||||
'icon' => 'far fa-calendar-alt',
|
||||
'text' => get_the_date('', $post_id),
|
||||
];
|
||||
}
|
||||
$meta_items[] = [
|
||||
'icon' => 'far fa-eye',
|
||||
'text' => sprintf(
|
||||
__('浏览 %s', 'aksrt'),
|
||||
function_exists('aksrt_format_number') ? aksrt_format_number($views) : number_format_i18n($views)
|
||||
),
|
||||
];
|
||||
$meta_items[] = [
|
||||
'icon' => 'far fa-comment-dots',
|
||||
'text' => sprintf(__('评论 %s', 'aksrt'), number_format_i18n($comment_count)),
|
||||
];
|
||||
$meta_box_html = function_exists('aksrt_get_single_meta_box')
|
||||
? aksrt_get_single_meta_box('abs-right', 'down', $post_id)
|
||||
: '';
|
||||
$meta_items_secondary = [];
|
||||
if ($word_count > 0) {
|
||||
$meta_items[] = [
|
||||
$meta_items_secondary[] = [
|
||||
'icon' => 'far fa-file-word',
|
||||
'text' => sprintf(__('约 %s 字', 'aksrt'), number_format_i18n($word_count)),
|
||||
];
|
||||
}
|
||||
if ($reading_minutes > 0) {
|
||||
$meta_items[] = [
|
||||
$meta_items_secondary[] = [
|
||||
'icon' => 'far fa-hourglass',
|
||||
'text' => sprintf(_n('约 %d 分钟', '约 %d 分钟', $reading_minutes, 'aksrt'), $reading_minutes),
|
||||
];
|
||||
@@ -92,23 +80,23 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
$breadcrumbs_html = '';
|
||||
if (!empty($settings['breadcrumbs']) && function_exists('aksrt_breadcrumbs')) {
|
||||
ob_start();
|
||||
aksrt_breadcrumbs($settings['breadcrumbs_home'] ?? ($settings['breadcrumbs_home_text'] ?? ''));
|
||||
aksrt_breadcrumbs(
|
||||
(string) ($settings['breadcrumbs_home'] ?? ($settings['breadcrumbs_home_text'] ?? '')),
|
||||
['single_text' => !isset($settings['breadcrumbs_single_text']) || !empty($settings['breadcrumbs_single_text'])]
|
||||
);
|
||||
$breadcrumbs_html = trim((string) ob_get_clean());
|
||||
}
|
||||
|
||||
$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])) {
|
||||
$status_badge = '<badge class="img-badge right ' . esc_attr($status_map[$post_status]['class']) . '">'
|
||||
. esc_html($status_map[$post_status]['label']) . '</badge>';
|
||||
}
|
||||
$status_badge = function_exists('aksrt_get_post_status_badge')
|
||||
? aksrt_get_post_status_badge($post_id)
|
||||
: '';
|
||||
|
||||
$allow_view = function_exists('aksrt_get_post_allow_view_data')
|
||||
? aksrt_get_post_allow_view_data($post_id)
|
||||
: ['allow' => true];
|
||||
if (empty($allow_view['allow'])) {
|
||||
// Zibll: pay box is skipped when allow_view denies.
|
||||
$show_pay_box = false;
|
||||
}
|
||||
|
||||
$aside_widgets = is_active_sidebar('sidebar-article')
|
||||
@@ -128,6 +116,10 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
'episode_count' => max(0, (int) ($settings['episode_count'] ?? 0)),
|
||||
'video_poster' => (string) ($settings['video_poster'] ?? ''),
|
||||
'meta_items' => $meta_items,
|
||||
'meta_items_secondary' => $meta_items_secondary,
|
||||
'meta_box_html' => $meta_box_html,
|
||||
'title_html' => function_exists('aksrt_get_single_title_html') ? aksrt_get_single_title_html($post_id) : esc_html(get_the_title($post_id)),
|
||||
'allow_view' => $allow_view,
|
||||
'views' => $views,
|
||||
'comment_count' => $comment_count,
|
||||
'like_count' => $like_count,
|
||||
@@ -194,46 +186,52 @@ if (!function_exists('aksrt_single_render_cover')) :
|
||||
$type = (string) $ctx['cover_type'];
|
||||
$badge = (string) $ctx['status_badge'];
|
||||
$crumbs = (string) $ctx['breadcrumbs_html'];
|
||||
$meta_items = is_array($ctx['meta_items'] ?? null) ? $ctx['meta_items'] : [];
|
||||
$meta_box = (string) ($ctx['meta_box_html'] ?? '');
|
||||
$img_scale = max(10, min(100, (int) $ctx['img_scale']));
|
||||
$video_scale = max(20, min(100, (int) $ctx['video_scale']));
|
||||
$episode = (int) $ctx['episode_count'];
|
||||
$slides = is_array($ctx['slide_images'] ?? null) ? $ctx['slide_images'] : [];
|
||||
$poster = (string) ($ctx['video_poster'] ?? '');
|
||||
$title = get_the_title();
|
||||
$title_html = (string) ($ctx['title_html'] ?? esc_html(get_the_title()));
|
||||
|
||||
if ($type === 'video') :
|
||||
?>
|
||||
<div class="single-head-cover">
|
||||
<div class="single-video single-cover single-cover--video graphic imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $video_scale); ?>%;">
|
||||
<video src="<?php echo esc_url($ctx['cover_url']); ?>"<?php echo $poster !== '' ? ' poster="' . esc_url($poster) . '"' : ''; ?> autoplay muted loop playsinline controls class="single-cover__video fit-cover"></video>
|
||||
<div class="single-cover__overlay"></div>
|
||||
</div>
|
||||
<div class="single-video-footer dplayer-featured">
|
||||
<div class="flex jsb at">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<div class="cover-meta single-metabox">
|
||||
<?php foreach ($meta_items as $item) : ?>
|
||||
<item class="meta-view"><?php echo esc_html((string) ($item['text'] ?? '')); ?></item>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="single-video">
|
||||
<div class="graphic single-cover single-cover--video imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $video_scale); ?>%;">
|
||||
<video src="<?php echo esc_url($ctx['cover_url']); ?>"<?php echo $poster !== '' ? ' poster="' . esc_url($poster) . '"' : ''; ?> controls playsinline class="fit-cover single-cover__video" data-aksrt-cover-video></video>
|
||||
</div>
|
||||
<h1 class="article-title">
|
||||
<?php if ($episode > 1) : ?>
|
||||
<span class="badg badg-sm b-theme mr6"><i class="fa fa-play-circle mr3" aria-hidden="true"></i><?php printf(esc_html__('共%d集', 'aksrt'), $episode); ?></span>
|
||||
<?php else : ?>
|
||||
<i class="fa fa-play-circle-o mr6 opacity8" aria-hidden="true"></i>
|
||||
<?php endif; ?>
|
||||
<?php echo esc_html($title); ?>
|
||||
</h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php if ($episode > 0) : ?>
|
||||
<div class="featured-video-episode mt10">
|
||||
<span class="switch-video text-ellipsis active"><span class="mr6 badg badg-sm">1</span><i class="episode-active-icon"></i><?php printf(esc_html__('第%d集', 'aksrt'), 1); ?></span>
|
||||
<div class="single-video-footer dplayer-featured">
|
||||
<div class="flex jsb at">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($meta_box !== '') : ?>
|
||||
<?php echo str_replace('abs-right', 'mb10 ml10 shrink0', $meta_box); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title">
|
||||
<?php if ($episode > 1) : ?>
|
||||
<span class="badg badg-sm b-theme mr6"><i class="fa fa-play-circle mr3" aria-hidden="true"></i><?php printf(esc_html__('共%d集', 'aksrt'), $episode); ?></span>
|
||||
<?php else : ?>
|
||||
<i class="fa fa-play-circle-o mr6 opacity8" aria-hidden="true"></i>
|
||||
<?php endif; ?>
|
||||
<?php echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php if ($episode > 0) : ?>
|
||||
<div class="featured-video-episode mt10">
|
||||
<a href="javascript:;" class="switch-video text-ellipsis active" data-index="1" video-url="<?php echo esc_url($ctx['cover_url']); ?>">
|
||||
<span class="mr6 badg badg-sm">1</span><i class="episode-active-icon"></i><?php printf(esc_html__('第%d集', 'aksrt'), 1); ?>
|
||||
</a>
|
||||
<?php for ($i = 2; $i <= $episode; $i++) : ?>
|
||||
<a href="javascript:;" class="switch-video text-ellipsis" data-index="<?php echo (int) $i; ?>" video-url="<?php echo esc_url($ctx['cover_url']); ?>">
|
||||
<span class="mr6 badg badg-sm"><?php echo (int) $i; ?></span><i class="episode-active-icon"></i><?php printf(esc_html__('第%d集', 'aksrt'), $i); ?>
|
||||
</a>
|
||||
<?php endfor; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@@ -241,56 +239,71 @@ if (!function_exists('aksrt_single_render_cover')) :
|
||||
endif;
|
||||
|
||||
if ($type === 'slide' && !empty($slides)) :
|
||||
$slide_items = [];
|
||||
foreach ($slides as $slide_url) {
|
||||
$slide_items[] = [
|
||||
'image' => (string) $slide_url,
|
||||
'alt' => wp_strip_all_tags(get_the_title()),
|
||||
];
|
||||
}
|
||||
$overlay = '<div class="abs-center left-bottom single-cover-con">'
|
||||
. '<h1 class="article-title title-h-left">' . $title_html . '</h1>'
|
||||
. ($crumbs !== '' ? $crumbs : '')
|
||||
. $badge
|
||||
. '</div>'
|
||||
. ($meta_box !== '' ? str_replace('abs-right', 'cover-meta abs-right', $meta_box) : '');
|
||||
$slider_html = '';
|
||||
if (function_exists('aksrt_render_slider')) {
|
||||
$slider_html = aksrt_render_slider([
|
||||
'slides' => $slide_items,
|
||||
'scale_height' => true,
|
||||
'scale_ratio' => $img_scale / 100,
|
||||
'wrapper_class' => 'mb20 single-cover-slide imgbox-container',
|
||||
'slider_class' => 'single-cover single-cover--slide',
|
||||
'show_nav' => true,
|
||||
'show_pagination' => true,
|
||||
'loop' => count($slide_items) > 1,
|
||||
'autoplay' => count($slide_items) > 1,
|
||||
]);
|
||||
}
|
||||
?>
|
||||
<div class="single-head-cover">
|
||||
<div class="single-cover single-cover--slide graphic imgbox-container mb20 single-cover-slide" style="padding-bottom:<?php echo esc_attr((string) $img_scale); ?>%;">
|
||||
<div class="single-cover__slides">
|
||||
<?php if ($slider_html !== '') : ?>
|
||||
<div class="single-cover-slide-wrap" style="position:relative">
|
||||
<?php echo $slider_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php echo $overlay; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="graphic mb20 single-cover single-cover--slide imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $img_scale); ?>%;">
|
||||
<?php foreach ($slides 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($title); ?>" class="fit-cover" loading="<?php echo $idx === 0 ? 'eager' : 'lazy'; ?>">
|
||||
</div>
|
||||
<img src="<?php echo esc_url($slide_url); ?>" alt="" class="fit-cover" style="<?php echo $idx === 0 ? '' : 'display:none;'; ?>" loading="<?php echo $idx === 0 ? 'eager' : 'lazy'; ?>">
|
||||
<?php endforeach; ?>
|
||||
<?php echo $overlay; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<div class="single-cover__overlay"></div>
|
||||
<div class="abs-center left-bottom single-cover-con single-cover__content">
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title title-h-left"><?php echo esc_html($title); ?></h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<div class="cover-meta abs-right">
|
||||
<?php foreach ($meta_items as $item) : ?>
|
||||
<item class="meta-view"><?php echo esc_html((string) ($item['text'] ?? '')); ?></item>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="single-cover__dots" aria-hidden="true">
|
||||
<?php foreach ($slides as $idx => $_slide) : ?>
|
||||
<span class="single-cover__dot<?php echo $idx === 0 ? ' is-active' : ''; ?>"></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
return;
|
||||
endif;
|
||||
|
||||
// Image cover (default).
|
||||
$img_attrs = function_exists('aksrt_lazy_img_attrs')
|
||||
? aksrt_lazy_img_attrs((string) $ctx['cover_url'], 'cover', 'fit-cover')
|
||||
: 'class="fit-cover" src="' . esc_url((string) $ctx['cover_url']) . '" loading="eager"';
|
||||
?>
|
||||
<div class="single-head-cover">
|
||||
<div class="graphic mb20 single-cover imgbox-container" style="padding-bottom:<?php echo esc_attr((string) $img_scale); ?>%;">
|
||||
<img src="<?php echo esc_url($ctx['cover_url']); ?>" alt="<?php echo esc_attr($title); ?>" class="fit-cover" loading="eager">
|
||||
<div class="single-cover__overlay"></div>
|
||||
<div class="abs-center left-bottom single-cover-con single-cover__content">
|
||||
<img <?php echo $img_attrs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="<?php echo esc_attr(wp_strip_all_tags(get_the_title())); ?>">
|
||||
<div class="abs-center left-bottom single-cover-con">
|
||||
<h1 class="article-title title-h-left"><?php echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h1>
|
||||
<?php if ($crumbs !== '') : ?>
|
||||
<div class="post-breadcrumbs"><?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
<?php echo $crumbs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
<h1 class="article-title title-h-left"><?php echo esc_html($title); ?></h1>
|
||||
<?php echo $badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<div class="cover-meta abs-right">
|
||||
<?php foreach ($meta_items as $item) : ?>
|
||||
<item class="meta-view"><?php echo esc_html((string) ($item['text'] ?? '')); ?></item>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($meta_box !== '') : ?>
|
||||
<?php echo str_replace('abs-right', 'cover-meta abs-right', $meta_box); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@@ -309,22 +322,18 @@ if (!function_exists('aksrt_single_render_box_header')) :
|
||||
<div class="article-header theme-box clearfix relative">
|
||||
<?php if (empty($ctx['show_cover'])) : ?>
|
||||
<?php echo (string) $ctx['status_badge']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<h1 class="article-title"><?php the_title(); ?></h1>
|
||||
<h1 class="article-title"><a href="<?php the_permalink(); ?>"><?php echo (string) ($ctx['title_html'] ?? esc_html(get_the_title())); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></a></h1>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$show_author_bar = array_key_exists('authordesc', $settings)
|
||||
? !empty($settings['authordesc'])
|
||||
: !empty($settings['authordesc_s']);
|
||||
if ($show_author_bar) :
|
||||
?>
|
||||
<?php
|
||||
aksrt_single_render_author_bar([
|
||||
'show_actions' => true,
|
||||
'meta_items' => empty($ctx['show_cover']) ? (array) $ctx['meta_items'] : [],
|
||||
]);
|
||||
?>
|
||||
<?php endif; ?>
|
||||
// Author bar always shows in header (Zibll zib_single_box_header).
|
||||
// `authordesc` only controls the after-box author card.
|
||||
aksrt_single_render_author_bar([
|
||||
'show_actions' => true,
|
||||
'show_time' => empty($settings['hide_time']),
|
||||
'meta_html' => empty($ctx['show_cover']) ? (string) ($ctx['meta_box_html'] ?? '') : '',
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
@@ -428,27 +437,13 @@ if (!function_exists('aksrt_single_render_content_footer')) :
|
||||
<?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
|
||||
$topics = taxonomy_exists('topics') ? wp_get_post_terms($post_id, 'topics') : [];
|
||||
if (!is_wp_error($topics) && !empty($topics)) :
|
||||
foreach (array_slice($topics, 0, 2) as $topic) :
|
||||
?>
|
||||
<a href="<?php echo esc_url(get_term_link($topic)); ?>" class="but"><i class="fas fa-cube" aria-hidden="true"></i> <?php echo esc_html($topic->name); ?></a>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
if (function_exists('aksrt_get_single_article_tags_html')) {
|
||||
echo aksrt_get_single_article_tags_html($post_id); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
?>
|
||||
<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
|
||||
}
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_single_render_author_card')) :
|
||||
@@ -472,7 +467,7 @@ if (!function_exists('aksrt_single_render_author_card')) :
|
||||
];
|
||||
$bio = trim((string) get_the_author_meta('description'));
|
||||
?>
|
||||
<div class="author author-box">
|
||||
<div class="author author-box zib-widget">
|
||||
<div class="author-box__header">
|
||||
<a href="<?php echo esc_url(get_author_posts_url($author_id)); ?>" class="author-box__avatar">
|
||||
<?php echo get_avatar($author_id, 56, '', esc_attr(get_the_author())); ?>
|
||||
@@ -569,7 +564,7 @@ if (!function_exists('aksrt_single_related_query_args')) :
|
||||
*/
|
||||
function aksrt_single_related_query_args(int $post_id, array $settings): array {
|
||||
$count = max(1, min(12, (int) ($settings['related_count'] ?? 6)));
|
||||
$type = sanitize_key((string) ($settings['related_type'] ?? 'category'));
|
||||
$type = sanitize_key((string) ($settings['related_source'] ?? ($settings['related_type'] ?? 'category')));
|
||||
if (!in_array($type, ['category', 'tag', 'random'], true)) {
|
||||
$type = 'category';
|
||||
}
|
||||
@@ -677,7 +672,11 @@ if (!function_exists('aksrt_single_render_related')) :
|
||||
$post_id = (int) $ctx['post_id'];
|
||||
$title = (string) ($settings['related_title'] ?? '');
|
||||
if ($title === '') {
|
||||
$title = __('相关文章', 'aksrt');
|
||||
$title = __('相关推荐', 'aksrt');
|
||||
}
|
||||
$style = sanitize_key((string) ($settings['related_style'] ?? 'img'));
|
||||
if (!in_array($style, ['img', 'list', 'text'], true)) {
|
||||
$style = 'img';
|
||||
}
|
||||
|
||||
$args = function_exists('aksrt_single_related_query_args')
|
||||
@@ -695,30 +694,59 @@ if (!function_exists('aksrt_single_render_related')) :
|
||||
wp_reset_postdata();
|
||||
return;
|
||||
}
|
||||
|
||||
$posts_html = '';
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
$p = get_post();
|
||||
if (!($p instanceof WP_Post)) {
|
||||
continue;
|
||||
}
|
||||
if ($style === 'img' && function_exists('aksrt_render_related_graphic_card')) {
|
||||
$posts_html .= aksrt_render_related_graphic_card($p);
|
||||
} else {
|
||||
$posts_html .= '<li><a class="icon-circle" href="' . esc_url(get_permalink($p)) . '">' . esc_html(get_the_title($p)) . '</a></li>';
|
||||
}
|
||||
}
|
||||
wp_reset_postdata();
|
||||
|
||||
$wrap_class = 'theme-box relates' . ($style === 'img' ? ' relates-thumb' : '');
|
||||
?>
|
||||
<div class="theme-box relates related-box">
|
||||
<div class="<?php echo esc_attr($wrap_class); ?>">
|
||||
<div class="box-body notop">
|
||||
<div class="title-theme related-box__title"><?php echo esc_html($title); ?></div>
|
||||
<div class="title-theme"><?php echo esc_html($title); ?></div>
|
||||
</div>
|
||||
<div class="zib-widget related-box__list">
|
||||
<?php if (function_exists('aksrt_render_post_list')) : ?>
|
||||
<?php aksrt_render_post_list($query, ['context' => 'related', 'mode' => 'mini', 'show_thumb' => true, 'show_meta' => true]); ?>
|
||||
<div class="zib-widget">
|
||||
<?php if ($style === 'img') : ?>
|
||||
<div class="swiper-container swiper-scroll">
|
||||
<div class="swiper-wrapper">
|
||||
<?php echo $posts_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
<div class="swiper-button-prev"></div>
|
||||
<div class="swiper-button-next"></div>
|
||||
</div>
|
||||
<?php elseif ($style === 'list') : ?>
|
||||
<?php
|
||||
$list_query = new WP_Query($args);
|
||||
if (function_exists('aksrt_render_post_list')) {
|
||||
aksrt_render_post_list($list_query, [
|
||||
'context' => 'related',
|
||||
'mode' => 'mini',
|
||||
'show_thumb' => true,
|
||||
'show_meta' => true,
|
||||
'show_number' => false,
|
||||
]);
|
||||
}
|
||||
wp_reset_postdata();
|
||||
?>
|
||||
<?php else : ?>
|
||||
<ul class="no-thumb related-list">
|
||||
<?php
|
||||
while ($query->have_posts()) :
|
||||
$query->the_post();
|
||||
?>
|
||||
<li>
|
||||
<a class="icon-circle" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||
</li>
|
||||
<?php endwhile; ?>
|
||||
<ul class="no-thumb">
|
||||
<?php echo $posts_html !== '' ? $posts_html : '<li>' . esc_html__('暂无相关文章', 'aksrt') . '</li>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
wp_reset_postdata();
|
||||
}
|
||||
endif;
|
||||
|
||||
@@ -736,6 +764,10 @@ if (!function_exists('aksrt_single_render_pay_box')) :
|
||||
if (empty($ctx['show_pay_box'])) {
|
||||
return;
|
||||
}
|
||||
$allow = $ctx['allow_view'] ?? null;
|
||||
if (is_array($allow) && empty($allow['allow'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = (int) ($ctx['post_id'] ?? get_the_ID());
|
||||
$post = get_post($post_id);
|
||||
@@ -745,7 +777,7 @@ if (!function_exists('aksrt_single_render_pay_box')) :
|
||||
|
||||
$pay_type = (string) ($ctx['pay_type'] ?? 'no');
|
||||
if (!empty($ctx['has_download']) || $pay_type === 'download') {
|
||||
echo '<div class="aksrt-single-pay-box aksrt-single-pay-box--download" id="posts-pay">';
|
||||
echo '<div class="zib-widget pay-box pay-type-download" id="posts-pay">';
|
||||
get_template_part('templates/parts/resource-download-box');
|
||||
echo '</div>';
|
||||
return;
|
||||
@@ -756,14 +788,15 @@ if (!function_exists('aksrt_single_render_pay_box')) :
|
||||
}
|
||||
|
||||
$has_access = function_exists('aksrt_has_paid_access') ? aksrt_has_paid_access($post) : false;
|
||||
echo '<div class="aksrt-single-pay-box aksrt-single-pay-box--' . esc_attr($pay_type) . '" id="posts-pay">';
|
||||
$paid_class = $has_access ? 'paid-box' : 'pay-box';
|
||||
echo '<div class="zib-widget ' . esc_attr($paid_class) . ' pay-type-' . esc_attr($pay_type) . '" id="posts-pay">';
|
||||
if ($has_access) {
|
||||
if ($pay_type === 'gallery' && function_exists('aksrt_render_paid_gallery')) {
|
||||
echo aksrt_render_paid_gallery($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} elseif ($pay_type === 'video' && function_exists('aksrt_render_paid_video')) {
|
||||
echo aksrt_render_paid_video($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
echo '<div class="zib-widget pay-box paid-box"><div class="box-body"><span class="badg c-green hollow badg-sm mr6">' . esc_html__('已解锁', 'aksrt') . '</span><b>' . esc_html(get_the_title($post)) . '</b></div></div>';
|
||||
echo '<div class="box-body"><span class="badg c-green hollow badg-sm mr6">' . esc_html__('已解锁', 'aksrt') . '</span><b>' . esc_html(get_the_title($post)) . '</b></div>';
|
||||
}
|
||||
} elseif (function_exists('aksrt_get_paywall_html')) {
|
||||
echo aksrt_get_paywall_html($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
@@ -780,6 +813,10 @@ if (!function_exists('aksrt_single_pay_box_matches')) :
|
||||
if (empty($ctx['show_pay_box'])) {
|
||||
return false;
|
||||
}
|
||||
$allow = $ctx['allow_view'] ?? null;
|
||||
if (is_array($allow) && empty($allow['allow'])) {
|
||||
return false;
|
||||
}
|
||||
return (string) ($ctx['paid_box_position'] ?? 'top') === $slot;
|
||||
}
|
||||
endif;
|
||||
@@ -814,7 +851,7 @@ if (!function_exists('aksrt_single_render_article')) :
|
||||
|
||||
<div class="theme-box wp-posts-content<?php echo $maxheight > 0 ? ' limit-height' : ''; ?>"
|
||||
<?php echo $maxheight > 0 ? ' style="max-height:' . esc_attr((string) $maxheight) . 'px;"' : ''; ?>
|
||||
data-nav="posts"
|
||||
<?php echo !empty($ctx['show_toc']) ? ' data-nav="posts"' : ''; ?>
|
||||
data-maxheight="<?php echo esc_attr((string) ($maxheight > 0 ? max(0, $maxheight - 80) : 0)); ?>"
|
||||
data-aksrt-toc="<?php echo !empty($ctx['show_toc']) ? '1' : '0'; ?>"
|
||||
data-aksrt-toc-depth="<?php echo esc_attr((string) ((int) ($settings['toc_depth'] ?? 3))); ?>"
|
||||
@@ -925,7 +962,10 @@ if (!function_exists('aksrt_single')) :
|
||||
echo $ctx['breadcrumbs_html']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} elseif (function_exists('aksrt_breadcrumbs')) {
|
||||
$settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : [];
|
||||
aksrt_breadcrumbs($settings['breadcrumbs_home'] ?? ($settings['breadcrumbs_home_text'] ?? ''));
|
||||
aksrt_breadcrumbs(
|
||||
(string) ($settings['breadcrumbs_home'] ?? ($settings['breadcrumbs_home_text'] ?? '')),
|
||||
['single_text' => !isset($settings['breadcrumbs_single_text']) || !empty($settings['breadcrumbs_single_text'])]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
aksrt_single_render_cover($ctx);
|
||||
|
||||
Reference in New Issue
Block a user