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
+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');
|
||||
|
||||
// ============================================================
|
||||
Reference in new issue
Block a user