diff --git a/email-templates/base.php b/email-templates/base.php index 4d550e9..9cb8fe8 100644 --- a/email-templates/base.php +++ b/email-templates/base.php @@ -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' => '

有访客催促你完成 TODO

+
+

📝 {{todo_content}}

+
+

快去完成吧!

+前往博客', + '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( diff --git a/functions.php b/functions.php index 5bbebdb..49f2fed 100644 --- a/functions.php +++ b/functions.php @@ -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 = ' -
-

' . __('有访客催促你完成 TODO', 'argon') . '

-
-

📝 ' . esc_html($todo_content) . '

-
-

' . __('快去完成吧!', 'argon') . '

-
-

' . __('来自', 'argon') . ' ' . $site_name . '

-
- '; - - send_mail($admin_email, $subject, $html); + argon_send_email($admin_email, 'todo_urge', $vars); // 该任务今天不能再被提醒(到明天0点) $tomorrow = strtotime('tomorrow'); diff --git a/settings.php b/settings.php index c9d3bc3..1046a95 100644 --- a/settings.php +++ b/settings.php @@ -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');