feat: 重构邮件模板系统,支持多类型模板自定义

- 新增可扩展的邮件类型系统(评论通知、回复通知、用户注册、密码重置、通用邮件)
- 每种邮件类型支持自定义主题和内容模板
- 实现占位符系统,支持动态数据替换(如 {{blog_name}}、{{post_title}} 等)
- 添加邮件类型启用/禁用开关
- 设置页面新增模板编辑器,支持切换不同邮件类型
- 可用占位符点击即可插入到编辑框
- 支持恢复默认模板功能
- 保留向后兼容的旧版 API
- 通过 filter 钩子支持扩展更多邮件类型
This commit is contained in:
2026-01-15 15:17:47 +08:00
parent 60daa43fb9
commit 5c2f5514c0
4 changed files with 424 additions and 129 deletions

View File

@@ -1,6 +1,6 @@
<?php
/**
* Argon 评论回复通知邮件模板
* Argon 评论回复通知邮件
*
* 当评论收到回复时发送给原评论者的通知邮件
*/
@@ -35,25 +35,18 @@ function argon_send_reply_notify_email($reply, $parent) {
return false;
}
$settings = argon_get_email_settings();
// 准备邮件内容
$content = argon_get_reply_notify_content(array(
// 准备模板变量
$vars = array(
'post_title' => $post->post_title,
'post_url' => get_permalink($post->ID),
'original_comment' => wp_trim_words($parent->comment_content, 50, '...'),
'replier_name' => $reply->comment_author,
'replier_email' => $reply->comment_author_email,
'reply_content' => $reply->comment_content,
'comment_url' => get_comment_link($reply),
'theme_color' => $settings['theme_color']
));
// 邮件主题
$subject = sprintf(
'[%s] 您的评论收到了回复',
$settings['blog_name']
'reply_date' => get_comment_date(get_option('date_format') . ' ' . get_option('time_format'), $reply),
);
// 发送邮件
return argon_send_email($parent->comment_author_email, $subject, $content, 'reply');
return argon_send_email($parent->comment_author_email, 'reply_notify', $vars);
}