feat(frontend): replace article system with Zibll 9.0

This commit is contained in:
2026-08-18 16:06:47 +08:00
parent 2881c69e9c
commit 0f2ac6c34a
69 changed files with 2603 additions and 4163 deletions
+208 -227
View File
@@ -1,6 +1,6 @@
<?php
/**
* Shared post renderer helpers.
* Zibll 9.0 article-list data and markup fragments.
*
* @package AKSRT
*/
@@ -8,12 +8,7 @@
defined('ABSPATH') || exit;
if (!function_exists('aksrt_renderer_collect_post_data')) {
/**
* Aggregate the runtime data needed by all renderer modes.
*
* @param array<string,mixed> $cfg Renderer config.
* @return array<string,mixed>
*/
/** @return array<string,mixed> */
function aksrt_renderer_collect_post_data(array $cfg): array {
$post_id = (int) get_the_ID();
if ($post_id <= 0) {
@@ -21,278 +16,264 @@ if (!function_exists('aksrt_renderer_collect_post_data')) {
}
$images = aksrt_renderer_resolve_images($post_id, $cfg);
$gallery_images = array_slice($images['gallery'], 0, $cfg['multi_thumb_limit']);
$is_mult_thumb = !empty($cfg['multi_thumb_enabled'])
&& count($gallery_images) >= (int) $cfg['multi_thumb_min']
&& $cfg['mode'] === 'list';
$author_id = (int) get_post_field('post_author', $post_id);
$categories = get_the_category($post_id) ?: [];
$tags = get_the_tags($post_id) ?: [];
$content_images = (array) $images['gallery'];
$gallery = array_slice($content_images, 0, 4);
$allow_conditional = !empty($cfg['allow_conditional_layout']) && ($cfg['mode'] ?? 'list') === 'list';
$is_mult_thumb = false;
$is_no_thumb = false;
if ($allow_conditional) {
if (($cfg['is_no_thumb'] ?? false) !== 'disable'
&& (($cfg['list_type'] ?? 'thumb') === 'text'
|| (($cfg['list_type'] ?? 'thumb') === 'thumb_if_has' && empty($images['has_real'])))) {
$is_no_thumb = true;
} elseif (($cfg['is_mult_thumb'] ?? false) !== 'disable' && count($gallery) > 2) {
$is_mult_thumb = has_post_format(['image', 'gallery'], $post_id);
if (!$is_mult_thumb) {
foreach ($categories as $category) {
if (in_array((int) $category->term_id, array_map('intval', (array) ($cfg['mult_thumb_cat'] ?? [])), true)) {
$is_mult_thumb = true;
break;
}
}
}
}
}
if (($cfg['is_no_thumb'] ?? false) === true) {
$is_no_thumb = true;
$is_mult_thumb = false;
}
if (($cfg['is_mult_thumb'] ?? false) === true && count($gallery) > 2 && !$is_no_thumb) {
$is_mult_thumb = true;
}
$custom_excerpt = class_exists('\AKSRT\Core\PostMetaBox')
? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post_id, 'custom_excerpt', '')
: '';
$custom_subtitle = (string) get_post_meta($post_id, '_subtitle', true);
$excerpt_source = $custom_excerpt !== '' ? $custom_excerpt : (string) get_the_excerpt($post_id);
if ($excerpt_source === '') {
$excerpt_source = (string) get_post_field('post_content', $post_id, 'raw');
$excerpt = $custom_excerpt !== '' ? $custom_excerpt : (string) get_the_excerpt($post_id);
if ($excerpt === '') {
$excerpt = (string) get_post_field('post_content', $post_id, 'raw');
}
$excerpt = wp_trim_words(wp_strip_all_tags($excerpt_source), $cfg['excerpt_words'], '...');
$author_id = (int) get_post_field('post_author', $post_id);
$author = get_userdata($author_id);
$time_value = ($cfg['time_source'] ?? 'modified') === 'date'
? (string) get_the_time('Y-m-d H:i:s', $post_id)
: (string) get_the_modified_time('Y-m-d H:i:s', $post_id);
$time_timestamp = strtotime($time_value) ?: (int) get_the_time('U', $post_id);
$resource_meta = function_exists('aksrt_get_resource_meta') ? aksrt_get_resource_meta($post_id) : [];
$resource_strip = function_exists('aksrt_resource_meta_strip') ? aksrt_resource_meta_strip($resource_meta) : [];
$subtitle = class_exists('\AKSRT\Core\PostMetaBox')
? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post_id, 'subtitle', '')
: '';
$pay_meta = aksrt_get_pay_meta($post_id);
if (!is_array($pay_meta)) {
$pay_meta = [];
}
return [
'post_id' => $post_id,
'permalink' => get_permalink($post_id),
'title' => get_the_title($post_id),
'subtitle' => $custom_subtitle,
'excerpt' => $excerpt,
'img_url' => $images['primary'],
'has_img' => !empty($images['has_thumb']),
'has_real_img' => !empty($images['has_real']),
'gallery_images' => $gallery_images,
'is_mult_thumb' => $is_mult_thumb,
'is_video_cover' => !empty(get_post_meta($post_id, '_aksrt_featured_video', true)) || !empty(get_post_meta($post_id, '_video_url', true)),
'author_id' => $author_id,
'avatar_url' => get_avatar_url($author_id, ['size' => 40]),
'author_name' => get_the_author(),
'categories' => $categories,
'tags' => $tags,
'comment_count' => (int) get_comments_number($post_id),
'views' => function_exists('aksrt_get_post_views') ? (int) aksrt_get_post_views($post_id) : 0,
'likes' => function_exists('aksrt_get_post_likes') ? (int) aksrt_get_post_likes($post_id) : 0,
'time_ago' => human_time_diff((int) get_the_time('U', $post_id), current_time('timestamp')),
'resource_badge' => function_exists('aksrt_resource_card_badge_text') ? (string) aksrt_resource_card_badge_text($post_id) : '',
'resource_strip' => $resource_strip,
'is_resource' => function_exists('aksrt_is_resource_post') ? aksrt_is_resource_post($post_id) : false,
'is_sticky' => is_sticky($post_id),
'thumb_ratio_css' => aksrt_renderer_thumb_ratio_value((string) $cfg['thumb_ratio']),
'thumb_ratio_key' => (string) $cfg['thumb_ratio'],
'post_id' => $post_id,
'permalink' => get_permalink($post_id),
'title' => get_the_title($post_id),
'subtitle' => $subtitle,
'excerpt' => wp_trim_words(wp_strip_all_tags($excerpt), 30, '...'),
'primary' => (string) $images['primary'],
'has_real' => !empty($images['has_real']),
'gallery' => $gallery,
'gallery_count' => count($content_images),
'slides' => array_slice((array) $images['slides'], 0, 8),
'is_slide' => !empty($images['is_slide']),
'video_url' => (string) $images['video_url'],
'is_mult_thumb' => $is_mult_thumb,
'is_no_thumb' => $is_no_thumb,
'categories' => $categories,
'tags' => $tags,
'author_id' => $author_id,
'author_name' => $author instanceof WP_User ? $author->display_name : '',
'avatar_url' => get_avatar_url($author_id, ['size' => 40]),
'time_title' => $time_value,
'time_ago' => human_time_diff($time_timestamp, current_time('timestamp')) . __('前', 'aksrt'),
'views' => (int) aksrt_get_post_views($post_id),
'likes' => (int) aksrt_get_post_likes($post_id),
'comments' => (int) get_comments_number($post_id),
'comments_open' => comments_open($post_id),
'comments_link' => get_comments_link($post_id),
'post_type' => (string) get_post_type($post_id),
'is_sticky' => is_sticky($post_id),
'resource_badge' => (string) aksrt_resource_card_badge_text($post_id),
'pay_type' => sanitize_key((string) ($pay_meta['pay_type'] ?? 'no')),
'pay_limit' => (int) ($pay_meta['pay_limit'] ?? 0),
];
}
}
if (!function_exists('aksrt_renderer_article_attrs')) {
/**
* Build the article wrapper attributes.
*
* @param string[] $classes CSS classes.
* @param array<string,mixed> $data Collected post data.
* @return string
*/
function aksrt_renderer_article_attrs(array $classes, array $data): string {
$classes[] = 'thumb-ratio--' . str_replace(':', '-', (string) $data['thumb_ratio_key']);
return sprintf(
'class="%s" style="%s"',
esc_attr(implode(' ', array_unique(array_filter($classes)))),
esc_attr('--aksrt-thumb-ratio:' . $data['thumb_ratio_css'])
);
}
}
if (!function_exists('aksrt_renderer_thumb')) {
/**
* Render the primary thumbnail.
*
* @param array<string,mixed> $data Collected post data.
* @param array<string,mixed> $cfg Renderer config.
* @return string
*/
function aksrt_renderer_thumb(array $data, array $cfg): string {
if (!$cfg['show_thumb'] || empty($data['has_img'])) {
if (!empty($data['is_no_thumb']) || (string) $data['primary'] === '') {
return '';
}
$is_contain = (($cfg['thumb']['list_thumb_fit'] ?? '') === 'contain');
$target = !empty($cfg['target_blank']) ? ' target="_blank"' : '';
$content = '';
$format_icon = '';
$default_attr = empty($data['has_real']) ? ' data-thumb="default"' : '';
$has_video_thumb = (string) $data['video_url'] !== '' && !empty($cfg['thumb']['list_thumb_video_s']);
$has_slides = !$has_video_thumb && !empty($data['is_slide']) && count((array) $data['slides']) > 0;
$img = (string) $data['img_url'];
$title = (string) $data['title'];
$href = (string) $data['permalink'];
$is_sticky = !empty($data['is_sticky']);
$has_real_img = !empty($data['has_real_img']);
$fit_class = !empty($cfg['thumb_fit']) && $cfg['thumb_fit'] === 'contain' ? 'fit-contain' : 'fit-cover';
$img_attr = aksrt_get_lazy_attr('lazy_posts_thumb', $img, $fit_class);
$img_html = '<img' . $img_attr . ' alt="' . esc_attr($title) . '">';
$sticky_html = ($is_sticky && !empty($cfg['badge_show']))
? '<badge class="img-badge left jb-red">' . esc_html__('置顶', 'aksrt') . '</badge>'
: '';
$format_badge = '';
if (!empty($data['is_mult_thumb']) && !empty($data['gallery_images'])) {
$format_badge = '<badge class="b-black opacity8 abs-right">' . esc_html(count($data['gallery_images'])) . '</badge>';
} elseif (!empty($data['is_video_cover'])) {
$format_badge = '<badge class="b-black opacity8 abs-right"><i class="fas fa-play-circle" aria-hidden="true"></i></badge>';
}
$empty_class = $has_real_img ? '' : ' item-thumbnail--fallback';
$target_attr = !empty($cfg['target_blank']) ? ' target="_blank"' : '';
if ($cfg['mode'] === 'list') {
$graphic_class = 'post-graphic';
if (($cfg['list_img_position'] ?? 'left') === 'right') {
$graphic_class .= ' order1';
if ($has_video_thumb) {
$muted = !empty($cfg['thumb']['list_thumb_video_mute_s']);
$content .= '<div class="video-thumb-box" video-url="' . esc_url((string) $data['video_url']) . '" data-volume="' . ($muted ? 'none' : '100') . '" data-post-thumb-video>';
$content .= '<div class="img-thumb"><img' . $default_attr . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $data['primary'], 'fit-cover radius8') . ' alt="' . esc_attr((string) $data['title']) . '"></div>';
$content .= '<div class="video-thumb"><div class="dplayer dplayer-thumb"><video playsinline loop preload="none"' . ($muted ? ' muted' : '') . ' data-src="' . esc_url((string) $data['video_url']) . '"></video></div></div></div>';
$format_icon = '<i class="fa fa-play-circle em12 mt6 c-white opacity8" aria-hidden="true"></i>';
} elseif ($has_slides) {
$content .= '<div class="relative zib-slider"><div class="new-swiper item-thumbnail' . ($is_contain ? ' gradient-background' : '') . '" data-loop="true" data-effect="slide" data-autoplay="1" data-post-thumb-slider><div class="swiper-wrapper">';
foreach ((array) $data['slides'] as $image) {
$content .= '<div class="swiper-slide' . ($is_contain ? ' gradient-bg' : '') . '"' . ($is_contain ? ' data-opacity="0.2"' : '') . '><a' . $target . ' href="' . esc_url((string) $data['permalink']) . '"><img' . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $image, 'radius8') . ' alt="' . esc_attr((string) $data['title']) . '"></a></div>';
}
$content .= '</div><div class="swiper-pagination kaoyou"></div></div></div>';
$format_icon = '<badge class="b-black opacity8 mt6"><i class="fa fa-image mr3" aria-hidden="true"></i>' . count((array) $data['slides']) . '</badge>';
} else {
$content .= '<a' . $target . ' href="' . esc_url((string) $data['permalink']) . '"><img' . $default_attr . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $data['primary'], 'fit-cover radius8') . ' alt="' . esc_attr((string) $data['title']) . '"></a>';
$format = get_post_format((int) $data['post_id']);
if ((string) $data['video_url'] !== '') {
$format_icon = '<i class="fa fa-play-circle em12 mt6 c-white opacity8" aria-hidden="true"></i>';
} elseif (in_array($format, ['image', 'gallery'], true) && (int) $data['gallery_count'] > 0) {
$format_icon = '<badge class="b-black opacity8 mr6 mt6"><i class="fa fa-image mr3" aria-hidden="true"></i>' . (int) $data['gallery_count'] . '</badge>';
} elseif ($format === 'video') {
$format_icon = '<i class="fa fa-play-circle em12 mr6 mt6 c-white opacity8" aria-hidden="true"></i>';
}
return '<div class="' . esc_attr($graphic_class) . '"><div class="item-thumbnail' . esc_attr($empty_class) . '"><a href="' . esc_url($href) . '" rel="bookmark"' . $target_attr . '>'
. $img_html . '</a>' . $sticky_html . $format_badge . '</div></div>';
}
return '<div class="item-thumbnail' . esc_attr($empty_class) . '"><a href="' . esc_url($href) . '" rel="bookmark"' . $target_attr . '>'
. $img_html . '</a>' . $sticky_html . $format_badge . '</div>';
if ($format_icon !== '') {
$content .= '<div class="abs-center right-top">' . $format_icon . '</div>';
}
if (!empty($data['is_sticky'])) {
$content .= '<badge class="img-badge left jb-red">' . esc_html__('置顶', 'aksrt') . '</badge>';
}
$fit = $is_contain && !$has_slides ? ' contain gradient-bg' : '';
$opacity = $is_contain && !$has_slides ? ' data-opacity="0.2"' : '';
return '<div class="item-thumbnail' . $fit . '"' . $opacity . '>' . $content . '</div>';
}
}
if (!function_exists('aksrt_renderer_mult_thumb')) {
/**
* Render the multi-image strip used by list cards.
*
* @param array<string,mixed> $data Collected post data.
* @return string
*/
function aksrt_renderer_mult_thumb(array $data): string {
if (empty($data['is_mult_thumb']) || empty($data['gallery_images'])) {
function aksrt_renderer_mult_thumb(array $data, array $cfg): string {
if (empty($data['is_mult_thumb'])) {
return '';
}
$html = '<a class="thumb-items contain" href="' . esc_url($data['permalink']) . '" aria-label="' . esc_attr($data['title']) . '">';
foreach (array_slice($data['gallery_images'], 0, 4) as $image) {
$html .= '<span>';
$html .= '<img' . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $image, 'fit-cover') . ' alt="">';
$html .= '</span>';
$fit = (($cfg['thumb']['list_thumb_fit'] ?? '') === 'contain') ? ' contain' : '';
$target = !empty($cfg['target_blank']) ? ' target="_blank"' : '';
$html = '<a' . $target . ' class="thumb-items' . $fit . '" href="' . esc_url((string) $data['permalink']) . '">';
foreach (array_slice((array) $data['gallery'], 0, 4) as $index => $image) {
$badge = '';
if ($index === 3 && (int) ($data['gallery_count'] ?? 0) > 4) {
$badge = '<div class="abs-center right-top"><badge class="b-black mr6 mt6 em09"><i class="fa fa-image mr3" aria-hidden="true"></i>+' . ((int) $data['gallery_count'] - 4) . '</badge></div>';
}
$html .= '<span>' . $badge . '<img' . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $image, 'fit-cover radius8') . ' alt=""></span>';
}
return $html . '</a>';
}
}
$html .= '</a>';
return $html;
if (!function_exists('aksrt_renderer_pay_badge')) {
function aksrt_renderer_pay_badge(array $data, bool $compact = false): string {
if ((string) $data['resource_badge'] === '') {
return '';
}
$is_vip = (int) ($data['pay_limit'] ?? 0) > 0 || (string) ($data['pay_type'] ?? '') === 'vip';
$vip_level = max(1, min(2, (int) ($data['pay_limit'] ?? 1)));
$class = $is_vip ? 'jb-vip' . $vip_level : 'c-yellow';
$type_labels = function_exists('aksrt_get_pay_types') ? aksrt_get_pay_types() : [];
$title = (string) ($type_labels[(string) ($data['pay_type'] ?? '')] ?? __('付费内容', 'aksrt'));
$icon = $is_vip ? aksrt_renderer_vip_icon($vip_level) : '';
if ($compact) {
return '<item class="meta-pay badg badg-sm mr6 ' . esc_attr($class) . '" data-toggle="tooltip" title="' . esc_attr($title) . '">' . $icon . esc_html((string) $data['resource_badge']) . '</item>';
}
$tooltip = $is_vip ? ' data-toggle="tooltip" title="' . esc_attr($title) . '"' : '';
return '<a rel="nofollow" href="' . esc_url((string) $data['permalink']) . '#posts-pay"' . $tooltip . ' class="meta-pay but ' . esc_attr($is_vip ? $class : 'jb-yellow') . '">' . $icon . esc_html((string) $data['resource_badge']) . '</a>';
}
}
if (!function_exists('aksrt_renderer_vip_icon')) {
function aksrt_renderer_vip_icon(int $level): string {
if (!class_exists('\AKSRT\Settings\Settings')) {
return '<i class="fas fa-crown mr3" aria-hidden="true"></i>';
}
$settings = \AKSRT\Settings\Settings::get_payment_vip_settings();
$url = esc_url((string) ($settings['levels'][$level]['img_icon'] ?? ''));
return $url !== ''
? '<img class="mr3" src="' . $url . '" alt="" aria-hidden="true">'
: '<i class="fas fa-crown mr3" aria-hidden="true"></i>';
}
}
if (!function_exists('aksrt_renderer_badges')) {
/**
* Render taxonomy and resource badges.
*
* @param array<string,mixed> $data Collected post data.
* @param array<string,mixed> $cfg Renderer config.
* @return string
*/
function aksrt_renderer_badges(array $data, array $cfg): string {
$items = [];
if (!empty($cfg['show_resource_badge']) && $data['resource_badge'] !== '') {
$items[] = '<a href="' . esc_url($data['permalink']) . '#posts-pay" class="meta-pay but jb-yellow">' . esc_html($data['resource_badge']) . '</a>';
}
if (!empty($cfg['show_badges']) && !empty($cfg['badge_show']) && $cfg['category_limit'] > 0) {
foreach (array_slice($data['categories'], 0, $cfg['category_limit']) as $category) {
$items[] = '<a href="' . esc_url(get_category_link($category->term_id)) . '" class="but"><i class="far fa-folder-open" aria-hidden="true"></i> ' . esc_html($category->name) . '</a>';
$types = (array) ($cfg['badge_types'] ?? []);
if (in_array('pay', $types, true)) {
$pay = aksrt_renderer_pay_badge($data);
if ($pay !== '') {
$items[] = $pay;
}
}
if (!empty($cfg['show_tags']) && $cfg['tag_limit'] > 0) {
foreach (array_slice($data['tags'], 0, $cfg['tag_limit']) as $tag) {
$items[] = '<a href="' . esc_url(get_tag_link($tag->term_id)) . '" class="but">#' . esc_html($tag->name) . '</a>';
if (empty($cfg['is_category']) && in_array('cat', $types, true)) {
$colors = ['c-blue', 'c-yellow', 'c-green', 'c-purple', 'c-red'];
foreach (array_slice((array) $data['categories'], 0, 3) as $index => $category) {
$items[] = '<a class="but ' . esc_attr($colors[$index % count($colors)]) . '" title="' . esc_attr__('查看更多分类文章', 'aksrt') . '" href="' . esc_url(get_category_link($category->term_id)) . '"><i class="fa fa-folder-open-o" aria-hidden="true"></i>' . esc_html($category->name) . '</a>';
}
}
if (!empty($data['is_resource'])) {
$items[] = '<span class="but jb-vip">VIP</span>';
if (empty($cfg['is_tag']) && in_array('tag', $types, true)) {
$tags = (array) $data['tags'];
usort($tags, static fn($left, $right): int => (int) $right->count <=> (int) $left->count);
foreach (array_slice($tags, 0, 3) as $tag) {
$items[] = '<a class="but" title="' . esc_attr__('查看此标签更多文章', 'aksrt') . '" href="' . esc_url(get_tag_link($tag->term_id)) . '"># ' . esc_html($tag->name) . '</a>';
}
}
if (empty($items)) {
return '';
}
return '<div class="item-tags scroll-x no-scrollbar">' . implode('', $items) . '</div>';
return $items ? '<div class="item-tags scroll-x no-scrollbar mb6">' . implode('', $items) . '</div>' : '';
}
}
if (!function_exists('aksrt_renderer_resource_strip')) {
/**
* Render compact resource meta chips.
*
* @param array<string,mixed> $data Collected post data.
* @return string
*/
function aksrt_renderer_resource_strip(array $data): string {
if (empty($data['resource_strip']) || !is_array($data['resource_strip'])) {
return '';
}
if (!function_exists('aksrt_renderer_meta_number')) {
function aksrt_renderer_meta_number(int $number): string {
return (string) aksrt_format_number($number);
}
}
$html = '<ul class="item-cms-strip">';
foreach ($data['resource_strip'] as $item) {
$html .= '<li>' . esc_html((string) $item) . '</li>';
}
$html .= '</ul>';
return $html;
if (!function_exists('aksrt_renderer_svg_icon')) {
function aksrt_renderer_svg_icon(string $name): string {
return '<svg class="icon" aria-hidden="true"><use xlink:href="#icon-' . esc_attr($name) . '"></use></svg>';
}
}
if (!function_exists('aksrt_renderer_meta')) {
/**
* Render the meta bar.
*
* @param array<string,mixed> $data Collected post data.
* @param array<string,mixed> $cfg Renderer config.
* @return string
*/
function aksrt_renderer_meta(array $data, array $cfg): string {
if (!$cfg['show_meta']) {
return '';
function aksrt_renderer_meta(array $data, array $cfg, bool $is_card = false): string {
$show_time = !empty($cfg['show_time']);
$meta_left = '';
if (empty($cfg['no_author']) && !empty($cfg['show_author'])) {
$name = (!$is_card || !$show_time) && (string) $data['author_name'] !== ''
? '<span class="' . ($show_time ? 'hide-sm ' : '') . 'ml6">' . esc_html((string) $data['author_name']) . '</span>'
: '';
$time = $show_time
? '<span title="' . esc_attr((string) $data['time_title']) . '" class="' . ($is_card ? 'ml6' : 'icon-circle') . '">' . esc_html((string) $data['time_ago']) . '</span>'
: '';
$avatar = '<img class="avatar-mini" src="' . esc_url((string) $data['avatar_url']) . '" alt="" width="20" height="20">';
$meta_left = '<item class="meta-author flex ac">' . $avatar . $name . $time . '</item>';
} elseif ($show_time) {
$meta_left = '<item title="' . esc_attr((string) $data['time_title']) . '" class="icon-circle mln3">' . esc_html((string) $data['time_ago']) . '</item>';
}
$format_number = function_exists('aksrt_format_number') ? 'aksrt_format_number' : 'strval';
if ($cfg['mode'] === 'mini') {
$items = [];
if (!empty($cfg['show_date'])) {
$items[] = '<span class="meta-item">' . esc_html($data['time_ago']) . '</span>';
}
if (!empty($cfg['show_views'])) {
$items[] = '<span class="meta-item"><i class="fas fa-eye" aria-hidden="true"></i> ' . esc_html($format_number($data['views'])) . '</span>';
}
if (empty($items)) {
return '';
}
return '<div class="item-meta">' . implode('<span class="meta-dot" aria-hidden="true"></span>', $items) . '</div>';
$right = '';
if (!empty($data['comments_open']) && empty($cfg['close_comments'])) {
$right .= '<item class="meta-comm"><a rel="nofollow" data-toggle="tooltip" title="' . esc_attr__('去评论', 'aksrt') . '" href="' . esc_url((string) $data['comments_link']) . '">' . aksrt_renderer_svg_icon('comment') . esc_html((string) $data['comments']) . '</a></item>';
}
$right .= '<item class="meta-view">' . aksrt_renderer_svg_icon('view') . esc_html(aksrt_renderer_meta_number((int) $data['views'])) . '</item>';
if (!empty($cfg['show_like']) && (string) ($data['post_type'] ?? '') === 'post') {
$right .= '<item class="meta-like">' . aksrt_renderer_svg_icon('like') . esc_html(aksrt_renderer_meta_number((int) $data['likes'])) . '</item>';
}
$left = [];
if (!empty($cfg['show_author'])) {
$left[] = '<item class="meta-author flex ac"><img' . aksrt_get_lazy_attr('lazy_avatar', (string) $data['avatar_url'], 'avatar-mini', aksrt_get_lazy_thumb('sm')) . ' alt="" width="20" height="20"><name class="meta-name">' . esc_html($data['author_name']) . '</name></item>';
}
if (!empty($cfg['show_date'])) {
$left[] = '<item class="meta-time">' . esc_html($data['time_ago']) . '</item>';
}
$right = [];
if (!empty($cfg['show_comments'])) {
$right[] = '<item class="meta-view"><i class="fas fa-comment" aria-hidden="true"></i> ' . esc_html((string) $data['comment_count']) . '</item>';
}
if (!empty($cfg['show_views'])) {
$right[] = '<item class="meta-view"><i class="fas fa-eye" aria-hidden="true"></i> ' . esc_html($format_number($data['views'])) . '</item>';
}
if (!empty($cfg['show_likes'])) {
$right[] = '<item class="meta-view"><i class="fas fa-thumbs-up" aria-hidden="true"></i> ' . esc_html($format_number($data['likes'])) . '</item>';
}
if (empty($left) && empty($right)) {
return '';
}
$html = '<div class="item-meta muted-2-color flex jsb ac">';
if (!empty($left)) {
$html .= '<div class="meta-author-group flex ac">' . implode('<span class="meta-dot" aria-hidden="true"></span>', $left) . '</div>';
}
if (!empty($right)) {
$html .= '<div class="meta-right">' . implode('', $right) . '</div>';
}
$html .= '</div>';
return $html;
return '<div class="item-meta muted-2-color flex jsb ac">' . $meta_left . '<div class="meta-right">' . $right . '</div></div>';
}
}