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();
-66
View File
@@ -1,66 +0,0 @@
<?php
/**
* Special Page Cover
*
* Renders the cover section for a special/topic page with
* background image, title, summary, and metadata.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$post_id = get_the_ID();
$cover_img = get_the_post_thumbnail_url($post_id, 'large');
$default_cover = isset($default_cover) ? $default_cover : '';
$show_post_count = isset($show_post_count) ? $show_post_count : true;
if (empty($cover_img) && !empty($default_cover)) {
$cover_img = $default_cover;
}
$title = get_the_title();
$excerpt = get_the_excerpt();
$summary_len = isset($summary_len) ? (int) $summary_len : 200;
if ($excerpt) {
$excerpt = wp_trim_words($excerpt, $summary_len, '...');
}
// Per-page meta
$cover_color = get_post_meta($post_id, '_aksrt_special_cover_color', true);
$cover_style = '';
if ($cover_color) {
$cover_style = 'background-color:' . sanitize_hex_color($cover_color) . ';';
}
?>
<header class="aksrt-special-cover" <?php echo $cover_style ? 'style="' . esc_attr($cover_style) . '"' : ''; ?>>
<?php if ($cover_img) : ?>
<div class="aksrt-special-cover__bg">
<img src="<?php echo esc_url($cover_img); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('cover') : ' loading="lazy"'; ?> class="aksrt-special-cover__img">
<div class="aksrt-special-cover__overlay"></div>
</div>
<?php endif; ?>
<div class="aksrt-special-cover__content">
<h1 class="aksrt-special-cover__title"><?php echo esc_html($title); ?></h1>
<?php if ($excerpt) : ?>
<p class="aksrt-special-cover__summary"><?php echo esc_html($excerpt); ?></p>
<?php endif; ?>
<div class="aksrt-special-cover__meta">
<span class="aksrt-special-cover__date">
<i class="fas fa-calendar-alt"></i>
<?php echo esc_html(get_the_date()); ?>
</span>
<?php
if ($show_post_count) :
$children = get_pages(['child_of' => $post_id, 'parent' => $post_id, 'post_status' => 'publish', 'fields' => 'ids']);
if (!empty($children)) : ?>
<span class="aksrt-special-cover__count">
<i class="fas fa-file-alt"></i>
<?php printf(esc_html__('%d 篇文章', 'aksrt'), count($children)); ?>
</span>
<?php endif; endif; ?>
</div>
</div>
</header>
-46
View File
@@ -1,46 +0,0 @@
<?php
/**
* Special Page Grid
*
* Renders the content grid for a special/topic page.
* Supports grid, list, and masonry layouts.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$posts = isset($posts) ? $posts : [];
$layout = isset($layout) ? $layout : 'grid';
$columns = isset($columns) ? (int) $columns : 2;
$show_dates = isset($show_dates) ? $show_dates : true;
if (empty($posts)) return;
?>
<div class="aksrt-special-grid aksrt-special-grid--<?php echo esc_attr($layout); ?>" style="--aksrt-cols:<?php echo esc_attr((string) $columns); ?>">
<?php foreach ($posts as $post) :
setup_postdata($post);
$img = get_the_post_thumbnail_url($post->ID, 'medium');
?>
<article class="aksrt-special-grid__item">
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" class="aksrt-special-grid__link">
<?php if ($img) : ?>
<div class="aksrt-special-grid__thumb">
<img src="<?php echo esc_url($img); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
</div>
<?php endif; ?>
<div class="aksrt-special-grid__body">
<h3 class="aksrt-special-grid__title"><?php echo esc_html($post->post_title); ?></h3>
<?php if ($post->post_excerpt) : ?>
<p class="aksrt-special-grid__desc"><?php echo esc_html(wp_trim_words($post->post_excerpt, 20)); ?></p>
<?php endif; ?>
<?php if ($show_dates) : ?>
<time class="aksrt-special-grid__date" datetime="<?php echo esc_attr(get_the_date('c', $post->ID)); ?>">
<?php echo esc_html(get_the_date('', $post->ID)); ?>
</time>
<?php endif; ?>
</div>
</a>
</article>
<?php endforeach; wp_reset_postdata(); ?>
</div>
-15
View File
@@ -98,19 +98,6 @@ if (is_wp_error($categories)) {
}
$current_cats = $edit_post ? wp_get_post_categories($edit_post->ID) : [];
$topics_terms = [];
$current_topics = [];
if (!empty($settings['topics_s']) && taxonomy_exists('topics')) {
$topics_terms = get_terms(['taxonomy' => 'topics', 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC']);
if (is_wp_error($topics_terms)) {
$topics_terms = [];
}
if ($edit_post) {
$t = wp_get_object_terms($edit_post->ID, 'topics', ['fields' => 'ids']);
$current_topics = is_wp_error($t) ? [] : $t;
}
}
$custom_dimensions = [];
$current_cf = [];
if (!empty($settings['custom_filter_s']) && class_exists('\AKSRT\Settings\Settings')) {
@@ -192,8 +179,6 @@ return [
'featured_args' => $featured_args,
'categories' => $categories,
'current_cats' => $current_cats,
'topics_terms' => $topics_terms,
'current_topics' => $current_topics,
'custom_dimensions' => $custom_dimensions,
'current_cf' => $current_cf,
'current_title' => $current_title,
-12
View File
@@ -48,18 +48,6 @@ if (file_exists($term_helper)) {
</details>
<?php endif; ?>
<?php if (!empty($settings['topics_s']) && !empty($ctx['topics_terms'])) : ?>
<details class="aksrt-submit-drop">
<summary>
<span><i class="fa fa-cube"></i> <?php esc_html_e('专题', 'aksrt'); ?></span>
<i class="fa fa-angle-right"></i>
</summary>
<div class="aksrt-submit-drop__body">
<?php aksrt_submit_render_term_checks($ctx['topics_terms'], array_map('intval', $ctx['current_topics']), 'topics', 'topics'); ?>
</div>
</details>
<?php endif; ?>
<?php if (!empty($settings['custom_filter_s']) && !empty($ctx['custom_dimensions'])) : ?>
<?php foreach ($ctx['custom_dimensions'] as $dim) :
$key = sanitize_key((string) ($dim['key'] ?? ''));
+6 -6
View File
@@ -30,16 +30,16 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext
$items = is_array($list['items'] ?? null) ? $list['items'] : [];
$total_pages = max(1, (int) ($list['total_pages'] ?? 1));
?>
<div class="uh-forum__subtabs uh-follow__subtabs">
<a class="uh-forum__subtab<?php echo $follow_sub === 'following' ? ' is-active' : ''; ?>"
<div class="uh-follow__subtabs">
<a class="uh-follow__subtab<?php echo $follow_sub === 'following' ? ' is-active' : ''; ?>"
href="<?php echo esc_url(add_query_arg(['tab' => 'follow', 'follow_sub' => 'following', 'follow_page' => 1], $home_url)); ?>">
<i class="fas fa-user-plus"></i> <?php esc_html_e('关注', 'aksrt'); ?>
<span class="uh-forum__subtab-count"><?php echo esc_html((string) $following_count); ?></span>
<span class="uh-follow__subtab-count"><?php echo esc_html((string) $following_count); ?></span>
</a>
<a class="uh-forum__subtab<?php echo $follow_sub === 'followers' ? ' is-active' : ''; ?>"
<a class="uh-follow__subtab<?php echo $follow_sub === 'followers' ? ' is-active' : ''; ?>"
href="<?php echo esc_url(add_query_arg(['tab' => 'follow', 'follow_sub' => 'followers', 'follow_page' => 1], $home_url)); ?>">
<i class="fas fa-users"></i> <?php esc_html_e('粉丝', 'aksrt'); ?>
<span class="uh-forum__subtab-count"><?php echo esc_html((string) $follower_count); ?></span>
<span class="uh-follow__subtab-count"><?php echo esc_html((string) $follower_count); ?></span>
</a>
</div>
@@ -64,7 +64,7 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext
<?php endforeach; ?>
</div>
<?php if ($total_pages > 1) : ?>
<div class="uh-forum__pagination">
<div class="uh-follow__pagination">
<?php
echo paginate_links([
'base' => add_query_arg(['tab' => 'follow', 'follow_sub' => $follow_sub, 'follow_page' => '%#%'], $home_url),