47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* User center sidebar: one-line account statistics.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$stats = [
|
|
[
|
|
'label' => __('文章', 'aksrt'),
|
|
'value' => (int) ($post_count ?? 0),
|
|
'url' => aksrt_get_user_center_tab_url('posts'),
|
|
'tab' => 'posts',
|
|
],
|
|
[
|
|
'label' => __('评论', 'aksrt'),
|
|
'value' => (int) ($comment_count ?? 0),
|
|
'url' => isset($dashboard_tabs['comments']) ? aksrt_get_user_center_tab_url('comments') : $public_home_url,
|
|
'tab' => isset($dashboard_tabs['comments']) ? 'comments' : '',
|
|
],
|
|
[
|
|
'label' => __('收藏', 'aksrt'),
|
|
'value' => (int) ($favorite_count ?? 0),
|
|
'url' => isset($dashboard_tabs['favorites']) ? aksrt_get_user_center_tab_url('favorites') : $public_home_url,
|
|
'tab' => isset($dashboard_tabs['favorites']) ? 'favorites' : '',
|
|
],
|
|
[
|
|
'label' => __('粉丝', 'aksrt'),
|
|
'value' => (int) ($follower_count ?? 0),
|
|
'url' => aksrt_get_user_center_tab_url('follow'),
|
|
'tab' => 'follow',
|
|
],
|
|
];
|
|
?>
|
|
<div class="uc-sidebar__section uc-sidebar__section--stats" aria-label="<?php esc_attr_e('账号统计', 'aksrt'); ?>">
|
|
<div class="uc-stats">
|
|
<?php foreach ($stats as $stat) : ?>
|
|
<a class="uc-stats__item" href="<?php echo esc_url((string) $stat['url']); ?>"<?php if (!empty($stat['tab'])) : ?> data-tab="<?php echo esc_attr((string) $stat['tab']); ?>"<?php endif; ?>>
|
|
<span class="uc-stats__value"><?php echo esc_html(number_format_i18n((int) $stat['value'])); ?></span>
|
|
<span class="uc-stats__label"><?php echo esc_html((string) $stat['label']); ?></span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|