refactor: remove forum and topic feature chains

This commit is contained in:
kate522 committed 2026-08-17 14:52:19 +08:00
1 parent 698e3750f9
commit 6c6c462df8
69 files changed
+339 -2057

No files matched your search

-148
View File
@@ -1,148 +0,0 @@
<?php
/**
* Template Name: AKSRT - Special Page
*
* 专题聚合页模板 — 用于内容专题、活动页、产品介绍页等。
* 读取 \AKSRT\Settings\Settings 中的 page_display.special 配置,支持 per-page meta 覆盖。
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
get_header();
$post_id = get_the_ID();
// 从门面 getter 读取专题页设置(validated & sanitized)
$special = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_special_page_settings()
: [];
$defaults = [
'cover_enabled' => true,
'summary_enabled' => true,
'summary_length' => 200,
'default_cover' => '',
'layout' => 'grid',
'columns' => 2,
'source_type' => 'category',
'source_ids' => '',
'subpage_display' => 'cards',
'subpage_count' => 6,
'sidebar' => true,
'pagination' => 'numeric',
'per_page' => 12,
'post_count' => false,
'orderby' => 'date',
];
$settings = array_merge($defaults, $special);
// Per-page meta override
$meta_layout = get_post_meta($post_id, '_aksrt_special_layout', true);
$meta_columns = get_post_meta($post_id, '_aksrt_special_columns', true);
$meta_source = get_post_meta($post_id, '_aksrt_special_source_type', true);
$meta_ids = get_post_meta($post_id, '_aksrt_special_source_ids', true);
if ($meta_layout) $settings['layout'] = sanitize_key($meta_layout);
if ($meta_columns) $settings['columns'] = max(1, min(4, (int) $meta_columns));
if ($meta_source) $settings['source_type'] = sanitize_key($meta_source);
if ($meta_ids !== '' && $meta_ids !== false) $settings['source_ids'] = $meta_ids;
$layout = in_array($settings['layout'], ['grid', 'list', 'masonry'], true) ? $settings['layout'] : 'grid';
$columns = max(1, min(4, (int) $settings['columns']));
$show_cover = !empty($settings['cover_enabled']);
$show_summary = !empty($settings['summary_enabled']);
$summary_len = max(50, min(500, (int) $settings['summary_length']));
$subpage_style = in_array($settings['subpage_display'], ['cards', 'list', 'timeline'], true) ? $settings['subpage_display'] : 'cards';
$per_page = max(4, min(48, (int) $settings['per_page']));
$orderby = in_array($settings['orderby'], ['date', 'modified', 'views', 'comments'], true) ? $settings['orderby'] : 'date';
// 聚合内容源
$source_type = sanitize_key($settings['source_type']);
$source_ids = array_filter(array_map('absint', explode(',', (string) $settings['source_ids'])));
$aggregated_posts = [];
if (!empty($source_ids)) {
$args = [
'posts_per_page' => $per_page,
'post_status' => 'publish',
'orderby' => ($orderby === 'modified') ? 'modified' : 'date',
'order' => 'DESC',
];
if ($source_type === 'category') {
$args['category__in'] = $source_ids;
} elseif ($source_type === 'tag') {
$args['tag__in'] = $source_ids;
}
$aggregated_query = new WP_Query($args);
$aggregated_posts = $aggregated_query->posts;
}
// 子页面列表
$children_per_page = max(1, min(20, (int) $settings['subpage_count']));
$children = get_pages([
'child_of' => $post_id,
'sort_column' => 'menu_order',
'sort_order' => 'ASC',
'parent' => $post_id,
'number' => $children_per_page,
]);
?>
<main id="main-content" class="site-main content-shell content-shell--page aksrt-special--<?php echo esc_attr($layout); ?>" tabindex="-1">
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
<?php if ($show_cover) :
$default_cover = $settings['default_cover'] ?? '';
$show_post_count = !empty($settings['post_count']);
include get_template_directory() . '/templates/parts/special/special-cover.php';
endif; ?>
<div class="aksrt-special-content container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="aksrt-special-content__body">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
</div>
<?php if (!empty($aggregated_posts)) : ?>
<section class="aksrt-special-aggregated container">
<h2 class="aksrt-special-aggregated__title"><?php esc_html_e('相关内容', 'aksrt'); ?></h2>
<?php
// Use the special-grid part
$grid_posts = $aggregated_posts;
$show_dates = true;
include get_template_directory() . '/templates/parts/special/special-grid.php';
?>
</section>
<?php endif; ?>
<?php if (!empty($children)) : ?>
<section class="aksrt-special-children container">
<h2 class="aksrt-special-children__title"><?php esc_html_e('子页面', 'aksrt'); ?></h2>
<div class="aksrt-special-children__grid aksrt-special-children__grid--<?php echo esc_attr($subpage_style); ?>" style="--aksrt-cols:<?php echo esc_attr((string) $columns); ?>">
<?php foreach ($children as $child) :
$child_img = get_the_post_thumbnail_url($child->ID, 'medium');
?>
<a href="<?php echo esc_url(get_permalink($child->ID)); ?>" class="aksrt-special-child-card">
<?php if ($child_img) : ?>
<div class="aksrt-special-child-card__image">
<img src="<?php echo esc_url($child_img); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
</div>
<?php endif; ?>
<div class="aksrt-special-child-card__body">
<h3 class="aksrt-special-child-card__title"><?php echo esc_html($child->post_title); ?></h3>
<?php if ($child->post_excerpt !== '') : ?>
<p class="aksrt-special-child-card__desc"><?php echo esc_html(wp_trim_words($child->post_excerpt, 30)); ?></p>
<?php endif; ?>
</div>
</a>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
</main>
<?php
get_footer();