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

@@ -14,104 +14,7 @@ class AKSRT_Admin_Schema_Post_List {
'domain' => 'post_list',
'title' => '文章&列表',
'sections' => [
'list' => [
'key' => 'list',
'title' => '文章列表',
'version' => '1.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['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' => 'meta', 'title' => '元信息显示', 'fields' => [
['key' => 'post_show_author', 'label' => '显示作者', 'type' => 'switch', 'default' => true],
['key' => 'post_show_date', 'label' => '显示日期', 'type' => 'switch', 'default' => true],
['key' => 'post_show_views', 'label' => '显示浏览数', 'type' => 'switch', 'default' => true],
['key' => 'post_show_category', 'label' => '显示分类', 'type' => 'switch', 'default' => true],
['key' => 'post_show_tags', 'label' => '显示标签', 'type' => 'switch', 'default' => false],
['key' => 'post_show_comments', 'label' => '显示评论数', 'type' => 'switch', 'default' => false],
['key' => 'post_show_likes', 'label' => '显示点赞数', 'type' => 'switch', 'default' => false],
['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' => 'post_list_meta_show', 'label' => '显示元信息', 'type' => 'switch', 'default' => true],
['key' => 'list_meta_show', 'label' => '移动端优先部件', 'type' => 'radio', 'default' => 'like', 'options' => [
['label' => '浏览数', 'value' => 'view'],
['label' => '点赞数', 'value' => 'like'],
['label' => '评论数', 'value' => 'comm'],
], 'description' => '移动端空间不足时保留显示的单一部件'],
]],
['key' => 'layout', 'title' => '布局设置', 'fields' => [
['key' => 'post_list_columns', 'label' => '列表列数', 'type' => 'number', 'default' => 1, 'min' => 1, 'max' => 3],
['key' => 'post_list_per_page', 'label' => '每页文章数', 'type' => 'number', 'default' => 12, 'min' => 4, 'max' => 48],
['key' => 'sticky_s', 'label' => '置顶范围', 'type' => 'checkbox', 'default' => ['home', 'cat'], 'options' => [
['label' => '首页', 'value' => 'home'],
['label' => '分类页', 'value' => 'cat'],
['label' => '标签页', 'value' => 'tag'],
['label' => '专题页', 'value' => 'topics'],
]],
['key' => 'post_target_blank', 'label' => '新窗口打开', 'type' => 'switch', 'default' => false],
['key' => 'item_heading_bold', 'label' => '标题加粗', 'type' => 'switch', 'default' => false],
['key' => 'list_show_type', 'label' => '列表样式', 'type' => 'radio', 'default' => 'separate', 'options' => [
['label' => '分隔卡片', 'value' => 'separate'],
['label' => '无间距', 'value' => 'no_margin'],
]],
['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],
]],
['key' => 'pagination', 'title' => '分页方式', 'fields' => [
['key' => 'post_pagination_mode', 'label' => '分页模式', 'type' => 'radio', 'default' => 'numbered', 'options' => [
['label' => '数字分页', 'value' => 'numbered'],
['label' => '加载更多', 'value' => 'load_more'],
['label' => '无限滚动', 'value' => 'infinite'],
]],
['key' => 'ias_max', 'label' => '最大加载页数', 'type' => 'number', 'default' => 3, 'min' => 0, 'max' => 10, 'description' => '0=不限'],
['key' => 'ajax_trigger_text', 'label' => '加载更多文案', 'type' => 'input', 'default' => ''],
['key' => 'ajax_nomore_text', 'label' => '没有更多文案', 'type' => 'input', 'default' => ''],
]],
['key' => 'sort', 'title' => '默认排序', 'fields' => [
['key' => 'list_orderby', 'label' => '列表默认排序', 'type' => 'radio', 'default' => 'modified', 'options' => [
['label' => '更新时间', 'value' => 'modified'],
['label' => '发布时间', 'value' => 'date'],
['label' => '评论数', 'value' => 'comments'],
['label' => 'WordPress 默认', 'value' => 'default'],
], 'help' => '分类/标签/归档页面的默认排序方式'],
]],
['key' => 'list_option', 'title' => '列表模式配置', 'fields' => [
['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' => 'card_option', 'title' => '卡片模式配置', 'fields' => [
['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],
]],
],
],
'list' => AKSRT_Admin_Schema_Post_List_List::build(),
'thumb' => [
'key' => 'thumb',
'title' => '列表缩略图',
@@ -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,
],
],
],
],
];
}
}
+1 -1
View File
@@ -470,7 +470,7 @@ class AKSRT_Settings {
* Only fires when no explicit orderby is set by URL params or other hooks.
*/
public static function apply_list_orderby($query): void {
AKSRT_Settings_Theme_Search::apply_list_orderby($query);
AKSRT_Settings_Post_Display::apply_list_orderby($query);
}
/**
@@ -1118,7 +1118,7 @@ trait AKSRT_Scripts_Part_1b {
'themeMode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::theme_mode_js_value() : 'auto',
'debug' => defined('WP_DEBUG') && WP_DEBUG,
'debugLog' => defined('WP_DEBUG') && WP_DEBUG && defined('WP_DEBUG_LOG') && WP_DEBUG_LOG,
'postPaginationMode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_pagination_mode() : 'numbered',
'postPaginationMode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_post_pagination_mode() : 'load_more',
'commentPaginationMode' => class_exists('AKSRT_Settings') ? AKSRT_Settings::get_comment_pagination_mode() : 'numbered',
'homepagePostsPerPage' => function_exists('aksrt_homepage_get_tab_posts_per_page') ? aksrt_homepage_get_tab_posts_per_page() : (int) get_option('posts_per_page'),
'homepageDefaultSort' => class_exists('AKSRT_Settings') ? AKSRT_Settings::homepage_default_sort() : 'modified',
@@ -162,23 +162,26 @@ trait AKSRT_Settings_Display_Page_Groups {
return [
'list' => [
'post_card_style' => $list['card_style'],
'post_show_author' => $list['show_author'],
'post_list_author' => $list['show_author'],
'post_show_date' => $list['show_date'],
'post_show_views' => $list['show_views'],
'post_show_category' => $list['show_category'],
'post_show_comments' => $list['show_comments'],
'post_show_likes' => $list['show_likes'],
'post_excerpt_length' => $list['excerpt_length'],
'paging_ajax_s' => AKSRT_Settings_Post_Display::is_list_paging_ajax() ? '1' : '0',
'paging_ajax_ias_s' => AKSRT_Settings_Post_Display::is_list_paging_ajax_ias(),
'post_pagination_mode' => self::get_post_pagination_mode(),
'render_mode' => $list['render_mode'],
'sticky_s' => $list['sticky_pages'],
'list_badge_show' => $list['badge_types'],
'post_target_blank' => $list['target_blank'],
'target_blank' => $list['target_blank'],
'item_heading_bold' => $list['heading_bold'],
'list_meta_show' => $list['mobile_meta'],
'list_show_type' => $list['list_show_type'],
'ias_max' => $list['ias_max'],
'ajax_trigger_text' => $list['ajax_trigger_text'],
'ajax_trigger' => $list['ajax_trigger_text'],
'ajax_nomore' => $list['ajax_nomore_text'],
'ajax_nomore_text' => $list['ajax_nomore_text'],
'post_list_columns' => $list['columns'],
'post_list_per_page' => $list['per_page'],
@@ -11,76 +11,105 @@ class AKSRT_Settings_Post_Display {
public static function get_post_list_style_settings(): array {
$settings = AKSRT_Settings::get_all();
$card_style = sanitize_key((string) ($settings['post_card_style'] ?? 'standard'));
$allowed_styles = ['standard', 'compact', 'large_thumb', 'multi_thumb', 'text', 'thumb_if_has'];
$card_style = sanitize_key((string) ($settings['post_card_style'] ?? 'thumb'));
$allowed_styles = ['thumb', 'compact', 'large_thumb', 'multi_thumb', 'text', 'thumb_if_has', 'card', 'standard'];
if (!in_array($card_style, $allowed_styles, true)) {
$card_style = 'standard';
$card_style = 'thumb';
}
// historical alias
if ($card_style === 'standard') {
$card_style = 'thumb';
}
$render_mode_map = [
'standard' => 'card',
'thumb' => 'card',
'compact' => 'list',
'large_thumb' => 'list',
'multi_thumb' => 'list',
'text' => 'list',
'thumb_if_has' => 'list',
'card' => 'card',
];
$sticky_pages_raw = $settings['sticky_s'] ?? null;
if (is_array($sticky_pages_raw)) {
$allowed_pages = ['home', 'cat', 'tag', 'topics'];
$sticky_pages = array_values(array_intersect(array_map('sanitize_key', $sticky_pages_raw), $allowed_pages));
} elseif (!isset($settings['post_sticky_enabled']) || !empty($settings['post_sticky_enabled'])) {
$sticky_pages = ['home', 'cat'];
} else {
$sticky_pages = [];
$sticky_pages = ['home', 'cat'];
}
$badge_types_raw = $settings['list_badge_show'] ?? null;
if (is_array($badge_types_raw)) {
$allowed_types = ['pay', 'cat', 'topics', 'tag'];
$badge_types = array_values(array_intersect(array_map('sanitize_key', $badge_types_raw), $allowed_types));
} elseif (!isset($settings['post_list_badge_show']) || !empty($settings['post_list_badge_show'])) {
$badge_types = ['pay', 'cat', 'topics', 'tag'];
} else {
$badge_types = [];
$badge_types = ['pay', 'cat', 'topics', 'tag'];
}
$show_author = array_key_exists('post_list_author', $settings)
? !empty($settings['post_list_author'])
: (!isset($settings['post_show_author']) || !empty($settings['post_show_author']));
$show_date = array_key_exists('post_list_time', $settings)
? !empty($settings['post_list_time'])
: (!isset($settings['post_show_date']) || !empty($settings['post_show_date']));
$target_blank = array_key_exists('target_blank', $settings)
? !empty($settings['target_blank'])
: !empty($settings['post_target_blank']);
$ajax_trigger = '';
if (array_key_exists('ajax_trigger', $settings)) {
$ajax_trigger = sanitize_text_field((string) $settings['ajax_trigger']);
} elseif (array_key_exists('ajax_trigger_text', $settings)) {
$ajax_trigger = sanitize_text_field((string) $settings['ajax_trigger_text']);
}
$ajax_nomore = '';
if (array_key_exists('ajax_nomore', $settings)) {
$ajax_nomore = sanitize_text_field((string) $settings['ajax_nomore']);
} elseif (array_key_exists('ajax_nomore_text', $settings)) {
$ajax_nomore = sanitize_text_field((string) $settings['ajax_nomore_text']);
}
return [
'card_style' => in_array(sanitize_key((string) ($settings['list_card_style'] ?? '')), ['', 'style3'], true) ? sanitize_key((string) ($settings['list_card_style'] ?? '')) : '',
'render_mode' => $render_mode_map[$card_style] ?? 'card',
'show_author' => !isset($settings['post_show_author']) || !empty($settings['post_show_author']),
'show_date' => !isset($settings['post_show_date']) || !empty($settings['post_show_date']),
'show_views' => !isset($settings['post_show_views']) || !empty($settings['post_show_views']),
'show_category' => !isset($settings['post_show_category']) || !empty($settings['post_show_category']),
'show_comments' => !isset($settings['post_meta_comments']) || !empty($settings['post_meta_comments']),
'show_likes' => !isset($settings['post_meta_likes']) || !empty($settings['post_meta_likes']),
'badge_types' => $badge_types,
'badge_show' => !empty($badge_types),
'sticky_pages' => $sticky_pages,
'sticky_enabled' => !empty($sticky_pages),
'target_blank' => !empty($settings['post_target_blank']),
'heading_bold' => !empty($settings['item_heading_bold']),
'mobile_meta' => in_array(sanitize_key((string) ($settings['list_meta_show'] ?? 'like')), ['view', 'like', 'comm'], true) ? sanitize_key((string) ($settings['list_meta_show'] ?? 'like')) : 'like',
'list_show_type' => in_array(sanitize_key((string) ($settings['list_show_type'] ?? 'separate')), ['separate', 'no_margin'], true) ? sanitize_key((string) ($settings['list_show_type'] ?? 'separate')) : 'separate',
'excerpt_length' => max(20, min(500, (int) ($settings['post_excerpt_length'] ?? 120))),
'ias_max' => max(0, min(10, (int) ($settings['ias_max'] ?? 3))),
'ajax_trigger_text' => sanitize_text_field((string) ($settings['ajax_trigger_text'] ?? '')),
'ajax_nomore_text' => sanitize_text_field((string) ($settings['ajax_nomore_text'] ?? '')),
'list_orderby' => in_array(sanitize_key((string) ($settings['list_orderby'] ?? 'modified')), ['modified', 'date', 'comments', 'default'], true) ? sanitize_key((string) ($settings['list_orderby'] ?? 'modified')) : 'modified',
'columns' => max(1, min(3, (int) ($settings['post_list_columns'] ?? 1))),
'per_page' => max(4, min(48, (int) ($settings['post_list_per_page'] ?? 12))),
'list_style' => in_array(sanitize_key((string) ($settings['list_list_style'] ?? '')), ['', 'style2'], true) ? sanitize_key((string) ($settings['list_list_style'] ?? '')) : '',
'card_style' => in_array(sanitize_key((string) ($settings['list_card_style'] ?? '')), ['', 'style3'], true) ? sanitize_key((string) ($settings['list_card_style'] ?? '')) : '',
'render_mode' => $render_mode_map[$card_style] ?? 'card',
'show_author' => $show_author,
'show_date' => $show_date,
'show_views' => !isset($settings['post_show_views']) || !empty($settings['post_show_views']),
'show_category' => !isset($settings['post_show_category']) || !empty($settings['post_show_category']),
'show_comments' => !isset($settings['post_meta_comments']) || !empty($settings['post_meta_comments']),
'show_likes' => !isset($settings['post_meta_likes']) || !empty($settings['post_meta_likes']),
'badge_types' => $badge_types,
'badge_show' => !empty($badge_types),
'sticky_pages' => $sticky_pages,
'sticky_enabled' => !empty($sticky_pages),
'target_blank' => $target_blank,
'heading_bold' => !empty($settings['item_heading_bold']),
'mobile_meta' => in_array(sanitize_key((string) ($settings['list_meta_show'] ?? 'like')), ['view', 'like', 'comm'], true) ? sanitize_key((string) ($settings['list_meta_show'] ?? 'like')) : 'like',
'list_show_type' => in_array(sanitize_key((string) ($settings['list_show_type'] ?? 'separate')), ['separate', 'no_margin'], true) ? sanitize_key((string) ($settings['list_show_type'] ?? 'separate')) : 'separate',
'excerpt_length' => max(20, min(500, (int) ($settings['post_excerpt_length'] ?? 120))),
'ias_max' => max(0, min(10, (int) ($settings['ias_max'] ?? 3))),
'paging_ajax' => self::is_list_paging_ajax($settings),
'paging_ajax_ias' => self::is_list_paging_ajax_ias($settings),
'ajax_trigger_text' => $ajax_trigger,
'ajax_nomore_text' => $ajax_nomore,
'list_orderby' => in_array(sanitize_key((string) ($settings['list_orderby'] ?? 'modified')), ['modified', 'date', 'default'], true) ? sanitize_key((string) ($settings['list_orderby'] ?? 'modified')) : 'modified',
'columns' => max(1, min(3, (int) ($settings['post_list_columns'] ?? 1))),
'per_page' => max(4, min(48, (int) ($settings['post_list_per_page'] ?? 12))),
'list_style' => in_array(sanitize_key((string) ($settings['list_list_style'] ?? '')), ['', 'style2'], true) ? sanitize_key((string) ($settings['list_list_style'] ?? '')) : '',
'list_img_position' => in_array(sanitize_key((string) ($settings['list_list_img_position'] ?? 'left')), ['left', 'right'], true) ? sanitize_key((string) ($settings['list_list_img_position'] ?? 'left')) : 'left',
'list_scale' => max(50, min(200, (int) ($settings['list_list_scale'] ?? 70))),
'card_scale' => max(20, min(200, (int) ($settings['list_card_scale'] ?? 70))),
'card_home' => !empty($settings['list_card_home']),
'card_cat' => !empty($settings['list_card_cat']),
'card_cat_ids' => is_array($settings['list_card_cat'] ?? null) ? array_map('intval', $settings['list_card_cat']) : [],
'card_tag' => !empty($settings['list_card_tag']),
'card_topics' => !empty($settings['list_card_topics']),
'card_author' => !empty($settings['list_card_author']),
'list_scale' => max(50, min(200, (int) ($settings['list_list_scale'] ?? 70))),
'card_scale' => max(20, min(200, (int) ($settings['list_card_scale'] ?? 70))),
'card_home' => !empty($settings['list_card_home']),
'card_cat' => !empty($settings['list_card_cat']),
'card_cat_ids' => is_array($settings['list_card_cat'] ?? null) ? array_map('intval', $settings['list_card_cat']) : [],
'card_tag' => !empty($settings['list_card_tag']),
'card_topics' => !empty($settings['list_card_topics']),
'card_author' => !empty($settings['list_card_author']),
];
}
@@ -290,6 +319,28 @@ class AKSRT_Settings_Post_Display {
];
}
public static function apply_list_orderby($query): void {
if (is_admin() || !($query instanceof WP_Query) || !$query->is_main_query()) {
return;
}
if (!$query->is_home() && !$query->is_archive() && !$query->is_search()) {
return;
}
if ($query->get('orderby')) {
return;
}
$orderby = sanitize_key((string) (self::get_post_list_style_settings()['list_orderby'] ?? 'modified'));
if ($orderby === '' || $orderby === 'default') {
return;
}
if (in_array($orderby, ['date', 'modified'], true)) {
$query->set('orderby', $orderby);
$query->set('order', 'DESC');
}
}
public static function apply_list_per_page($query): void {
if (is_admin() || !$query->is_main_query()) {
return;
@@ -310,13 +361,61 @@ class AKSRT_Settings_Post_Display {
}
public static function get_post_pagination_mode(): string {
$mode = (string) AKSRT_Settings::get_value('post_pagination_mode', 'numbered');
$settings = AKSRT_Settings::get_all();
// Zibll: paging_ajax_s '1' = ajax append, '0' = numeric buttons.
if (array_key_exists('paging_ajax_s', $settings)) {
$ajax = self::is_list_paging_ajax($settings);
if (!$ajax) {
return 'numbered';
}
return self::is_list_paging_ajax_ias($settings) ? 'infinite' : 'load_more';
}
// Temporary bridge for installs still holding the previous schema key only.
$mode = (string) ($settings['post_pagination_mode'] ?? 'numbered');
if ($mode === 'numeric') {
$mode = 'numbered';
}
return in_array($mode, ['numbered', 'load_more', 'infinite'], true) ? $mode : 'numbered';
}
/**
* Whether list pagination uses AJAX append (Zibll paging_ajax_s).
*
* @param array<string,mixed>|null $settings
*/
public static function is_list_paging_ajax(?array $settings = null): bool {
$settings = $settings ?? AKSRT_Settings::get_all();
if (!array_key_exists('paging_ajax_s', $settings)) {
// Fallback from previous 3-mode key.
$mode = (string) ($settings['post_pagination_mode'] ?? 'numbered');
return in_array($mode, ['load_more', 'infinite', 'ajax'], true);
}
$raw = $settings['paging_ajax_s'];
if (is_bool($raw)) {
return $raw;
}
return (string) $raw === '1' || (string) $raw === 'true';
}
/**
* Whether AJAX list paging auto-loads on scroll (Zibll paging_ajax_ias_s).
*
* @param array<string,mixed>|null $settings
*/
public static function is_list_paging_ajax_ias(?array $settings = null): bool {
$settings = $settings ?? AKSRT_Settings::get_all();
if (!self::is_list_paging_ajax($settings)) {
return false;
}
if (!array_key_exists('paging_ajax_ias_s', $settings)) {
$mode = (string) ($settings['post_pagination_mode'] ?? '');
return $mode === 'infinite';
}
return !empty($settings['paging_ajax_ias_s']);
}
public static function get_comment_pagination_mode(): string {
$mode = (string) AKSRT_Settings::get_value('comment_pagination_type', 'numbered');
if ($mode === 'page') {