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,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Shared author info bar for single post content.
|
||||
* Shared author info bar for single post content (Zibll article-avatar / user-info).
|
||||
*
|
||||
* Contract: get_template_part(..., null, $args)
|
||||
*
|
||||
@@ -20,94 +20,115 @@ $meta_items = is_array($args['meta_items'] ?? null) ? array_values(array_filter(
|
||||
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' : ''));
|
||||
$author_name = get_the_author();
|
||||
$author_url = get_author_posts_url($author_id);
|
||||
$modified_ts = (int) get_the_modified_time('U');
|
||||
$published_ts = (int) get_the_time('U');
|
||||
$now = (int) current_time('timestamp');
|
||||
$use_modified = $modified_ts > $published_ts;
|
||||
$rel_base = $use_modified ? $modified_ts : $published_ts;
|
||||
$rel_label = $use_modified ? __('更新', 'aksrt') : __('发布', 'aksrt');
|
||||
$abs_fmt = $use_modified
|
||||
? sprintf(__('%s更新', 'aksrt'), get_the_modified_time('Y年m月d日 H:i'))
|
||||
: sprintf(__('%s发布', 'aksrt'), get_the_time('Y年m月d日 H:i'));
|
||||
$time_text = human_time_diff($rel_base, $now) . $rel_label;
|
||||
|
||||
$classes = trim('article-avatar ' . $extra_class);
|
||||
$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() : '';
|
||||
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
|
||||
$is_self = is_user_logged_in() && get_current_user_id() === $author_id;
|
||||
?>
|
||||
|
||||
<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 class="user-info flex ac">
|
||||
<a class="avatar-img" href="<?php echo esc_url($author_url); ?>">
|
||||
<?php echo get_avatar($author_id, 52, '', esc_attr($author_name), ['class' => 'avatar avatar-id-' . $author_id]); ?>
|
||||
</a>
|
||||
<div class="user-right flex flex1 ac jsb ml10">
|
||||
<div class="flex1">
|
||||
<a class="display-name text-ellipsis" href="<?php echo esc_url($author_url); ?>"><?php echo esc_html($author_name); ?></a>
|
||||
<div class="px12-sm muted-2-color text-ellipsis">
|
||||
<span class="icon-circle" title="<?php echo esc_attr($abs_fmt); ?>" data-toggle="tooltip"><?php echo esc_html($time_text); ?></span>
|
||||
<?php if ($show_bio) : ?>
|
||||
<?php $bio = trim((string) get_the_author_meta('description')); ?>
|
||||
<?php if ($bio !== '') : ?>
|
||||
<span class="icon-circle"><?php echo esc_html($bio); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($show_bio && $author_bio !== '') : ?>
|
||||
<p class="article-avatar__bio"><?php echo esc_html($author_bio); ?></p>
|
||||
<?php if ($show_actions) : ?>
|
||||
<div class="flex0 user-action">
|
||||
<?php if (!$is_self) : ?>
|
||||
<?php if (is_user_logged_in()) : ?>
|
||||
<button type="button" class="px12-sm ml10 follow but c-red" data-aksrt-follow="<?php echo (int) $author_id; ?>">
|
||||
<i class="fa fa-heart em09" aria-hidden="true"></i> <?php esc_html_e('关注', 'aksrt'); ?>
|
||||
</button>
|
||||
<?php if ($aksrt_pm_on && $aksrt_msg_url !== '') : ?>
|
||||
<a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', $aksrt_msg_url)); ?>" class="ml6 but c-blue px12-sm">
|
||||
<i class="fa fa-comment em09" aria-hidden="true"></i> <?php esc_html_e('私信', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url($login_url); ?>" class="px12-sm ml10 follow but c-red">
|
||||
<i class="fa fa-heart em09" aria-hidden="true"></i> <?php esc_html_e('关注', 'aksrt'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?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>
|
||||
<div class="relative">
|
||||
<i class="line-form-line" aria-hidden="true"></i>
|
||||
<?php if (!empty($meta_items)) : ?>
|
||||
<div class="flex ac single-metabox abs-right">
|
||||
<div class="post-metas">
|
||||
<?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>
|
||||
<div class="clearfix ml6 post-drop-meta">
|
||||
<button type="button" class="but cir post-drop-meta__toggle" aria-haspopup="true" aria-expanded="false" aria-label="<?php esc_attr_e('更多', 'aksrt'); ?>">
|
||||
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
|
||||
</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 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="fa 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="fa 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="fa fa-flag" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('举报', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url($login_url); ?>" class="post-drop-meta__item">
|
||||
<i class="fa fa-flag" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('登录后举报', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user