统一 archive/category/tag/search 主内容流壳层
抽出 aksrt-archive 共享 shell/stream/render config, 四类列表页统一 content-shell + shared renderer + page-owned sidebar。
This commit is contained in:
+51
-71
@@ -11,47 +11,19 @@ get_header();
|
||||
|
||||
global $wp_query;
|
||||
|
||||
$list_settings = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::get_post_list_style_settings()
|
||||
: ['render_mode' => 'card', 'card_style' => 'standard'];
|
||||
$render_config = [
|
||||
'context' => 'archive',
|
||||
'mode' => (string) ($list_settings['render_mode'] ?? 'card'),
|
||||
'card_style' => (string) ($list_settings['card_style'] ?? 'standard'),
|
||||
];
|
||||
$render_config = function_exists('aksrt_archive_get_render_config')
|
||||
? aksrt_archive_get_render_config(['context' => 'archive'])
|
||||
: ['context' => 'archive', 'mode' => 'card', 'card_style' => 'standard'];
|
||||
$has_sidebar = function_exists('aksrt_archive_has_sidebar')
|
||||
? aksrt_archive_has_sidebar()
|
||||
: (function_exists('aksrt_is_show_sidebar') ? aksrt_is_show_sidebar() : false);
|
||||
|
||||
// Per-category card mode override: if visiting a category in card_cat_ids, force card mode
|
||||
if (is_category() && !empty($list_settings['card_cat_ids'])) {
|
||||
$current_cat_id = (int) get_queried_object_id();
|
||||
if (in_array($current_cat_id, $list_settings['card_cat_ids'], true)) {
|
||||
$render_config['mode'] = 'card';
|
||||
}
|
||||
}
|
||||
|
||||
// Per-category multi-thumb override
|
||||
if (is_category() && class_exists('AKSRT_Settings')) {
|
||||
$thumb_settings = AKSRT_Settings::get_post_thumb_settings();
|
||||
if (!empty($thumb_settings['mult_thumb_cat_ids'])) {
|
||||
$current_cat_id = (int) get_queried_object_id();
|
||||
if (in_array($current_cat_id, $thumb_settings['mult_thumb_cat_ids'], true)) {
|
||||
$render_config['multi_thumb_enabled'] = true;
|
||||
$render_config['multi_thumb_limit'] = (int) ($thumb_settings['multi_count'] ?? 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$has_sidebar = function_exists('aksrt_is_show_sidebar') ? aksrt_is_show_sidebar() : false;
|
||||
$archive_description = trim(strip_tags((string) get_the_archive_description()));
|
||||
$archive_description = trim(wp_strip_all_tags((string) get_the_archive_description()));
|
||||
$archive_summary = '';
|
||||
|
||||
if (is_author()) {
|
||||
$author = get_queried_object();
|
||||
if ($author instanceof WP_User) {
|
||||
$archive_summary = sprintf(
|
||||
/* translators: %s: author display name */
|
||||
__('作者:%s', 'aksrt'),
|
||||
$author->display_name
|
||||
);
|
||||
$archive_summary = sprintf(__('作者:%s', 'aksrt'), $author->display_name);
|
||||
}
|
||||
} elseif ($archive_description !== '') {
|
||||
$archive_summary = $archive_description;
|
||||
@@ -61,43 +33,51 @@ if (is_author()) {
|
||||
(int) $wp_query->found_posts
|
||||
);
|
||||
}
|
||||
|
||||
if (function_exists('aksrt_archive_open_shell')) {
|
||||
aksrt_archive_open_shell([
|
||||
'main_class' => 'site-main content-shell content-shell--stream',
|
||||
'has_sidebar' => $has_sidebar,
|
||||
'page_kind' => 'archive',
|
||||
]);
|
||||
} else {
|
||||
echo '<main id="main-content" class="site-main content-shell content-shell--stream" tabindex="-1"><div class="content-wrap"><div class="content-layout' . ($has_sidebar ? '' : ' content-layout--no-sidebar') . '"><div class="content-layout__primary">';
|
||||
}
|
||||
?>
|
||||
<div class="content-main content-main--archive">
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell content-shell--stream" tabindex="-1">
|
||||
<div class="content-layout<?php echo $has_sidebar ? '' : ' content-layout--no-sidebar'; ?>">
|
||||
<div class="content-layout__primary">
|
||||
<div class="content-main content-main--archive">
|
||||
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||
|
||||
<?php
|
||||
$admin_link = function_exists('aksrt_render_admin_quick_link') ? aksrt_render_admin_quick_link('post-list/list', __('列表样式设置', 'aksrt')) : '';
|
||||
set_query_var('aksrt_ph_eyebrow', __('内容归档', 'aksrt'));
|
||||
set_query_var('aksrt_ph_title', get_the_archive_title());
|
||||
set_query_var('aksrt_ph_desc', $archive_summary);
|
||||
set_query_var('aksrt_ph_extra', $admin_link);
|
||||
get_template_part('templates/parts/page-header');
|
||||
?>
|
||||
|
||||
<section class="content-stream content-stream--archive" data-page-kind="archive" data-render-mode="<?php echo esc_attr((string) $render_config['mode']); ?>" data-card-style="<?php echo esc_attr((string) $render_config['card_style']); ?>">
|
||||
<?php if (have_posts()) : ?>
|
||||
<?php aksrt_render_post_list(null, array_merge($render_config, ['wrapper_class' => 'content-stream__list'])); ?>
|
||||
<div class="content-stream__footer">
|
||||
<?php aksrt_render_pagination(null, ['query_context' => 'archive', 'render_config' => $render_config]); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="no-results content-stream__empty">
|
||||
<p><?php esc_html_e('暂无文章', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($has_sidebar) : ?>
|
||||
<?php get_sidebar(); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</main>
|
||||
<?php
|
||||
ob_start();
|
||||
if (function_exists('aksrt_render_admin_quick_link')) {
|
||||
aksrt_render_admin_quick_link('post-list/list', __('列表样式设置', 'aksrt'));
|
||||
}
|
||||
$admin_link = trim((string) ob_get_clean());
|
||||
set_query_var('aksrt_ph_eyebrow', __('内容归档', 'aksrt'));
|
||||
set_query_var('aksrt_ph_title', get_the_archive_title());
|
||||
set_query_var('aksrt_ph_desc', $archive_summary);
|
||||
set_query_var('aksrt_ph_extra', $admin_link);
|
||||
get_template_part('templates/parts/page-header');
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (function_exists('aksrt_archive_render_stream')) {
|
||||
aksrt_archive_render_stream(null, $render_config, [
|
||||
'page_kind' => 'archive',
|
||||
'query_context' => 'archive',
|
||||
'stream_class' => 'content-stream--archive',
|
||||
'empty_text' => __('暂无文章', 'aksrt'),
|
||||
]);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if (function_exists('aksrt_archive_close_shell')) {
|
||||
aksrt_archive_close_shell(['has_sidebar' => $has_sidebar]);
|
||||
} else {
|
||||
echo '</div>';
|
||||
if ($has_sidebar) { get_sidebar(); }
|
||||
echo '</div></div></main>';
|
||||
}
|
||||
|
||||
get_footer();
|
||||
|
||||
Reference in New Issue
Block a user