feat(user-center): redesign sidebar and wallet tips
This commit is contained in:
1 parent
82e71d1bf9
commit
a7f3caec59
24 files changed
+895
-528
No files matched your search
@@ -32,55 +32,6 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
|
||||
<?php require __DIR__ . '/form-contacts.php'; ?>
|
||||
|
||||
<?php
|
||||
$rewards_on = function_exists('aksrt_rewards_enabled') ? aksrt_rewards_enabled() : false;
|
||||
$rw = (string) get_user_meta((int) $user_id, 'aksrt_rewards_weixin', true);
|
||||
$ra = (string) get_user_meta((int) $user_id, 'aksrt_rewards_alipay', true);
|
||||
$rw_url = '';
|
||||
$ra_url = '';
|
||||
if (function_exists('aksrt_get_user_rewards_img_urls')) {
|
||||
$urls = aksrt_get_user_rewards_img_urls((int) $user_id);
|
||||
$rw_url = (string) ($urls['weixin'] ?? '');
|
||||
$ra_url = (string) ($urls['alipay'] ?? '');
|
||||
}
|
||||
?>
|
||||
<?php if ($rewards_on) : ?>
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e('打赏收款码', 'aksrt'); ?></h3>
|
||||
<p class="profile-hint"><?php esc_html_e('上传微信/支付宝收款码后,读者可在文章与作者卡赞赏你。留空则不显示赞赏按钮。', 'aksrt'); ?></p>
|
||||
<div class="aksrt-reward-upload-grid">
|
||||
<div class="aksrt-reward-upload">
|
||||
<label class="aksrt-reward-upload__label"><?php esc_html_e('微信收款码', 'aksrt'); ?></label>
|
||||
<div class="aksrt-reward-upload__preview" data-reward-preview="weixin">
|
||||
<?php if ($rw_url !== '') : ?>
|
||||
<img src="<?php echo esc_url($rw_url); ?>" alt="" />
|
||||
<?php else : ?>
|
||||
<span class="muted-2-color em09"><?php esc_html_e('未上传', 'aksrt'); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<input type="hidden" name="rewards_weixin" id="rewards-weixin" value="<?php echo esc_attr($rw); ?>" />
|
||||
<input type="file" id="rewards-weixin-file" accept="image/*" class="aksrt-reward-upload__file" data-reward-kind="weixin" />
|
||||
<button type="button" class="btn-primary btn-sm" data-reward-upload="weixin"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
|
||||
<button type="button" class="btn-sm" data-reward-clear="weixin"><?php esc_html_e('清除', 'aksrt'); ?></button>
|
||||
</div>
|
||||
<div class="aksrt-reward-upload">
|
||||
<label class="aksrt-reward-upload__label"><?php esc_html_e('支付宝收款码', 'aksrt'); ?></label>
|
||||
<div class="aksrt-reward-upload__preview" data-reward-preview="alipay">
|
||||
<?php if ($ra_url !== '') : ?>
|
||||
<img src="<?php echo esc_url($ra_url); ?>" alt="" />
|
||||
<?php else : ?>
|
||||
<span class="muted-2-color em09"><?php esc_html_e('未上传', 'aksrt'); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<input type="hidden" name="rewards_alipay" id="rewards-alipay" value="<?php echo esc_attr($ra); ?>" />
|
||||
<input type="file" id="rewards-alipay-file" accept="image/*" class="aksrt-reward-upload__file" data-reward-kind="alipay" />
|
||||
<button type="button" class="btn-primary btn-sm" data-reward-upload="alipay"><?php esc_html_e('选择图片', 'aksrt'); ?></button>
|
||||
<button type="button" class="btn-sm" data-reward-clear="alipay"><?php esc_html_e('清除', 'aksrt'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="profile-form__submit">
|
||||
<button type="submit" class="btn-primary btn-lg" id="profile-save-btn">
|
||||
|
||||
@@ -25,27 +25,20 @@ $section = sanitize_key((string) ($_GET['section'] ?? ''));
|
||||
if ($tab === '' && isset($_GET['tab']) && sanitize_key((string) $_GET['tab']) !== 'orders') {
|
||||
// When rendered as standalone legacy include, outer tab may be status.
|
||||
$maybe = sanitize_key((string) $_GET['tab']);
|
||||
if (in_array($maybe, ['pending', 'shipped', 'received', 'review', 'after', 'wait-pay', 'wait-shipped', 'wait-receive', 'wait-evaluate', 'after-sale', 'all'], true)) {
|
||||
if (in_array($maybe, ['pending', 'to-ship', 'shipped', 'received', 'review', 'after'], true)) {
|
||||
$tab = $maybe;
|
||||
}
|
||||
}
|
||||
|
||||
$tab_aliases = [
|
||||
'wait-pay' => 'pending',
|
||||
'wait-shipped' => 'shipped',
|
||||
'wait-receive' => 'shipped',
|
||||
'wait-evaluate' => 'review',
|
||||
'after-sale' => 'after',
|
||||
'all' => '',
|
||||
];
|
||||
$tab_aliases = [];
|
||||
if (isset($tab_aliases[$tab])) {
|
||||
$tab = $tab_aliases[$tab];
|
||||
}
|
||||
|
||||
$tab_status_map = [
|
||||
'pending' => \AKSRT\Payment\Order::STATUS_PENDING,
|
||||
'to-ship' => \AKSRT\Payment\Order::STATUS_PAID,
|
||||
'shipped' => \AKSRT\Payment\Order::STATUS_DELIVERED,
|
||||
'received' => \AKSRT\Payment\Order::STATUS_COMPLETED,
|
||||
'review' => \AKSRT\Payment\Order::STATUS_PENDING_REVIEW,
|
||||
'after' => \AKSRT\Payment\Order::STATUS_REFUNDING,
|
||||
];
|
||||
@@ -70,6 +63,7 @@ $shop = class_exists('\AKSRT\Shop\Shop') ? \AKSRT\Shop\Shop::get_instance() : nu
|
||||
$tabs = [
|
||||
'' => __('全部', 'aksrt'),
|
||||
'pending' => __('待支付', 'aksrt'),
|
||||
'to-ship' => __('待发货', 'aksrt'),
|
||||
'shipped' => __('待收货', 'aksrt'),
|
||||
'review' => __('待评价', 'aksrt'),
|
||||
'after' => __('售后', 'aksrt'),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* User center profile sidebar part (orchestrator).
|
||||
* User center profile sidebar orchestrator.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -11,10 +11,11 @@ $context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
|
||||
require __DIR__ . '/sidebar-stats.php';
|
||||
require __DIR__ . '/sidebar-nav.php';
|
||||
require __DIR__ . '/sidebar-creator.php';
|
||||
require __DIR__ . '/sidebar-orders.php';
|
||||
require __DIR__ . '/sidebar-commerce.php';
|
||||
require __DIR__ . '/sidebar-creator.php';
|
||||
require __DIR__ . '/sidebar-nav.php';
|
||||
?>
|
||||
<button type="button" class="uc-sidebar__drawer-trigger" id="uc-drawer-trigger" aria-label="<?php esc_attr_e('打开导航', 'aksrt'); ?>">
|
||||
<i class="fas fa-bars" aria-hidden="true"></i>
|
||||
<i class="fas fa-th-large" aria-hidden="true"></i>
|
||||
</button>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* User center sidebar: Zibll dual asset mini cards + commerce shortcuts.
|
||||
* User center sidebar: balance and points pair.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -8,73 +8,32 @@
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$show_wallet = !empty($balance_enabled);
|
||||
$show_credits = !empty($show_credit_tabs) || !empty($credits_enabled);
|
||||
$wallet = (float) ($wallet_balance ?? 0.0);
|
||||
$points = (float) ($credit_balance ?? 0.0);
|
||||
$currency = (string) ($currency_name ?? __('积分', 'aksrt'));
|
||||
|
||||
if ($show_wallet || $show_credits) :
|
||||
$assets_url = function_exists('aksrt_get_user_center_tab_url')
|
||||
? aksrt_get_user_center_tab_url('credits')
|
||||
: '#';
|
||||
?>
|
||||
<div class="uc-sidebar__section">
|
||||
<div class="uc-sidebar__title"><?php esc_html_e('我的资产', 'aksrt'); ?></div>
|
||||
<div class="uc-asset-mini flex ab jsb col-ml6">
|
||||
<?php if ($show_wallet) : ?>
|
||||
<a class="uc-asset-mini__card flex1" href="<?php echo esc_url($assets_url); ?>">
|
||||
<div class="uc-asset-mini__label muted-2-color em09"><?php esc_html_e('余额', 'aksrt'); ?><i class="ml6 fa fa-angle-right em12" aria-hidden="true"></i></div>
|
||||
<div class="flex jsb ac">
|
||||
<span class="font-bold c-blue-2"><?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($wallet) : number_format_i18n($wallet, 2)); ?></span>
|
||||
<i class="fas fa-wallet em14 c-blue-2" aria-hidden="true"></i>
|
||||
</div>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($show_credits) : ?>
|
||||
<a class="uc-asset-mini__card flex1" href="<?php echo esc_url($assets_url); ?>">
|
||||
<div class="uc-asset-mini__label muted-2-color em09"><?php echo esc_html($currency); ?><i class="ml6 fa fa-angle-right em12" aria-hidden="true"></i></div>
|
||||
<div class="flex jsb ac">
|
||||
<span class="font-bold c-yellow"><?php echo esc_html(function_exists('aksrt_format_credits') ? aksrt_format_credits((int) $points) : (string) (int) $points); ?></span>
|
||||
<i class="fas fa-coins em14 c-yellow" aria-hidden="true"></i>
|
||||
</div>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if (empty($orders_url) && empty($show_vip) && empty($show_credit_tabs) && empty($balance_enabled) && empty($affiliate_enabled)) {
|
||||
$show_credits = !empty($credits_enabled) || !empty($show_credit_tabs);
|
||||
if (!$show_wallet && !$show_credits) {
|
||||
return;
|
||||
}
|
||||
|
||||
$assets_url = aksrt_get_user_center_tab_url('credits');
|
||||
$wallet = (float) ($wallet_balance ?? 0);
|
||||
$points = (float) ($credit_balance ?? 0);
|
||||
?>
|
||||
<div class="uc-sidebar__section">
|
||||
<div class="uc-sidebar__title"><?php esc_html_e('权益与消费', 'aksrt'); ?></div>
|
||||
<div class="uc-sidebar__buttons">
|
||||
<?php $revenue_url = function_exists('aksrt_get_revenue_page_url') ? aksrt_get_revenue_page_url() : ''; ?>
|
||||
<?php
|
||||
$orders_href = !empty($orders_url)
|
||||
? (string) $orders_url
|
||||
: (function_exists('aksrt_get_user_center_tab_url') ? aksrt_get_user_center_tab_url('orders') : '');
|
||||
if ($orders_href !== '') :
|
||||
$orders_active = !empty($active_tab) && $active_tab === 'orders';
|
||||
?>
|
||||
<a href="<?php echo esc_url($orders_href); ?>" class="uc-sidebar__btn<?php echo $orders_active ? ' is-active' : ''; ?>" data-tab="orders">
|
||||
<i class="fas fa-receipt" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('我的订单', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($show_vip)) : ?>
|
||||
<a class="uc-sidebar__btn payvip-icon<?php echo (!empty($active_tab) && $active_tab === 'vip') ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('vip')); ?>" data-tab="vip">
|
||||
<i class="fas fa-crown" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('VIP 会员', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($affiliate_enabled) && $revenue_url) : ?>
|
||||
<a href="<?php echo esc_url($revenue_url); ?>" class="uc-sidebar__btn">
|
||||
<i class="fas fa-share-alt" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('推广返佣', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-sidebar__pair uc-sidebar__pair--assets">
|
||||
<?php if ($show_wallet) : ?>
|
||||
<a class="uc-summary-card uc-summary-card--wallet" href="<?php echo esc_url($assets_url); ?>">
|
||||
<span class="uc-summary-card__head"><?php esc_html_e('账户余额', 'aksrt'); ?><i class="fas fa-angle-right" aria-hidden="true"></i></span>
|
||||
<span class="uc-summary-card__body">
|
||||
<strong><?php echo esc_html(class_exists('\AKSRT\Credits\Balance') ? \AKSRT\Credits\Balance::format($wallet) : number_format_i18n($wallet, 2)); ?></strong>
|
||||
<i class="fas fa-wallet" aria-hidden="true"></i>
|
||||
</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($show_credits) : ?>
|
||||
<a class="uc-summary-card uc-summary-card--points" href="<?php echo esc_url(add_query_arg('asset_tab', 'points', $assets_url)); ?>">
|
||||
<span class="uc-summary-card__head"><?php echo esc_html((string) ($currency_name ?? __('积分', 'aksrt'))); ?><i class="fas fa-angle-right" aria-hidden="true"></i></span>
|
||||
<span class="uc-summary-card__body">
|
||||
<strong><?php echo esc_html(function_exists('aksrt_format_credits') ? aksrt_format_credits((int) $points) : number_format_i18n((int) $points)); ?></strong>
|
||||
<i class="fas fa-coins" aria-hidden="true"></i>
|
||||
</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -1,47 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* User center sidebar: creator and community shortcuts.
|
||||
* User center sidebar: creation and promotion center pair.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$creator_links = array_filter([
|
||||
[
|
||||
'url' => (string) ($new_post_url ?? ''),
|
||||
'icon' => 'pen',
|
||||
'label' => __('发布文章', 'aksrt'),
|
||||
],
|
||||
[
|
||||
'url' => (string) ($new_product_url ?? ''),
|
||||
'icon' => 'store',
|
||||
'label' => __('发布商品', 'aksrt'),
|
||||
],
|
||||
[
|
||||
'url' => (string) ($forum_compose_url ?? ''),
|
||||
'icon' => 'comments',
|
||||
'label' => __('论坛发帖', 'aksrt'),
|
||||
],
|
||||
[
|
||||
'url' => (string) ($revenue_url ?? ''),
|
||||
'icon' => 'chart-line',
|
||||
'label' => __('创作收益', 'aksrt'),
|
||||
],
|
||||
], static fn(array $item): bool => $item['url'] !== '');
|
||||
$creation_url = (string) ($new_post_url ?? '');
|
||||
if ($creation_url === '') {
|
||||
$creation_url = isset($dashboard_tabs['posts']) ? aksrt_get_user_center_tab_url('posts') : '';
|
||||
}
|
||||
$promotion_url = (string) ($revenue_url ?? '');
|
||||
|
||||
if (!$creator_links) {
|
||||
return;
|
||||
if ($creation_url === '' && $promotion_url === '') {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="uc-sidebar__section">
|
||||
<div class="uc-sidebar__title"><?php esc_html_e('创作服务', 'aksrt'); ?></div>
|
||||
<div class="uc-sidebar__buttons">
|
||||
<?php foreach ($creator_links as $item) : ?>
|
||||
<a class="uc-sidebar__btn" href="<?php echo esc_url($item['url']); ?>">
|
||||
<i class="fas fa-<?php echo esc_attr($item['icon']); ?>" aria-hidden="true"></i>
|
||||
<span><?php echo esc_html($item['label']); ?></span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="uc-sidebar__pair uc-sidebar__pair--centers">
|
||||
<?php if ($creation_url !== '') : ?>
|
||||
<a class="uc-center-card uc-center-card--creation" href="<?php echo esc_url($creation_url); ?>">
|
||||
<span class="uc-center-card__icon"><i class="fas fa-feather-alt" aria-hidden="true"></i></span>
|
||||
<span><strong><?php esc_html_e('创作中心', 'aksrt'); ?></strong><small><?php esc_html_e('发布与管理内容', 'aksrt'); ?></small></span>
|
||||
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($promotion_url !== '') : ?>
|
||||
<a class="uc-center-card uc-center-card--promotion" href="<?php echo esc_url($promotion_url); ?>">
|
||||
<span class="uc-center-card__icon"><i class="fas fa-bullhorn" aria-hidden="true"></i></span>
|
||||
<span><strong><?php esc_html_e('推广中心', 'aksrt'); ?></strong><small><?php esc_html_e('返佣与收益', 'aksrt'); ?></small></span>
|
||||
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -1,36 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* User center sidebar: main service navigation.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
* User center sidebar: services and account settings.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
?>
|
||||
<div class="uc-sidebar__section">
|
||||
<div class="uc-sidebar__title"><?php esc_html_e('我的服务', 'aksrt'); ?></div>
|
||||
<div class="uc-sidebar__buttons">
|
||||
<?php foreach ($dashboard_tabs as $tab_key => $tab) :
|
||||
// VIP / 订单 only under 权益与消费 (sidebar-commerce), not duplicated here.
|
||||
if (in_array((string) $tab_key, ['vip', 'orders'], true)) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<a class="uc-sidebar__btn<?php echo $active_tab === $tab_key ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url($tab_key)); ?>" data-tab="<?php echo esc_attr($tab_key); ?>">
|
||||
<i class="fas fa-<?php echo esc_attr($tab['icon']); ?>" aria-hidden="true"></i>
|
||||
<span><?php echo esc_html($tab['label']); ?></span>
|
||||
|
||||
$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; ?>
|
||||
<?php if (!empty($messages_url)) : ?>
|
||||
<a href="<?php echo esc_url($messages_url); ?>" class="uc-sidebar__btn">
|
||||
<i class="fas fa-bell" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('消息通知', 'aksrt'); ?></span>
|
||||
<?php if ($notification_unread_count > 0) : ?>
|
||||
<span class="uc-sidebar__badge"><?php echo esc_html((string) $notification_unread_count); ?></span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</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; ?>
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* User center sidebar: task-oriented order shortcuts.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$orders_base_url = (string) ($orders_url ?? '');
|
||||
if ($orders_base_url === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$order_stats = class_exists('\AKSRT\Payment\Order')
|
||||
? \AKSRT\Payment\Order::get_instance()->get_stats((int) ($user_id ?? 0))
|
||||
: [];
|
||||
$order_items = [
|
||||
[
|
||||
'label' => __('待支付', 'aksrt'),
|
||||
'icon' => 'wallet',
|
||||
'tab' => 'pending',
|
||||
'count' => (int) ($order_stats['pending'] ?? 0),
|
||||
],
|
||||
[
|
||||
'label' => __('待发货', 'aksrt'),
|
||||
'icon' => 'gift',
|
||||
'tab' => 'to-ship',
|
||||
'count' => (int) ($order_stats['paid'] ?? 0),
|
||||
],
|
||||
[
|
||||
'label' => __('待收货', 'aksrt'),
|
||||
'icon' => 'truck',
|
||||
'tab' => 'shipped',
|
||||
'count' => (int) ($order_stats['delivered'] ?? 0),
|
||||
],
|
||||
[
|
||||
'label' => __('待评价', 'aksrt'),
|
||||
'icon' => 'comment-dots',
|
||||
'tab' => 'review',
|
||||
'count' => (int) ($order_stats['pending_review'] ?? 0),
|
||||
],
|
||||
[
|
||||
'label' => __('售后', 'aksrt'),
|
||||
'icon' => 'undo-alt',
|
||||
'tab' => 'after',
|
||||
'count' => (int) ($order_stats['refunding'] ?? 0),
|
||||
],
|
||||
];
|
||||
?>
|
||||
<div class="uc-sidebar__section uc-order-card">
|
||||
<div class="uc-sidebar__heading">
|
||||
<span><?php esc_html_e('我的订单', 'aksrt'); ?></span>
|
||||
<a href="<?php echo esc_url($orders_base_url); ?>">
|
||||
<?php esc_html_e('全部', 'aksrt'); ?><i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="uc-order-grid">
|
||||
<?php foreach ($order_items as $item) :
|
||||
$item_url = add_query_arg('order_tab', $item['tab'], $orders_base_url);
|
||||
?>
|
||||
<a class="uc-order-grid__item" href="<?php echo esc_url($item_url); ?>">
|
||||
<span class="uc-order-grid__icon">
|
||||
<i class="fas fa-<?php echo esc_attr((string) $item['icon']); ?>" aria-hidden="true"></i>
|
||||
<?php if ($item['count'] > 0) : ?>
|
||||
<small><?php echo esc_html($item['count'] > 99 ? '99+' : (string) $item['count']); ?></small>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<span><?php echo esc_html((string) $item['label']); ?></span>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,34 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* User center sidebar: stats section.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
* User center sidebar: one-line account statistics.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$public_home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($target_user ?? null) : '';
|
||||
$stats = [
|
||||
[
|
||||
'label' => __('文章', 'aksrt'),
|
||||
'value' => (int) ($post_count ?? 0),
|
||||
'url' => isset($dashboard_tabs['posts']) ? aksrt_get_user_center_tab_url('posts') : $public_home_url,
|
||||
],
|
||||
[
|
||||
'label' => __('评论', 'aksrt'),
|
||||
'value' => (int) ($comment_count ?? 0),
|
||||
'url' => isset($dashboard_tabs['comments']) ? aksrt_get_user_center_tab_url('comments') : $public_home_url,
|
||||
],
|
||||
[
|
||||
'label' => __('收藏', 'aksrt'),
|
||||
'value' => (int) ($favorite_count ?? 0),
|
||||
'url' => isset($dashboard_tabs['favorites']) ? aksrt_get_user_center_tab_url('favorites') : $public_home_url,
|
||||
],
|
||||
[
|
||||
'label' => __('粉丝', 'aksrt'),
|
||||
'value' => (int) ($follower_count ?? 0),
|
||||
'url' => $public_home_url !== '' ? add_query_arg(['tab' => 'follow', 'follow_sub' => 'followers'], $public_home_url) : '',
|
||||
],
|
||||
];
|
||||
?>
|
||||
<div class="uc-sidebar__section">
|
||||
<div class="uc-sidebar__title"><?php esc_html_e('数据统计', 'aksrt'); ?></div>
|
||||
<div class="uc-sidebar__section uc-sidebar__section--stats" aria-label="<?php esc_attr_e('账号统计', 'aksrt'); ?>">
|
||||
<div class="uc-stats">
|
||||
<?php foreach (['posts', 'comments', 'favorites'] as $stat_tab) : ?>
|
||||
<?php if (!isset($dashboard_tabs[$stat_tab])) { continue; } ?>
|
||||
<?php
|
||||
$stat_count = 'posts' === $stat_tab
|
||||
? $post_count
|
||||
: ('comments' === $stat_tab ? $comment_count : $favorite_count);
|
||||
?>
|
||||
<a class="uc-stats__item" href="<?php echo esc_url(add_query_arg('tab', $stat_tab, remove_query_arg('tab'))); ?>">
|
||||
<span class="uc-stats__value"><?php echo esc_html((string) $stat_count); ?></span>
|
||||
<span class="uc-stats__label"><?php echo esc_html($dashboard_tabs[$stat_tab]['label']); ?></span>
|
||||
<?php foreach ($stats as $stat) : ?>
|
||||
<a class="uc-stats__item" href="<?php echo esc_url((string) $stat['url']); ?>">
|
||||
<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; ?>
|
||||
<?php if (!empty($messages_url)) : ?>
|
||||
<a class="uc-stats__item" href="<?php echo esc_url($messages_url); ?>">
|
||||
<span class="uc-stats__value"><?php echo esc_html((string) $notification_unread_count); ?></span>
|
||||
<span class="uc-stats__label"><?php esc_html_e('通知', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user