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

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

true, 'show_time' => empty($settings['hide_time']), 'meta_html' => empty($ctx['show_cover']) ? (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 && function_exists('aksrt_get_rewards_button')) ? aksrt_get_rewards_button($reward_author, 'action action-rewards') : ''; if ($reward_btn === '' && !empty($settings['rewards_enabled']) && function_exists('aksrt_user_has_rewards_qr') && $reward_author > 0 && aksrt_user_has_rewards_qr($reward_author)) { $label = esc_html((string) ($settings['rewards_btn_text'] ?? __('赞赏', 'aksrt'))); $reward_btn = ''; } if ($reward_btn !== '') : echo $reward_btn; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if (function_exists('aksrt_render_rewards_modal_for_user')) { aksrt_render_rewards_modal_for_user($reward_author); } endif; // legacy placeholder to keep structure; actual button echoed above if (false) : ?>
$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; } $author_url = get_author_posts_url($author_id); $author_name = get_the_author(); $bio = trim((string) get_the_author_meta('description')); $name_html = function_exists('aksrt_get_user_name') ? aksrt_get_user_name([ 'id' => $author_id, 'class' => 'user-name flex jc ac', 'vip' => true, 'medal' => true, 'auth' => true, 'level' => true, 'follow' => false, ]) : ''; $identity_chips = ($name_html === '' && function_exists('aksrt_render_user_identity_chips')) ? aksrt_render_user_identity_chips($author_id, 'card') : ''; $avatar = function_exists('aksrt_get_avatar_html') ? aksrt_get_avatar_html($author_id, 80, ['class' => 'avatar avatar-lg']) : get_avatar($author_id, 80, '', esc_attr($author_name), ['class' => 'avatar avatar-lg']); $page_s = class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_post_page_settings') ? \AKSRT\Settings\Settings::get_post_page_settings() : []; $card_limit = max(0, min(12, (int) ($page_s['author_card_limit'] ?? 6))); $card_orderby = sanitize_key((string) ($page_s['author_card_orderby'] ?? 'views')); $card_style = sanitize_key((string) ($page_s['author_card_style'] ?? 'card')); $recent = []; if ($card_limit > 0) { $q = [ 'author' => $author_id, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $card_limit, 'ignore_sticky_posts' => true, 'no_found_rows' => true, ]; $cur = get_the_ID(); if ($cur) { $q['post__not_in'] = [(int) $cur]; } if ($card_orderby === 'views') { $q['meta_key'] = 'views'; $q['orderby'] = 'meta_value_num'; $q['order'] = 'DESC'; } elseif ($card_orderby === 'comment_count') { $q['orderby'] = 'comment_count'; $q['order'] = 'DESC'; } elseif ($card_orderby === 'modified') { $q['orderby'] = 'modified'; $q['order'] = 'DESC'; } else { $q['orderby'] = 'date'; $q['order'] = 'DESC'; } $recent = get_posts($q); } $is_self = is_user_logged_in() && get_current_user_id() === $author_id; $login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink()); $aksrt_pm_on = class_exists('\AKSRT\Settings\Settings') && !empty(\AKSRT\Settings\Settings::private_message_settings()['enabled']); $aksrt_msg_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : ''; $aksrt_post_settings = class_exists('\AKSRT\Settings\Settings') && method_exists('\AKSRT\Settings\Settings', 'get_post_page_settings') ? \AKSRT\Settings\Settings::get_post_page_settings() : []; $rewards_on = !empty($aksrt_post_settings['rewards_enabled']) || !empty($aksrt_post_settings['post_rewards_enabled']) || !empty($aksrt_post_settings['post_rewards_s']); ?>
$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; } // Zibll: 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))); $type = sanitize_key((string) ($settings['related_source'] ?? ($settings['related_type'] ?? 'category'))); if (!in_array($type, ['category', 'tag', 'random'], true)) { $type = 'category'; } $orderby = sanitize_key((string) ($settings['related_orderby'] ?? 'views')); if (!in_array($orderby, ['rand', 'relevance', 'date', 'views', 'modified'], true)) { $orderby = 'views'; } $args = [ 'post_type' => get_post_type($post_id) ?: 'post', 'post_status' => 'publish', 'post__not_in' => [$post_id], 'posts_per_page' => $count, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'order' => 'DESC', ]; if ($type === 'random') { $args['orderby'] = 'rand'; return $args; } $tax_query = ['relation' => 'OR']; if ($type === 'tag') { $tag_ids = wp_get_post_terms($post_id, 'post_tag', ['fields' => 'ids']); if (!empty($tag_ids) && !is_wp_error($tag_ids)) { $tax_query[] = [ 'taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => array_map('intval', $tag_ids), ]; } } else { // category (default): OR across category + tags + topics like Zibll. $cat_ids = wp_get_post_terms($post_id, 'category', ['fields' => 'ids']); if (!empty($cat_ids) && !is_wp_error($cat_ids)) { $tax_query[] = [ 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => array_map('intval', $cat_ids), ]; } $tag_ids = wp_get_post_terms($post_id, 'post_tag', ['fields' => 'ids']); if (!empty($tag_ids) && !is_wp_error($tag_ids)) { $tax_query[] = [ 'taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => array_map('intval', $tag_ids), ]; } if (taxonomy_exists('topics')) { $topic_ids = wp_get_post_terms($post_id, 'topics', ['fields' => 'ids']); if (!empty($topic_ids) && !is_wp_error($topic_ids)) { $tax_query[] = [ 'taxonomy' => 'topics', 'field' => 'term_id', 'terms' => array_map('intval', $topic_ids), ]; } } } if (count($tax_query) > 1) { $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 'views': $args['meta_key'] = 'aksrt_post_views'; $args['orderby'] = 'meta_value_num'; break; case 'relevance': default: // Prefer date when no search relevance context. $args['orderby'] = 'date'; break; } return $args; } endif; if (!function_exists('aksrt_single_render_related')) : /** * Related posts — Zibll-like list + optional shared mini renderer. * * @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 = function_exists('aksrt_single_related_query_args') ? aksrt_single_related_query_args($post_id, $settings) : [ 'post_type' => get_post_type($post_id) ?: 'post', 'post_status' => 'publish', 'post__not_in' => [$post_id], 'posts_per_page' => max(1, min(12, (int) ($settings['related_count'] ?? 6))), 'ignore_sticky_posts' => true, ]; $query = new WP_Query($args); if (!$query->have_posts()) { wp_reset_postdata(); $empty_wrap = 'theme-box relates' . ($style === 'img' ? ' relates-thumb' : ''); ?>
'related', 'mode' => 'mini', 'show_thumb' => true, 'show_meta' => true, 'show_number' => false, ]); ?> 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 .= '
  • ' . esc_html(get_the_title($p)) . '
  • '; } } ?>
      ' . esc_html__('暂无相关文章', 'aksrt') . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
    $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 (!empty($ctx['has_download']) || $pay_type === 'download') { echo '
    '; get_template_part('templates/parts/resource-download-box'); echo '
    '; return; } if (!function_exists('aksrt_get_pay_meta')) { return; } $has_access = function_exists('aksrt_has_paid_access') ? aksrt_has_paid_access($post) : false; $paid_class = $has_access ? 'paid-box' : 'pay-box'; echo '
    '; 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 '
    ' . esc_html__('已解锁', 'aksrt') . '' . esc_html(get_the_title($post)) . '
    '; } } elseif (function_exists('aksrt_get_paywall_html')) { echo aksrt_get_paywall_html($post); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
    '; } 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 (Zibll zib_single_content 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)); ?>" data-aksrt-toc="" data-aksrt-toc-depth="" > '

    ', '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', ]); } // Accept both `authordesc` (Settings DTO) and legacy `authordesc_s`. $show_author = array_key_exists('authordesc', $settings) ? !empty($settings['authordesc']) : !empty($settings['authordesc_s']); if ($show_author) { aksrt_single_render_author_card($ctx); } aksrt_single_render_prevnext($ctx); aksrt_single_render_related($ctx); } endif; if (!function_exists('aksrt_single_render_aside')) : /** * Page-owned single aside (not a generic sidebar prepend hack). * * @param array $ctx Single context. */ function aksrt_single_render_aside(array $ctx): void { if (empty($ctx['show_aside']) || wp_is_mobile()) { return; } ?>