feat(frontend): replace article system with Zibll 9.0
This commit is contained in:
+44
-60
@@ -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([
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
|
||||
@@ -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' => '没有更多内容了'],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user