Files
wordpress-theme-aksrt/archive-resources.php
T
kate522andClaude Opus 5 35bb96e82f refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.

Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
  cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
  window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)

Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
  so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
  (dropped 3 stale entries, added the 17 missing ones)

Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
  get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
  when it is empty

Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.

Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-01 20:05:04 +08:00

189 lines
6.4 KiB
PHP

<?php
/**
* Resource Archive Template
*
* Virtual list at /resources/ — ordinary posts marked with _jio_is_resource.
*
* @package Jio
*/
defined('ABSPATH') || exit;
get_header();
$current_orderby = isset($_GET['orderby']) ? sanitize_key((string) $_GET['orderby']) : 'date';
$allowed_orderby = ['date', 'downloads', 'views'];
if (!in_array($current_orderby, $allowed_orderby, true)) {
$current_orderby = 'date';
}
$current_price = isset($_GET['price']) ? sanitize_key((string) $_GET['price']) : 'all';
if (!in_array($current_price, ['all', 'free', 'paid'], true)) {
$current_price = 'all';
}
$price_min = isset($_GET['price_min']) && $_GET['price_min'] !== '' ? (float) $_GET['price_min'] : '';
$price_max = isset($_GET['price_max']) && $_GET['price_max'] !== '' ? (float) $_GET['price_max'] : '';
$archive_url = function_exists('jio_resource_archive_url') ? jio_resource_archive_url() : home_url('/resources/');
$sort_options = [
'date' => __('最新', 'jio'),
'downloads' => __('热门下载', 'jio'),
'views' => __('阅读最多', 'jio'),
];
$price_options = [
'all' => __('全部', 'jio'),
'free' => __('免费', 'jio'),
'paid' => __('付费', 'jio'),
];
$preserve = [];
if ($current_orderby !== 'date') {
$preserve['orderby'] = $current_orderby;
}
if ($current_price !== 'all') {
$preserve['price'] = $current_price;
}
if ($price_min !== '' && $price_min > 0) {
$preserve['price_min'] = $price_min;
}
if ($price_max !== '') {
$preserve['price_max'] = $price_max;
}
$has_filter = $current_orderby !== 'date' || $current_price !== 'all' || $price_min !== '' || $price_max !== '';
?>
<main id="main-content" class="site-main container" tabindex="-1">
<header class="resource-archive-header page-cover">
<div class="container">
<?php if (function_exists('jio_breadcrumbs')) : ?>
<nav class="resource-archive-header__breadcrumbs" aria-label="<?php esc_attr_e('面包屑', 'jio'); ?>">
<?php jio_breadcrumbs(); ?>
</nav>
<?php endif; ?>
<h1 class="resource-archive-header__title"><?php esc_html_e('资源', 'jio'); ?></h1>
<p class="resource-archive-header__sub">
<?php
global $wp_query;
/* translators: %s: resource count */
printf(esc_html__('共 %s 个资源', 'jio'), esc_html(number_format_i18n((int) $wp_query->found_posts)));
?>
</p>
</div>
</header>
<div class="content-wrap">
<div class="content-layout content-layout--no-sidebar">
<div class="content-layout__primary resource-archive">
<nav class="resource-archive__toolbar" aria-label="<?php esc_attr_e('筛选', 'jio'); ?>">
<div class="resource-archive__filter-group">
<span class="resource-archive__filter-label"><?php esc_html_e('排序', 'jio'); ?></span>
<ul class="resource-archive__sort">
<?php foreach ($sort_options as $key => $label) :
$args = $preserve;
if ($key === 'date') {
unset($args['orderby']);
} else {
$args['orderby'] = $key;
}
$url = $args ? add_query_arg($args, $archive_url) : $archive_url;
$active = $current_orderby === $key;
?>
<li>
<a href="<?php echo esc_url($url); ?>"
class="resource-archive__sort-link<?php echo $active ? ' is-active' : ''; ?>"
<?php echo $active ? 'aria-current="true"' : ''; ?>>
<?php echo esc_html($label); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<div class="resource-archive__filter-group">
<span class="resource-archive__filter-label"><?php esc_html_e('价格', 'jio'); ?></span>
<ul class="resource-archive__sort">
<?php foreach ($price_options as $key => $label) :
$args = $preserve;
if ($key === 'all') {
unset($args['price']);
} else {
$args['price'] = $key;
}
unset($args['price_min'], $args['price_max']);
$url = $args ? add_query_arg($args, $archive_url) : $archive_url;
$active = $current_price === $key;
?>
<li>
<a href="<?php echo esc_url($url); ?>"
class="resource-archive__sort-link<?php echo $active ? ' is-active' : ''; ?>"
<?php echo $active ? 'aria-current="true"' : ''; ?>>
<?php echo esc_html($label); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
<form class="resource-archive__price-range" method="get" action="<?php echo esc_url($archive_url); ?>">
<?php
if ($current_orderby !== 'date') {
echo '<input type="hidden" name="orderby" value="' . esc_attr($current_orderby) . '">';
}
if ($current_price !== 'all') {
echo '<input type="hidden" name="price" value="' . esc_attr($current_price) . '">';
}
?>
<label class="resource-archive__price-input">
<span><?php esc_html_e('最低', 'jio'); ?></span>
<input type="number" name="price_min" min="0" step="1" value="<?php echo esc_attr((string) $price_min); ?>">
</label>
<span class="resource-archive__price-sep">—</span>
<label class="resource-archive__price-input">
<span><?php esc_html_e('最高', 'jio'); ?></span>
<input type="number" name="price_max" min="0" step="1" value="<?php echo esc_attr((string) $price_max); ?>">
</label>
<button type="submit" class="btn-primary btn-sm"><?php esc_html_e('应用', 'jio'); ?></button>
</form>
<?php if ($has_filter) : ?>
<a class="resource-archive__reset" href="<?php echo esc_url($archive_url); ?>">
<i class="fa fas fa-times-circle" aria-hidden="true"></i>
<?php esc_html_e('清除筛选', 'jio'); ?>
</a>
<?php endif; ?>
</nav>
<?php if (have_posts()) : ?>
<?php
$render_config = jio_resolve_post_list_render_config([
'context' => 'archive',
'overrides' => ['type' => 'card'],
]);
jio_render_post_list(array_merge($render_config, ['wrapper_class' => 'content-stream__list']));
jio_render_pagination(null, [
'query_context' => 'archive',
'render_config' => $render_config,
]);
?>
<?php else : ?>
<div class="no-results">
<p><?php esc_html_e('暂无资源。', 'jio'); ?></p>
<?php if ($has_filter) : ?>
<p><a class="btn-outline btn-sm" href="<?php echo esc_url($archive_url); ?>"><?php esc_html_e('清除筛选条件', 'jio'); ?></a></p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</main>
<?php
get_footer();