<?php
/**
* Email Me With The Replay For SAE
*
* Usage:将此段代码粘贴到以后主题的 functions.php 文件中即可。
* 或许将此文件放进主标题录,在 functions.php 中蕴含此文件
*
* 基于 comment_mail_notify v1.0 by willin kan. http://kan.willin.org/?p=1295(已生效)
* changelist
* 2012-03-29
* version 0.1
*
* 2012-04-29
* version 0.2
* edit $subject to this code
* $subject = '您的评论 ' . mb_substr(strip_tags(get_comment($parent_id)->comment_content), 0, 10, 'utf-8') . ' 有了回应 - ' . get_option("blogname");
*
*
* @author IT不倒翁, willin kan
* @copyright (C) 2011,2012 Just Use It!
* @link yungbo.com
* @version 0.2
*/
function comment_mail_notify($comment_id) {
//换行标记
$lineBreak = "\n";
//缩进标记
$tabBreak = "\t";
$admin_notify = '1'; // are you willing to receive the email? 1 is yes.
$admin_email = get_bloginfo('admin_email'); // you can change $admin_email to your e-mail optionaly.
$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 = '[email protected]' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail
$to = trim(get_comment($parent_id)->comment_author_email);
$subject = '您的评论 ' . mb_substr(strip_tags(get_comment($parent_id)->comment_content), 0, 10, 'utf-8') . ' 有了回应 - ' . get_option("blogname");
//邮件主体内容
//预计新浪思考到平安成绩,全副用 htmlspecialchars() 过滤了,所以不要应用 html 标志
$message = '您好,' . trim(get_comment($parent_id)->comment_author) . $lineBreak;
$message .= '您曾在 ' . get_option("blogname") . ' 留言:' . $lineBreak;
$message .= $tabBreak . trim(get_comment($parent_id)->comment_content) . $lineBreak;
$message .= trim($comment->comment_author) . ' 回复了您:' . $lineBreak;
$message .= $tabBreak . trim($comment->comment_content) . $lineBreak;
$message .= '您能够点击 ' . get_comment_link($parent_id) . ' 查看详细状况' . $lineBreak;
$message .= $lineBreak;
$message .= '(零碎邮件,请不要间接回复)' . $lineBreak;
$message .= get_option('blogname') . $lineBreak;
$message .= home_url() . $lineBreak;
/*SAE 配置地位*/
$saeTo = $to;
$saeSubject = $subject;
$saeMessage = $message;
$saeSMTPUser = '';//SMTP邮箱
$saeSMTPPass = '';//SMTP明码
$mail = new SaeMail();
$result = $mail->quickSend($saeTo, $saeSubject, $saeMessage, $saeSMTPUser, $saeSMTPPass);
// if ($result === false)
// var_dump($mail->errno(), $mail->errmsg());
}
}
add_action('comment_post', 'comment_mail_notify');
/* Auto checked */
function add_checkbox() {
echo '<input type="checkbox" name="comment_mail_notify" id="comment_mail_notify" value="comment_mail_notify" checked="checked" /><label for="comment_mail_notify">有人回复我时邮件告诉我</label>';
}
add_action('comment_form', 'add_checkbox');
以上就是安达网络工作室关于《WordPress 有人回复时邮件通知的实现方法 SAE 移植版》的一些看法。更多内容请查看本栏目更多内容!
咱们都晓得,wordpress默许状况下会主动跳转到后盾规则的home_url下来,例如你的空间同时绑定了jb51.net和w...
最近关上博客后盾,发现后盾关上速度很慢。 经过开发者调试工具对网络加载进行检测,发现是因为后盾应用了谷...
明天在修正网站的时分,不小心把最新版Wordpress3.5.1的wp-includes目录下的functions.php笼罩出来了,招致...
次要出于两个目的,第一搜集比便大家和当前学习回顾;第二,从根底做一些适用的,添加搜寻量,进步博客流量...
WordPress 从 2.5 的版本开端,添加了一个 shortcode (短代码) API ,相似于 BBS 上的 BBCode , shortcode ...
wordpress操作数据库用一个全局变量$wpdb来进行各种操作,应用的时分先在函数申明global $wpdb,而后调用它...