fix(user-home): match reference cover metas with 人气值/点赞 pills
The public user homepage cover showed a single bottom-right 粉丝 pill, which the reference theme does not render there — it shows 人气值 and 点赞 as a translucent pill group pinned to the cover's top-right corner. - Cover metas: replace 粉丝 with 人气值 (zibsvg-hot) + 点赞 (zibsvg-like), summed over the user's published posts via aksrt_get_user_posts_meta_sum() and abbreviated with aksrt_cut_count(); each is zero-suppressed independently, matching zib_get_author_header_metas() - Titles use the reference strings 人气值 N / 获得N个点赞 via data-toggle="tooltip" - CSS: adopt .single-metabox.cover-meta semantics (one rgba(0,0,0,.3) pill at right:1em/top:1.6em, 14px, 6px item gaps, 3px icon margins) plus the reference's <=480px override; drop the per-stat bottom-right pills - Drop the dead __stats / __stat / __contacts CSS blocks and the unused $tab_counts hero contract arg Follower counts remain in the content tab bar (tab_counts['follow']). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
* Author Hero — shared hero section for author archive and public user homepage.
|
||||
*
|
||||
* Aligns with legacy(): cover, avatar, name, identity, desc,
|
||||
* and header actions. Content stats live in the tab bar, not a body stats row.
|
||||
* and header actions. The cover carries the 人气值 / 点赞 meta pills
|
||||
* (legacy zib_get_author_header_metas); follower counts stay in the tab bar.
|
||||
*
|
||||
* Contract: get_template_part(..., null, $args)
|
||||
* user WP_User
|
||||
* dashboard array from aksrt_get_user_dashboard_view()
|
||||
* user_home_settings array
|
||||
* is_author_page bool
|
||||
* tab_counts array (optional)
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -22,7 +22,6 @@ $user = $args['user'] ?? null;
|
||||
$dashboard = is_array($args['dashboard'] ?? null) ? $args['dashboard'] : [];
|
||||
$settings = is_array($args['user_home_settings'] ?? null) ? $args['user_home_settings'] : [];
|
||||
$is_author = !empty($args['is_author_page']);
|
||||
$tab_counts = is_array($args['tab_counts'] ?? null) ? $args['tab_counts'] : [];
|
||||
|
||||
if (!($user instanceof WP_User)) {
|
||||
return;
|
||||
@@ -48,9 +47,26 @@ $show_report = !empty($dashboard['show_report']);
|
||||
$bg_url = function_exists('aksrt_get_user_cover_url') ? aksrt_get_user_cover_url($user_id) : '';
|
||||
$is_own = !empty($dashboard['is_own_profile']);
|
||||
|
||||
$follower_count = (int) ($tab_counts['follow'] ?? 0);
|
||||
if ($follower_count <= 0 && class_exists('\AKSRT\User\Follow')) {
|
||||
$follower_count = (int) \AKSRT\User\Follow::get_instance()->get_follower_count($user_id);
|
||||
// 封面右上角数据条(参考主题 zib_get_author_header_metas):人气值 + 点赞,
|
||||
// 粉丝数只在内容 tab 上呈现,不进入封面。
|
||||
$cover_metas = [];
|
||||
if (function_exists('aksrt_get_user_posts_meta_sum') && function_exists('aksrt_cut_count')) {
|
||||
$view_n = aksrt_cut_count(aksrt_get_user_posts_meta_sum($user_id, 'aksrt_post_views'));
|
||||
$like_n = aksrt_cut_count(aksrt_get_user_posts_meta_sum($user_id, '_aksrt_like_count'));
|
||||
if ($view_n !== '' && $view_n !== '0') {
|
||||
$cover_metas[] = [
|
||||
'count' => $view_n,
|
||||
'title' => sprintf(__('人气值 %s', 'aksrt'), $view_n),
|
||||
'icon' => 'zibsvg-hot',
|
||||
];
|
||||
}
|
||||
if ($like_n !== '' && $like_n !== '0') {
|
||||
$cover_metas[] = [
|
||||
'count' => $like_n,
|
||||
'title' => sprintf(__('获得%s个点赞', 'aksrt'), $like_n),
|
||||
'icon' => 'zibsvg-like',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$notification_settings = class_exists('\AKSRT\Settings\Settings')
|
||||
@@ -74,12 +90,14 @@ $show_cover_menu = $has_more_details || $show_cover_report || $cover_ban_html !=
|
||||
<div class="aksrt-author-hero__cover">
|
||||
<img<?php echo aksrt_get_lazy_attr('lazy_cover', (string) $bg_url, 'aksrt-author-hero__cover-img', aksrt_get_lazy_thumb('lg')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="">
|
||||
<div class="aksrt-author-hero__cover-mask"></div>
|
||||
<?php if ($follower_count > 0) : ?>
|
||||
<?php if ($cover_metas) : ?>
|
||||
<div class="aksrt-author-hero__cover-metas" aria-label="<?php esc_attr_e('主页数据', 'aksrt'); ?>">
|
||||
<span class="aksrt-author-hero__cover-meta" title="<?php esc_attr_e('粉丝', 'aksrt'); ?>">
|
||||
<i class="fa fas fa-heart" aria-hidden="true"></i>
|
||||
<?php echo esc_html((string) $follower_count); ?>
|
||||
</span>
|
||||
<?php foreach ($cover_metas as $cover_meta) : ?>
|
||||
<span class="aksrt-author-hero__cover-meta" data-toggle="tooltip" title="<?php echo esc_attr((string) $cover_meta['title']); ?>">
|
||||
<?php echo aksrt_icon_markup((string) $cover_meta['icon']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- fixed sprite markup. ?>
|
||||
<?php echo esc_html((string) $cover_meta['count']); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($show_cover_menu) : ?>
|
||||
|
||||
Reference in New Issue
Block a user