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([