feat(admin): rebuild page display settings

This commit is contained in:
kate522 committed 2026-08-19 00:07:13 +08:00
1 parent 09b1e8fd35
commit 480e2bf07e
117 files changed
+1815 -9081

No files matched your search

+11 -35
View File
@@ -51,15 +51,11 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
* Homepage category tabs with full config.
*
* Returns enabled tabs in config order, each with 'term', 'title', 'orderby'.
* Uses homepage_tab_limit from settings.
* Preserves every configured row in the saved order.
*
* @return array<int, array{term:WP_Term, title:string, orderby:string, term_id:int}>
*/
function aksrt_homepage_get_tab_configs(): array {
$limit = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_tab_limit()
: 4;
if (!class_exists('\AKSRT\Settings\Settings')) {
return [];
}
@@ -73,12 +69,9 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
$configs = [];
foreach ($structured_tabs as $tab) {
if (empty($tab['enabled']) || $tab['term_id'] <= 0) {
if ($tab['term_id'] <= 0) {
continue;
}
if (count($configs) >= $limit) {
break;
}
if (isset($excluded_cat_ids[$tab['term_id']])) {
continue;
}
@@ -95,7 +88,7 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
'term' => $term,
'term_id' => (int) $tab['term_id'],
'title' => $tab['title'] !== '' ? $tab['title'] : $term->name,
'orderby' => $tab['orderby'] ?: 'date',
'orderby' => $tab['orderby'] ?: 'modified',
];
}
@@ -143,19 +136,6 @@ if (!function_exists('aksrt_homepage_sticky_tabs_enabled')) {
}
}
if (!function_exists('aksrt_homepage_module_banner_enabled')) {
/**
* Whether the fixed homepage should render the built-in banner section.
*/
function aksrt_homepage_module_banner_enabled(): bool {
if (class_exists('\AKSRT\Settings\Settings')) {
return \AKSRT\Settings\Settings::homepage_module_banner_enabled();
}
return true;
}
}
if (!function_exists('aksrt_homepage_get_sort_mode')) {
/**
* Current homepage main-stream sort mode.
@@ -163,10 +143,10 @@ if (!function_exists('aksrt_homepage_get_sort_mode')) {
function aksrt_homepage_get_sort_mode(): string {
$allowed = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
: ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'];
$default_sort = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_default_sort()
: 'date';
: 'modified';
$override_sort = get_query_var('aksrt_homepage_sort_override');
$sort = is_string($override_sort) && $override_sort !== ''
? sanitize_key($override_sort)
@@ -187,8 +167,7 @@ if (!function_exists('aksrt_homepage_get_sort_items')) {
? \AKSRT\Settings\Settings::homepage_sort_labels()
: [
'modified' => '更新', 'date' => '发布', 'views' => '浏览',
'likes' => '点赞', 'comments' => '评论', 'favorites' => '收藏',
'downloads' => '下载', 'rand' => '随机',
'like' => '点赞', 'comment_count' => '评论', 'favorite' => '收藏', 'rand' => '随机',
];
$enabled_keys = class_exists('\AKSRT\Settings\Settings')
@@ -239,20 +218,17 @@ if (!function_exists('aksrt_homepage_apply_sort_args')) {
$args['orderby'] = 'modified';
$args['order'] = 'DESC';
break;
case 'downloads':
$args = $apply_meta_sort($args, '_aksrt_res_download_count');
break;
case 'views':
// Canonical public views key (align hotspot consumers later).
$args = $apply_meta_sort($args, 'aksrt_post_views');
break;
case 'likes':
case 'like':
$args = $apply_meta_sort($args, '_aksrt_like_count');
break;
case 'favorites':
case 'favorite':
$args = $apply_meta_sort($args, '_aksrt_favorite_count');
break;
case 'comments':
case 'comment_count':
$args['orderby'] = 'comment_count';
$args['order'] = 'DESC';
break;
@@ -278,10 +254,10 @@ if (!function_exists('aksrt_homepage_apply_named_sort_args')) {
function aksrt_homepage_apply_named_sort_args(array $args, string $sort_mode): array {
$allowed = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
: ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'];
if (!in_array($sort_mode, $allowed, true)) {
$sort_mode = 'date';
$sort_mode = 'modified';
}
$previous = get_query_var('aksrt_homepage_sort_override');