/* 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评论邮件通知无插件实现思路及代码》的一些看法。更多内容请查看本栏目更多内容!
明天发文章时,惊奇的发现文章的ID居然曾经抵达了19了。鉴于我以前折腾Wordpress的经历,我晓得这是Wordpre...
虽然说紧缩wordpress页面后对查看源代码来说不太敌对,更能够说是惨目忍睹。 然而紧缩页面的益处就是缩小了...
在主题的function.php文件中,能够找到形如如下内容的语句:复制代码代码如下:if ( function_exists(&lsquo...
前几天见到某 Blog (遗记名字和网址了) 有一个相当适用的评论性能. 访客留言之后材料输出框会被暗藏起来, 好...
WordPress 的自定义字段就是文章的 meta 信息(元信息),利用这个性能,能够扩大文章的性能,是学习 WordP...
招致wordpress页面呈现空白框的缘由大略有两点: 一,UTF-8即文件保留类型 文件保留类型与应用版本之间假如...