refactor: remove forum and topic feature chains
This commit is contained in:
1 parent
698e3750f9
commit
6c6c462df8
69 files changed
+339
-2057
No files matched your search
+2
-2
@@ -17,7 +17,7 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-avatar.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-domain-model.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-template-tags.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-frontend-tags.php';
|
||||
// Comment kernel (shared by post / forum / shop surfaces).
|
||||
// Shared comment kernel.
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-ip-geo.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/comments/content.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/comments/actions.php';
|
||||
@@ -37,7 +37,7 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-single-aside.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-archive.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-archive-filters.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-comments.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-forum.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-page-template.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-slider.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-vip.php';
|
||||
require_once AKSRT_DIR . '/inc/helpers/aksrt-auth-ui.php';
|
||||
|
||||
+60
-83
@@ -1,83 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* AKSRT Theme Core Hooks
|
||||
*
|
||||
* 从 functions.php 中抽离的核心功能钩子:
|
||||
* - SMTP 邮件配置注入
|
||||
* - 评论开关控制
|
||||
* - Banner CPT 注册
|
||||
* - Admin Bar 隐藏
|
||||
*
|
||||
* @package AKSRT
|
||||
* @version 3.2.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// ============================================================
|
||||
// 评论功能开关
|
||||
// ============================================================
|
||||
|
||||
add_filter('comments_open', function ($open, $post_id) {
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$display = \AKSRT\Settings\Settings::get_comment_display_settings();
|
||||
if (!empty($display['close_comments'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $open;
|
||||
}, 10, 2);
|
||||
|
||||
add_filter('comment_text', function ($comment_text, $comment = null, $args = []) {
|
||||
if (function_exists('aksrt_render_comment_content')) {
|
||||
return aksrt_render_comment_content((string) $comment_text);
|
||||
}
|
||||
return $comment_text;
|
||||
}, 20, 3);
|
||||
|
||||
// ============================================================
|
||||
// 注册自定义文章类型 - Banner (REST API for SPA)
|
||||
// ============================================================
|
||||
|
||||
function aksrt_register_banner_cpt() {
|
||||
register_post_type('aksrt_banner', array(
|
||||
'labels' => array(
|
||||
'name' => __('Banners', 'aksrt'),
|
||||
'singular_name' => __('Banner', 'aksrt'),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => false,
|
||||
'show_in_rest' => true,
|
||||
'supports' => array('title'),
|
||||
'menu_icon' => 'dashicons-images-alt2',
|
||||
'capability_type' => 'post',
|
||||
'capabilities' => array('create_posts' => 'manage_options'),
|
||||
'map_meta_cap' => true,
|
||||
));
|
||||
}
|
||||
add_action('init', 'aksrt_register_banner_cpt');
|
||||
|
||||
// ============================================================
|
||||
// §3.7 Register Topics taxonomy for posts (专题分类)
|
||||
// ============================================================
|
||||
function aksrt_register_topics_taxonomy() {
|
||||
register_taxonomy('topics', 'post', [
|
||||
'labels' => [
|
||||
'name' => __('专题', 'aksrt'),
|
||||
'singular_name' => __('专题', 'aksrt'),
|
||||
'search_items' => __('搜索专题', 'aksrt'),
|
||||
'all_items' => __('所有专题', 'aksrt'),
|
||||
'edit_item' => __('编辑专题', 'aksrt'),
|
||||
'add_new_item' => __('添加专题', 'aksrt'),
|
||||
'menu_name' => __('专题', 'aksrt'),
|
||||
],
|
||||
'hierarchical' => true,
|
||||
'public' => true,
|
||||
'show_in_rest' => true,
|
||||
'show_admin_column' => true,
|
||||
'rewrite' => ['slug' => 'topics'],
|
||||
]);
|
||||
}
|
||||
add_action('init', 'aksrt_register_topics_taxonomy');
|
||||
|
||||
// ============================================================␍
|
||||
<?php
|
||||
/**
|
||||
* AKSRT Theme Core Hooks
|
||||
*
|
||||
* 从 functions.php 中抽离的核心功能钩子:
|
||||
* - SMTP 邮件配置注入
|
||||
* - 评论开关控制
|
||||
* - Banner CPT 注册
|
||||
* - Admin Bar 隐藏
|
||||
*
|
||||
* @package AKSRT
|
||||
* @version 3.2.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
// ============================================================
|
||||
// 评论功能开关
|
||||
// ============================================================
|
||||
|
||||
add_filter('comments_open', function ($open, $post_id) {
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$display = \AKSRT\Settings\Settings::get_comment_display_settings();
|
||||
if (!empty($display['close_comments'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $open;
|
||||
}, 10, 2);
|
||||
|
||||
add_filter('comment_text', function ($comment_text, $comment = null, $args = []) {
|
||||
if (function_exists('aksrt_render_comment_content')) {
|
||||
return aksrt_render_comment_content((string) $comment_text);
|
||||
}
|
||||
return $comment_text;
|
||||
}, 20, 3);
|
||||
|
||||
// ============================================================
|
||||
// 注册自定义文章类型 - Banner (REST API for SPA)
|
||||
// ============================================================
|
||||
|
||||
function aksrt_register_banner_cpt() {
|
||||
register_post_type('aksrt_banner', array(
|
||||
'labels' => array(
|
||||
'name' => __('Banners', 'aksrt'),
|
||||
'singular_name' => __('Banner', 'aksrt'),
|
||||
),
|
||||
'public' => false,
|
||||
'show_ui' => false,
|
||||
'show_in_rest' => true,
|
||||
'supports' => array('title'),
|
||||
'menu_icon' => 'dashicons-images-alt2',
|
||||
'capability_type' => 'post',
|
||||
'capabilities' => array('create_posts' => 'manage_options'),
|
||||
'map_meta_cap' => true,
|
||||
));
|
||||
}
|
||||
add_action('init', 'aksrt_register_banner_cpt');
|
||||
|
||||
// ============================================================
|
||||
@@ -31,7 +31,6 @@ if (!function_exists('aksrt_archive_get_list_style_settings')) :
|
||||
'card_cat_ids' => is_array($settings['card_cat_ids'] ?? null) ? array_map('intval', $settings['card_cat_ids']) : [],
|
||||
'card_home' => !empty($settings['card_home']),
|
||||
'card_tag' => !empty($settings['card_tag']),
|
||||
'card_topics' => !empty($settings['card_topics']),
|
||||
'card_author' => !empty($settings['card_author']),
|
||||
'list_show_type' => (string) ($settings['list_show_type'] ?? 'separate'),
|
||||
'list_img_position'=> (string) ($settings['list_img_position'] ?? 'left'),
|
||||
@@ -55,10 +54,10 @@ if (!function_exists('aksrt_resolve_post_list_render_config')) :
|
||||
* Decision order mirrors zib_mian_posts_while():
|
||||
* 1) explicit override mode/type
|
||||
* 2) global list_type (post_card_style): only "card" is card grid; thumb/text/thumb_if_has are list
|
||||
* 3) surface card switches (home/tag/topics/author/cat IDs)
|
||||
* 3) surface card switches (home/tag/author/cat IDs)
|
||||
*
|
||||
* @param array<string,mixed> $args {
|
||||
* @type string $context home|category|tag|topics|author|search|archive
|
||||
* @type string $context home|category|tag|author|search|archive
|
||||
* @type int $term_id Optional term id for list_card_cat
|
||||
* @type array<string,mixed> $overrides Optional renderer overrides (mode, style, …)
|
||||
* }
|
||||
@@ -84,8 +83,6 @@ if (!function_exists('aksrt_resolve_post_list_render_config')) :
|
||||
$context = 'category';
|
||||
} elseif (is_tag()) {
|
||||
$context = 'tag';
|
||||
} elseif (is_tax('topics')) {
|
||||
$context = 'topics';
|
||||
} elseif (is_author()) {
|
||||
$context = 'author';
|
||||
} elseif (is_search()) {
|
||||
@@ -126,8 +123,6 @@ if (!function_exists('aksrt_resolve_post_list_render_config')) :
|
||||
$mode = 'card';
|
||||
} elseif ($context === 'tag' && !empty($list['card_tag'])) {
|
||||
$mode = 'card';
|
||||
} elseif ($context === 'topics' && !empty($list['card_topics'])) {
|
||||
$mode = 'card';
|
||||
} elseif ($context === 'author' && !empty($list['card_author'])) {
|
||||
$mode = 'card';
|
||||
} elseif ($term_id > 0 && !empty($list['card_cat_ids']) && in_array($term_id, array_map('intval', (array) $list['card_cat_ids']), true)) {
|
||||
@@ -191,7 +186,7 @@ if (!function_exists('aksrt_resolve_post_list_render_config')) :
|
||||
$config['multi_thumb_limit'] = (int) ($thumb_settings['multi_count'] ?? 4);
|
||||
$config['multi_thumb_min'] = 3;
|
||||
}
|
||||
if (($context === 'category' || $context === 'topics') && !empty($thumb_settings['mult_thumb_cat_ids']) && $term_id > 0) {
|
||||
if ($context === 'category' && !empty($thumb_settings['mult_thumb_cat_ids']) && $term_id > 0) {
|
||||
if (in_array($term_id, array_map('intval', (array) $thumb_settings['mult_thumb_cat_ids']), true)) {
|
||||
$config['multi_thumb_enabled'] = true;
|
||||
$config['multi_thumb_limit'] = (int) ($thumb_settings['multi_count'] ?? 4);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Shared coupon burn helpers for cash content / topic orders.
|
||||
* Shared coupon burn helpers for cash content orders.
|
||||
*
|
||||
* Idempotent via coupon_usage.order_number. Prefer note.coupon snapshot ids
|
||||
* so burn still works after use_coupon increments used_count past limit.
|
||||
|
||||
@@ -34,7 +34,7 @@ if (!function_exists('aksrt_get_new_add_actions')) :
|
||||
/**
|
||||
* Build multi-type publish actions.
|
||||
*
|
||||
* @param string[] $types post|topic|product
|
||||
* @param string[] $types Currently only post is supported.
|
||||
* @return list<array{type:string,url:string,label:string,icon:string}>
|
||||
*/
|
||||
function aksrt_get_new_add_actions(array $types = ['post']): array {
|
||||
|
||||
@@ -87,7 +87,7 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
|
||||
if (!$term || is_wp_error($term)) {
|
||||
continue;
|
||||
}
|
||||
if (!in_array($term->taxonomy, ['category', 'topics'], true)) {
|
||||
if ($term->taxonomy !== 'category') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
File renamed without changes.
@@ -75,7 +75,7 @@ function aksrt_get_pay_types(): array {
|
||||
}
|
||||
|
||||
/**
|
||||
* Cash payment methods available for content/topic cashiers.
|
||||
* Cash payment methods available for content cashiers.
|
||||
*
|
||||
* @return array<int, array{id:string,name:string}>
|
||||
*/
|
||||
|
||||
@@ -592,13 +592,6 @@ if (!function_exists('aksrt_renderer_badges')) {
|
||||
}
|
||||
}
|
||||
|
||||
$topics = taxonomy_exists('topics') ? wp_get_post_terms((int) $data['post_id'], 'topics') : [];
|
||||
if (!is_wp_error($topics) && !empty($topics)) {
|
||||
foreach (array_slice($topics, 0, 2) as $topic) {
|
||||
$items[] = '<a href="' . esc_url(get_term_link($topic)) . '" class="but"><i class="fas fa-cube" aria-hidden="true"></i> ' . esc_html($topic->name) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['is_resource'])) {
|
||||
$items[] = '<span class="but jb-vip">VIP</span>';
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_get_colored_term_tags')) :
|
||||
/**
|
||||
* Colored but-links for terms (Zibll cat/topics palette).
|
||||
* Colored but-links for terms.
|
||||
*
|
||||
* @param WP_Term[] $terms Terms.
|
||||
* @param string $class Base class.
|
||||
@@ -207,22 +207,9 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_get_single_article_tags_html')) :
|
||||
/**
|
||||
* topics → categories → tags (Zibll footer order).
|
||||
* Categories → tags.
|
||||
*/
|
||||
function aksrt_get_single_article_tags_html(int $post_id): string {
|
||||
$topics_html = '';
|
||||
if (taxonomy_exists('topics')) {
|
||||
$topics = wp_get_post_terms($post_id, 'topics');
|
||||
if (!is_wp_error($topics) && !empty($topics)) {
|
||||
$topics_html = aksrt_get_colored_term_tags(
|
||||
array_slice($topics, 0, 6),
|
||||
'but ml6 radius',
|
||||
'<i class="fa fa-cube" aria-hidden="true"></i> ',
|
||||
['c-yellow', 'c-green', 'c-purple', 'c-red', 'c-blue']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$cats = get_the_category($post_id) ?: [];
|
||||
$cat_html = aksrt_get_colored_term_tags(
|
||||
$cats,
|
||||
@@ -246,7 +233,7 @@ if (!function_exists('aksrt_get_single_article_tags_html')) :
|
||||
}
|
||||
}
|
||||
|
||||
$top = $topics_html . $cat_html;
|
||||
$top = $cat_html;
|
||||
if ($top === '' && $tags_html === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -605,7 +605,7 @@ if (!function_exists('aksrt_single_related_query_args')) :
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// category (default): OR across category + tags + topics like Zibll.
|
||||
// category (default): OR across category + tags.
|
||||
$cat_ids = wp_get_post_terms($post_id, 'category', ['fields' => 'ids']);
|
||||
if (!empty($cat_ids) && !is_wp_error($cat_ids)) {
|
||||
$tax_query[] = [
|
||||
@@ -622,16 +622,6 @@ if (!function_exists('aksrt_single_related_query_args')) :
|
||||
'terms' => array_map('intval', $tag_ids),
|
||||
];
|
||||
}
|
||||
if (taxonomy_exists('topics')) {
|
||||
$topic_ids = wp_get_post_terms($post_id, 'topics', ['fields' => 'ids']);
|
||||
if (!empty($topic_ids) && !is_wp_error($topic_ids)) {
|
||||
$tax_query[] = [
|
||||
'taxonomy' => 'topics',
|
||||
'field' => 'term_id',
|
||||
'terms' => array_map('intval', $topic_ids),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($tax_query) > 1) {
|
||||
|
||||
@@ -1424,7 +1424,7 @@ if (!function_exists('aksrt_user_can')) :
|
||||
*
|
||||
* @param string $cap Capability id (e.g. 'new_post_add', 'comment_edit').
|
||||
* @param int $user_id User ID. Defaults to current user.
|
||||
* @param int|null $context Optional plate/post context for moderator-scoped caps.
|
||||
* @param int|null $context Optional content context for scoped capabilities.
|
||||
* @return bool
|
||||
*/
|
||||
function aksrt_user_can(string $cap, int $user_id = 0, ?int $context = null): bool {
|
||||
|
||||
@@ -63,7 +63,7 @@ if (!function_exists('aksrt_homepage_get_tab_query')) {
|
||||
|
||||
$term = get_term($term_id);
|
||||
$taxonomy = ($term && !is_wp_error($term)) ? (string) $term->taxonomy : 'category';
|
||||
if (!in_array($taxonomy, ['category', 'topics'], true)) {
|
||||
if ($taxonomy !== 'category') {
|
||||
$taxonomy = 'category';
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ if (!function_exists('aksrt_header_components_page_type_keys')) {
|
||||
function aksrt_header_components_page_type_keys(): array {
|
||||
return [
|
||||
'home',
|
||||
'topics',
|
||||
'category',
|
||||
'tag',
|
||||
'author',
|
||||
@@ -68,11 +67,6 @@ if (!function_exists('aksrt_header_slide_match_page_type')) {
|
||||
$post_type = (string) $raw_post_type;
|
||||
}
|
||||
|
||||
// Special keys that are not plain is_{$type} flags.
|
||||
if ($type === 'topics') {
|
||||
return is_tax('topics');
|
||||
}
|
||||
|
||||
// Generic WP_Query is_* flags (home/category/tag/author/single/search/page).
|
||||
$query_flag = 'is_' . $type;
|
||||
if (empty($wp_query->{$query_flag})) {
|
||||
|
||||
Reference in new issue
Block a user