$ctx Single context. */ function aksrt_single_render_cover(array $ctx): void { if (empty($ctx['show_cover']) || $ctx['cover_url'] === '') { return; } $type = (string) $ctx['cover_type']; $badge = (string) $ctx['status_badge']; $crumbs = (string) $ctx['breadcrumbs_html']; $img_scale = max(10, min(100, (int) $ctx['img_scale'])); $video_scale = max(20, min(100, (int) $ctx['video_scale'])); $slides = is_array($ctx['slide_images'] ?? null) ? $ctx['slide_images'] : []; $poster = (string) ($ctx['video_poster'] ?? ''); $title_html = (string) ($ctx['title_html'] ?? esc_html(get_the_title())); if ($type === 'video') : ?>
style="position:absolute;inset:0;width:100%;height:100%;">
(string) $slide_url, 'alt' => wp_strip_all_tags(get_the_title()), ]; } $overlay = '
' . '

' . $title_html . '

' . ($crumbs !== '' ? $crumbs : '') . $badge . '
'; $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, 'overlay_html' => $overlay, ]); } ?>
$slide_url) : ?> alt="" style="">
alt="">

$ctx Single context. */ function aksrt_single_render_box_header(array $ctx): void { $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; ?>

empty($settings['hide_time']), 'meta_html' => (string) ($ctx['meta_box_html'] ?? ''), ]); ?>
$attrs Optional data-share-* overrides. */ function aksrt_render_share_dropdown(array $attrs = []): void { static $printed = false; if ($printed) { return; } $printed = true; $title = (string) ($attrs['title'] ?? get_the_title()); $url = (string) ($attrs['url'] ?? (get_permalink() ?: '')); $image = (string) ($attrs['image'] ?? (get_the_post_thumbnail_url(null, 'large') ?: '')); ?> $ctx Single context. */ function aksrt_single_render_actions(array $ctx): void { $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; $post_id = (int) $ctx['post_id']; $like_count = (int) $ctx['like_count']; $favorite_count = (int) $ctx['favorite_count']; $is_liked = !empty($ctx['is_liked']); $is_favorited = !empty($ctx['is_favorited']); ?>
0 && !empty($settings['rewards_enabled']) && function_exists('aksrt_get_rewards_button')) ? aksrt_get_rewards_button($reward_author, 'action action-rewards', $post_id) : ''; if ($reward_btn !== '') { echo $reward_btn; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped aksrt_render_rewards_modal_for_user($reward_author, $post_id); } ?>
$ctx Single context. */ function aksrt_single_render_content_footer(array $ctx): void { $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; $post_id = (int) $ctx['post_id']; ?> 'article-yiyan yiyan-box aksrt-yiyan yiyan--footer', ]); ?>
©
THE END
$ctx Single context. */ function aksrt_single_render_author_card(array $ctx): void { $author_id = (int) get_the_author_meta('ID'); if ($author_id <= 0) { return; } $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; $avatar_box = aksrt_get_avatar_box($author_id, 'avatar-img avatar-lg'); $name_html = aksrt_get_user_name([ 'id' => $author_id, 'class' => 'flex1 flex ac', 'vip' => false, 'medal' => true, 'auth' => true, 'level' => true, 'follow' => true, ]); $badges = aksrt_get_user_badges($author_id); $desc = aksrt_get_user_description($author_id); $card_style = sanitize_key((string) ($settings['author_card_style'] ?? 'card')) === 'card' ? 'card' : 'mini'; $posts_html = aksrt_render_user_card_posts([ 'user_id' => $author_id, 'limit' => max(0, min(12, (int) ($settings['author_card_limit'] ?? 6))), 'orderby' => sanitize_key((string) ($settings['author_card_orderby'] ?? 'views')), 'post_type' => 'post', 'post_style' => $card_style, 'exclude' => (int) get_the_ID(), ]); ?>
$ctx Single context. */ function aksrt_single_render_prevnext(array $ctx = []): void { $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; $enabled = array_key_exists('prevnext', $settings) ? !empty($settings['prevnext']) : (!array_key_exists('prevnext_s', $settings) || !empty($settings['prevnext_s'])); if (!$enabled) { return; } // legacy: constrain to current category when available. $in_same_term = !empty(get_the_category()); $prev = get_previous_post($in_same_term, '', 'category'); $next = get_next_post($in_same_term, '', 'category'); if (!$prev && !$next) { // Fallback: any post. $prev = get_previous_post(); $next = get_next_post(); } if (!$prev && !$next) { return; } $prev_title = $prev ? get_the_title($prev) : __('无更多文章', 'aksrt'); $next_title = $next ? get_the_title($next) : __('无更多文章', 'aksrt'); $prev_href = $prev ? get_permalink($prev) : 'javascript:;'; $next_href = $next ? get_permalink($next) : 'javascript:;'; ?>
$settings Single display settings. * @return array */ function aksrt_single_related_query_args(int $post_id, array $settings): array { $count = max(1, min(12, (int) ($settings['related_count'] ?? 6))); $orderby = sanitize_key((string) ($settings['related_orderby'] ?? 'views')); if (!in_array($orderby, ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'], true)) { $orderby = 'views'; } $args = [ 'showposts' => $count, 'ignore_sticky_posts' => true, 'post_type' => 'post', 'post_status' => 'publish', 'order' => 'DESC', 'no_found_rows' => true, ]; // legacy: all three term clauses are always present (even when empty). $tax_query = ['relation' => 'OR']; foreach (['category', 'topics', 'post_tag'] as $taxonomy) { $term_ids = wp_get_post_terms($post_id, $taxonomy, ['fields' => 'ids']); $tax_query[] = [ 'taxonomy' => $taxonomy, 'field' => 'term_id', 'terms' => array_map('intval', (array) $term_ids), ]; } $args['tax_query'] = $tax_query; switch ($orderby) { case 'rand': $args['orderby'] = 'rand'; break; case 'date': $args['orderby'] = 'date'; break; case 'modified': $args['orderby'] = 'modified'; break; case 'like': $args['meta_key'] = '_aksrt_like_count'; $args['orderby'] = 'meta_value_num'; break; case 'favorite': $args['meta_key'] = '_aksrt_favorite_count'; $args['orderby'] = 'meta_value_num'; break; case 'comment_count': $args['orderby'] = 'comment_count'; break; case 'views': default: $args['meta_key'] = 'aksrt_post_views'; $args['orderby'] = 'meta_value_num'; break; } return $args; } endif; if (!function_exists('aksrt_single_render_related')) : /** * Related posts — legacy zib_posts_related parity (img/list/text). * * @param array $ctx Single context. */ function aksrt_single_render_related(array $ctx): void { $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; if (empty($settings['related_enabled'])) { return; } $post_id = (int) $ctx['post_id']; $title = (string) ($settings['related_title'] ?? ''); if ($title === '') { $title = __('相关推荐', 'aksrt'); } $style = sanitize_key((string) ($settings['related_style'] ?? 'img')); if (!in_array($style, ['img', 'list', 'text'], true)) { $style = 'img'; } $args = aksrt_single_related_query_args($post_id, $settings); $query = new WP_Query($args); $wrap_class = 'theme-box relates' . ($style === 'img' ? ' relates-thumb' : ''); $posts_html = ''; $mini_cfg = aksrt_renderer_config([ 'type' => 'list', 'show_number' => false, ]); while ($query->have_posts()) { $query->the_post(); $post = get_post(); if (!($post instanceof WP_Post)) { continue; } if ($style === 'list') { $data = aksrt_renderer_collect_post_data($mini_cfg); if ($data) { $posts_html .= aksrt_renderer_mini($data, $mini_cfg); } } elseif ($style === 'img') { $posts_html .= '
' . aksrt_render_graphic_card_post($post) . '
'; } else { $subtitle = class_exists('\AKSRT\Core\PostMetaBox') ? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post->ID, 'subtitle', '') : ''; $posts_html .= '
  • ' . esc_html(get_the_title($post) . $subtitle) . '
  • '; } } wp_reset_postdata(); if ($posts_html === '') { $posts_html = '
  • ' . esc_html__('暂无相关文章', 'aksrt') . '
  • '; } ?>
    $ctx Single context. */ function aksrt_single_render_pay_box(array $ctx = []): void { if ($ctx === []) { $ctx = function_exists('aksrt_single_build_context') ? aksrt_single_build_context() : []; } 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); if (!($post instanceof WP_Post)) { return; } $pay_type = (string) ($ctx['pay_type'] ?? 'no'); if (!function_exists('aksrt_get_pay_meta')) { return; } $has_access = function_exists('aksrt_has_paid_access') ? aksrt_has_paid_access($post) : false; if ($has_access) { echo aksrt_get_paid_box_html($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } elseif ($pay_type !== 'reading') { echo aksrt_get_paywall_html($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } endif; if (!function_exists('aksrt_single_pay_box_matches')) : /** * @param array $ctx */ function aksrt_single_pay_box_matches(array $ctx, string $slot): bool { 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; if (!function_exists('aksrt_single_render_article')) : /** * Main article box (legacy order). * * @param array $ctx Single context. */ function aksrt_single_render_article(array $ctx): void { $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; $maxheight = (int) $ctx['content_maxheight']; ?>
    >
    'article-yiyan yiyan-box aksrt-yiyan yiyan--header theme-box text-center radius8 main-shadow', ]); ?>
    0 ? ' style="max-height:' . esc_attr((string) $maxheight) . 'px;"' : ''; ?> data-maxheight=" 0 ? max(0, $maxheight - 80) : 0)); ?>"> '

    ', 'after' => '

    ', ]); ?>
    $ctx Single context. */ function aksrt_single_render_after_box(array $ctx): void { $settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : []; if (!empty($settings['yiyan_box'])) { aksrt_render_yiyan_block([ 'class' => 'yiyan-box main-bg theme-box text-center box-body radius8 main-shadow aksrt-yiyan', ]); } if (!empty($settings['authordesc'])) { aksrt_single_render_author_card($ctx); } aksrt_single_render_prevnext($ctx); aksrt_single_render_related($ctx); } endif;