Files
wordpress-theme-aksrt/templates/parts/single-author-bar.php
T
kate522andClaude Fable 5 8afb4ec856 兼容层收口:隔离非主线入口
将文档模式、下载中心、专题聚合、消息中心、前台投稿等非 Zibll 主线能力
收敛为“兼容保留”,默认不再作为主入口暴露,但保留路由/模板/数据/设置键。

- 新增 inc/helpers/aksrt-compat.php 兼容策略中枢:
  - aksrt_get_messages_url()(补齐此前缺失、被两处模板调用的 helper)
  - aksrt_pm_frontend_enabled()(前台私信入口开关,默认关闭)
  - aksrt_show_compat_page_templates()(兼容页面模板下拉开关,默认关闭)
- AKSRT_Templates::page_template_map() 拆分为主线/兼容两组,兼容模板默认
  移出 wp-admin 页面模板下拉;已分配这些模板的历史页面照常渲染。
- 作者操作条“私信”按钮(停用候选)默认前台隐藏,可经 filter/常量开启。
- 修复 admin-sections.js barrel 未再导出 getAdminSections 的缺陷,该缺陷
  会使 router 的兼容分区默认落点重定向在加载时抛错。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 15:22:34 +08:00

110 lines
5.2 KiB
PHP

<?php
/**
* Shared author info bar for single post/resource content.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$extra_class = (string) get_query_var('aksrt_author_bar_class', '');
$show_actions = (bool) get_query_var('aksrt_author_bar_actions', false);
$show_bio = (bool) get_query_var('aksrt_author_bar_bio', false);
$meta_items = get_query_var('aksrt_author_bar_meta_items', []);
$meta_items = is_array($meta_items) ? array_values(array_filter($meta_items, static function ($meta_item) {
if (is_array($meta_item)) {
return !empty($meta_item['text']);
}
return is_string($meta_item) && $meta_item !== '';
})) : [];
$updated_text = sprintf(
esc_html__('%s前更新', 'aksrt'),
esc_html(human_time_diff(get_the_modified_time('U'), current_time('timestamp')))
);
$author_bio = trim((string) get_the_author_meta('description'));
$author_id = (int) get_the_author_meta('ID');
$classes = trim('article-avatar ' . $extra_class . ($show_actions ? ' article-avatar--with-actions' : ''));
?>
<div class="<?php echo esc_attr($classes); ?>">
<div class="author-box flex ac">
<div class="article-avatar__image">
<?php echo get_avatar($author_id, 52, '', esc_attr(get_the_author()), ['class' => 'article-avatar']); ?>
</div>
<div class="article-avatar__body">
<a href="<?php echo esc_url(get_author_posts_url($author_id)); ?>" class="article-avatar__name"><?php the_author(); ?></a>
<div class="comt-meta muted-2-color">
<item class="post-time"><i class="far fa-clock" aria-hidden="true"></i> <?php echo $updated_text; ?></item>
<?php foreach ($meta_items as $meta_item) : ?>
<?php
$meta_text = is_array($meta_item) ? (string) ($meta_item['text'] ?? '') : (string) $meta_item;
$meta_icon = is_array($meta_item) ? (string) ($meta_item['icon'] ?? '') : '';
if ($meta_text === '') {
continue;
}
?>
<item class="meta-view"><?php if ($meta_icon !== '') : ?><i class="<?php echo esc_attr($meta_icon); ?>" aria-hidden="true"></i> <?php endif; ?><?php echo esc_html($meta_text); ?></item>
<?php endforeach; ?>
</div>
<?php if ($show_bio && $author_bio !== '') : ?>
<p class="article-avatar__bio"><?php echo esc_html($author_bio); ?></p>
<?php endif; ?>
</div>
</div>
<?php if ($show_actions) : ?>
<i class="line-form-line" aria-hidden="true"></i>
<div class="single-metabox abs-right" aria-label="<?php esc_attr_e('作者操作', 'aksrt'); ?>">
<?php if (is_user_logged_in() && $author_id !== get_current_user_id()) : ?>
<button type="button" class="author-action-btn author-action-btn--follow" data-aksrt-follow="<?php echo $author_id; ?>">
<i class="far fa-heart" aria-hidden="true"></i>
<span><?php esc_html_e('关注', 'aksrt'); ?></span>
</button>
<?php // 私信为“停用候选”兼容能力:默认不在前台暴露,仅在站点显式开启时显示。 ?>
<?php if (function_exists('aksrt_pm_frontend_enabled') && aksrt_pm_frontend_enabled()) : ?>
<a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', aksrt_get_messages_url())); ?>" class="author-action-btn author-action-btn--ghost">
<i class="far fa-comment-dots" aria-hidden="true"></i>
<span><?php esc_html_e('私信', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php elseif (!is_user_logged_in()) : ?>
<a href="<?php echo esc_url(function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink())); ?>" class="author-action-btn author-action-btn--follow">
<i class="far fa-heart" aria-hidden="true"></i>
<span><?php esc_html_e('登录后关注', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<div class="post-drop-meta">
<button type="button" class="post-drop-meta__toggle author-action-btn author-action-btn--ghost" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-h" aria-hidden="true"></i>
<span><?php esc_html_e('更多', 'aksrt'); ?></span>
</button>
<div class="post-drop-meta__menu" aria-hidden="true">
<?php if (current_user_can('edit_post', get_the_ID())) : ?>
<a href="<?php echo esc_url(get_edit_post_link(get_the_ID())); ?>" class="post-drop-meta__item">
<i class="far fa-edit" aria-hidden="true"></i>
<span><?php esc_html_e('编辑文章', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<button type="button" class="post-drop-meta__item" data-share-copy data-share-url="<?php echo esc_url(get_permalink()); ?>">
<i class="fas fa-link" aria-hidden="true"></i>
<span><?php esc_html_e('复制链接', 'aksrt'); ?></span>
</button>
<?php if (is_user_logged_in()) : ?>
<button type="button" class="post-drop-meta__item" data-aksrt-report='{"target_type":"post","target_id":<?php echo (int) get_the_ID(); ?>}'>
<i class="far fa-flag" aria-hidden="true"></i>
<span><?php esc_html_e('举报', 'aksrt'); ?></span>
</button>
<?php else : ?>
<a href="<?php echo esc_url(function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink())); ?>" class="post-drop-meta__item">
<i class="far fa-flag" aria-hidden="true"></i>
<span><?php esc_html_e('登录后举报', 'aksrt'); ?></span>
</a>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>