61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?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');
|
|
|
|
// ============================================================
|