Files
wordpress-theme-aksrt/inc/helpers/user-center-renderers/sidebar-nav.php
T

92 lines
2.9 KiB
PHP

<?php
/**
* User center sidebar: services and account settings.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$level_url = isset($dashboard_tabs['level'])
? aksrt_get_user_center_tab_url('level')
: '';
$auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : '';
$orders_available = isset($dashboard_tabs['orders']);
$orders_url = $orders_available ? (string) ($orders_url ?? '') : '';
$services = array_values(array_filter([
[
'label' => __('我的等级', 'aksrt'),
'icon' => 'chart-line',
'tone' => 'level',
'url' => $level_url,
],
[
'label' => __('官方认证', 'aksrt'),
'icon' => 'id-badge',
'tone' => 'auth',
'url' => $auth_url,
'tab' => 'auth',
],
[
'label' => __('我的订单', 'aksrt'),
'icon' => 'receipt',
'tone' => 'orders',
'url' => $orders_url,
'tab' => 'orders',
],
], 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']); ?><?php echo !empty($item['tab']) && ($active_tab ?? '') === $item['tab'] ? ' is-active' : ''; ?>" href="<?php echo esc_url((string) $item['url']); ?>"<?php if (!empty($item['tab'])) : ?> data-tab="<?php echo esc_attr((string) $item['tab']); ?>"<?php endif; ?>>
<span class="uc-service-grid__icon">
<i class="fa 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; ?>