我看到你的评论了,让我华丽的通知你我回复YOU了!

美化你的Comment Mail Notify评论回复通知邮件样式

每日必做的功课就是四处发评论,干谷鸽,操百毒,突然一封来自【萝莉天下】的评论回复通知邮件让我惊艳了,眼红了,流口水了!
有图有真相,欢迎围观效果图:

邮件回复效果图

这么好的东西怎么能不求分享呢,嘿嘿……
可灵曦给我的样式代码仅适用于WP Thread Comment这个邮件通知回复插件,而我用的是Willin的Comment Mail Notify评论回复邮件通知代码……
我拿着两段代码折腾了一下午,总是报错。
唉,菜鸟就是菜鸟啊。最后找kaka帮忙,终于成功把他的样式代码跟Willin的回复代码整合到一起了。

这样的事,对高手们来说,可能不值一提,但是我相信一定还有很多跟我一样的菜鸟需要这个代码,所以在征求kaka的意见后,放出这段代码。
使用很简单,把代码插入主题的functions.php文件即可,如果找不准合适的位置,就在第一行<?php后另起一行插入吧!

/* comment_mail_notify v1.0 by willin kan. (有勾選欄, 由訪客決定) */
function comment_mail_notify($comment_id) {
$admin_notify = '1'; // admin 要不要收回覆通知 ( '1'=要 ; '0'=不要 )
$admin_email = get_bloginfo ('admin_email'); // $admin_email 可改為你指定的 e-mail.
$comment = get_comment($comment_id);
$comment_author_email = trim($comment->comment_author_email);
$parent_id = $comment->comment_parent ? $comment->comment_parent : '';
global $wpdb;
if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '')
$wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 0;");
if (($comment_author_email != $admin_email && isset($_POST['comment_mail_notify'])) || ($comment_author_email == $admin_email && $admin_notify == '1'))
$wpdb->query("UPDATE {$wpdb->comments} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'");
$notify = $parent_id ? get_comment($parent_id)->comment_mail_notify : '0';
$spam_confirmed = $comment->comment_approved;
if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') {
$wp_email = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 發出點, no-reply 可改為可用的 e-mail.
$to = trim(get_comment($parent_id)->comment_author_email);
$subject = '您在 [' . get_option("blogname") . '] 的评论被回应';
$message = '
    


 

‘; $from = “From: “” . get_option(‘blogname’) . “” <$wp_email>”; $headers = “$fromnContent-Type: text/html; charset=” . get_option(‘blog_charset’) . “n”; wp_mail( $to, $subject, $message, $headers ); //echo ‘mail to ‘, $to, ‘
‘ , $subject, $message; // for testing } } add_action(‘comment_post’, ‘comment_mail_notify’); /* 自動加勾選欄 */ function add_checkbox() { echo ‘‘; } add_action(‘comment_form’, ‘add_checkbox’); // — END —————————————-

把代码中的相关信息改成你自己的就可以了,这个应该不用细说了吧……

—————–补充说明—————–

现在放出的是经卡卡重新优化过的最新版代码,解决了一些细节上的小问题,变得更加完美!

相关链接:
kaka的黄绿橙:http://thehlc.cn
Willin Kan的博客:http://willin.atbhost.net
可灵曦的萝莉天下:https://www.lolis.info

发布日期:
分类:玩着

作者:秦大叔

裆下很忧郁…… 邮箱:qf0105*qq.com QQ:10381684