进行了一些小优化

This commit is contained in:
2026-08-24 17:35:46 +08:00
parent 85a124b886
commit 9d3bfb91cd
7 changed files with 45 additions and 39 deletions
@@ -15,7 +15,7 @@ if ($user_id <= 0) {
}
$raw_query = [
'status' => $_GET['order_status'] ?? '',
'status' => $_GET['order_status'] ?? 'all',
'type' => $_GET['order_type'] ?? '',
'order_number' => $_GET['order_number'] ?? '',
'page' => $_GET['order_page'] ?? 1,
@@ -52,7 +52,7 @@ $orders_url = static function (array $override = []) use ($status, $type, $order
return add_query_arg($values, remove_query_arg(['order_tab', 'otab', 'section'], $base));
};
$tabs = [
$status_options = [
'all' => __('全部', 'aksrt'),
'pending' => __('待支付', 'aksrt'),
'paid' => __('已支付', 'aksrt'),
@@ -90,24 +90,28 @@ $tabs = [
</form>
<div id="aksrt-orders-filter-panel" class="aksrt-orders-page__filter-panel" data-aksrt-orders-filter-panel hidden>
<span class="aksrt-orders-page__filter-label"><?php esc_html_e('订单类型', 'aksrt'); ?></span>
<div class="aksrt-orders-page__type-filters">
<?php foreach ($type_options as $key => $label) : ?>
<a class="aksrt-orders-page__filter-chip<?php echo (string) $key === $type ? ' is-active' : ''; ?>" href="<?php echo esc_url($orders_url(['order_type' => $key, 'order_page' => null])); ?>"><?php echo esc_html((string) $label); ?></a>
<?php endforeach; ?>
<div class="aksrt-orders-page__filter-group">
<span class="aksrt-orders-page__filter-label"><?php esc_html_e('订单状态', 'aksrt'); ?></span>
<nav class="aksrt-orders-page__status-filters" aria-label="<?php esc_attr_e('订单状态', 'aksrt'); ?>">
<?php foreach ($status_options as $key => $label) : ?>
<a class="aksrt-orders-page__filter-chip<?php echo $status === $key ? ' is-active' : ''; ?>" href="<?php echo esc_url($orders_url(['order_status' => $key, 'order_page' => null])); ?>">
<?php echo esc_html($label); ?>
<?php if ($key === 'pending' && !empty($stats['pending'])) : ?><span class="aksrt-orders-page__filter-count"><?php echo esc_html((string) $stats['pending']); ?></span><?php endif; ?>
</a>
<?php endforeach; ?>
</nav>
</div>
<div class="aksrt-orders-page__filter-group">
<span class="aksrt-orders-page__filter-label"><?php esc_html_e('订单类型', 'aksrt'); ?></span>
<div class="aksrt-orders-page__type-filters">
<?php foreach ($type_options as $key => $label) : ?>
<a class="aksrt-orders-page__filter-chip<?php echo (string) $key === $type ? ' is-active' : ''; ?>" href="<?php echo esc_url($orders_url(['order_type' => $key, 'order_page' => null])); ?>"><?php echo esc_html((string) $label); ?></a>
<?php endforeach; ?>
</div>
</div>
<a class="aksrt-orders-page__clear" href="<?php echo esc_url($orders_url(['order_status' => null, 'order_type' => null, 'order_number' => null, 'order_page' => null])); ?>"><?php esc_html_e('清除条件', 'aksrt'); ?></a>
</div>
<nav class="aksrt-orders-page__tabs" aria-label="<?php esc_attr_e('订单状态', 'aksrt'); ?>">
<?php foreach ($tabs as $key => $label) : ?>
<a class="aksrt-orders-page__tab<?php echo $status === $key ? ' is-active' : ''; ?>" href="<?php echo esc_url($orders_url(['order_status' => $key, 'order_page' => null])); ?>">
<?php echo esc_html($label); ?>
<?php if ($key === 'pending' && !empty($stats['pending'])) : ?><span class="aksrt-orders-page__tab-badge"><?php echo esc_html((string) $stats['pending']); ?></span><?php endif; ?>
</a>
<?php endforeach; ?>
</nav>
<?php if ($orders !== []) : ?>
<div class="aksrt-orders-page__list" data-aksrt-order-list>
<?php foreach ($orders as $order) :