feat(frontend): align single post page 1:1 with Zibll
Restore Zibll float dual-column shell, fix single settings DTO key mapping, reorder article footer/actions, and match author bar, prev/next, title/body typography, and limit-height expand UX.
This commit is contained in:
1 parent
a651bd6d2d
commit
5ae1a9ad93
12 files changed
+626
-218
No files matched your search
@@ -92,7 +92,7 @@ if (!function_exists('aksrt_single_build_context')) :
|
||||
$breadcrumbs_html = '';
|
||||
if (!empty($settings['breadcrumbs']) && function_exists('aksrt_breadcrumbs')) {
|
||||
ob_start();
|
||||
aksrt_breadcrumbs($settings['breadcrumbs_home'] ?? '');
|
||||
aksrt_breadcrumbs($settings['breadcrumbs_home'] ?? ($settings['breadcrumbs_home_text'] ?? ''));
|
||||
$breadcrumbs_html = trim((string) ob_get_clean());
|
||||
}
|
||||
|
||||
@@ -508,13 +508,12 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_single_render_prevnext')) :
|
||||
/**
|
||||
* Previous / next navigation.
|
||||
* Previous / next navigation (Zibll .article-nav).
|
||||
*
|
||||
* @param array<string,mixed> $ctx Single context.
|
||||
*/
|
||||
function aksrt_single_render_prevnext(array $ctx = []): void {
|
||||
$settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : [];
|
||||
// Accept both canonical `prevnext` (Settings DTO) and legacy `prevnext_s`.
|
||||
$enabled = array_key_exists('prevnext', $settings)
|
||||
? !empty($settings['prevnext'])
|
||||
: (!array_key_exists('prevnext_s', $settings) || !empty($settings['prevnext_s']));
|
||||
@@ -522,30 +521,40 @@ if (!function_exists('aksrt_single_render_prevnext')) :
|
||||
return;
|
||||
}
|
||||
|
||||
$prev = get_previous_post();
|
||||
$next = get_next_post();
|
||||
// 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:;';
|
||||
?>
|
||||
<nav class="post-nav-box theme-box box-body radius8 main-shadow">
|
||||
<?php if ($prev) : ?>
|
||||
<a class="post-nav-box__item post-nav-box__item--prev" href="<?php echo esc_url(get_permalink($prev)); ?>">
|
||||
<span class="post-nav-box__label"><?php esc_html_e('上一篇', 'aksrt'); ?></span>
|
||||
<span class="post-nav-box__title"><?php echo esc_html(get_the_title($prev)); ?></span>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<span class="post-nav-box__item post-nav-box__item--prev is-empty" aria-hidden="true"></span>
|
||||
<?php endif; ?>
|
||||
<?php if ($next) : ?>
|
||||
<a class="post-nav-box__item post-nav-box__item--next" href="<?php echo esc_url(get_permalink($next)); ?>">
|
||||
<span class="post-nav-box__label"><?php esc_html_e('下一篇', 'aksrt'); ?></span>
|
||||
<span class="post-nav-box__title"><?php echo esc_html(get_the_title($next)); ?></span>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<span class="post-nav-box__item post-nav-box__item--next is-empty" aria-hidden="true"></span>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<div class="theme-box" style="height:99px">
|
||||
<nav class="article-nav">
|
||||
<div class="main-bg box-body radius8 main-shadow">
|
||||
<a href="<?php echo $prev ? esc_url($prev_href) : 'javascript:;'; ?>">
|
||||
<p class="muted-2-color"><i class="fa fa-angle-left em12" aria-hidden="true"></i><i class="fa fa-angle-left em12 mr6" aria-hidden="true"></i><?php esc_html_e('上一篇', 'aksrt'); ?></p>
|
||||
<div class="text-ellipsis-2"><?php echo esc_html($prev_title); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="main-bg box-body radius8 main-shadow">
|
||||
<a href="<?php echo $next ? esc_url($next_href) : 'javascript:;'; ?>">
|
||||
<p class="muted-2-color"><?php esc_html_e('下一篇', 'aksrt'); ?><i class="fa fa-angle-right em12 ml6" aria-hidden="true"></i><i class="fa fa-angle-right em12" aria-hidden="true"></i></p>
|
||||
<div class="text-ellipsis-2"><?php echo esc_html($next_title); ?></div>
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
@@ -777,7 +786,7 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_single_render_article')) :
|
||||
/**
|
||||
* Main article box.
|
||||
* Main article box (Zibll zib_single_content order).
|
||||
*
|
||||
* @param array<string,mixed> $ctx Single context.
|
||||
*/
|
||||
@@ -785,49 +794,51 @@ if (!function_exists('aksrt_single_render_article')) :
|
||||
$settings = is_array($ctx['settings'] ?? null) ? $ctx['settings'] : [];
|
||||
$maxheight = (int) $ctx['content_maxheight'];
|
||||
?>
|
||||
<article <?php post_class('article article-shell main-bg theme-box box-body radius8 main-shadow'); ?>>
|
||||
<article <?php post_class('article main-bg theme-box box-body radius8 main-shadow'); ?>>
|
||||
<?php aksrt_single_render_box_header($ctx); ?>
|
||||
|
||||
<?php if (!empty($settings['yiyan_header'])) : ?>
|
||||
<div class="article-yiyan yiyan-box aksrt-yiyan yiyan--header" data-aksrt-yiyan data-type="hitokoto"></div>
|
||||
<?php endif; ?>
|
||||
<div class="article-content">
|
||||
<?php if (!empty($settings['yiyan_header'])) : ?>
|
||||
<div class="article-yiyan yiyan-box aksrt-yiyan yiyan--header theme-box text-center radius8 main-shadow" data-aksrt-yiyan data-type="hitokoto"></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action('aksrt_single_content_before', get_post()); ?>
|
||||
<?php do_action('aksrt_single_content_before', get_post()); ?>
|
||||
|
||||
<?php if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'top')) : ?>
|
||||
<?php if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'top')) : ?>
|
||||
<?php aksrt_single_render_pay_box($ctx); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($ctx['front_content'] !== '') : ?>
|
||||
<div class="post_front_content theme-box box-body"><?php echo wp_kses_post((string) $ctx['front_content']); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($ctx['front_content'] !== '') : ?>
|
||||
<div class="post_front_content theme-box box-body"><?php echo wp_kses_post((string) $ctx['front_content']); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="theme-box wp-posts-content entry-content<?php echo $maxheight > 0 ? ' limit-height' : ''; ?>"
|
||||
<?php echo $maxheight > 0 ? ' style="max-height:' . esc_attr((string) $maxheight) . 'px;"' : ''; ?>
|
||||
data-nav="posts"
|
||||
data-maxheight="<?php echo esc_attr((string) $maxheight); ?>"
|
||||
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))); ?>"
|
||||
<?php echo !empty($settings['lightbox']) ? ' data-aksrt-lightbox="1"' : ''; ?>>
|
||||
<?php the_content(); ?>
|
||||
<?php
|
||||
wp_link_pages([
|
||||
'before' => '<p class="text-center post-nav-links radius8 padding-6">',
|
||||
'after' => '</p>',
|
||||
]);
|
||||
?>
|
||||
<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"
|
||||
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))); ?>"
|
||||
<?php echo !empty($settings['lightbox']) ? ' data-aksrt-lightbox="1"' : ''; ?>>
|
||||
<?php the_content(); ?>
|
||||
<?php
|
||||
wp_link_pages([
|
||||
'before' => '<p class="text-center post-nav-links radius8 padding-6">',
|
||||
'after' => '</p>',
|
||||
]);
|
||||
?>
|
||||
<?php if ($ctx['after_content'] !== '') : ?>
|
||||
<?php echo wp_kses_post((string) $ctx['after_content']); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'bottom')) : ?>
|
||||
<?php aksrt_single_render_pay_box($ctx); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php aksrt_single_render_content_footer($ctx); ?>
|
||||
</div>
|
||||
|
||||
<?php if ($ctx['after_content'] !== '') : ?>
|
||||
<div class="post_after_content theme-box box-body"><?php echo wp_kses_post((string) $ctx['after_content']); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (function_exists('aksrt_single_pay_box_matches') && aksrt_single_pay_box_matches($ctx, 'bottom')) : ?>
|
||||
<?php aksrt_single_render_pay_box($ctx); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php aksrt_single_render_actions($ctx); ?>
|
||||
<?php aksrt_single_render_content_footer($ctx); ?>
|
||||
</article>
|
||||
<?php
|
||||
}
|
||||
@@ -914,7 +925,7 @@ 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'] ?? '');
|
||||
aksrt_breadcrumbs($settings['breadcrumbs_home'] ?? ($settings['breadcrumbs_home_text'] ?? ''));
|
||||
}
|
||||
} else {
|
||||
aksrt_single_render_cover($ctx);
|
||||
|
||||
Reference in new issue
Block a user