Files
wordpress-theme-aksrt/inc/helpers/aksrt-single-aside.php
T
kate522 9375b1c30c refactor(assets): vendor 资产迁入标准目录并全仓去除 zibll 标识
- assets/vendor 全量迁移: fontawesome5→assets/fontawesome5, css→assets/css,
  js→assets/js/runtime(避开 14 个同名自有文件), img 合并去重→assets/img,
  fonts→assets/fonts; 删除 assets/vendor
- libs 五个与 widgets/third-party 字节相同的库不重复入库, loader paths 改指向
- 运行时切换: _win.uri=assets 根, loader baseUrl=/js/runtime, enlighter 注入
  路径同步; PHP 7 个引用文件切换并改名 $zibll_*→$runtime_*
- 去品牌: Qinver 头注释/品牌 console.log/演示链接清除, 默认文案中性化
- 功能标识符改名: zib__→aksrt__, zib_ajax→aksrt_ajax, window.zib→
  window.aksrtLegacy, zibllblock/*→aksrtblock/*, .zib-widget→.aksrt-panel,
  .zib-slider→.aksrt-slider, zib_menu_options meta 键等
- 自有 CSS 改名: legacy-utilities/compat-vars/footer shell
- admin SPA 重建; 契约测试同步(路径/断言/文件更名)
- 例外保留: tests/visual 对照环境与 fixtures 前缀(外部 Zibll 产品引用)

验证: php -l 133 个改动文件通过; runtime 86 个 JS node --check 通过;
契约测试 68/70(2 个失败经 stash 对照确认为存量问题)
2026-08-22 16:16:30 +08:00

98 lines
4.0 KiB
PHP

<?php
/**
* Single-post sidebar composition.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (!function_exists('aksrt_single_render_overview_widget')) :
/**
* Render a useful fallback when no article sidebar widgets are configured.
*
* @param array<string,mixed> $ctx Single context.
*/
function aksrt_single_render_overview_widget(array $ctx): void {
$post_id = (int) ($ctx['post_id'] ?? get_the_ID());
$categories = get_the_category($post_id);
$primary_category = !empty($categories) && $categories[0] instanceof WP_Term ? $categories[0] : null;
$modified = get_the_modified_date('', $post_id);
$overview_items = is_array($ctx['meta_items_secondary'] ?? null) ? $ctx['meta_items_secondary'] : [];
?>
<section class="aksrt-panel single-overview-widget" aria-labelledby="single-overview-title">
<h3 id="single-overview-title" class="single-overview-widget__title">
<i class="fa fas fa-file-alt" aria-hidden="true"></i>
<?php esc_html_e('文章概览', 'aksrt'); ?>
</h3>
<dl class="single-overview-widget__list">
<?php if ($primary_category instanceof WP_Term) : ?>
<div><dt><?php esc_html_e('分类', 'aksrt'); ?></dt><dd><a href="<?php echo esc_url(get_category_link($primary_category)); ?>"><?php echo esc_html($primary_category->name); ?></a></dd></div>
<?php endif; ?>
<div><dt><?php esc_html_e('浏览', 'aksrt'); ?></dt><dd><?php echo esc_html(number_format_i18n((int) ($ctx['views'] ?? 0))); ?></dd></div>
<div><dt><?php esc_html_e('评论', 'aksrt'); ?></dt><dd><a href="<?php echo esc_url(get_comments_link($post_id)); ?>"><?php echo esc_html(number_format_i18n((int) ($ctx['comment_count'] ?? 0))); ?></a></dd></div>
<?php foreach ($overview_items as $item) : ?>
<?php if (is_array($item) && !empty($item['text'])) : ?>
<div><dt><i class="<?php echo esc_attr((string) ($item['icon'] ?? 'fa fas fa-circle')); ?>" aria-hidden="true"></i></dt><dd><?php echo esc_html((string) $item['text']); ?></dd></div>
<?php endif; ?>
<?php endforeach; ?>
<?php if ($modified !== '') : ?>
<div><dt><?php esc_html_e('更新', 'aksrt'); ?></dt><dd><?php echo esc_html($modified); ?></dd></div>
<?php endif; ?>
</dl>
</section>
<?php
}
endif;
if (!function_exists('aksrt_single_render_aside')) :
/**
* Render the page-owned single sidebar.
*
* @param array<string,mixed> $ctx Single context.
*/
function aksrt_single_render_aside(array $ctx): void {
$post_id = (int) ($ctx['post_id'] ?? get_the_ID());
if (get_post_type($post_id) !== 'post') {
return;
}
// The body site-layout-* class owns visibility. Always render the post
// sidebar so User-Agent or request-specific context cannot remove widgets
// from an otherwise two-column article page.
$has_article_widgets = is_active_sidebar('all_sidebar_top')
|| is_active_sidebar('single_sidebar')
|| is_active_sidebar('all_sidebar_bottom');
?>
<div class="sidebar aksrt-article-sidebar" role="complementary" aria-label="<?php esc_attr_e('侧栏', 'aksrt'); ?>">
<?php if (!empty($ctx['has_download'])) : ?>
<?php get_template_part('templates/parts/resource-meta-box'); ?>
<?php endif; ?>
<?php if (!$has_article_widgets) : ?>
<?php aksrt_single_render_overview_widget($ctx); ?>
<?php endif; ?>
<?php if (!empty($ctx['show_toc'])) : ?>
<div class="aksrt-panel toc-widget posts-nav-box" data-title="<?php echo esc_attr((string) ($ctx['toc_title'] ?? __('文章目录', 'aksrt'))); ?>">
<h3><?php echo esc_html((string) ($ctx['toc_title'] ?? __('文章目录', 'aksrt'))); ?></h3>
<ol class="toc-list"></ol>
</div>
<?php endif; ?>
<?php if (is_active_sidebar('all_sidebar_top')) : ?>
<?php dynamic_sidebar('all_sidebar_top'); ?>
<?php endif; ?>
<?php if (is_active_sidebar('single_sidebar')) : ?>
<?php dynamic_sidebar('single_sidebar'); ?>
<?php endif; ?>
<?php if (is_active_sidebar('all_sidebar_bottom')) : ?>
<?php dynamic_sidebar('all_sidebar_bottom'); ?>
<?php endif; ?>
</div>
<?php
}
endif;