feat: 将 TODO 提醒邮件纳入模板系统
- 新增 todo_urge 邮件类型 - 支持自定义 TODO 提醒邮件的主题和内容 - 可用占位符:todo_content、todo_id、urge_time 等 - 修改 argon_ajax_urge_todo 函数使用新的邮件模板系统
This commit is contained in:
@@ -97,6 +97,25 @@ function argon_get_email_types() {
|
||||
'theme_color' => __('主题色', 'argon'),
|
||||
),
|
||||
),
|
||||
'todo_urge' => array(
|
||||
'name' => __('TODO 提醒', 'argon'),
|
||||
'description' => __('访客催促作者完成 TODO 时发送的邮件', 'argon'),
|
||||
'default_subject' => '[{{blog_name}}] 有人催你完成 TODO',
|
||||
'default_content' => '<h2 style="margin: 0 0 16px 0; font-size: 20px; font-weight: 600; color: #32325d;">有访客催促你完成 TODO</h2>
|
||||
<div style="background: #f6f9fc; border-left: 4px solid {{theme_color}}; padding: 16px; border-radius: 4px; margin: 0 0 24px 0;">
|
||||
<p style="margin: 0; color: #525f7f; line-height: 1.6;">📝 {{todo_content}}</p>
|
||||
</div>
|
||||
<p style="margin: 0 0 24px 0; color: #525f7f; line-height: 1.6;">快去完成吧!</p>
|
||||
<a href="{{blog_url}}" style="display: inline-block; background: {{theme_color}}; color: #ffffff; padding: 12px 24px; border-radius: 6px; text-decoration: none; font-weight: 500;">前往博客</a>',
|
||||
'placeholders' => array(
|
||||
'blog_name' => __('博客名称', 'argon'),
|
||||
'blog_url' => __('博客链接', 'argon'),
|
||||
'todo_content' => __('TODO 内容', 'argon'),
|
||||
'todo_id' => __('TODO ID', 'argon'),
|
||||
'urge_time' => __('提醒时间', 'argon'),
|
||||
'theme_color' => __('主题色', 'argon'),
|
||||
),
|
||||
),
|
||||
'general' => array(
|
||||
'name' => __('通用邮件', 'argon'),
|
||||
'description' => __('其他类型的通用邮件模板', 'argon'),
|
||||
@@ -445,6 +464,13 @@ function argon_get_sample_email_vars($type) {
|
||||
'reset_url' => home_url('/wp-login.php?action=rp&key=sample_key'),
|
||||
));
|
||||
|
||||
case 'todo_urge':
|
||||
return array_merge($common, array(
|
||||
'todo_content' => '这是一个示例 TODO 任务内容',
|
||||
'todo_id' => 'sample_todo_id',
|
||||
'urge_time' => date_i18n(get_option('date_format') . ' ' . get_option('time_format')),
|
||||
));
|
||||
|
||||
case 'general':
|
||||
default:
|
||||
return array_merge($common, array(
|
||||
|
||||
@@ -3754,25 +3754,15 @@ function argon_ajax_urge_todo() {
|
||||
wp_send_json_error(__('TODO 不存在', 'argon'));
|
||||
}
|
||||
|
||||
// 使用主题内置的邮件发送接口
|
||||
// 使用邮件模板系统发送
|
||||
$admin_email = get_option('admin_email');
|
||||
$site_name = get_bloginfo('name');
|
||||
$site_url = get_bloginfo('url');
|
||||
$vars = array(
|
||||
'todo_content' => $todo_content,
|
||||
'todo_id' => $id,
|
||||
'urge_time' => date_i18n(get_option('date_format') . ' ' . get_option('time_format')),
|
||||
);
|
||||
|
||||
$subject = '[' . $site_name . '] ' . __('有人催你完成 TODO', 'argon');
|
||||
$html = '
|
||||
<div style="max-width: 600px; margin: 0 auto; padding: 20px; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif;">
|
||||
<h2 style="color: #5e72e4; margin-bottom: 20px;">' . __('有访客催促你完成 TODO', 'argon') . '</h2>
|
||||
<div style="background: #f8f9fa; border-left: 4px solid #5e72e4; padding: 15px; margin: 20px 0;">
|
||||
<p style="margin: 0; font-size: 16px;">📝 ' . esc_html($todo_content) . '</p>
|
||||
</div>
|
||||
<p style="color: #666;">' . __('快去完成吧!', 'argon') . '</p>
|
||||
<hr style="border: none; border-top: 1px solid #eee; margin: 20px 0;">
|
||||
<p style="color: #999; font-size: 12px;">' . __('来自', 'argon') . ' <a href="' . $site_url . '">' . $site_name . '</a></p>
|
||||
</div>
|
||||
';
|
||||
|
||||
send_mail($admin_email, $subject, $html);
|
||||
argon_send_email($admin_email, 'todo_urge', $vars);
|
||||
|
||||
// 该任务今天不能再被提醒(到明天0点)
|
||||
$tomorrow = strtotime('tomorrow');
|
||||
|
||||
@@ -5415,7 +5415,7 @@ function argon_update_themeoptions(){
|
||||
update_option('argon_email_social_links', $social_links);
|
||||
|
||||
// 保存邮件模板配置
|
||||
$email_types = array('comment_notify', 'reply_notify', 'user_register', 'password_reset', 'general');
|
||||
$email_types = array('comment_notify', 'reply_notify', 'user_register', 'password_reset', 'todo_urge', 'general');
|
||||
foreach ($email_types as $type) {
|
||||
// 保存启用状态
|
||||
argon_update_option_checkbox('argon_email_template_' . $type . '_enabled');
|
||||
|
||||
Reference in New Issue
Block a user