107 lines
5.0 KiB
PHP
107 lines
5.0 KiB
PHP
<?php
|
|
/**
|
|
* 公开用户主页 — 侧边栏
|
|
*
|
|
* @package AKSRT
|
|
* @since 5.0.0
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$user = $args['user'] ?? null;
|
|
$user_id = $user ? (int) $user->ID : 0;
|
|
$dashboard = $args['dashboard'] ?? [];
|
|
$settings = $args['settings'] ?? [];
|
|
$show_follow = $settings['follow'] ?? true;
|
|
$is_own = $dashboard['is_own_profile'] ?? false;
|
|
$viewer_id = $dashboard['viewer_id'] ?? 0;
|
|
$contacts = $dashboard['user_contacts'] ?? [];
|
|
|
|
if (!$user) return;
|
|
?>
|
|
|
|
<div class="uh-sidebar">
|
|
<!-- 数据统计 -->
|
|
<div class="widget">
|
|
<div class="widget-title"><i class="fas fa-chart-bar"></i> <?php esc_html_e('数据概览', 'aksrt'); ?></div>
|
|
<div class="widget-content">
|
|
<div class="uh-sidebar__stats">
|
|
<div class="uh-sidebar__stat">
|
|
<span class="uh-sidebar__stat-num"><?php echo esc_html($dashboard['post_count'] ?? 0); ?></span>
|
|
<span class="uh-sidebar__stat-label"><?php esc_html_e('文章', 'aksrt'); ?></span>
|
|
</div>
|
|
<div class="uh-sidebar__stat">
|
|
<span class="uh-sidebar__stat-num"><?php echo esc_html($dashboard['comment_count'] ?? 0); ?></span>
|
|
<span class="uh-sidebar__stat-label"><?php esc_html_e('评论', 'aksrt'); ?></span>
|
|
</div>
|
|
<div class="uh-sidebar__stat">
|
|
<span class="uh-sidebar__stat-num"><?php echo esc_html($dashboard['follower_count'] ?? 0); ?></span>
|
|
<span class="uh-sidebar__stat-label"><?php esc_html_e('粉丝', 'aksrt'); ?></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 社交链接 -->
|
|
<?php if (!empty($contacts)) : ?>
|
|
<div class="widget">
|
|
<div class="widget-title"><i class="fas fa-link"></i> <?php esc_html_e('社交链接', 'aksrt'); ?></div>
|
|
<div class="widget-content">
|
|
<div class="uh-sidebar__contacts">
|
|
<?php foreach ($contacts as $contact) : ?>
|
|
<a href="<?php echo esc_url($contact['url'] ?? '#'); ?>" target="_blank" rel="noopener noreferrer" class="uh-sidebar__contact" title="<?php echo esc_attr($contact['name'] ?? ''); ?>">
|
|
<i class="fab fa-<?php echo esc_attr($contact['icon'] ?? 'link'); ?>"></i>
|
|
<span><?php echo esc_html($contact['name'] ?? ''); ?></span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- 关注/粉丝 -->
|
|
<?php if ($show_follow && !$is_own && $viewer_id > 0) : ?>
|
|
<?php
|
|
$following_ids = function_exists('aksrt_get_following_ids') ? aksrt_get_following_ids($user_id, 6) : [];
|
|
$follower_ids = function_exists('aksrt_get_follower_ids') ? aksrt_get_follower_ids($user_id, 6) : [];
|
|
?>
|
|
<?php if (!empty($following_ids) || !empty($follower_ids)) : ?>
|
|
<div class="widget">
|
|
<div class="widget-title"><i class="fas fa-users"></i> <?php esc_html_e('社交关系', 'aksrt'); ?></div>
|
|
<div class="widget-content">
|
|
<?php if (!empty($following_ids)) : ?>
|
|
<div class="uh-sidebar__follow-section">
|
|
<span class="uh-sidebar__follow-label"><?php esc_html_e('关注', 'aksrt'); ?></span>
|
|
<div class="uh-sidebar__avatars">
|
|
<?php foreach ($following_ids as $fid) :
|
|
$f_user = get_userdata($fid);
|
|
if (!$f_user) continue;
|
|
?>
|
|
<a href="<?php echo esc_url(get_author_posts_url($fid)); ?>">
|
|
<?php echo get_avatar($fid, 32); ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($follower_ids)) : ?>
|
|
<div class="uh-sidebar__follow-section">
|
|
<span class="uh-sidebar__follow-label"><?php esc_html_e('粉丝', 'aksrt'); ?></span>
|
|
<div class="uh-sidebar__avatars">
|
|
<?php foreach ($follower_ids as $fid) :
|
|
$f_user = get_userdata($fid);
|
|
if (!$f_user) continue;
|
|
?>
|
|
<a href="<?php echo esc_url(get_author_posts_url($fid)); ?>">
|
|
<?php echo get_avatar($fid, 32); ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|