统一邮件模板系统:添加 blacklist_spam_notify 和 username_change_notify 配置,重构相关文件使用统一接口
This commit is contained in:
@@ -68,6 +68,38 @@ function argon_get_email_types() {
|
||||
<p style="margin: 0; color: #718096; font-size: 12px;">识别码:{{ai_detection_code}}</p>
|
||||
</div>
|
||||
<p style="margin: 0 0 20px 0; color: #525f7f; line-height: 1.6;">如果您认为这是误判,请通过识别码查询详细信息或联系网站管理员申诉。</p>
|
||||
<p style="margin: 0;">
|
||||
<a href="{{query_url}}" style="display: inline-block; background: {{theme_color}}; color: #ffffff; padding: 10px 20px; border-radius: 4px; text-decoration: none; font-size: 14px;">查询识别详情</a>
|
||||
</p>',
|
||||
'placeholders' => array(
|
||||
'blog_name' => __('博客名称', 'argon'),
|
||||
'post_title' => __('文章标题', 'argon'),
|
||||
'post_url' => __('文章链接', 'argon'),
|
||||
'commenter_name' => __('评论者名称', 'argon'),
|
||||
'comment_content' => __('评论内容', 'argon'),
|
||||
'ai_spam_reason' => __('AI 识别理由', 'argon'),
|
||||
'ai_detection_code' => __('AI 识别码', 'argon'),
|
||||
'query_url' => __('查询链接', 'argon'),
|
||||
'unsubscribe_url' => __('退订链接', 'argon'),
|
||||
'theme_color' => __('主题色', 'argon'),
|
||||
),
|
||||
),
|
||||
'panic_mode_notify' => array(
|
||||
'name' => __('怕死模式审核通知', 'argon'),
|
||||
'description' => __('当评论在怕死模式下未通过审核时发送给评论者', 'argon'),
|
||||
'default_subject' => '[{{blog_name}}] 您的评论未通过审核',
|
||||
'default_content' => '<h2 style="margin: 0 0 20px 0; font-size: 18px; font-weight: 600; color: {{theme_color}};">评论审核通知</h2>
|
||||
<p style="margin: 0 0 16px 0; color: #525f7f; line-height: 1.6;">尊敬的用户 <strong>{{commenter_name}}</strong>:</p>
|
||||
<p style="margin: 0 0 20px 0; color: #525f7f; line-height: 1.6;">您在文章《<a href="{{post_url}}" style="color: {{theme_color}}; text-decoration: none;">{{post_title}}</a>》中发表的评论未通过系统审核。</p>
|
||||
<div style="background: #fff5f5; border-left: 4px solid #f56565; padding: 16px; border-radius: 4px; margin: 0 0 20px 0;">
|
||||
<p style="margin: 0 0 8px 0; color: #2d3748; font-size: 14px; font-weight: 600;">您的评论内容</p>
|
||||
<p style="margin: 0; color: #4a5568; line-height: 1.6;">{{comment_content}}</p>
|
||||
</div>
|
||||
<div style="background: #fef3c7; border-left: 4px solid #f59e0b; padding: 16px; border-radius: 4px; margin: 0 0 20px 0;">
|
||||
<p style="margin: 0 0 8px 0; color: #92400e; font-size: 14px; font-weight: 600;">审核说明</p>
|
||||
<p style="margin: 0; color: #78350f; line-height: 1.6;">很抱歉,由于该文章当前处于特殊审核状态,评论内容需要经过更严格的审查。您的评论未能通过此次审核,建议您修改后重新提交。</p>
|
||||
</div>
|
||||
<p style="margin: 0 0 20px 0; color: #525f7f; line-height: 1.6;">如果您认为这是误判,请联系网站管理员申诉。</p>
|
||||
<p style="margin: 0;">
|
||||
<a href="{{query_url}}" style="display: inline-block; background: {{theme_color}}; color: #ffffff; padding: 10px 20px; border-radius: 4px; text-decoration: none; font-size: 14px;">查询识别详情</a>
|
||||
</p>',
|
||||
@@ -134,6 +166,69 @@ function argon_get_email_types() {
|
||||
'theme_color' => __('主题色', 'argon'),
|
||||
),
|
||||
),
|
||||
'blacklist_spam_notify' => array(
|
||||
'name' => __('黑名单拦截通知', 'argon'),
|
||||
'description' => __('当评论被黑名单关键字拦截时发送给评论者', 'argon'),
|
||||
'default_subject' => '[{{blog_name}}] 您的评论被系统拦截',
|
||||
'default_content' => '<h2 style="margin: 0 0 20px 0; font-size: 18px; font-weight: 600; color: {{theme_color}};">评论拦截通知</h2>
|
||||
<p style="margin: 0 0 16px 0; color: #525f7f; line-height: 1.6;">您好,<strong>{{commenter_name}}</strong>!</p>
|
||||
<p style="margin: 0 0 20px 0; color: #525f7f; line-height: 1.6;">您在文章《<a href="{{post_url}}" style="color: {{theme_color}}; text-decoration: none;">{{post_title}}</a>》中的评论因触发关键字过滤规则而被系统自动拦截。</p>
|
||||
<div style="background: #fff5f5; border-left: 4px solid #f56565; padding: 16px; border-radius: 4px; margin: 0 0 20px 0;">
|
||||
<p style="margin: 0 0 8px 0; color: #2d3748; font-size: 14px; font-weight: 600;">您的评论内容</p>
|
||||
<p style="margin: 0; color: #4a5568; line-height: 1.6;">{{comment_content}}</p>
|
||||
</div>
|
||||
<div style="background: #fef3c7; border-left: 4px solid #f59e0b; padding: 16px; border-radius: 4px; margin: 0 0 20px 0;">
|
||||
<p style="margin: 0; color: #92400e; font-size: 14px;"><strong>触发的关键字:</strong>{{blacklist_keywords}}</p>
|
||||
</div>
|
||||
<p style="margin: 0 0 20px 0; color: #525f7f; line-height: 1.6;">如果您认为这是一次误判,可以点击下方按钮申请 AI 复审。</p>
|
||||
<p style="margin: 0;">
|
||||
<a href="{{feedback_url}}" style="display: inline-block; background: {{theme_color}}; color: #ffffff; padding: 10px 20px; border-radius: 4px; text-decoration: none; font-size: 14px;">申请 AI 复审</a>
|
||||
</p>',
|
||||
'placeholders' => array(
|
||||
'blog_name' => __('博客名称', 'argon'),
|
||||
'post_title' => __('文章标题', 'argon'),
|
||||
'post_url' => __('文章链接', 'argon'),
|
||||
'commenter_name' => __('评论者名称', 'argon'),
|
||||
'comment_content' => __('评论内容', 'argon'),
|
||||
'blacklist_keywords' => __('触发的关键字', 'argon'),
|
||||
'feedback_url' => __('申诉链接', 'argon'),
|
||||
'theme_color' => __('主题色', 'argon'),
|
||||
),
|
||||
),
|
||||
'username_change_notify' => array(
|
||||
'name' => __('用户名变更通知', 'argon'),
|
||||
'description' => __('当评论用户名被 AI 识别为不合规并自动修改时发送给评论者', 'argon'),
|
||||
'default_subject' => '[{{blog_name}}] 您的评论用户名已被修改',
|
||||
'default_content' => '<h2 style="margin: 0 0 20px 0; font-size: 18px; font-weight: 600; color: {{theme_color}};">用户名变更通知</h2>
|
||||
<p style="margin: 0 0 16px 0; color: #525f7f; line-height: 1.6;">您好,<strong>{{original_username}}</strong>!</p>
|
||||
<p style="margin: 0 0 20px 0; color: #525f7f; line-height: 1.6;">您在文章《<a href="{{post_url}}" style="color: {{theme_color}}; text-decoration: none;">{{post_title}}</a>》发表的评论已成功提交,但系统检测到您的用户名可能不符合规范。</p>
|
||||
<div style="background: #fef3c7; border-left: 4px solid #f59e0b; padding: 16px; border-radius: 4px; margin: 0 0 20px 0;">
|
||||
<p style="margin: 0 0 8px 0; color: #92400e; font-size: 14px; font-weight: 600;">AI 检测结果</p>
|
||||
<p style="margin: 0; color: #92400e; font-size: 14px; line-height: 1.6;">{{ai_reason}}</p>
|
||||
</div>
|
||||
<div style="background: #f6f9fc; padding: 16px; border-radius: 4px; margin: 0 0 20px 0;">
|
||||
<p style="margin: 0 0 8px 0; color: #8898aa; font-size: 14px;">原用户名:<del>{{original_username}}</del></p>
|
||||
<p style="margin: 0; color: {{theme_color}}; font-size: 14px; font-weight: 600;">新用户名:{{new_username}}</p>
|
||||
</div>
|
||||
<div style="background: #e3f2fd; border-left: 4px solid #2196f3; padding: 16px; border-radius: 4px; margin: 0 0 20px 0;">
|
||||
<p style="margin: 0 0 8px 0; color: #1565c0; font-size: 14px; font-weight: 600;">温馨提示</p>
|
||||
<p style="margin: 0; color: #1976d2; font-size: 14px; line-height: 1.6;">您的评论内容正常,仅用户名被自动修改。今后发表评论时,请使用符合规范的用户名。</p>
|
||||
</div>
|
||||
<p style="margin: 0;">
|
||||
<a href="{{comment_url}}" style="display: inline-block; background: {{theme_color}}; color: #ffffff; padding: 10px 20px; border-radius: 4px; text-decoration: none; font-size: 14px;">查看您的评论</a>
|
||||
</p>',
|
||||
'placeholders' => array(
|
||||
'blog_name' => __('博客名称', 'argon'),
|
||||
'post_title' => __('文章标题', 'argon'),
|
||||
'post_url' => __('文章链接', 'argon'),
|
||||
'original_username' => __('原用户名', 'argon'),
|
||||
'new_username' => __('新用户名', 'argon'),
|
||||
'ai_reason' => __('AI 判断理由', 'argon'),
|
||||
'ai_detection_code' => __('识别码', 'argon'),
|
||||
'comment_url' => __('评论链接', 'argon'),
|
||||
'theme_color' => __('主题色', 'argon'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// 允许通过 filter 扩展邮件类型
|
||||
|
||||
@@ -43,58 +43,16 @@ function argon_send_blacklist_spam_notify_email($comment) {
|
||||
'token' => $feedback_token
|
||||
], home_url());
|
||||
|
||||
// 邮件设置
|
||||
$settings = argon_get_email_settings();
|
||||
$site_name = get_bloginfo('name');
|
||||
$site_url = home_url();
|
||||
|
||||
// 邮件主题
|
||||
$subject = sprintf('[%s] 您的评论被系统拦截', $site_name);
|
||||
|
||||
// 邮件内容
|
||||
$message = argon_get_email_template('base', [
|
||||
'site_name' => $site_name,
|
||||
'site_url' => $site_url,
|
||||
'header_color' => $settings['header_color'],
|
||||
'content' => sprintf('
|
||||
<h2 style="color: #333; font-size: 20px; margin-bottom: 20px;">评论拦截通知</h2>
|
||||
<p style="color: #666; line-height: 1.8; margin-bottom: 15px;">
|
||||
您好,%s!
|
||||
</p>
|
||||
<p style="color: #666; line-height: 1.8; margin-bottom: 15px;">
|
||||
您在文章《<a href="%s" style="color: #5e72e4; text-decoration: none;">%s</a>》中的评论因触发关键字过滤规则而被系统自动拦截。
|
||||
</p>
|
||||
<div style="background: #f8f9fa; border-left: 4px solid #ffc107; padding: 15px; margin: 20px 0; border-radius: 4px;">
|
||||
<p style="color: #666; margin: 0 0 10px 0;"><strong>您的评论内容:</strong></p>
|
||||
<p style="color: #666; margin: 0; font-style: italic;">%s</p>
|
||||
</div>
|
||||
<div style="background: #fff3cd; border: 1px solid #ffc107; padding: 15px; margin: 20px 0; border-radius: 4px;">
|
||||
<p style="color: #856404; margin: 0 0 10px 0;"><strong>触发的关键字:</strong>%s</p>
|
||||
</div>
|
||||
<p style="color: #666; line-height: 1.8; margin-bottom: 15px;">
|
||||
如果您认为这是一次误判,可以点击下方按钮申请 AI 复审。我们的 AI 系统会重新评估您的评论,如果确认无误,将自动恢复您的评论并优化关键字规则。
|
||||
</p>
|
||||
<div style="text-align: center; margin: 30px 0;">
|
||||
<a href="%s" style="display: inline-block; padding: 12px 30px; background: #5e72e4; color: #fff; text-decoration: none; border-radius: 4px; font-weight: bold;">申请 AI 复审</a>
|
||||
</div>
|
||||
<p style="color: #999; font-size: 12px; line-height: 1.6; margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee;">
|
||||
此邮件由系统自动发送,请勿直接回复。如有疑问,请联系网站管理员。
|
||||
</p>
|
||||
',
|
||||
esc_html($comment->comment_author),
|
||||
esc_url(get_permalink($post->ID)),
|
||||
esc_html($post->post_title),
|
||||
esc_html($comment->comment_content),
|
||||
esc_html($keywords_text),
|
||||
esc_url($feedback_url)
|
||||
)
|
||||
]);
|
||||
// 准备模板变量
|
||||
$vars = array(
|
||||
'post_title' => $post->post_title,
|
||||
'post_url' => get_permalink($post->ID),
|
||||
'commenter_name' => $comment->comment_author,
|
||||
'comment_content' => $comment->comment_content,
|
||||
'blacklist_keywords' => $keywords_text,
|
||||
'feedback_url' => $feedback_url,
|
||||
);
|
||||
|
||||
// 发送邮件
|
||||
$headers = ['Content-Type: text/html; charset=UTF-8'];
|
||||
if (!empty($settings['from_email'])) {
|
||||
$headers[] = 'From: ' . $settings['from_name'] . ' <' . $settings['from_email'] . '>';
|
||||
}
|
||||
|
||||
return wp_mail($comment->comment_author_email, $subject, $message, $headers);
|
||||
return argon_send_email($comment->comment_author_email, 'blacklist_spam_notify', $vars);
|
||||
}
|
||||
|
||||
@@ -31,118 +31,17 @@ function argon_send_username_change_notify_email($comment, $original_username, $
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取 AI 配置信息
|
||||
$provider = get_option('argon_ai_summary_provider', 'openai');
|
||||
$model = get_option('argon_ai_summary_model', '');
|
||||
|
||||
$provider_names = [
|
||||
'openai' => 'OpenAI',
|
||||
'anthropic' => 'Anthropic',
|
||||
'deepseek' => 'DeepSeek',
|
||||
'qianwen' => '通义千问',
|
||||
'wenxin' => '文心一言',
|
||||
'doubao' => '豆包',
|
||||
'kimi' => 'Kimi',
|
||||
'zhipu' => '智谱',
|
||||
'siliconflow' => 'SiliconFlow'
|
||||
];
|
||||
|
||||
$provider_display = isset($provider_names[$provider]) ? $provider_names[$provider] : $provider;
|
||||
|
||||
// 获取邮件设置
|
||||
$settings = argon_get_email_settings();
|
||||
|
||||
// 构建邮件内容
|
||||
$email_subject = sprintf(__('您在「%s」的评论用户名已被修改', 'argon'), wp_trim_words($post->post_title, 20));
|
||||
|
||||
$email_body = '
|
||||
<div style="background: #f8f9fa; padding: 32px 24px; border-radius: 8px; margin: 24px 0;">
|
||||
<h2 style="margin: 0 0 16px 0; color: #32325d; font-size: 20px; font-weight: 600;">
|
||||
' . __('用户名变更通知', 'argon') . '
|
||||
</h2>
|
||||
<p style="margin: 0 0 16px 0; color: #525f7f; font-size: 15px; line-height: 1.6;">
|
||||
' . sprintf(__('您好,%s!', 'argon'), '<strong>' . esc_html($original_username) . '</strong>') . '
|
||||
</p>
|
||||
<p style="margin: 0 0 16px 0; color: #525f7f; font-size: 15px; line-height: 1.6;">
|
||||
' . sprintf(
|
||||
__('您在文章「<a href="%s" style="color: %s; text-decoration: none;">%s</a>」发表的评论已成功提交,但系统检测到您的用户名可能不符合规范。', 'argon'),
|
||||
esc_url(get_permalink($post->ID)),
|
||||
$settings['theme_color'],
|
||||
esc_html($post->post_title)
|
||||
) . '
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div style="background: #fff3cd; border-left: 4px solid #ffc107; padding: 16px 20px; margin: 24px 0; border-radius: 4px;">
|
||||
<p style="margin: 0 0 8px 0; color: #856404; font-size: 14px; font-weight: 600;">
|
||||
' . __('AI 检测结果', 'argon') . '
|
||||
</p>
|
||||
<p style="margin: 0; color: #856404; font-size: 14px; line-height: 1.6;">
|
||||
' . esc_html($reason) . '
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div style="background: #f8f9fa; padding: 24px; border-radius: 8px; margin: 24px 0;">
|
||||
<table style="width: 100%; border-collapse: collapse;">
|
||||
<tr>
|
||||
<td style="padding: 8px 0; color: #8898aa; font-size: 14px; width: 100px;">
|
||||
' . __('原用户名', 'argon') . '
|
||||
</td>
|
||||
<td style="padding: 8px 0; color: #32325d; font-size: 14px; font-weight: 500;">
|
||||
<del>' . esc_html($original_username) . '</del>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px 0; color: #8898aa; font-size: 14px;">
|
||||
' . __('新用户名', 'argon') . '
|
||||
</td>
|
||||
<td style="padding: 8px 0; color: ' . $settings['theme_color'] . '; font-size: 14px; font-weight: 600;">
|
||||
' . esc_html($new_username) . '
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div style="background: #e3f2fd; padding: 16px 20px; margin: 24px 0; border-radius: 4px; border-left: 4px solid #2196f3;">
|
||||
<p style="margin: 0 0 8px 0; color: #1565c0; font-size: 14px; font-weight: 600;">
|
||||
' . __('温馨提示', 'argon') . '
|
||||
</p>
|
||||
<p style="margin: 0; color: #1976d2; font-size: 14px; line-height: 1.6;">
|
||||
' . __('您的评论内容正常,仅用户名被自动修改。今后发表评论时,请使用符合规范的用户名。', 'argon') . '
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div style="margin: 32px 0; text-align: center;">
|
||||
<a href="' . esc_url(get_permalink($post->ID) . '#comment-' . $comment->comment_ID) . '"
|
||||
style="display: inline-block; padding: 12px 32px; background: ' . $settings['theme_color'] . '; color: #fff; text-decoration: none; border-radius: 4px; font-size: 15px; font-weight: 500;">
|
||||
' . __('查看您的评论', 'argon') . '
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 32px; padding-top: 24px; border-top: 1px solid #e3e8ee;">
|
||||
<p style="margin: 0 0 8px 0; color: #8898aa; font-size: 13px;">
|
||||
' . __('检测信息', 'argon') . '
|
||||
</p>
|
||||
<table style="width: 100%; font-size: 12px; color: #8898aa;">
|
||||
<tr>
|
||||
<td style="padding: 4px 0;">' . __('AI 模型', 'argon') . ':</td>
|
||||
<td style="padding: 4px 0;">' . esc_html($provider_display) . ' - ' . esc_html($model) . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 4px 0;">' . __('识别码', 'argon') . ':</td>
|
||||
<td style="padding: 4px 0; font-family: monospace;">' . esc_html($detection_code) . '</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 4px 0;">' . __('检测时间', 'argon') . ':</td>
|
||||
<td style="padding: 4px 0;">' . current_time('Y-m-d H:i:s') . '</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
|
||||
// 渲染完整邮件
|
||||
$html = argon_render_email($email_body, ['subject' => $email_subject]);
|
||||
// 准备模板变量
|
||||
$vars = array(
|
||||
'post_title' => $post->post_title,
|
||||
'post_url' => get_permalink($post->ID),
|
||||
'original_username' => $original_username,
|
||||
'new_username' => $new_username,
|
||||
'ai_reason' => $reason,
|
||||
'ai_detection_code' => $detection_code,
|
||||
'comment_url' => get_comment_link($comment),
|
||||
);
|
||||
|
||||
// 发送邮件
|
||||
return send_mail($comment->comment_author_email, $email_subject, $html);
|
||||
return argon_send_email($comment->comment_author_email, 'username_change_notify', $vars);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user