From 98aeee3cc18e8b30c54787ca0151f4ae4cc366e1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Jul 2026 19:05:43 +0800 Subject: [PATCH] fix(phase1): backfill pagination, fix card stacking, unify archive render - Backfill aksrt_render_pagination() into inc/helpers/aksrt-template-tags.php (numbered + load_more/infinite branches, \AKSRT\Settings\Settings facade) - post-card.css: drop display:block !important from base .posts-item so .posts-item.card inline-block 3-col grid wins; scope block forcing - archive-resources.php: replace hand-written .posts-row.ajaxpager + get_template_part loop with aksrt_render_post_list() + aksrt_render_pagination() Refs .specs/plans/zibll-widgets-1to1.md Phase 1 (US2/US3/US5) Co-Authored-By: Claude Fable 5 --- archive-resources.php | 28 ++++--- assets/css/frontend/post-card.css | 8 +- inc/helpers/aksrt-template-tags.php | 116 ++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 13 deletions(-) diff --git a/archive-resources.php b/archive-resources.php index 0edc2f88..facd0a68 100644 --- a/archive-resources.php +++ b/archive-resources.php @@ -159,18 +159,24 @@ $has_filter = $current_orderby !== 'date' || $current_price !== 'all' || $price_ -
- -
+ 'archive', + 'overrides' => ['mode' => 'card'], + ]) + : ['context' => 'archive', 'mode' => 'card']; - + if (function_exists('aksrt_render_post_list')) { + aksrt_render_post_list(null, array_merge($render_config, ['wrapper_class' => 'content-stream__list'])); + } + if (function_exists('aksrt_render_pagination')) { + aksrt_render_pagination(null, [ + 'query_context' => 'archive', + 'render_config' => $render_config, + ]); + } + ?>

diff --git a/assets/css/frontend/post-card.css b/assets/css/frontend/post-card.css index fa7ab527..fee34016 100644 --- a/assets/css/frontend/post-card.css +++ b/assets/css/frontend/post-card.css @@ -28,8 +28,6 @@ posts.posts-item, article.posts-item, .posts-item { - /* Custom element is inline by default — force block layout. */ - display: block !important; opacity: 1 !important; visibility: visible !important; padding: 20px; @@ -45,6 +43,12 @@ article.posts-item, opacity: 1; } +/* Custom element is inline by default — force block layout here only, + scoped so it never overrides .posts-item.card inline-block grid (Phase 1 fix). */ +posts.posts-item { + display: block; +} + .posts-item.list { display: block; width: 100%; diff --git a/inc/helpers/aksrt-template-tags.php b/inc/helpers/aksrt-template-tags.php index 307529e0..877ba5d6 100644 --- a/inc/helpers/aksrt-template-tags.php +++ b/inc/helpers/aksrt-template-tags.php @@ -1126,6 +1126,122 @@ if (!function_exists('aksrt_render_comment_pagination')) { } } +// ============================================================ +// 模板标签:文章列表分页渲染 +// ============================================================ + +if (!function_exists('aksrt_render_pagination')) { + /** + * 渲染文章列表分页(根据后台配置选择模式)。 + * + * Zibll 对齐:numbered = 数字分页按钮;load_more/infinite = AJAX 追加。 + * + * @param WP_Query|null $query 可选,传入自定义查询对象;默认用主查询。 + * @param array $args { + * @type string $query_context search|archive|home|tag|category... 供 AJAX 路由解析。 + * @type array $render_config 透传给 AJAX 渲染器(aksrt_resolve_post_list_render_config)。 + * } + */ + function aksrt_render_pagination(?WP_Query $query = null, array $args = []): void { + $pagination_mode = class_exists('\AKSRT\Settings\Settings') + ? \AKSRT\Settings\Settings::get_post_pagination_mode() + : 'numbered'; + + if ($pagination_mode === 'numbered') { + global $wp_query; + $q = $query ?? $wp_query; + if (!($q instanceof WP_Query) || $q->max_num_pages <= 1) { + return; + } + + $current_page = max(1, (int) $q->get('paged'), (int) get_query_var('paged'), (int) get_query_var('page')); + $max_pages = (int) $q->max_num_pages; + $links = paginate_links([ + 'total' => $max_pages, + 'current' => $current_page, + 'mid_size' => 2, + 'prev_text' => '', + 'next_text' => '', + 'type' => 'plain', + ]); + + if (empty($links)) { + return; + } + + echo ''; + return; + } + + // load_more / infinite 模式 + global $wp_query; + $q = $query ?? $wp_query; + if (!($q instanceof WP_Query)) { + return; + } + $max_pages = (int) $q->max_num_pages; + $current_page = max(1, (int) $q->get('paged'), (int) get_query_var('paged'), (int) get_query_var('page')); + + if ($current_page >= $max_pages) { + return; + } + + $query_context = ''; + if (!empty($args['query_context']) && is_string($args['query_context'])) { + $query_context = sanitize_key($args['query_context']); + } elseif (is_search()) { + $query_context = 'search'; + } elseif (is_archive()) { + $query_context = 'archive'; + } + + $query_vars = $q->query_vars; + if (!is_array($query_vars)) { + $query_vars = []; + } else { + unset($query_vars['paged'], $query_vars['page']); + } + + $render_config = !empty($args['render_config']) && is_array($args['render_config']) + ? $args['render_config'] + : []; + + $trigger_text = __('加载更多', 'aksrt'); + if (class_exists('\AKSRT\Settings\Settings')) { + $list_settings = \AKSRT\Settings\Settings::get_post_list_style_settings(); + if (!empty($list_settings['ajax_trigger_text'])) { + $trigger_text = (string) $list_settings['ajax_trigger_text']; + } + } + ?> + +