Files
wordpress-theme-aksrt/templates/forum/forum-plate-cat.php
T
kate522 aaf458af1c refactor(autoload): migrate theme classes to Composer PSR-4
Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
2026-07-17 13:29:22 +08:00

116 lines
5.0 KiB
PHP

<?php
/**
* Plate category (分区) archive template.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
get_header();
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
$term = get_queried_object();
$cat_id = $term ? (int) $term->term_id : 0;
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
$forum_names = $forum_settings['names'] ?? [];
$forum_name = $forum_names['forum'] ?? __('论坛', 'aksrt');
$plates = [];
if ($forum && $cat_id > 0) {
$plates = $forum->get_sorted_plates('menu_order', 'ASC', 100);
$plates = array_filter($plates, static function ($plate) use ($cat_id): bool {
return isset($plate['plate_cat']['id']) && (int) $plate['plate_cat']['id'] === $cat_id;
});
$plates = array_values($plates);
}
$cat_moderator_ids = get_term_meta($cat_id, '_aksrt_cat_moderator', true);
$cat_moderators = [];
if (is_array($cat_moderator_ids)) {
foreach ($cat_moderator_ids as $uid) {
$user = get_userdata((int) $uid);
if ($user) {
$cat_moderators[] = [
'id' => (int) $user->ID,
'name' => $user->display_name,
'avatar' => function_exists('aksrt_get_avatar_url') ? aksrt_get_avatar_url($user->ID, 36) : get_avatar_url($user->ID, ['size' => 36]),
];
}
}
}
?>
<main id="main-content" class="site-main content-shell content-shell--stream content-shell--forum" tabindex="-1">
<div class="content-wrap container">
<div class="content-layout content-layout--no-sidebar">
<div class="content-layout__primary">
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
<div class="aksrt-forum-plate-cat">
<div class="aksrt-forum-plate-cat__header">
<h1><?php echo esc_html($term ? $term->name : ''); ?></h1>
<?php if ($term && $term->description) : ?>
<p><?php echo esc_html($term->description); ?></p>
<?php endif; ?>
<?php if (!empty($cat_moderators)) : ?>
<div class="aksrt-forum-plate-cat__moderators">
<span><?php esc_html_e('分区版主:', 'aksrt'); ?></span>
<?php foreach ($cat_moderators as $mod) : ?>
<span class="aksrt-forum-plate-cat__moderator">
<?php if (!empty($mod['avatar'])) : ?>
<img src="<?php echo esc_url($mod['avatar']); ?>" alt="" width="24" height="24">
<?php endif; ?>
<?php echo esc_html($mod['name']); ?>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div class="aksrt-forum-plate-cat__plates">
<?php if (!empty($plates)) : ?>
<?php foreach ($plates as $plate) : ?>
<a href="<?php echo esc_url((string) ($plate['url'] ?? '#')); ?>" class="aksrt-forum-plate-cat__plate-card">
<?php if (!empty($plate['cover_url'])) : ?>
<img class="aksrt-forum-plate-cat__plate-cover" src="<?php echo esc_url($plate['cover_url']); ?>" alt="" loading="lazy">
<?php elseif (!empty($plate['icon'])) : ?>
<div class="aksrt-forum-plate-cat__plate-icon"><i class="<?php echo esc_attr($plate['icon']); ?>"></i></div>
<?php endif; ?>
<div class="aksrt-forum-plate-cat__plate-info">
<h3><?php echo esc_html((string) ($plate['name'] ?? '')); ?></h3>
<p><?php echo esc_html((string) ($plate['description'] ?? '')); ?></p>
<div class="aksrt-forum-plate-cat__plate-meta">
<span><?php printf(esc_html__('%d 主题', 'aksrt'), (int) ($plate['post_count'] ?? 0)); ?></span>
<span><?php printf(esc_html__('%d 关注', 'aksrt'), (int) ($plate['follow_count'] ?? 0)); ?></span>
<?php if (!empty($plate['is_hot'])) : ?>
<span class="aksrt-forum-plate-cat__hot-badge"><?php esc_html_e('热门', 'aksrt'); ?></span>
<?php endif; ?>
</div>
</div>
</a>
<?php endforeach; ?>
<?php else : ?>
<div class="aksrt-forum-plate-cat__empty">
<p><?php esc_html_e('该分区暂无版块。', 'aksrt'); ?></p>
</div>
<?php endif; ?>
</div>
<div class="aksrt-forum-plate-cat__back">
<a href="<?php echo esc_url(aksrt_get_forum_home_url()); ?>">
<i class="fas fa-arrow-left"></i> <?php printf(esc_html__('返回%s', 'aksrt'), esc_html($forum_name)); ?>
</a>
</div>
</div>
</div>
</div>
</div>
</main>
<?php get_footer(); ?>