feat(frontend): replace article system with Zibll 9.0

This commit is contained in:
2026-08-18 16:06:47 +08:00
parent 2881c69e9c
commit 0f2ac6c34a
69 changed files with 2603 additions and 4163 deletions
+44 -60
View File
@@ -203,7 +203,9 @@ class Admin {
public static function sanitize_public_query_vars(array $vars): array {
$allowed = [
'post_type', 'post_status', 'posts_per_page', 'paged', 'orderby', 'order',
'cat', 'tag', 'tag_id', 'category_name', 's', 'post__not_in', 'category__not_in',
'cat', 'tag', 'tag_id', 'category_name', 's', 'author', 'author_name', 'offset',
'post__in', 'post__not_in', 'category__in', 'category__not_in', 'tag__in',
'tag__not_in', 'tag_slug__in', 'ignore_sticky_posts',
];
$clean = [];
foreach ($allowed as $key) {
@@ -223,15 +225,28 @@ class Admin {
if (isset($clean['paged'])) {
$clean['paged'] = max(1, (int) $clean['paged']);
}
foreach (['author', 'cat', 'tag_id', 'offset'] as $int_key) {
if (isset($clean[$int_key])) {
$clean[$int_key] = max(0, (int) $clean[$int_key]);
}
}
foreach (['post__in', 'post__not_in', 'category__in', 'category__not_in', 'tag__in', 'tag__not_in'] as $ids_key) {
if (isset($clean[$ids_key])) {
$clean[$ids_key] = array_values(array_filter(array_map('absint', (array) $clean[$ids_key])));
}
}
if (isset($clean['ignore_sticky_posts'])) {
$clean['ignore_sticky_posts'] = !empty($clean['ignore_sticky_posts']);
}
return $clean;
}
public static function sanitize_public_render_config(array $config): array {
$clean = [];
if (isset($config['mode'])) {
$mode = sanitize_key((string) $config['mode']);
if (in_array($mode, ['list', 'card', 'mini', 'grid-cms'], true)) {
$clean['mode'] = $mode;
if (isset($config['type'])) {
$type = sanitize_key((string) $config['type']);
if (in_array($type, ['auto', 'list', 'card'], true)) {
$clean['type'] = $type;
}
}
if (isset($config['context'])) {
@@ -240,44 +255,18 @@ class Admin {
if (isset($config['query_context'])) {
$clean['query_context'] = sanitize_key((string) $config['query_context']);
}
if (isset($config['style'])) {
$style = sanitize_key((string) $config['style']);
if (in_array($style, ['', 'style2', 'style3'], true)) {
$clean['style'] = $style;
}
}
if (isset($config['card_style'])) {
$card_style = sanitize_key((string) $config['card_style']);
$allowed = ['thumb', 'text', 'thumb_if_has', 'card', 'compact', 'large_thumb', 'multi_thumb', 'standard'];
if (in_array($card_style, $allowed, true)) {
$clean['card_style'] = $card_style;
}
}
if (isset($config['list_show_type'])) {
$v = sanitize_key((string) $config['list_show_type']);
if (in_array($v, ['separate', 'no_margin'], true)) {
$clean['list_show_type'] = $v;
}
}
if (isset($config['list_img_position'])) {
$v = sanitize_key((string) $config['list_img_position']);
if (in_array($v, ['left', 'right'], true)) {
$clean['list_img_position'] = $v;
}
}
foreach (['thumb_if_has', 'show_thumb', 'show_author', 'show_date', 'show_views', 'show_comments', 'show_likes', 'show_excerpt', 'heading_bold', 'target_blank', 'badge_show', 'multi_thumb_enabled', 'skip_wrapper'] as $bool_key) {
if (array_key_exists($bool_key, $config)) {
$clean[$bool_key] = !empty($config[$bool_key]);
}
}
if (isset($config['multi_thumb_limit'])) {
$clean['multi_thumb_limit'] = max(1, min(6, (int) $config['multi_thumb_limit']));
}
if (isset($config['multi_thumb_min'])) {
$clean['multi_thumb_min'] = max(1, min(6, (int) $config['multi_thumb_min']));
}
if (isset($config['excerpt_words'])) {
$clean['excerpt_words'] = max(0, min(200, (int) $config['excerpt_words']));
foreach (['no_author', 'no_margin', 'is_card', 'skip_wrapper'] as $bool_key) {
if (array_key_exists($bool_key, $config)) {
$clean[$bool_key] = !empty($config[$bool_key]);
}
}
foreach (['is_mult_thumb', 'is_no_thumb'] as $layout_key) {
if (array_key_exists($layout_key, $config)) {
$clean[$layout_key] = $config[$layout_key] === 'disable' ? 'disable' : !empty($config[$layout_key]);
}
}
if (isset($config['highlight_query'])) {
$clean['highlight_query'] = sanitize_text_field((string) $config['highlight_query']);
}
return $clean;
}
@@ -294,18 +283,15 @@ class Admin {
$render_config = json_decode(wp_unslash((string) ($_POST['render_config'] ?? '{}')), true);
$query_vars = is_array($query_vars) ? self::sanitize_public_query_vars($query_vars) : [];
$render_config = is_array($render_config) ? self::sanitize_public_render_config($render_config) : [];
// Prefer server-side resolution so AJAX matches SSR styles even if client config is slim.
if (function_exists('aksrt_resolve_post_list_render_config')) {
$context = sanitize_key((string) ($render_config['context'] ?? 'archive'));
if ($context === '') {
$context = 'archive';
}
$resolved = aksrt_resolve_post_list_render_config([
'context' => $context,
'overrides' => $render_config,
]);
$render_config = array_merge($resolved, $render_config);
}
$context = sanitize_key((string) ($render_config['context'] ?? 'archive'));
if ($context === '') {
$context = 'archive';
}
$resolved = aksrt_resolve_post_list_render_config([
'context' => $context,
'overrides' => $render_config,
]);
$render_config = array_merge($resolved, $render_config, ['skip_wrapper' => true]);
$query_vars['paged'] = $page;
if (empty($query_vars['post_status'])) {
$query_vars['post_status'] = 'publish';
@@ -314,11 +300,9 @@ class Admin {
$query_vars['post_type'] = 'post';
}
$query = new \WP_Query($query_vars);
ob_start();
if (function_exists('aksrt_render_post_list')) {
aksrt_render_post_list($query, $render_config, true);
}
$query = new \WP_Query($query_vars);
ob_start();
aksrt_render_post_list($render_config, $query, true);
$html = (string) ob_get_clean();
wp_send_json_success([
+5 -28
View File
@@ -129,7 +129,6 @@ class GlobalController extends ControllerBase {
'page' => ['type' => 'integer', 'default' => 1, 'sanitize_callback' => 'absint'],
'per_page' => ['type' => 'integer', 'default' => 10, 'sanitize_callback' => 'absint'],
'sort' => ['type' => 'string', 'default' => 'modified', 'sanitize_callback' => 'sanitize_text_field'],
'view_mode' => ['type' => 'string', 'default' => 'list', 'sanitize_callback' => 'sanitize_text_field'],
'page_url' => ['type' => 'string', 'default' => '', 'sanitize_callback' => 'esc_url_raw'],
'panel' => ['type' => 'string', 'default' => 'latest', 'sanitize_callback' => 'sanitize_key'],
'source' => ['type' => 'string', 'default' => 'home', 'sanitize_callback' => 'sanitize_key'],
@@ -239,7 +238,6 @@ class GlobalController extends ControllerBase {
$page = max(1, (int) $request->get_param('page'));
$per_page = min(50, max(1, (int) $request->get_param('per_page')));
$sort = sanitize_key($request->get_param('sort') ?: 'modified');
$view_mode = sanitize_key($request->get_param('view_mode') ?: 'list');
$tab_orderby = sanitize_key($request->get_param('tab_orderby') ?: '');
$panel = sanitize_key($request->get_param('panel') ?: 'latest');
@@ -294,32 +292,11 @@ class GlobalController extends ControllerBase {
$query = new \WP_Query($args);
$mode = in_array($view_mode, ['card', 'list'], true) ? $view_mode : '';
$html = '';
if (function_exists('aksrt_render_post_list')) {
$overrides = ['context' => 'home'];
if ($mode !== '') {
$overrides['mode'] = $mode;
}
$render_config = function_exists('aksrt_resolve_post_list_render_config')
? aksrt_resolve_post_list_render_config([
'context' => 'home',
'overrides' => $overrides,
])
: array_merge(['mode' => ($mode !== '' ? $mode : 'list'), 'context' => 'home'], $overrides);
$render_config['skip_wrapper'] = true;
$html = aksrt_render_post_list($query, $render_config, false);
} elseif ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
if (function_exists('aksrt_homepage_render_post_card')) {
ob_start();
aksrt_homepage_render_post_card();
$html .= ob_get_clean();
}
}
wp_reset_postdata();
}
$render_config = aksrt_resolve_post_list_render_config([
'context' => 'home',
]);
$render_config['skip_wrapper'] = true;
$html = aksrt_render_post_list($render_config, $query, false);
$has_more = $page < (int) $query->max_num_pages;
-17
View File
@@ -62,26 +62,9 @@ trait HomepageSettingsRest {
$settings['home_lists'] = $this->sanitize_home_lists($params['home_lists'], $allowed_sorts);
}
// --- AKSRT presentation extras (optional, not Zibll dual-write) ---
if (isset($params['homepage_card_style'])) {
$settings['homepage_card_style'] = in_array($params['homepage_card_style'], ['default', 'style2', 'style3'], true)
? $params['homepage_card_style']
: 'default';
}
if (array_key_exists('homepage_multi_thumb_enabled', $params)) {
$settings['homepage_multi_thumb_enabled'] = !empty($params['homepage_multi_thumb_enabled']);
}
if (isset($params['homepage_multi_thumb_min_images'])) {
$settings['homepage_multi_thumb_min_images'] = max(2, min(4, (int) $params['homepage_multi_thumb_min_images']));
}
if (array_key_exists('homepage_sidebar_mini_enabled', $params)) {
$settings['homepage_sidebar_mini_enabled'] = !empty($params['homepage_sidebar_mini_enabled']);
}
if (isset($params['homepage_default_view'])) {
$settings['homepage_default_view'] = in_array($params['homepage_default_view'], ['list', 'card'], true)
? $params['homepage_default_view']
: 'list';
}
if (array_key_exists('homepage_sort_ajax_enabled', $params)) {
$settings['homepage_sort_ajax_enabled'] = !empty($params['homepage_sort_ajax_enabled']);
}
+117 -261
View File
@@ -9,265 +9,121 @@ defined('ABSPATH') || exit;
class SchemaPostListList {
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'],
],
],
],
],
[
'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', 'cat'],
'options' => [
['label' => '付费', 'value' => 'pay'],
['label' => '分类', 'value' => 'cat'],
['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_author',
'label' => '用户页卡片模式',
'type' => 'switch',
'default' => false,
],
],
],
],
];
}
public static function build(): array {
return [
'key' => 'list',
'title' => '文章列表',
'version' => '9.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'],
]],
['key' => 'post_time_source', 'label' => '时间显示数据源', 'type' => 'radio', 'default' => 'modified', 'options' => [
['label' => '发布时间', 'value' => 'date'],
['label' => '更新时间', 'value' => 'modified'],
]],
['key' => 'sticky_s', 'label' => '显示置顶文章', 'type' => 'checkbox', 'default' => ['home', 'cat'], 'options' => [
['label' => '首页', 'value' => 'home'],
['label' => '分类页', 'value' => 'cat'],
['label' => '标签页', 'value' => 'tag'],
]],
],
],
[
'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],
['key' => 'list_meta_show', 'label' => '列表小部件(移动端优先)', 'type' => 'radio', 'default' => 'like', 'options' => [
['label' => '阅读量', 'value' => 'view'],
['label' => '点赞数', 'value' => 'like'],
['label' => '评论', 'value' => 'comm'],
]],
['key' => 'list_badge_show', 'label' => '显示列表标签', 'type' => 'checkbox', 'default' => ['pay', 'cat', 'tag'], 'options' => [
['label' => '付费信息', 'value' => 'pay'],
['label' => '分类', 'value' => 'cat'],
['label' => '标签', 'value' => 'tag'],
]],
],
],
[
'key' => 'layout',
'title' => '列表模式与 UI',
'fields' => [
['key' => 'list_show_type', 'label' => '列表样式', 'type' => 'radio', 'default' => 'separate', 'options' => [
['label' => '分离', 'value' => 'separate'],
['label' => '无间距', 'value' => 'no_margin'],
]],
['key' => 'list_type', 'label' => '默认列表模式', 'type' => 'radio', 'default' => 'thumb', 'options' => [
['label' => '列表文字模式', 'value' => 'text'],
['label' => '列表图文模式', 'value' => 'thumb'],
['label' => '列表自动图文模式', 'value' => 'thumb_if_has'],
['label' => '卡片模式', 'value' => 'card'],
], 'help' => '文字、自动图文和多图模式仅在开启侧栏的页面有效。'],
['key' => 'list_card_home', 'label' => '首页列表卡片模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_tag', 'label' => '标签页列表卡片模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_author', 'label' => '用户页列表卡片模式', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
['key' => 'list_card_cat', 'label' => '分类页自定义卡片模式', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'dependsOn' => ['key' => 'list_type', 'not' => true, 'value' => 'card']],
[
'key' => 'list_list_option',
'label' => '列表模式 UI 配置',
'type' => 'fieldset',
'sanitize_type' => 'array',
'default' => ['style' => 'null', 'img_position' => 'left', 'scale' => 70],
'fields' => [
['key' => 'style', 'label' => '列表样式', 'type' => 'radio', 'default' => 'null', 'options' => [
['label' => '默认', 'value' => 'null'],
['label' => '样式 2', 'value' => 'style2'],
]],
['key' => 'img_position', 'label' => '缩略图位置', 'type' => 'radio', 'default' => 'left', 'options' => [
['label' => '靠左', 'value' => 'left'],
['label' => '靠右', 'value' => 'right'],
]],
['key' => 'scale', 'label' => '缩略图长宽比例(%)', 'type' => 'number', 'default' => 70, 'min' => 50, 'max' => 200, 'step' => 5],
],
],
[
'key' => 'list_card_option',
'label' => '卡片模式 UI 配置',
'type' => 'fieldset',
'sanitize_type' => 'array',
'default' => ['style' => 'null', 'scale' => 70],
'fields' => [
['key' => 'style', 'label' => '卡片样式', 'type' => 'radio', 'default' => 'null', 'options' => [
['label' => '默认', 'value' => 'null'],
['label' => '样式 3', 'value' => 'style3'],
]],
['key' => 'scale', 'label' => '缩略图长宽比例(%)', 'type' => 'number', 'default' => 70, 'min' => 20, 'max' => 200, 'step' => 5],
],
],
['key' => 'mult_thumb_cat', 'label' => '列表多图显示分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'help' => '文章格式为图片或画廊时默认显示 4 张缩略图;卡片模式或无侧栏时无效。'],
],
],
[
'key' => 'paging',
'title' => '列表翻页',
'fields' => [
['key' => 'paging_ajax_s', 'label' => '列表翻页模式', 'type' => 'radio', 'default' => '1', 'options' => [
['label' => 'AJAX 追加列表翻页', 'value' => '1'],
['label' => '数字翻页按钮', 'value' => '0'],
]],
['key' => 'paging_ajax_ias_s', 'label' => 'AJAX 自动加载', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1']],
['key' => 'ias_max', 'label' => '自动加载页数', 'type' => 'number', 'default' => 3, 'min' => 0, 'max' => 10, 'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1']],
['key' => 'ajax_trigger', 'label' => '翻页按钮文字', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<i class="fa fa-angle-right"></i>加载更多'],
['key' => 'ajax_nomore', 'label' => '列表全部加载完毕文案', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '没有更多内容了'],
],
],
],
];
}
}
+28 -52
View File
@@ -18,43 +18,28 @@ class SchemaPostList {
'thumb' => [
'key' => 'thumb',
'title' => '列表缩略图',
'version' => '1.0.0',
'version' => '9.0.0',
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'source', 'title' => '图片来源', 'fields' => [
['key' => 'thumb_priority', 'label' => '图片优先级', 'type' => 'input', 'default' => 'featured,attachment,resource,custom'],
['key' => 'thumb_fallback', 'label' => '无图时处理', 'type' => 'radio', 'default' => 'placeholder', 'options' => [
['label' => '显示占位图', 'value' => 'placeholder'],
['label' => '隐藏缩略图', 'value' => 'hide'],
['label' => '随机封面', 'value' => 'random'],
]],
['key' => 'thumb_spare_images', 'label' => '备用缩略图', 'type' => 'gallery', 'default' => [], 'dependsOn' => ['key' => 'thumb_fallback', 'value' => 'random'], 'description' => '当 thumb_fallback 为 random 时从此图库随机选取'],
['key' => 'thumb_aspect_ratio', 'label' => '图片比例', 'type' => 'select', 'default' => '16:9', 'options' => [
['label' => '16:9 宽屏', 'value' => '16:9'],
['label' => '4:3 标准', 'value' => '4:3'],
['label' => '1:1 正方形', 'value' => '1:1'],
['label' => '自适应', 'value' => 'auto'],
]],
['key' => 'list_thumb_fit', 'label' => '缩略图填充方式', 'type' => 'radio', 'default' => 'cover', 'options' => [
['label' => '填充裁剪', 'value' => 'cover'],
['label' => '完整显示', 'value' => 'contain'],
]],
['key' => 'source', 'title' => '图片来源', 'description' => '缩略图获取优先级:文章特色图像 > 外链特色图像 > 文章首图 > 分类封面图 > 备用缩略图 > 懒加载预载图。', 'fields' => [
['key' => 'list_thumb_slides_s', 'label' => '幻灯片缩略图', 'type' => 'switch', 'default' => true, 'description' => '允许幻灯片作为列表缩略图'],
['key' => 'list_thumb_video_s', 'label' => '视频缩略图', 'type' => 'switch', 'default' => true, 'description' => '鼠标悬停时自动播放视频缩略图'],
['key' => 'list_thumb_video_mute_s', 'label' => '视频缩略图静音', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'list_thumb_video_s', 'value' => true], 'description' => '视频缩略图播放时静音'],
['key' => 'thumb_postfirstimg_s', 'label' => '自动获取文章首图', 'type' => 'switch', 'default' => true, 'description' => '自动从文章内容中提取第一张图片作为缩略图'],
['key' => 'thumb_catimg_s', 'label' => '自动获取分类封面', 'type' => 'switch', 'default' => true, 'description' => '无特色图时使用分类封面图作为缩略图'],
['key' => 'list_thumb_fit', 'label' => '缩略图填充方式', 'type' => 'radio', 'default' => '', 'options' => [
['label' => 'cover 铺满', 'value' => ''],
['label' => 'contain 等比例缩放', 'value' => 'contain'],
]],
['key' => 'thumb_postfirstimg_size', 'label' => '首图尺寸', 'type' => 'radio', 'default' => 'medium', 'dependsOn' => ['key' => 'thumb_postfirstimg_s', 'value' => true], 'options' => [
['label' => '缩略图', 'value' => 'thumbnail'],
['label' => '中等', 'value' => 'medium'],
['label' => '大', 'value' => 'large'],
['label' => '原始', 'value' => 'full'],
], 'description' => '自动获取文章首图时使用的 WP 图片尺寸'],
]],
['key' => 'multi', 'title' => '多图模式', 'fields' => [
['key' => 'thumb_multi_enabled', 'label' => '多图卡片', 'type' => 'switch', 'default' => false],
['key' => 'thumb_multi_count', 'label' => '最多显示几张', 'type' => 'number', 'default' => 3, 'min' => 2, 'max' => 6, 'dependsOn' => ['key' => 'thumb_multi_enabled', 'value' => true]],
['key' => 'mult_thumb_cat', 'label' => '按分类多图显示', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => [], 'dependsOn' => ['key' => 'thumb_multi_enabled', 'value' => true]],
['key' => 'spare_thumbnail', 'label' => '备用缩略图', 'type' => 'repeater', 'sanitize_type' => 'array', 'default' => [['img' => get_template_directory_uri() . '/assets/img/thumbnail.svg']], 'addText' => '添加备用缩略图', 'fields' => [
['key' => 'img', 'label' => '图片', 'type' => 'media', 'default' => ''],
]],
]],
],
],
@@ -102,34 +87,25 @@ class SchemaPostList {
['key' => 'post_lightbox_down', 'label' => '灯箱下载', 'type' => 'switch', 'default' => false],
['key' => 'post_lightbox_play', 'label' => '灯箱播放', 'type' => 'switch', 'default' => false],
]],
['key' => 'related', 'title' => '相关推荐', 'fields' => [
['key' => 'post_related_enabled', 'label' => '显示相关推荐', 'type' => 'switch', 'default' => true],
['key' => 'post_related_count', 'label' => '推荐数量', 'type' => 'number', 'default' => 6, 'min' => 1, 'max' => 20],
['key' => 'post_related_style', 'label' => '展示样式', 'type' => 'radio', 'default' => 'img', 'options' => [
['label' => '图文卡片', 'value' => 'img'],
['label' => '列表', 'value' => 'list'],
['label' => '纯文字', 'value' => 'text'],
], 'description' => '对齐 Zibll 相关文章三种样式'],
['key' => 'post_related_source', 'label' => '推荐来源', 'type' => 'radio', 'default' => 'category', 'options' => [
['label' => '同分类/标签', 'value' => 'category'],
['label' => '同标签', 'value' => 'tag'],
['label' => '随机', 'value' => 'random'],
]],
// Legacy alias kept so old saved values still round-trip.
['key' => 'post_related_type', 'label' => '推荐方式(兼容)', 'type' => 'radio', 'default' => 'category', 'options' => [
['label' => '同分类', 'value' => 'category'],
['label' => '同标签', 'value' => 'tag'],
['label' => '随机', 'value' => 'random'],
]],
['key' => 'post_related_orderby', 'label' => '推荐排序', 'type' => 'select', 'default' => 'views', 'options' => [
['label' => '浏览量', 'value' => 'views'],
['label' => '随机', 'value' => 'rand'],
['label' => '相关度', 'value' => 'relevance'],
['label' => '时间', 'value' => 'date'],
['label' => '更新时间', 'value' => 'modified'],
]],
['key' => 'post_related_title', 'label' => '推荐标题', 'type' => 'input', 'default' => '相关推荐'],
]],
['key' => 'related', 'title' => '相关推荐', 'fields' => [
['key' => 'post_related_s', 'label' => '显示相关推荐', 'type' => 'switch', 'default' => true],
['key' => 'post_related_type', 'label' => '展示样式', 'type' => 'radio', 'default' => 'img', 'options' => [
['label' => '图文卡片', 'value' => 'img'],
['label' => '列表', 'value' => 'list'],
['label' => '纯文字', 'value' => 'text'],
]],
['key' => 'related_title', 'label' => '推荐标题', 'type' => 'input', 'default' => '相关推荐'],
['key' => 'post_related_n', 'label' => '推荐数量', 'type' => 'number', 'default' => 6, 'min' => 4, 'max' => 12, 'step' => 2],
['key' => 'post_related_orderby', 'label' => '推荐排序', 'type' => 'select', 'default' => 'views', 'options' => [
['label' => '更新时间', 'value' => 'modified'],
['label' => '发布时间', 'value' => 'date'],
['label' => '浏览量', 'value' => 'views'],
['label' => '点赞量', 'value' => 'like'],
['label' => '评论量', 'value' => 'comment_count'],
['label' => '收藏数量', 'value' => 'favorite'],
['label' => '随机', 'value' => 'rand'],
]],
]],
['key' => 'interactions', 'title' => '互动功能', 'fields' => [
['key' => 'post_like_enabled', 'label' => '点赞', 'type' => 'switch', 'default' => true],
['key' => 'post_favorite_enabled', 'label' => '收藏', 'type' => 'switch', 'default' => true],
-2
View File
@@ -71,7 +71,6 @@ class DomainModel {
return [
'cover_images' => '',
'custom_excerpt' => '',
'layout_override' => '',
'header_image_mode' => '',
'show_toc' => '',
'show_reading_progress' => '',
@@ -105,7 +104,6 @@ class DomainModel {
return [
'cover_url' => '',
'description' => '',
'layout_mode' => '',
'show_sidebar' => '',
'show_header' => true,
'show_featured' => false,
+1 -1
View File
@@ -214,7 +214,7 @@ class HomeModules {
return [
['type' => 'hero', 'config' => []],
['type' => 'tabs', 'config' => ['count' => 8]],
['type' => 'recent', 'config' => ['count' => 8, 'layout' => 'grid-cms']],
['type' => 'recent', 'config' => ['count' => 8, 'layout' => 'card']],
['type' => 'ranking', 'config' => ['metric' => 'downloads', 'count' => 6]],
];
}
+5 -43
View File
@@ -163,14 +163,6 @@ class PostMetaBox {
<small class="description"><?php esc_html_e('用于列表多图模式,填写附件 ID(逗号分隔)。', 'aksrt'); ?></small>
</p>
<p><strong><?php esc_html_e('列表布局覆盖', 'aksrt'); ?></strong></p>
<select name="aksrt_post_meta[layout_override]" class="widefat">
<option value="" <?php selected($meta['layout_override'], ''); ?>><?php esc_html_e('跟随全局', 'aksrt'); ?></option>
<option value="card" <?php selected($meta['layout_override'], 'card'); ?>><?php esc_html_e('卡片', 'aksrt'); ?></option>
<option value="list" <?php selected($meta['layout_override'], 'list'); ?>><?php esc_html_e('列表', 'aksrt'); ?></option>
<option value="mini" <?php selected($meta['layout_override'], 'mini'); ?>><?php esc_html_e('迷你', 'aksrt'); ?></option>
</select>
<p><strong><?php esc_html_e('侧栏布局(Zibll show_layout)', 'aksrt'); ?></strong></p>
<?php
$show_layout = (string) get_post_meta($post->ID, '_aksrt_show_layout', true);
@@ -251,9 +243,9 @@ class PostMetaBox {
<p><strong><?php esc_html_e('副标题', 'aksrt'); ?></strong></p>
<input type="text" name="aksrt_post_meta[subtitle]" value="<?php echo esc_attr($meta['subtitle']); ?>" class="widefat" placeholder="<?php esc_attr_e('可选,显示在标题下方', 'aksrt'); ?>">
<p><strong><?php esc_html_e('外链特色图', 'aksrt'); ?></strong></p>
<input type="url" name="aksrt_post_meta[thumbnail_url]" value="<?php echo esc_url($meta['thumbnail_url']); ?>" class="widefat" placeholder="<?php esc_attr_e('外部图片 URL(覆盖特色图片)', 'aksrt'); ?>">
<small class="description"><?php esc_html_e('填入外部图片 URL 将替代特色图片。', 'aksrt'); ?></small>
<p><strong><?php esc_html_e('外链特色图', 'aksrt'); ?></strong></p>
<input type="url" name="aksrt_post_meta[thumbnail_url]" value="<?php echo esc_url($meta['thumbnail_url']); ?>" class="widefat" placeholder="<?php esc_attr_e('外部图片 URL(覆盖特色图片)', 'aksrt'); ?>">
<small class="description"><?php esc_html_e('未设置文章特色图片时使用此外链图片。', 'aksrt'); ?></small>
<p><strong><?php esc_html_e('幻灯片封面', 'aksrt'); ?></strong></p>
<input type="text" name="aksrt_post_meta[featured_slide]" value="<?php echo esc_attr($meta['featured_slide']); ?>" class="widefat" placeholder="<?php esc_attr_e('图片 URL,逗号分隔', 'aksrt'); ?>">
@@ -359,7 +351,7 @@ class PostMetaBox {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (!current_user_can('edit_post', $post_id)) return;
// Zibll show_layout (independent of list layout_override).
// Zibll show_layout.
$show_layout = isset($_POST['aksrt_show_layout']) ? sanitize_key((string) wp_unslash($_POST['aksrt_show_layout'])) : '';
if (!in_array($show_layout, ['no_sidebar', 'sidebar_left', 'sidebar_right'], true)) {
$show_layout = '';
@@ -391,7 +383,6 @@ class PostMetaBox {
$sanitized = [
'cover_images' => isset($raw['cover_images']) ? sanitize_text_field($raw['cover_images']) : '',
'custom_excerpt' => isset($raw['custom_excerpt']) ? sanitize_textarea_field($raw['custom_excerpt']) : '',
'layout_override' => isset($raw['layout_override']) ? sanitize_key($raw['layout_override']) : '',
'header_image_mode' => isset($raw['header_image_mode']) ? sanitize_key($raw['header_image_mode']) : '',
// New route: '' follow | '1' force on | '0' force off.
'show_toc' => isset($raw['show_toc']) && in_array((string) $raw['show_toc'], ['', '0', '1'], true) ? (string) $raw['show_toc'] : '',
@@ -417,11 +408,6 @@ class PostMetaBox {
'maxheight' => isset($raw['maxheight']) ? max(0, (int) $raw['maxheight']) : 0,
];
$valid_modes = ['', 'card', 'list', 'mini', 'grid-cms'];
if (!in_array($sanitized['layout_override'], $valid_modes, true)) {
$sanitized['layout_override'] = '';
}
$valid_header_modes = ['', 'featured', 'auto', 'none'];
if (!in_array($sanitized['header_image_mode'], $valid_header_modes, true)) {
$sanitized['header_image_mode'] = '';
@@ -476,10 +462,9 @@ class PostMetaBox {
echo esc_html($views > 0 ? (string) $views : '—');
} elseif ($column === 'aksrt_likes') {
$likes = (int) ($meta['likes'] ?? 0);
$layout = esc_attr($meta['layout_override'] ?? '');
$toc = esc_attr($meta['show_toc'] ?? '');
$mh = (int) ($meta['maxheight'] ?? 0);
echo '<span class="aksrt-col-data" data-views="' . (int) ($meta['views'] ?? 0) . '" data-likes="' . $likes . '" data-layout="' . $layout . '" data-toc="' . $toc . '" data-maxheight="' . $mh . '">' . esc_html($likes > 0 ? (string) $likes : '—') . '</span>';
echo '<span class="aksrt-col-data" data-views="' . (int) ($meta['views'] ?? 0) . '" data-likes="' . $likes . '" data-toc="' . $toc . '" data-maxheight="' . $mh . '">' . esc_html($likes > 0 ? (string) $likes : '—') . '</span>';
} elseif ($column === 'aksrt_sales') {
$this->render_sales_column($post_id);
}
@@ -631,17 +616,6 @@ class PostMetaBox {
<span class="title"><?php esc_html_e('点赞数', 'aksrt'); ?></span>
<input type="number" name="aksrt_qe_likes" min="0" step="1" value="" class="aksrt-qe-likes">
</label>
<label class="alignleft">
<span class="title"><?php esc_html_e('布局', 'aksrt'); ?></span>
<select name="aksrt_qe_layout" class="aksrt-qe-layout">
<option value="-1"><?php esc_html_e('— 不更改 —', 'aksrt'); ?></option>
<option value=""><?php esc_html_e('跟随全局', 'aksrt'); ?></option>
<option value="card"><?php esc_html_e('卡片', 'aksrt'); ?></option>
<option value="list"><?php esc_html_e('列表', 'aksrt'); ?></option>
<option value="mini"><?php esc_html_e('迷你', 'aksrt'); ?></option>
<option value="grid-cms"><?php esc_html_e('CMS网格', 'aksrt'); ?></option>
</select>
</label>
<label class="alignleft">
<span class="title"><?php esc_html_e('目录树', 'aksrt'); ?></span>
<select name="aksrt_qe_toc" class="aksrt-qe-toc">
@@ -771,14 +745,6 @@ class PostMetaBox {
? max(0, (int) $_POST['aksrt_qe_likes'])
: (int) ($existing['likes'] ?? 0);
$layout = $existing['layout_override'] ?? '';
if (isset($_POST['aksrt_qe_layout']) && $_POST['aksrt_qe_layout'] !== '-1') {
$layout = sanitize_key((string) $_POST['aksrt_qe_layout']);
if (!in_array($layout, ['', 'card', 'list', 'mini', 'grid-cms'], true)) {
$layout = $existing['layout_override'] ?? '';
}
}
$toc = $existing['show_toc'] ?? '';
if (isset($_POST['aksrt_qe_toc']) && $_POST['aksrt_qe_toc'] !== '-1') {
$toc_v = sanitize_key((string) $_POST['aksrt_qe_toc']);
@@ -791,7 +757,6 @@ class PostMetaBox {
$existing['views'] = $views;
$existing['likes'] = $likes;
$existing['layout_override'] = $layout;
$existing['show_toc'] = $toc;
$existing['maxheight'] = $mh;
@@ -835,7 +800,6 @@ class PostMetaBox {
var v = data.getAttribute('data-views') || '';
var l = data.getAttribute('data-likes') || '';
var layout = data.getAttribute('data-layout') || '';
var toc = data.getAttribute('data-toc') || '';
var mh = data.getAttribute('data-maxheight') || '';
@@ -844,8 +808,6 @@ class PostMetaBox {
if (qv) qv.value = v;
if (ql) ql.value = l;
var qLayout = form.querySelector('.aksrt-qe-layout');
if (qLayout) qLayout.value = layout;
var qToc = form.querySelector('.aksrt-qe-toc');
if (qToc) qToc.value = toc;
var qMh = form.querySelector('.aksrt-qe-maxheight');
+2 -5
View File
@@ -316,7 +316,7 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|| is_page_template('templates/pages/page-user-home.php');
$is_fixed_homepage = function_exists('aksrt_is_fixed_homepage_request') && aksrt_is_fixed_homepage_request();
// CMS 形态判定(可能在博客流页面也需要 grid-cms 卡片样式)
// CMS route detection.
$is_cms_mode = function_exists('aksrt_is_cms_mode') ? aksrt_is_cms_mode() : false;
// 首页/归档/搜索:卡片 + 侧栏
if ($is_home_or_archive) {
@@ -755,10 +755,8 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
$enqueue_module('pages');
}
// grid-cms 卡片样式
// Resource archives use the canonical Zibll article-card stylesheet.
if ($is_resource_archive || $is_single_resource || ($is_cms_mode && ($is_home_or_archive || $is_static_page) && !$is_fixed_homepage)) {
$enqueue_module('post-card-cms');
// 确保 post-card 基础样式也加载(若上面分支未加)
if (!$is_home_or_archive && !$is_single_post && !$is_static_page) {
$enqueue_module('post-card');
}
@@ -797,7 +795,6 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
$enqueue_module('home-modules');
$enqueue_module('post-card'); // 模块内复用
$enqueue_module('header-components'); // header components 模块依赖
$enqueue_module('post-card-cms'); // grid-cms 卡片依赖
wp_enqueue_script(
'aksrt-cms-home-modules',
+22 -9
View File
@@ -72,8 +72,9 @@ trait ScriptsPart1c {
// ===== 7. JS =====
// Swiper.js(首页/归档/CMS 模块/单篇文章页加载)
$needs_swiper = $is_home_or_archive || $is_single_post || $is_single_resource;
// Swiper.js(文章列表媒体及单篇资源页加载)
$needs_post_list_media = wp_style_is('aksrt-post-card', 'enqueued');
$needs_swiper = $needs_post_list_media || $is_home_or_archive || $is_single_post || $is_single_resource;
if ($needs_swiper) {
wp_enqueue_style(
'aksrt-swiper',
@@ -119,6 +120,17 @@ trait ScriptsPart1c {
true
);
if ($needs_post_list_media) {
$grade_js = get_template_directory() . '/assets/js/grade.min.js';
wp_enqueue_script(
'aksrt-grade',
$base_uri . '/assets/js/grade.min.js',
[],
file_exists($grade_js) ? (string) filemtime($grade_js) : $version,
true
);
}
$notyf_js = get_template_directory() . '/assets/js/notyf.js';
wp_enqueue_script(
'aksrt-notyf',
@@ -173,6 +185,8 @@ trait ScriptsPart1c {
$deps = ['aksrt-rehydrate', 'aksrt-runtime'];
if ($handle === 'aksrt-core-slider') {
$deps = array_merge($deps, $needs_swiper ? ['aksrt-swiper'] : []);
} elseif ($handle === 'aksrt-core-misc' && $needs_post_list_media) {
$deps[] = 'aksrt-grade';
} elseif ($handle === 'aksrt-core-modal-runtime') {
$deps = array_merge($deps, [
'aksrt-core-modal-telemetry',
@@ -558,15 +572,14 @@ trait ScriptsPart1c {
'commentPaginationMode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\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\Settings') ? \AKSRT\Settings\Settings::homepage_default_sort() : 'modified',
'homepageDefaultView' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_default_view() : 'list',
'homepageSortAjax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_sort_ajax_enabled() : true,
'homepageStickyTabs' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_sticky_tabs_enabled() : true,
'homePostsListEnabled' => !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_posts_list_enabled(),
'homeListSortEnabled' => !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_list_sort_enabled(),
'homeListSortDropdown' => class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::home_list_sort_dropdown(),
// AJAX 翻页文案
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger_text'] ?? '') !== '') ? $t : __('加载更多', 'aksrt'),
'ajaxNomore' => (class_exists('\AKSRT\Settings\Settings') && ($n = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_nomore_text'] ?? '') !== '') ? $n : __('没有更多了', 'aksrt'),
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger'] ?? '') !== '') ? $t : '<i class="fa fa-angle-right"></i>加载更多',
'ajaxNomore' => (class_exists('\AKSRT\Settings\Settings') && ($n = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_nomore'] ?? '') !== '') ? $n : __('没有更多内容了', 'aksrt'),
'ajaxLoading' => __('正在加载...', 'aksrt'),
'iasMax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['ias_max'] : 3,
'commentIasAuto' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias'] : true,
@@ -585,10 +598,10 @@ trait ScriptsPart1c {
'identity' => true,
'badge' => true,
],
'stickyEnabled' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_enabled'] : true,
'stickyPages' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_pages'] : ['home', 'cat'],
'badgeShow' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['badge_show'] : true,
'badgeTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['badge_types'] : ['pay', 'tag', 'cat'],
'stickyEnabled' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s']) : true,
'stickyPages' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s'] : ['home', 'cat'],
'badgeShow' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show']) : true,
'badgeTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show'] : ['pay', 'tag', 'cat'],
'search' => [
'mode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::search_mode() : 'default',
'placeholder' => function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索...', 'aksrt'),
+7 -8
View File
@@ -274,10 +274,6 @@ class Shortcodes {
* 用统一渲染器输出文章列表,避免内容里手写卡片循环。
*/
public function render_posts(array $atts = [], string $content = ''): string {
if (!function_exists('aksrt_render_post_list')) {
return '';
}
$a = shortcode_atts([
'count' => 6,
'cat' => '',
@@ -309,10 +305,13 @@ class Shortcodes {
$mode = in_array($a['mode'], ['card', 'list', 'mini'], true) ? $a['mode'] : 'card';
$query = new \WP_Query($query_args);
$html = aksrt_render_post_list($query, [
'context' => 'widget',
'mode' => $mode,
], false);
if ($mode === 'mini') {
$html = aksrt_render_mini_list($query, [], false);
} else {
$html = aksrt_render_post_list([
'type' => $mode === 'card' ? 'card' : 'list',
], $query, false);
}
wp_reset_postdata();
return '<div class="aksrt-shortcode-posts">' . $html . '</div>';
-50
View File
@@ -66,7 +66,6 @@ class TermMeta {
'header_style' => 'cover',
'cover_enabled' => true,
'desc_enabled' => true,
'list_mode' => 'grid',
'filter_bar' => true,
'sidebar' => true,
'per_page' => 12,
@@ -77,25 +76,6 @@ class TermMeta {
$saved = [];
}
// Empty term layout_mode means follow global post-list settings (Zibll).
// Do not fall back to page-display list_mode=grid which forced card everywhere.
$layout_preset = isset($saved['layout_mode']) ? sanitize_key((string) $saved['layout_mode']) : '';
if ($layout_preset === '') {
$resolved_layout = ['mode' => '', 'card_style' => ''];
$layout_mode = '';
} else {
$layout_mode = $layout_preset;
$layout_map = [
'grid' => ['mode' => 'card', 'card_style' => 'thumb'],
'card' => ['mode' => 'card', 'card_style' => 'thumb'],
'list' => ['mode' => 'list', 'card_style' => 'thumb'],
'compact' => ['mode' => 'list', 'card_style' => 'compact'],
'mini' => ['mode' => 'mini', 'card_style' => 'thumb'],
'grid-cms' => ['mode' => 'grid-cms', 'card_style' => 'thumb'],
];
$resolved_layout = $layout_map[$layout_mode] ?? ['mode' => 'list', 'card_style' => 'thumb'];
}
$header_style = (string) ($global['header_style'] ?? 'simple');
if (!in_array($header_style, ['cover', 'simple', 'none'], true)) {
$header_style = 'simple';
@@ -126,9 +106,6 @@ class TermMeta {
return [
'taxonomy' => $taxonomy,
'layout_mode' => $resolved_layout['mode'],
'card_style' => $resolved_layout['card_style'],
'layout_preset' => $layout_mode,
'header_style' => $header_style,
'show_sidebar' => $sidebar_enabled,
'show_cover' => $header_style === 'cover' && !empty($global['cover_enabled']) && $cover_url !== '',
@@ -191,15 +168,6 @@ class TermMeta {
<input type="url" name="aksrt_term_meta[cover_url]" id="aksrt_term_cover_url" value="" placeholder="https://...">
<p class="description"><?php esc_html_e('分类/标签页顶部封面图,留空则不显示。', 'aksrt'); ?></p>
</div>
<div class="form-field">
<label for="aksrt_term_layout"><?php esc_html_e('列表布局', 'aksrt'); ?></label>
<select name="aksrt_term_meta[layout_mode]" id="aksrt_term_layout">
<option value=""><?php esc_html_e('跟随全局设置', 'aksrt'); ?></option>
<option value="card"><?php esc_html_e('卡片模式', 'aksrt'); ?></option>
<option value="list"><?php esc_html_e('列表模式', 'aksrt'); ?></option>
<option value="mini"><?php esc_html_e('迷你模式', 'aksrt'); ?></option>
</select>
</div>
<?php
}
@@ -223,17 +191,6 @@ class TermMeta {
<p class="description"><?php esc_html_e('覆盖默认的分类/标签描述。', 'aksrt'); ?></p>
</td>
</tr>
<tr class="form-field">
<th scope="row"><label for="aksrt_term_layout"><?php esc_html_e('列表布局', 'aksrt'); ?></label></th>
<td>
<select name="aksrt_term_meta[layout_mode]" id="aksrt_term_layout">
<option value="" <?php selected($meta['layout_mode'], ''); ?>><?php esc_html_e('跟随全局设置', 'aksrt'); ?></option>
<option value="card" <?php selected($meta['layout_mode'], 'card'); ?>><?php esc_html_e('卡片模式', 'aksrt'); ?></option>
<option value="list" <?php selected($meta['layout_mode'], 'list'); ?>><?php esc_html_e('列表模式', 'aksrt'); ?></option>
<option value="mini" <?php selected($meta['layout_mode'], 'mini'); ?>><?php esc_html_e('迷你模式', 'aksrt'); ?></option>
</select>
</td>
</tr>
<tr class="form-field">
<th scope="row"><?php esc_html_e('显示设置', 'aksrt'); ?></th>
<td>
@@ -269,18 +226,11 @@ class TermMeta {
$sanitized = [
'cover_url' => isset($raw['cover_url']) ? esc_url_raw($raw['cover_url']) : '',
'description' => isset($raw['description']) ? sanitize_textarea_field($raw['description']) : '',
'layout_mode' => isset($raw['layout_mode']) ? sanitize_key($raw['layout_mode']) : '',
'show_sidebar' => isset($raw['show_sidebar']) ? '1' : '',
'show_header' => isset($raw['show_header']) ? true : false,
'show_featured' => isset($raw['show_featured']) ? true : false,
];
// Only allow valid layout modes
$valid_modes = ['', 'card', 'list', 'mini', 'grid-cms'];
if (!in_array($sanitized['layout_mode'], $valid_modes, true)) {
$sanitized['layout_mode'] = '';
}
update_term_meta($term_id, self::META_KEY, $sanitized);
}
}
+11 -2
View File
@@ -77,8 +77,8 @@ class InlineStyleBuilder {
'--aksrt-logo-width' => $logo_width . 'px',
'--nav-height' => '60px',
'--single-cover-scale' => '35%',
'--posts-list-scale' => (class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['list_scale'] ?? 70 : 70) . '%',
'--posts-card-scale' => (class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['card_scale'] ?? 70 : 70) . '%',
'--posts-list-scale' => (class_exists('\AKSRT\Settings\Settings') ? (\AKSRT\Settings\Settings::get_post_list_style_settings()['list_list_option']['scale'] ?? 70) : 70) . '%',
'--posts-card-scale' => (class_exists('\AKSRT\Settings\Settings') ? (\AKSRT\Settings\Settings::get_post_list_style_settings()['list_card_option']['scale'] ?? 70) : 70) . '%',
];
echo '<style id="aksrt-runtime-vars">:root{';
@@ -106,6 +106,15 @@ class InlineStyleBuilder {
}
echo '}</style>' . "\n";
if (class_exists('\AKSRT\Settings\Settings')) {
$list_settings = \AKSRT\Settings\Settings::get_post_list_style_settings();
$mobile_meta = sanitize_key((string) ($list_settings['list_meta_show'] ?? 'like'));
if (!in_array($mobile_meta, ['view', 'like', 'comm'], true)) {
$mobile_meta = 'like';
}
echo '<style id="aksrt-post-list-mobile-meta">@media (max-width:640px){.meta-right .meta-' . esc_attr($mobile_meta) . '{display:unset!important}}</style>' . "\n";
}
// Zibll header_theme_custom → --header-bg / --header-color on .header.
if (class_exists('\AKSRT\Settings\Settings')) {
$ht = \AKSRT\Settings\Settings::get_header_theme_config();
+2 -49
View File
@@ -170,55 +170,8 @@ trait DisplayPageGroups {
$filter = self::get_post_filter_settings();
return [
'list' => [
'post_card_style' => $list['list_type'] ?? $list['card_style'] ?? 'thumb',
'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' => PostDisplay::is_list_paging_ajax() ? '1' : '0',
'paging_ajax_ias_s' => PostDisplay::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'],
'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' => $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'],
'list_list_style' => $list['list_style'],
'list_list_img_position' => $list['list_img_position'],
'list_list_scale' => $list['list_scale'],
'list_card_style' => $list['card_variant'] ?? '',
'list_card_scale' => $list['card_scale'],
'list_card_home' => $list['card_home'],
'list_card_cat' => $list['card_cat_ids'] ?? [],
'list_card_tag' => $list['card_tag'],
'list_card_author' => $list['card_author'],
],
'thumb' => [
'thumb_priority' => implode(',', $thumb['priority']),
'thumb_fallback' => $thumb['fallback'],
'thumb_spare_images' => $thumb['spare_images'],
'thumb_aspect_ratio' => $thumb['aspect_ratio'],
'thumb_multi_enabled' => $thumb['multi_enabled'],
'thumb_multi_count' => $thumb['multi_count'],
'list_thumb_fit' => $thumb['fit'],
'list_thumb_slides_s' => $thumb['slides_s'],
'list_thumb_video_s' => $thumb['video_s'],
'list_thumb_video_mute_s' => $thumb['video_mute_s'],
'thumb_postfirstimg_s' => $thumb['postfirstimg_s'],
'thumb_catimg_s' => $thumb['catimg_s'],
],
'list' => $list,
'thumb' => $thumb,
'filter' => [
'filter_enabled' => $filter['enabled'],
'filter_categories' => $filter['categories'],
+5 -7
View File
@@ -259,13 +259,11 @@ trait FacadeBulk {
'reading_progress' => !isset($settings['post_reading_progress']) || !empty($settings['post_reading_progress']),
'breadcrumbs' => !isset($settings['breadcrumbs_single_s']) || !empty($settings['breadcrumbs_single_s']),
'breadcrumbs_home' => trim((string) ($settings['breadcrumbs_home_text'] ?? '')) ?: __('首页', 'aksrt'),
'related_enabled' => !isset($settings['post_related_enabled']) || !empty($settings['post_related_enabled']),
'related_count' => max(1, min(20, (int) ($settings['post_related_count'] ?? 6))),
'related_style' => 'img',
'related_source' => 'category',
'related_type' => 'category',
'related_orderby' => 'views',
'related_title' => sanitize_text_field((string) ($settings['post_related_title'] ?? '相关推荐')),
'related_enabled' => !isset($settings['post_related_s']) || !empty($settings['post_related_s']),
'related_count' => max(4, min(12, (int) ($settings['post_related_n'] ?? 6))),
'related_style' => in_array(($settings['post_related_type'] ?? 'img'), ['img', 'list', 'text'], true) ? (string) $settings['post_related_type'] : 'img',
'related_orderby' => 'views',
'related_title' => sanitize_text_field((string) ($settings['related_title'] ?? '相关推荐')),
];
}
-35
View File
@@ -212,12 +212,7 @@ class HomeCms {
'home_exclude_cats' => $exclude_cats,
'home_lists' => self::normalize_homepage_tabs($tabs_raw),
// AKSRT presentation extras.
'homepage_card_style' => isset($s['homepage_card_style']) ? sanitize_key((string) $s['homepage_card_style']) : 'default',
'homepage_multi_thumb_enabled' => !empty($s['homepage_multi_thumb_enabled']),
'homepage_multi_thumb_min_images' => (int) ($s['homepage_multi_thumb_min_images'] ?? 3),
'homepage_sidebar_mini_enabled' => !isset($s['homepage_sidebar_mini_enabled']) || !empty($s['homepage_sidebar_mini_enabled']),
'homepage_default_view' => isset($s['homepage_default_view']) ? sanitize_key((string) $s['homepage_default_view']) : 'list',
'homepage_sort_ajax_enabled' => !isset($s['homepage_sort_ajax_enabled']) || !empty($s['homepage_sort_ajax_enabled']),
'homepage_sticky_tabs_enabled' => !isset($s['homepage_sticky_tabs_enabled']) || !empty($s['homepage_sticky_tabs_enabled']),
'home_list_sort_dropdown' => !empty($s['home_list_sort_dropdown']),
@@ -227,16 +222,6 @@ class HomeCms {
'homepage_module_banner_enabled' => !isset($s['homepage_module_banner_enabled']) || !empty($s['homepage_module_banner_enabled']),
];
if (!in_array($settings['homepage_card_style'], ['default', 'style2', 'style3'], true)) {
$settings['homepage_card_style'] = 'default';
}
$settings['homepage_multi_thumb_min_images'] = max(2, min(4, $settings['homepage_multi_thumb_min_images']));
if (!in_array($settings['homepage_default_view'], ['list', 'card'], true)) {
$settings['homepage_default_view'] = 'list';
}
return $settings;
}
@@ -259,21 +244,6 @@ class HomeCms {
return self::homepage_tabs();
}
public static function homepage_card_style(): string {
$settings = self::get_homepage_fixed_settings();
return $settings['homepage_card_style'];
}
public static function homepage_multi_thumb_enabled(): bool {
$settings = self::get_homepage_fixed_settings();
return !empty($settings['homepage_multi_thumb_enabled']);
}
public static function homepage_multi_thumb_min_images(): int {
$settings = self::get_homepage_fixed_settings();
return (int) $settings['homepage_multi_thumb_min_images'];
}
public static function homepage_sidebar_mini_enabled(): bool {
$settings = self::get_homepage_fixed_settings();
return !empty($settings['homepage_sidebar_mini_enabled']);
@@ -284,11 +254,6 @@ class HomeCms {
return $settings['home_list1_orderby_option']['orderby'] ?? 'date';
}
public static function homepage_default_view(): string {
$settings = self::get_homepage_fixed_settings();
return $settings['homepage_default_view'];
}
public static function homepage_sort_ajax_enabled(): bool {
$settings = self::get_homepage_fixed_settings();
return !empty($settings['homepage_sort_ajax_enabled']);
-30
View File
@@ -54,29 +54,6 @@ trait HomepageReader {
return HomeCms::homepage_tabs();
}
/**
* Homepage card view variant.
*
* @return string default|style2|style3
*/
public static function homepage_card_style(): string {
return HomeCms::homepage_card_style();
}
/**
* Whether homepage list cards should switch to the multi-thumb layout.
*/
public static function homepage_multi_thumb_enabled(): bool {
return HomeCms::homepage_multi_thumb_enabled();
}
/**
* Minimum image count required to trigger the multi-thumb layout.
*/
public static function homepage_multi_thumb_min_images(): int {
return HomeCms::homepage_multi_thumb_min_images();
}
/**
* Whether homepage sidebar widgets should use the compact mini list style.
*/
@@ -91,13 +68,6 @@ trait HomepageReader {
return HomeCms::homepage_default_sort();
}
/**
* Default homepage view mode.
*/
public static function homepage_default_view(): string {
return HomeCms::homepage_default_view();
}
/**
* Whether the homepage sortbar should refresh through AJAX.
*/
+93 -227
View File
@@ -11,177 +11,92 @@ class PostDisplay {
public static function get_post_list_style_settings(): array {
$settings = Settings::get_all();
// post_card_style storage key mirrors Zibll list_type.
$list_type = sanitize_key((string) ($settings['post_card_style'] ?? 'thumb'));
$allowed_list_types = ['thumb', 'compact', 'large_thumb', 'multi_thumb', 'text', 'thumb_if_has', 'card', 'standard'];
if (!in_array($list_type, $allowed_list_types, true)) {
$list_type = sanitize_key((string) ($settings['list_type'] ?? 'thumb'));
if (!in_array($list_type, ['text', 'thumb', 'thumb_if_has', 'card'], true)) {
$list_type = 'thumb';
}
// Historical aliases → Zibll list_type tokens.
if ($list_type === 'standard') {
$list_type = 'thumb';
}
// Non-Zibll extras stay list-mode variants (never force card grid).
if (in_array($list_type, ['compact', 'large_thumb', 'multi_thumb'], true)) {
// Keep token for CSS hooks; render as list.
}
// Zibll: only list_type=card is card mode; thumb/text/thumb_if_has are list.
$render_mode_map = [
'thumb' => 'list',
'compact' => 'list',
'large_thumb' => 'list',
'multi_thumb' => 'list',
'text' => 'list',
'thumb_if_has' => 'list',
'card' => 'card',
];
$list_option = is_array($settings['list_list_option'] ?? null) ? $settings['list_list_option'] : [];
$list_style = sanitize_key((string) ($list_option['style'] ?? 'null'));
$list_style = $list_style === 'style2' ? 'style2' : 'null';
$list_position = sanitize_key((string) ($list_option['img_position'] ?? 'left'));
$list_position = $list_position === 'right' ? 'right' : 'left';
$sticky_pages_raw = $settings['sticky_s'] ?? null;
if (is_array($sticky_pages_raw)) {
$allowed_pages = ['home', 'cat', 'tag'];
$sticky_pages = array_values(array_intersect(array_map('sanitize_key', $sticky_pages_raw), $allowed_pages));
} else {
$sticky_pages = ['home', 'cat'];
}
$card_option = is_array($settings['list_card_option'] ?? null) ? $settings['list_card_option'] : [];
$card_style = sanitize_key((string) ($card_option['style'] ?? 'null'));
$card_style = $card_style === 'style3' ? 'style3' : 'null';
$badge_types_raw = $settings['list_badge_show'] ?? null;
if (is_array($badge_types_raw)) {
$allowed_types = ['pay', 'cat', 'tag'];
$badge_types = array_values(array_intersect(array_map('sanitize_key', $badge_types_raw), $allowed_types));
} else {
$badge_types = ['pay', 'cat', 'tag'];
}
$sticky_pages = is_array($settings['sticky_s'] ?? null)
? array_values(array_intersect(array_map('sanitize_key', $settings['sticky_s']), ['home', 'cat', 'tag']))
: ['home', 'cat'];
$badge_types = is_array($settings['list_badge_show'] ?? null)
? array_values(array_intersect(array_map('sanitize_key', $settings['list_badge_show']), ['pay', 'cat', 'tag']))
: ['pay', 'cat', 'tag'];
$card_cat_ids = is_array($settings['list_card_cat'] ?? null)
? array_values(array_filter(array_map('intval', $settings['list_card_cat'])))
: [];
$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']);
}
$list_style = sanitize_key((string) ($settings['list_list_style'] ?? ''));
if (!in_array($list_style, ['', 'style2'], true)) {
$list_style = '';
}
$card_variant = sanitize_key((string) ($settings['list_card_style'] ?? ''));
if (!in_array($card_variant, ['', 'style3'], true)) {
$card_variant = '';
}
$card_cat_ids = [];
if (is_array($settings['list_card_cat'] ?? null)) {
$card_cat_ids = array_values(array_filter(array_map('intval', $settings['list_card_cat'])));
}
$time_source = sanitize_key((string) ($settings['post_time_source'] ?? 'modified'));
$mobile_meta = sanitize_key((string) ($settings['list_meta_show'] ?? 'like'));
$list_show_type = sanitize_key((string) ($settings['list_show_type'] ?? 'separate'));
$list_orderby = sanitize_key((string) ($settings['list_orderby'] ?? 'modified'));
return [
// Zibll list_type (storage: post_card_style).
'list_type' => $list_type,
// Base mode from list_type only (surface card overrides applied by resolver).
'render_mode' => $render_mode_map[$list_type] ?? 'list',
// List item subtype token for text/thumb_if_has class hooks (not card variant).
'list_type_token' => $list_type,
// List mode visual variant (Zibll list_list_option.style).
'list_style' => $list_style,
// Card mode visual variant (Zibll list_card_option.style).
'card_variant' => $card_variant,
// Back-compat aliases used by older callers (prefer list_type / card_variant).
'card_style' => $list_type,
'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_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($card_cat_ids),
'card_cat_ids' => $card_cat_ids,
'card_tag' => !empty($settings['list_card_tag']),
'card_author' => !empty($settings['list_card_author']),
'list_type' => $list_type,
'list_orderby' => in_array($list_orderby, ['date', 'modified', 'default'], true) ? $list_orderby : 'modified',
'post_time_source' => $time_source === 'date' ? 'date' : 'modified',
'sticky_s' => $sticky_pages,
'target_blank' => !empty($settings['target_blank']),
'item_heading_bold' => !empty($settings['item_heading_bold']),
'post_list_author' => !array_key_exists('post_list_author', $settings) || !empty($settings['post_list_author']),
'post_list_time' => !array_key_exists('post_list_time', $settings) || !empty($settings['post_list_time']),
'paging_ajax_s' => (string) ($settings['paging_ajax_s'] ?? '1') === '1',
'paging_ajax_ias_s' => !array_key_exists('paging_ajax_ias_s', $settings) || !empty($settings['paging_ajax_ias_s']),
'ias_max' => max(0, min(10, (int) ($settings['ias_max'] ?? 3))),
'list_meta_show' => in_array($mobile_meta, ['view', 'like', 'comm'], true) ? $mobile_meta : 'like',
'list_badge_show' => $badge_types,
'list_show_type' => in_array($list_show_type, ['separate', 'no_margin'], true) ? $list_show_type : 'separate',
'list_card_home' => !empty($settings['list_card_home']),
'list_card_tag' => !empty($settings['list_card_tag']),
'list_card_author' => !empty($settings['list_card_author']),
'list_card_cat' => $card_cat_ids,
'list_list_option' => [
'style' => $list_style,
'img_position' => $list_position,
'scale' => max(50, min(200, (int) ($list_option['scale'] ?? 70))),
],
'list_card_option' => [
'style' => $card_style,
'scale' => max(20, min(200, (int) ($card_option['scale'] ?? 70))),
],
'mult_thumb_cat' => is_array($settings['mult_thumb_cat'] ?? null) ? array_values(array_filter(array_map('intval', $settings['mult_thumb_cat']))) : [],
'ajax_trigger' => wp_kses_post((string) ($settings['ajax_trigger'] ?? '<i class="fa fa-angle-right"></i>加载更多')),
'ajax_nomore' => wp_kses_post((string) ($settings['ajax_nomore'] ?? '没有更多内容了')),
];
}
public static function get_post_thumb_settings(): array {
$settings = Settings::get_all();
$priority_raw = (string) ($settings['thumb_priority'] ?? 'featured,attachment,resource,custom');
$priority = preg_split('/[\s,]+/', strtolower($priority_raw)) ?: [];
$priority = array_values(array_unique(array_filter(array_map('sanitize_key', $priority))));
$allowed_sources = ['featured', 'attachment', 'resource', 'custom', 'category_cover', 'post_first_img'];
$priority = array_values(array_filter($priority, static function (string $source) use ($allowed_sources): bool {
return in_array($source, $allowed_sources, true);
}));
if (empty($priority)) {
$priority = ['featured', 'attachment', 'resource', 'custom'];
public static function get_post_thumb_settings(): array {
$settings = Settings::get_all();
$spare_settings = array_key_exists('spare_thumbnail', $settings)
? (array) $settings['spare_thumbnail']
: [['img' => get_template_directory_uri() . '/assets/img/thumbnail.svg']];
$spare = [];
foreach ($spare_settings as $item) {
$url = is_array($item) ? (string) ($item['img'] ?? '') : '';
if ($url !== '') {
$spare[] = esc_url_raw($url);
}
}
$fallback = sanitize_key((string) ($settings['thumb_fallback'] ?? 'placeholder'));
if (!in_array($fallback, ['placeholder', 'hide', 'random'], true)) {
$fallback = 'placeholder';
}
$aspect_ratio = (string) ($settings['thumb_aspect_ratio'] ?? '16:9');
if (!in_array($aspect_ratio, ['16:9', '4:3', '1:1', 'auto'], true)) {
$aspect_ratio = '16:9';
}
$fit = sanitize_key((string) ($settings['list_thumb_fit'] ?? ''));
return [
'priority' => $priority,
'fallback' => $fallback,
'spare_images' => is_array($settings['thumb_spare_images'] ?? null) ? $settings['thumb_spare_images'] : [],
'aspect_ratio' => $aspect_ratio,
'multi_enabled' => !empty($settings['thumb_multi_enabled']),
'multi_count' => max(2, min(6, (int) ($settings['thumb_multi_count'] ?? 3))),
'fit' => in_array(sanitize_key((string) ($settings['list_thumb_fit'] ?? 'cover')), ['cover', 'contain'], true) ? sanitize_key((string) ($settings['list_thumb_fit'] ?? 'cover')) : 'cover',
'slides_s' => !isset($settings['list_thumb_slides_s']) || !empty($settings['list_thumb_slides_s']),
'video_s' => !isset($settings['list_thumb_video_s']) || !empty($settings['list_thumb_video_s']),
'video_mute_s' => !isset($settings['list_thumb_video_mute_s']) || !empty($settings['list_thumb_video_mute_s']),
'postfirstimg_s' => !isset($settings['thumb_postfirstimg_s']) || !empty($settings['thumb_postfirstimg_s']),
'catimg_s' => !isset($settings['thumb_catimg_s']) || !empty($settings['thumb_catimg_s']),
'postfirstimg_size'=> in_array(sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')), ['thumbnail', 'medium', 'large', 'full'], true) ? sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')) : 'medium',
'mult_thumb_cat_ids' => is_array($settings['mult_thumb_cat'] ?? null) ? array_map('intval', $settings['mult_thumb_cat']) : [],
'list_thumb_slides_s' => !array_key_exists('list_thumb_slides_s', $settings) || !empty($settings['list_thumb_slides_s']),
'list_thumb_video_s' => !array_key_exists('list_thumb_video_s', $settings) || !empty($settings['list_thumb_video_s']),
'list_thumb_video_mute_s' => !array_key_exists('list_thumb_video_mute_s', $settings) || !empty($settings['list_thumb_video_mute_s']),
'thumb_postfirstimg_s' => !array_key_exists('thumb_postfirstimg_s', $settings) || !empty($settings['thumb_postfirstimg_s']),
'thumb_catimg_s' => !array_key_exists('thumb_catimg_s', $settings) || !empty($settings['thumb_catimg_s']),
'list_thumb_fit' => $fit === 'contain' ? 'contain' : '',
'thumb_postfirstimg_size' => in_array(sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')), ['thumbnail', 'medium', 'large', 'full'], true) ? sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')) : 'medium',
'spare_thumbnail' => $spare,
];
}
@@ -262,30 +177,15 @@ class PostDisplay {
$maxheight = 1000;
}
// Related: split Zibll display style (img/list/text) from query source (category/tag/random).
// Legacy post_related_type held either style (img|list|text) or source (category|tag|random).
$raw_related_type = sanitize_key((string) ($settings['post_related_type'] ?? ''));
$raw_related_style = sanitize_key((string) ($settings['post_related_style'] ?? ''));
$raw_related_source = sanitize_key((string) ($settings['post_related_source'] ?? ''));
$related_style = sanitize_key((string) ($settings['post_related_type'] ?? 'img'));
if (!in_array($related_style, ['img', 'list', 'text'], true)) {
$related_style = 'img';
}
$related_style = 'img';
if (in_array($raw_related_style, ['img', 'list', 'text'], true)) {
$related_style = $raw_related_style;
} elseif (in_array($raw_related_type, ['img', 'list', 'text'], true)) {
$related_style = $raw_related_type;
}
$related_source = 'category';
if (in_array($raw_related_source, ['category', 'tag', 'random'], true)) {
$related_source = $raw_related_source;
} elseif (in_array($raw_related_type, ['category', 'tag', 'random'], true)) {
$related_source = $raw_related_type;
}
$related_orderby = sanitize_key((string) ($settings['post_related_orderby'] ?? 'views'));
if (!in_array($related_orderby, ['rand', 'relevance', 'date', 'views', 'modified'], true)) {
$related_orderby = 'views';
}
$related_orderby = sanitize_key((string) ($settings['post_related_orderby'] ?? 'views'));
if (!in_array($related_orderby, ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'], true)) {
$related_orderby = 'views';
}
return [
'toc_enabled' => !isset($settings['post_toc_enabled']) || !empty($settings['post_toc_enabled']),
@@ -317,15 +217,11 @@ class PostDisplay {
'lightbox_full' => !isset($settings['post_lightbox_full']) || !empty($settings['post_lightbox_full']),
'lightbox_down' => !empty($settings['post_lightbox_down']),
'lightbox_play' => !empty($settings['post_lightbox_play']),
'related_enabled' => !isset($settings['post_related_enabled']) || !empty($settings['post_related_enabled']),
'related_count' => max(1, min(20, (int) ($settings['post_related_count'] ?? 6))),
// Display style (Zibll img/list/text) + query source (category/tag/random).
'related_style' => $related_style,
'related_source' => $related_source,
// Legacy alias: older code treated related_type as source.
'related_type' => $related_source,
'related_orderby' => $related_orderby,
'related_title' => sanitize_text_field((string) ($settings['post_related_title'] ?? '相关推荐')),
'related_enabled' => !isset($settings['post_related_s']) || !empty($settings['post_related_s']),
'related_count' => max(4, min(12, (int) ($settings['post_related_n'] ?? 6))),
'related_style' => $related_style,
'related_orderby' => $related_orderby,
'related_title' => sanitize_text_field((string) ($settings['related_title'] ?? '相关推荐')),
'like_enabled' => !isset($settings['post_like_enabled']) || !empty($settings['post_like_enabled']),
'favorite_enabled' => !isset($settings['post_favorite_enabled']) || !empty($settings['post_favorite_enabled']),
// Canonical + legacy share.
@@ -534,42 +430,21 @@ class PostDisplay {
}
public static function apply_list_per_page($query): void {
if (is_admin() || !$query->is_main_query()) {
return;
}
if (!$query->is_archive() && !$query->is_search() && !$query->is_home()) {
return;
}
$s = Settings::get_all();
$per_page = max(4, min(48, (int) ($s['post_list_per_page'] ?? 12)));
if ($per_page !== 12) {
$query->set('posts_per_page', $per_page);
}
unset($query);
}
public static function get_archive_layout(): string {
$settings = self::get_post_list_style_settings();
return $settings['render_mode'];
return ($settings['list_type'] ?? 'thumb') === 'card' ? 'card' : 'list';
}
public static function get_post_pagination_mode(): string {
$settings = 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';
if (!self::is_list_paging_ajax($settings)) {
return 'numbered';
}
// 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';
return self::is_list_paging_ajax_ias($settings) ? 'infinite' : 'load_more';
}
/**
@@ -579,12 +454,7 @@ class PostDisplay {
*/
public static function is_list_paging_ajax(?array $settings = null): bool {
$settings = $settings ?? 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'];
$raw = $settings['paging_ajax_s'] ?? '1';
if (is_bool($raw)) {
return $raw;
}
@@ -601,11 +471,7 @@ class PostDisplay {
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']);
return !array_key_exists('paging_ajax_ias_s', $settings) || !empty($settings['paging_ajax_ias_s']);
}
public static function get_comment_pagination_mode(): string {
+5 -8
View File
@@ -646,9 +646,9 @@ class Settings {
/**
* Post-list card style and meta display settings.
*
* @return array{card_style:string,render_mode:string,show_author:bool,show_date:bool,show_views:bool,show_category:bool,show_comments:bool,show_likes:bool,excerpt_length:int}
* Zibll 9.0 post-list display settings.
*
* @return array<string,mixed>
*/
public static function get_post_list_style_settings(): array {
return PostDisplay::get_post_list_style_settings();
@@ -659,7 +659,7 @@ class Settings {
/**
* Post-list thumbnail policy settings.
*
* @return array{priority:string[],fallback:string,aspect_ratio:string,multi_enabled:bool,multi_count:int,lazy:bool}
* @return array<string,mixed>
*/
public static function get_post_thumb_settings(): array {
return PostDisplay::get_post_thumb_settings();
@@ -949,10 +949,7 @@ class Settings {
/**
* 获取归档布局模式。
*
* 从 post_list.list schema 的 render_mode 字段读取。
* 后台可在 /post-list/list 页面配置。
*
* @return string grid-cms|list|compact
* @return string card|list
*/
public static function get_archive_layout(): string {
return PostDisplay::get_archive_layout();
+28 -27
View File
@@ -31,48 +31,49 @@ final class PostRenderer {
$style = (string) ($instance['style'] ?? 'card');
$mode = in_array($style, ['list', 'card', 'mini'], true) ? $style : 'card';
$config = [
'mode' => $mode,
'context' => 'widget',
'columns' => $mode === 'card' ? 3 : 1,
'show_thumb' => $slug !== 'hot_posts' || !empty($instance['show_thumbnail']),
'show_meta' => $mode !== 'mini',
'show_excerpt' => $mode === 'list',
'show_author' => false,
'show_comments' => true,
'show_likes' => true,
'show_tags' => false,
'show_badges' => true,
'type' => $mode === 'card' ? 'card' : 'list',
'show_number' => $slug === 'hot_posts',
'show_thumb' => $slug !== 'hot_posts' || !array_key_exists('show_thumbnail', $instance) || !empty($instance['show_thumbnail']),
'show_meta' => true,
'number_offset' => ($page - 1) * max(1, (int) ($instance['count'] ?? 8)),
'wrapper_class' => 'aksrt-widget-posts aksrt-widget-posts--' . $slug,
'widget_style' => $mode,
];
if ($slug === 'oneline_posts') {
return self::oneline($query, $config, !empty($instance['autoplay']));
}
if (function_exists('aksrt_render_post_list')) {
return aksrt_render_post_list($query, $config, false);
if ($mode === 'mini') {
return aksrt_render_mini_list($query, $config, false);
}
$html = '<div class="aksrt-widget-posts aksrt-widget-posts--fallback">';
while ($query->have_posts()) {
$query->the_post();
$html .= '<article><a href="' . esc_url(get_permalink()) . '">' . get_the_post_thumbnail(get_the_ID(), 'medium') . '<strong>' . esc_html(get_the_title()) . '</strong></a></article>';
}
wp_reset_postdata();
return $html . '</div>';
return aksrt_render_post_list($config, $query, false);
}
private static function oneline(\WP_Query $query, array $config, bool $autoplay): string {
$slides = '';
$items = '';
$style = in_array(($config['widget_style'] ?? 'card'), ['list', 'card', 'mini'], true)
? (string) $config['widget_style']
: 'card';
while ($query->have_posts()) {
$query->the_post();
$item = function_exists('aksrt_render_post')
? aksrt_render_post(array_merge($config, ['skip_wrapper' => true]))
: '<a href="' . esc_url(get_permalink()) . '">' . esc_html(get_the_title()) . '</a>';
$slides .= '<div class="swiper-slide">' . $item . '</div>';
if ($style === 'mini') {
$data = aksrt_renderer_collect_post_data($config);
$items .= $data ? aksrt_renderer_mini($data, array_merge($config, [
'class' => 'posts-item',
'show_thumb' => true,
'show_meta' => true,
'show_number' => false,
])) : '';
} else {
$items .= aksrt_render_post(array_merge($config, [
'type' => $style === 'card' ? 'card' : 'list',
'is_mult_thumb' => 'disable',
'is_no_thumb' => 'disable',
]));
}
}
wp_reset_postdata();
return '<div class="swiper aksrt-widget-swiper aksrt-widget-oneline" data-aksrt-swiper="scroll" data-autoplay="' . ($autoplay ? '1' : '0') . '"><div class="swiper-wrapper">' . $slides . '</div><button class="swiper-button-prev" type="button" aria-label="' . esc_attr__('上一组', 'aksrt') . '"></button><button class="swiper-button-next" type="button" aria-label="' . esc_attr__('下一组', 'aksrt') . '"></button></div>';
$autoplay_attr = $autoplay ? ' data-autoplay="true"' : '';
return '<div class="widget-main-post mb20 style-' . esc_attr($style) . '"><div class="swiper-container swiper-scroll" data-slideClass="posts-item"' . $autoplay_attr . '><div class="swiper-wrapper">' . $items . '</div><div class="swiper-button-prev"></div><div class="swiper-button-next"></div></div></div>';
}
private static function pagination(array $instance, int $page, int $max_pages): string {