104 lines
3.6 KiB
PHP
104 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* Generic archive template.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
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'),
|
|
];
|
|
|
|
// 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_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
|
|
);
|
|
}
|
|
} elseif ($archive_description !== '') {
|
|
$archive_summary = $archive_description;
|
|
} elseif (isset($wp_query->found_posts)) {
|
|
$archive_summary = sprintf(
|
|
esc_html(_n('共 %d 篇内容', '共 %d 篇内容', (int) $wp_query->found_posts, 'aksrt')),
|
|
(int) $wp_query->found_posts
|
|
);
|
|
}
|
|
?>
|
|
|
|
<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
|
|
get_footer();
|