feat(post-list): align list schema with Zibll paging contract

Replace the post_list.list admin contract with a dedicated schema module
using Zibll keys (paging_ajax_s, paging_ajax_ias_s, ajax_trigger,
ajax_nomore, list_orderby, post_list_author/time, target_blank). Runtime
derives numbered/load_more/infinite from those keys and applies list
orderby on main queries without legacy dual-write layers.
This commit is contained in:
kate522 committed 2026-07-11 13:49:48 +08:00
1 parent 63efe5b5a8
commit 6a9db98204
9 files changed
+652 -280

No files matched your search

@@ -0,0 +1,284 @@
<?php
/**
* Post list — "list" section schema (Zibll-aligned field contract).
*
* Storage keys mirror Zibll option IDs where the admin list section is the source of truth.
* Runtime maps them into render modes; no legacy key fallbacks.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
class AKSRT_Admin_Schema_Post_List_List {
public static function build(): array {
return [
'key' => 'list',
'title' => '文章列表',
'version' => '2.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
[
'key' => 'order',
'title' => '默认排序与置顶',
'fields' => [
[
'key' => 'list_orderby',
'label' => '默认排序方式',
'type' => 'radio',
'default' => 'modified',
'options' => [
['label' => '发布时间', 'value' => 'date'],
['label' => '更新时间', 'value' => 'modified'],
['label' => 'WP默认', 'value' => 'default'],
],
'help' => '文章列表全局默认排序(对齐 Zibll list_orderby)',
],
[
'key' => 'sticky_s',
'label' => '显示置顶文章',
'type' => 'checkbox',
'default' => ['home', 'cat'],
'options' => [
['label' => '首页', 'value' => 'home'],
['label' => '分类页', 'value' => 'cat'],
['label' => '标签页', 'value' => 'tag'],
['label' => '专题页', 'value' => 'topics'],
],
],
],
],
[
'key' => 'display',
'title' => '列表显示',
'fields' => [
[
'key' => 'target_blank',
'label' => '新窗口打开文章',
'type' => 'switch',
'default' => false,
],
[
'key' => 'item_heading_bold',
'label' => '列表标题粗体显示',
'type' => 'switch',
'default' => false,
],
[
'key' => 'post_list_author',
'label' => '显示文章作者',
'type' => 'switch',
'default' => true,
],
[
'key' => 'post_list_time',
'label' => '显示文章时间',
'type' => 'switch',
'default' => true,
'help' => '建议作者与时间至少开启一项',
],
[
'key' => 'list_meta_show',
'label' => '列表小部件(移动端优先)',
'type' => 'radio',
'default' => 'like',
'options' => [
['label' => '阅读量', 'value' => 'view'],
['label' => '点赞数', 'value' => 'like'],
['label' => '评论', 'value' => 'comm'],
],
'help' => '移动端空间不足时始终保留的部件',
],
[
'key' => 'list_badge_show',
'label' => '列表徽章',
'type' => 'checkbox',
'default' => ['pay', 'tag', 'topics', 'cat'],
'options' => [
['label' => '付费', 'value' => 'pay'],
['label' => '分类', 'value' => 'cat'],
['label' => '专题', 'value' => 'topics'],
['label' => '标签', 'value' => 'tag'],
],
],
],
],
[
'key' => 'paging',
'title' => '列表翻页',
'fields' => [
[
'key' => 'paging_ajax_s',
'label' => '列表翻页模式',
'type' => 'radio',
'default' => '1',
'options' => [
['label' => 'AJAX 追加列表翻页', 'value' => '1'],
['label' => '数字翻页按钮', 'value' => '0'],
],
'help' => '对齐 Zibll paging_ajax_s;单页数量仍受 WP 阅读设置影响',
],
[
'key' => 'paging_ajax_ias_s',
'label' => 'AJAX 自动加载',
'type' => 'switch',
'default' => true,
'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1'],
'help' => '滚动到列表尽头时自动加载下一页(Zibll paging_ajax_ias_s)',
],
[
'key' => 'ias_max',
'label' => '自动加载页数',
'type' => 'number',
'default' => 3,
'min' => 0,
'max' => 10,
'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1'],
'help' => '0 表示不限制,直到加载完全部列表',
],
[
'key' => 'ajax_trigger',
'label' => '加载更多文案',
'type' => 'input',
'default' => '加载更多',
'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1'],
],
[
'key' => 'ajax_nomore',
'label' => '没有更多文案',
'type' => 'input',
'default' => '没有更多了',
'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1'],
],
],
],
[
'key' => 'card',
'title' => '卡片与布局',
'fields' => [
[
'key' => 'post_card_style',
'label' => '列表卡片样式',
'type' => 'select',
'default' => 'thumb',
'options' => [
['label' => '标准图文', 'value' => 'thumb'],
['label' => '紧凑卡', 'value' => 'compact'],
['label' => '大图卡', 'value' => 'large_thumb'],
['label' => '多图卡', 'value' => 'multi_thumb'],
['label' => '纯文字', 'value' => 'text'],
['label' => '有图则图文', 'value' => 'thumb_if_has'],
['label' => '卡片模式', 'value' => 'card'],
],
],
[
'key' => 'post_excerpt_length',
'label' => '摘要长度',
'type' => 'number',
'default' => 120,
'min' => 20,
'max' => 500,
],
[
'key' => 'post_list_per_page',
'label' => '每页文章数',
'type' => 'number',
'default' => 12,
'min' => 4,
'max' => 48,
],
[
'key' => 'list_show_type',
'label' => '列表间距样式',
'type' => 'radio',
'default' => 'separate',
'options' => [
['label' => '分隔卡片', 'value' => 'separate'],
['label' => '无间距', 'value' => 'no_margin'],
],
],
[
'key' => 'list_list_style',
'label' => '列表样式变体',
'type' => 'radio',
'default' => '',
'options' => [
['label' => '默认', 'value' => ''],
['label' => '样式2', 'value' => 'style2'],
],
],
[
'key' => 'list_list_img_position',
'label' => '列表缩略图位置',
'type' => 'radio',
'default' => 'left',
'options' => [
['label' => '左侧', 'value' => 'left'],
['label' => '右侧', 'value' => 'right'],
],
],
[
'key' => 'list_list_scale',
'label' => '列表缩略图比例 (%)',
'type' => 'number',
'default' => 70,
'min' => 50,
'max' => 200,
],
[
'key' => 'list_card_style',
'label' => '卡片样式变体',
'type' => 'radio',
'default' => '',
'options' => [
['label' => '默认', 'value' => ''],
['label' => '样式3', 'value' => 'style3'],
],
],
[
'key' => 'list_card_scale',
'label' => '卡片缩略图比例 (%)',
'type' => 'number',
'default' => 70,
'min' => 20,
'max' => 200,
],
[
'key' => 'list_card_home',
'label' => '首页卡片模式',
'type' => 'switch',
'default' => false,
],
[
'key' => 'list_card_cat',
'label' => '分类卡片模式',
'type' => 'taxonomy_select',
'taxonomy' => 'category',
'multiple' => true,
'default' => [],
],
[
'key' => 'list_card_tag',
'label' => '标签页卡片模式',
'type' => 'switch',
'default' => false,
],
[
'key' => 'list_card_topics',
'label' => '专题页卡片模式',
'type' => 'switch',
'default' => false,
],
[
'key' => 'list_card_author',
'label' => '用户页卡片模式',
'type' => 'switch',
'default' => false,
],
],
],
],
];
}
}