临近放假事情不算多,利用空余时间陆陆续续对博客做了一些调整。
评论回复邮件通知延迟发送
无意发现了ze3kr 的评论回复邮件通知代码含有执行计划任务的代码,抄过来加到在用的评论回复邮件通知插件上,这个网站的评论回复邮件通知依赖 Comment Email Reply 插件,不知从 WordPress 的哪个版本开始这个插件便不再正常工作了,插件作者迟迟没有更新,一并做了修改,下面是修改后的完整代码:
<?php
/**
* Plugin Name: Comment Email Reply
* Plugin URI: http://kilozwo.de/wordpress-comment-email-reply-plugin
* Description: Simply notifies comment-author via email if someone replies to his comment. Zero Configuration. Available in English and German. More languages welcome.
* Version: 1.0.5(dev)
* Author: Jan Eichhorn
* Author URI: http://kilozwo.de
* License: GPLv2
*/
add_filter('wp_mail_content_type', function($contentType) { return 'text/html'; });
function cer_comment_notification($comment_id) {
$comment_object = get_comment($comment_id);
if ($comment_object->comment_approved == 1 && $comment_object->comment_parent > 0) {
$comment_parent = get_comment($comment_object->comment_parent);
$mailcontent =
'<html>
<head>
<style>
#mgy{margin:0;padding:0;font-size:16px;font-size:1rem;line-height:1.8;color:#444}
#mgy .a{width:100%}
#mgy .b{width:520px;margin:0 auto;padding:20px}
#mgy .c{clear:both}
#mgy .d,#mgy .n{margin:0 0 24px}
#mgy .e{border-top:1px solid #DDD}
#mgy .f{margin-bottom:10px}
#mgy .g{margin:0 5px 0 0}
#mgy .h{width:100px;height:32px;line-height:32px;padding:2px;border-radius:30px;color:#FFF;background:#52C69C;box-shadow:1px 1px 0 #DDD}
#mgy .h:hover{background:#57AD68}
#mgy .j{margin:0 6px;border-bottom:1px dotted;text-decoration:none}
#mgy .k{text-align:center;text-decoration:none}
#mgy .l{display:block}
#mgy .m{color:#57AD68}
#mgy .o{margin:5px 0}
#mgy .p{color:#5A5A5A}
#mgy .q{background:#F0F0F0;border-radius:4px;padding:8px;line-height:1.5rem;line-height:24px}
#mgy .s{color:#2458A1}
@media screen and (max-width:720px) {
#mgy{font-size:18px;font-size:1.125rem;line-height:2}
#mgy .b{width:100%;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
}
</style>
</head>
<body>
<div id="mgy">
<div class="a"><div class="b"><div class="o"><span class="g">'
.$comment_parent->comment_author.
':</span>你好</div>'.
'<div class="f"><span class="g s">'.$comment_object->comment_author.'</span>在'.
'<a class="j" href="'.get_permalink($comment_parent->comment_post_ID).'">'.get_the_title($comment_parent->comment_post_ID).'</a>中 <span class="f">对你发表的评论:</span></div>'.
'<div class="f q">'. esc_html($comment_parent->comment_content) .'</div>'.
'<div class="f">作了如下回复:</div><div class="d s q">'
. esc_html($comment_object->comment_content) .
'</div>'.
'<a class="d h k l" href="'.get_comment_link( $comment_parent->comment_ID ).'">继续回复</a>'.
'<div class="f">感谢对<a class="j m" href="//maliyana.com">木瓜园</a>的支持,谢谢!</div>'.'<div class="e"><span class="p">MALI<span class="m">YA</span>NA</span></div></div></div></div>
</body></html>';
$email = $comment_parent->comment_author_email;
$title ='来自 ['.get_option('blogname') . '] 的评论回复';
wp_mail($email, $title, $mailcontent);
}
}
add_action('comment_mail_notify','cer_comment_notification');
function comment_mail_notify_schedule($comment_id) {
wp_schedule_single_event( time()+300, 'comment_mail_notify', array($comment_id));
}
add_action('wp_insert_comment','comment_mail_notify_schedule',99,2);
function cer_comment_status_changed($comment_id, $comment_status) {
$comment_object = get_comment($comment_id);
if ($comment_status == 'approve') {
cer_comment_notification($comment_object->comment_ID, $comment_object);
}
}
# Fire Email when comments gets approved later.
add_action('wp_set_comment_status','cer_comment_status_changed',99,2);
?>
更改防垃圾评论机制
卸载了 Akismet 插件,给评论功能加了两个小机关,配合起来效果不错,只是对人工垃圾评论无能为力。
外观上的一些调整
- 过年了,要有气氛,临时改了个有春节喜庆氛围的配色;
- 给无限滚动改了新的加载动画,这是个 css3 动画,主要目的是改善手机无图模式下的浏览体验,同时,对 css3的支持,就意味着逐步停止对 IE 老旧浏览器的支持了。
这个主题蛮清爽的
博客真喜庆啊,新年快乐。
@角落里 新年快乐,万事大吉!