/* comment_mail_notify v1.0 by willin kan. (無勾選欄) */
function comment_mail_notify($comment_id) {
$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 : '';
$to = $parent_id ? trim(get_comment($parent_id)->comment_author_email) : '';
$spam_confirmed = $comment->comment_approved;
if (($parent_id != '') && ($spam_confirmed != 'spam') && ($to != $admin_email) && ($comment_author_email == $admin_email)) {
/* 下面的判斷式,決定發出郵件的必要條件:
($parent_id != '') && ($spam_confirmed != 'spam'): 回覆的, 而且不是 spam 才可發, 必须!!
($to != $admin_email) : 不發給 admin.
($comment_author_email == $admin_email) : 只有 admin 的回覆才可發.
可視個人需要修正以上條件.
*/
$wp_email = '[email protected]' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 發出點, no-reply 可改為可用的 e-mail.
$subject = '您在【' . get_option("blogname") . '】的留言有回复了!去看看吧 ^_^';
$message = '
<p style="margin: 1em 40px 1em 40px;background-color:#eef2fa;border:1px solid #d8e3e8;color:#111;padding: 0 15px;-moz-border-radius:5px;-webkit-border-radius:5px;-khtml-border-radius:5px;border-radius:5px;">
<p>Hi !<strong>' . trim(get_comment($parent_id)->comment_author) . '</strong>,您好!
您曾在<strong>《' . get_the_title($comment->comment_post_ID) . '》</strong>的留言有了新回复。</p></p>
<p style="margin: 1em 40px 1em 40px;background-color:#eef2fa;border:1px solid #d8e3e8;color:#111;padding: 0 15px;-moz-border-radius:5px;-webkit-border-radius:5px;-khtml-border-radius:5px;border-radius:5px;"><p><strong>
您</strong>说:' . trim(get_comment($parent_id)->comment_content) . '</p>
<p><strong>' . trim($comment->comment_author) . '</strong>说:
' . trim($comment->comment_content) . '</p>
<p>您能够点击<a href="' . htmlspecialchars(get_comment_link($parent_id)) . '">查看完好的回复內容。</a></p>
<p>欢送再度莅临 <a href="' . get_option('home') . '">' . get_option('blogname') . '</a></p>
<p>(此邮件由零碎主动发送,请勿回复。)</p></p>
';
$from = "From: \"" . get_option('blogname') . "\" <$wp_email>";
$headers = "$from\nContent-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');
// -- END ----------------------------------------
以上就是安达网络工作室关于《WordPress评论邮件通知无插件实现思路及代码》的一些看法。更多内容请查看本栏目更多内容!
自定义 WordPress 默许评论头像 关于没有设置Gravatra头像的评论者来说,WordPress会显示一个你在后盾设置的...
软件及版本抉择 Ubuntu 14.04 Ubuntu 是目前用户数量首屈一指的发行版,面前有大土豪保护,能够说是轻量级用...
Hana Flv Player 是一个在 WordPress 中使用比拟宽泛的播放器插件, 该插件内置了5种媒体播放器,其播放文件...
wp_mail() 函数用来发送邮件,相似于 PHP 的 mail() 函数。 默许的发件人称号是 WordPress,发件人邮箱是相...
咱们常见的WordPress站点文章排序,通常状况下是按公布工夫的升序或降序形式陈列,这种排序形式简直能够满足...
随着 WordPress 一版一版的晋级,性能越来越多,代码量也越来越宏大,对 WordPress 速度慢的埋怨声也越来越...