90 lines
2.7 KiB
PHP
90 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* User center sidebar: services and account settings.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$cart_url = function_exists('aksrt_get_cart_page_url') ? aksrt_get_cart_page_url() : '';
|
|
$level_url = isset($dashboard_tabs['credits'])
|
|
? add_query_arg('asset_tab', 'points', aksrt_get_user_center_tab_url('credits'))
|
|
: '';
|
|
$auth_url = function_exists('aksrt_get_page_url_by_template')
|
|
? aksrt_get_page_url_by_template('templates/pages/page-user-auth.php')
|
|
: '';
|
|
|
|
$services = array_values(array_filter([
|
|
[
|
|
'label' => __('购物车', 'aksrt'),
|
|
'icon' => 'shopping-cart',
|
|
'tone' => 'cart',
|
|
'url' => $cart_url,
|
|
],
|
|
[
|
|
'label' => __('我的等级', 'aksrt'),
|
|
'icon' => 'chart-line',
|
|
'tone' => 'level',
|
|
'url' => $level_url,
|
|
],
|
|
[
|
|
'label' => __('官方认证', 'aksrt'),
|
|
'icon' => 'id-badge',
|
|
'tone' => 'auth',
|
|
'url' => $auth_url,
|
|
],
|
|
], static fn(array $item): bool => (string) $item['url'] !== ''));
|
|
|
|
$settings = array_values(array_filter([
|
|
[
|
|
'label' => __('消息通知', 'aksrt'),
|
|
'icon' => 'bell',
|
|
'tone' => 'notice',
|
|
'url' => (string) ($messages_url ?? ''),
|
|
'count' => (int) ($notification_unread_count ?? 0),
|
|
],
|
|
[
|
|
'label' => __('个人资料', 'aksrt'),
|
|
'icon' => 'user-edit',
|
|
'tone' => 'profile',
|
|
'url' => isset($dashboard_tabs['profile']) ? aksrt_get_user_center_tab_url('profile') : '',
|
|
],
|
|
[
|
|
'label' => __('账户安全', 'aksrt'),
|
|
'icon' => 'shield-alt',
|
|
'tone' => 'security',
|
|
'url' => isset($dashboard_tabs['settings']) ? aksrt_get_user_center_tab_url('settings') : '',
|
|
],
|
|
], static fn(array $item): bool => (string) $item['url'] !== ''));
|
|
|
|
$render_grid = static function (array $items): void {
|
|
?>
|
|
<div class="uc-service-grid">
|
|
<?php foreach ($items as $item) : ?>
|
|
<a class="uc-service-grid__item uc-service-grid__item--<?php echo esc_attr((string) $item['tone']); ?>" href="<?php echo esc_url((string) $item['url']); ?>">
|
|
<span class="uc-service-grid__icon">
|
|
<i class="fas fa-<?php echo esc_attr((string) $item['icon']); ?>" aria-hidden="true"></i>
|
|
<?php if (!empty($item['count'])) : ?><small><?php echo esc_html((string) $item['count']); ?></small><?php endif; ?>
|
|
</span>
|
|
<span><?php echo esc_html((string) $item['label']); ?></span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php
|
|
};
|
|
?>
|
|
<?php if ($services) : ?>
|
|
<div class="uc-sidebar__section">
|
|
<div class="uc-sidebar__heading"><span><?php esc_html_e('我的服务', 'aksrt'); ?></span></div>
|
|
<?php $render_grid($services); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($settings) : ?>
|
|
<div class="uc-sidebar__section">
|
|
<div class="uc-sidebar__heading"><span><?php esc_html_e('功能设置', 'aksrt'); ?></span></div>
|
|
<?php $render_grid($settings); ?>
|
|
</div>
|
|
<?php endif; ?>
|