修复了一些小问题

This commit is contained in:
kate522 committed 2026-08-30 13:49:54 +08:00
1 parent 1b4928d69b
commit ed914d2eec
12 files changed
+339 -349

No files matched your search

+35 -20
View File
@@ -475,34 +475,49 @@ endif;
// Register gate once helpers load.
add_filter('the_content', 'aksrt_single_content_allow_view', 8);
if (!function_exists('aksrt_render_related_graphic_card')) :
if (!function_exists('aksrt_render_graphic_card_post')) :
/**
* Minimal legacy style-3 related thumb card.
* legacy parity: style-3 图文卡(相关推荐 / 作者卡文章条共用)。
*
* @param WP_Post $post 文章对象。
* @param array<string,mixed> $args {
* @type string $class .graphic 附加类(mb10 / em09)。
* @type int $cut 悬停第二行标题截断宽度。
* }
*/
function aksrt_render_related_graphic_card(WP_Post $post): string {
function aksrt_render_graphic_card_post(WP_Post $post, array $args = []): string {
$args = wp_parse_args($args, [
'class' => 'mb10',
'cut' => 45,
]);
$subtitle = class_exists('\AKSRT\Core\PostMetaBox')
? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post->ID, 'subtitle', '')
: '';
$title = get_the_title($post) . $subtitle;
$url = get_permalink($post);
$media = aksrt_renderer_resolve_images($post->ID, aksrt_renderer_config(['type' => 'card']));
$thumb = (string) $media['primary'];
$time = human_time_diff((int) get_the_time('U', $post), (int) current_time('timestamp'));
$img = (string) ($media['primary'] ?? '');
if ($img === '') {
$img = aksrt_get_lazy_thumb('lg');
}
$time = aksrt_time_ago((string) get_the_time('Y-m-d H:i:s', $post));
$views = function_exists('aksrt_get_post_views') ? (int) aksrt_get_post_views($post->ID) : 0;
$views_label = function_exists('aksrt_format_number') ? aksrt_format_number($views) : number_format_i18n($views);
$info = '<item>' . esc_html($time) . '</item>'
. '<item class="pull-right">' . aksrt_renderer_svg_icon('view') . ' ' . esc_html(aksrt_cut_count($views)) . '</item>';
$img_attrs = aksrt_get_lazy_attr('lazy_cover', (string) $thumb, 'fit-cover', aksrt_get_lazy_thumb('lg'));
$html = '<div class="swiper-slide mr10">';
$html .= '<div class="graphic style-3 mb10">';
$html .= '<a href="' . esc_url((string) $url) . '" class="radius8" title="' . esc_attr($title) . '">';
$html .= '<div class="graphic-img" style="padding-bottom:70%">';
$html .= '<img' . $img_attrs . ' alt="' . esc_attr($title) . '">';
$html .= '<div class="abs-center left-bottom graphic-text">';
$html .= '<div class="text1 text-ellipsis">' . esc_html($title) . '</div>';
$html .= '<div class="text3 muted-2-color em09"><span class="item">' . esc_html($time) . '</span>';
$html .= '<span class="item pull-right"><i class="fa fas fa-eye" aria-hidden="true"></i> ' . esc_html((string) $views_label) . '</span></div>';
$html .= '</div></div></a></div></div>';
return $html;
return aksrt_graphic_card([
'type' => 'style-3',
'class' => (string) $args['class'],
'img' => $img,
'alt' => $title,
'link' => [
'url' => get_permalink($post),
'target' => '',
],
'text1' => esc_html($title),
'text2' => esc_html(aksrt_str_cut($title, 0, (int) $args['cut'], '...')),
'text3' => $info,
'lazy' => true,
'height_scale' => 70,
]);
}
endif;