fix: 主题切换时批量开启已有 tucao 评论

This commit is contained in:
2026-05-17 00:44:20 +08:00
parent 5409f649f1
commit 6ea4e59255
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -56,9 +56,19 @@ function kjweji_register_tucao() {
'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'), 'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'),
'menu_position' => 25, 'menu_position' => 25,
'menu_icon' => 'dashicons-format-chat', 'menu_icon' => 'dashicons-format-chat',
'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'),
)); ));
} }
// 主题激活时,把已存在的 tucao 文章全部开放评论
add_action('after_switch_theme', 'kjweji_open_tucao_comments');
function kjweji_open_tucao_comments() {
$posts = get_posts(array('post_type' => 'tucao', 'posts_per_page' => -1, 'post_status' => 'any'));
foreach ($posts as $post) {
wp_update_post(array('ID' => $post->ID, 'comment_status' => 'open'));
}
}
// ── 摘要取前 2-3 句 ─────────────────────────── // ── 摘要取前 2-3 句 ───────────────────────────
// 摘要:取文章内容的前 N 个字符(在句号处截断) // 摘要:取文章内容的前 N 个字符(在句号处截断)
function kjweji_excerpt($max_sentences = 5, $max_chars = 300) { function kjweji_excerpt($max_sentences = 5, $max_chars = 300) {
+1 -1
View File
@@ -1,6 +1,6 @@
/* /*
Theme Name: 空笺未寄 Theme Name: 空笺未寄
Version: 0.14.3 Version: 0.14.4
Requires at least: 6.0 Requires at least: 6.0
Requires PHP: 7.4 Requires PHP: 7.4
License: MIT License: MIT