对齐 Zibll 消息中心主 tab 语义,补齐 messages/conversation 资源 enqueue,按 message_s/private_s 门控私信与总开关,并收束页面壳层与作者栏入口。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
114 lines
5.3 KiB
PHP
114 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* Shared author info bar for single post content.
|
|
*
|
|
* Contract: get_template_part(..., null, $args)
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$args = is_array($args ?? null) ? $args : [];
|
|
$extra_class = (string) ($args['extra_class'] ?? '');
|
|
$show_actions = !empty($args['show_actions']);
|
|
$show_bio = !empty($args['show_bio']);
|
|
$meta_items = is_array($args['meta_items'] ?? null) ? array_values(array_filter($args['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((int) 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; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></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 (int) $author_id; ?>">
|
|
<i class="far fa-heart" aria-hidden="true"></i>
|
|
<span><?php esc_html_e('关注', 'aksrt'); ?></span>
|
|
</button>
|
|
<?php
|
|
$aksrt_pm_on = class_exists('AKSRT_Settings') && !empty(AKSRT_Settings::private_message_settings()['enabled']);
|
|
$aksrt_msg_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '';
|
|
if ($aksrt_pm_on && $aksrt_msg_url !== '') :
|
|
?>
|
|
<a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', $aksrt_msg_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>
|