WordPress评论审核、评论回复通知、账户变更通知、文章修改、新文章邮件通知美化模板-国外便宜VPS

Wordpress评论审核、评论回复通知、账户变更通知、文章修改、新文章邮件通知美化模板

前天才弄了一个Wordpress评论回复通知美化模板,但是突然在Wordpress大学看到一篇各种通知的模板,折腾的心就又停不下来了,还在龙笑天下和小浩博客分别看到更新文章通知和新建文章通知,结合前天的模板风格,整合了这个各种通知美化模板。

模板包含两套头部风格,居中和标准,在文章下方查看演示页,效果演示页的第一个为居中,其他的都为标准风格

问题:标准风格右上角的菜单按钮在QQ手机邮箱里面没有隐藏,导致排版有点问题。因为他没有生效 @media only screen and (max-width: 500px)的css风格,在浏览器上表现正常。

(adsbygoogle = window.adsbygoogle || []).push({});

Wordpress评论审核、评论回复通知、账户变更通知、文章修改、新文章邮件通知美化模板

代码有点多,放个下载链接,到下面下载吧。

你也可以使用只有评论通知的面板

建站技巧

WordPress评论审核、评论回复通知、账户变更通知、文章修改、新文章邮件通知美化模板-国外便宜VPS




WordPress邮件回复样式,美化样式
WordPress邮件回复美化样式,预览图,首先这不是我写的,这是我从搜索引擎上找……

1年前 (2019-04-22)
509
2

<?php /* ------------------------------------- * By... 内容都是网上找的,一为只是做了整合 * 文章地址:https://www.iowen.cn/wordpress-pinglunshenhepinglunhuifutongzhizhanghubiangengtongzhiwenzhangxiugaixinwenzhangyoujiantongai * 设置: * 1、模板提供两种头样式请到下方设置邮件头的样式 * 2、邮件底部有广告位,可设置内容或者删除 * ------------------------------------- *------------------------------------- * 新文章/更新文章邮件通知所有评论用户选择工具 * 文章编辑页小工具 *-----------------------------------*/ add_action('submitpost_box', 'i_submit_box'); function i_submit_box(){ echo ' <div> <div> <div title="点击以切换"><br /></div> <h3><span>邮件通知</span></h3> <div><div> <div><label title="慎用此功能,重要文章才勾选嘛,以免引起读者反感哈"><input type="checkbox" unchecked value="true" title="勾选此项,将邮件通知博客所有评论者"/>邮件通知"博客"所有评论者</label></div> <div><label title="慎用此功能,重要文章才勾选嘛,以免引起读者反感哈"><input type="checkbox" unchecked value="true" title="勾选此项,将邮件通知本文所有评论者"/>邮件通知"本文"所有评论者</label></div> <div><label title="填写文章更新内容简介">填写文章更新简介,作为邮件内容<br><textarea rows="1" cols="40"></textarea></label></div> <script type="text/javascript"> function chk(obj){ if(obj.checked){ $("#myid").show(); }else{ $("#myid").hide(); } } </script> </div></div> </div> </div>'; } /*------------------------------------- * 头部风格,true 为居中, false 为标准 * 效果查看:https://www.iowen.cn/demo/email-notify.html * 效果演示页的第一个为居中,其他的都为标准风格 * 问题:标准风格右上角的菜单按钮在QQ手机邮箱里面没有隐藏,导致排版有点问题 * 他没有生效 @media only screen and (max-width: 500px) * 在浏览器上表现正常。 *-----------------------------------*/ $style_center = true; //定义界面顶部区域内容,请注意修改您的主题目录 $email_headertop_center = ' <div> <div> <div> <div> <div> <img src="'http://www.367783.net/jianzhan/.zm_get_option('logo').'" title="' . get_option("blogname") . '"> </div> <div> <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'" title="' . get_option("blogname") . '">首页</a> <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'/articleupdate" title="最新动态">最新动态</a> <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'/tryluck" title="随便看看">随便看看</a> </div> <div></div> </div> <div> '; $email_headertop = ' <style> @media only screen and (max-width: 500px){.ititle{padding: 15px 0px 0 80px!important;}.imenu{display: none;}} </style> <div> <div> <div> <div> <div><div><img src="'http://www.367783.net/jianzhan/.zm_get_option('logo').'" title="' . get_option("blogname") . '"></div></div> <div> '; /*--------------- **----标题空间---- **-------------*/ $email_headerbot_center = ' </div> <div> '; $email_headerbot = ' </div> <div><div> <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'" title="' . get_option("blogname") . '">首页</a> <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'/articleupdate" title="最新动态">最新动态</a> <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'/tryluck" title="随便看看">随便看看</a> </div></div> <div></div> </div> <div> '; if($style_center){ define ('emailheadertop', $email_headertop_center ); define ('emailheaderbot', $email_headerbot_center ); } else{ define ('emailheadertop', $email_headertop ); define ('emailheaderbot', $email_headerbot ); } //定义界面底部区域内容,---[请注意修改下面广告图片地址,不需要请删除 <div ......</div> 这 4 行]--- $email_footer = ' </div> <div> <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'"> <img src="https://s2.ax1x.com/2019/04/24/EVn0Y9.jpg" alt=""> </a> </div> <div> <p>(此为系统自动发送邮件, 请勿回复!)</p> <p>© '. date("Y") . ' · 邮件来自 · <a href="'http://www.367783.net/jianzhan/%20.%20get_bloginfo('url')%20.%20'">' . get_option("blogname") . '</a></p> </div> </div> </div> </div> '; define ('emailfooter', $email_footer ); //修改网站默认发信人以及邮箱 function new_from_name($email){ $wp_from_name = get_option('blogname'); return $wp_from_name; } function new_from_email($email) { $wp_from_email = get_option('admin_email'); return $wp_from_email; } add_filter('wp_mail_from_name', 'new_from_name'); add_filter('wp_mail_from', 'new_from_email'); //评论通过通知评论者 add_action('comment_unapproved_to_approved', 'iwill_comment_approved'); function iwill_comment_approved($comment) { if(is_email($comment->comment_author_email)) { $post_link = get_permalink($comment->comment_post_ID); // 邮件标题,可自行更改 $title = '您在 [' . get_option('blogname') . '] 的评论已通过审核'; // 邮件内容,按需更改。如果不懂改,可以给我留言 $body = emailheadertop.'留言审核通过通知'.emailheaderbot.' <p>您在' . get_option('blogname') . '《<a href="'http://www.367783.net/jianzhan/.$post_link.'">'.get_the_title($comment->comment_post_ID).'</a>》发表的评论:</p> <p>'.$comment->comment_content.'</p> <p>已通过管理员审核并显示。<br /> 您可在此查看您的评论:<a href="'http://www.367783.net/jianzhan/.get_comment_link(%20$comment->comment_ID%20).'">前往查看</a></p>'.emailfooter; @wp_mail($comment->comment_author_email, $title, $body, "Content-Type: text/html; charset=UTF-8"); } } /* 邮件评论回复美化版 */ function comment_mail_notify($comment_id) { $admin_email = get_bloginfo ('admin_email'); $admin_notify = '1'; // admin 要不要收回复通知 ( '1'=要 ; '0'=不要 ) $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 != $comment_author_email)) { $wp_email = 'no-reply@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); $subject = '您在 [' . get_option("blogname") . '] 的留言有了新回复'; $message = emailheadertop.'您在' . get_option("blogname") . '上的留言有回复啦!'.emailheaderbot.' <p>' . trim(get_comment($parent_id)->comment_author) . ', 您好!</p> <p>您于 '. trim(get_comment($parent_id)->comment_date) . ' 在文章《' . get_the_title($comment->comment_post_ID) . '》上发表评论:<br /> <p>'. trim(get_comment($parent_id)->comment_content) . '</p> <p>' . trim($comment->comment_author) . ' 于' . trim($comment->comment_date) . ' 给您的回复如下:<br /> <p>'. trim($comment->comment_content) . '</p> <p>你可以点击 <a href="'http://www.367783.net/jianzhan/%20.%20htmlspecialchars(get_comment_link($parent_id,%20array('type'%20=>%20'comment')))%20.%20'">查看完整内容</a></p> <p>欢迎再度光临 <a href="'http://www.367783.net/jianzhan/%20.%20get_option('home')%20.%20'">' . get_option('blogname') . '</a></p> '.emailfooter; $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 ); } //文章新评论给管理员通知 if($parent_id == '' && $comment_author_email != $admin_email && $admin_notify == '1'){ $wp_email = ''; $subject = ' [' . get_option("blogname") . '] 上的文章有了新的评论'; $message = emailheadertop. get_option("blogname") . '上有新的评论'.emailheaderbot.' <p>' . trim($comment->comment_author) . ' 在文章《<a href="'http://www.367783.net/jianzhan/%20.%20htmlspecialchars(get_comment_link($comment_id))%20.%20'" target="_blank">' . get_the_title($comment->comment_post_ID) . '</a>》中发表了回复,快去看看吧:<br></p> <p>'. trim($comment->comment_content) . '</p> '.emailfooter; $from = "From: \"" . get_option('blogname') . "\" <$wp_email>"; $headers = "$from\nContent-Type: text/html; charset=" . get_option('blog_charset') . "\n"; wp_mail( $admin_email, $subject, $message, $headers ); } } add_action('comment_post', 'comment_mail_notify'); // 博客后台登录失败时发送邮件通知管理员 function wp_login_failed_notify(){ date_default_timezone_set('PRC'); $admin_email = get_bloginfo('admin_email'); $to = $admin_email; $subject = '【登录失败】有人使用了错误的用户名或密码登录' . get_bloginfo('name') . '!'; $message = emailheadertop . get_bloginfo('name') . '账户登录失败通知!'.emailheaderbot.' <div>尊敬的管理员您好!</div> <p>' . get_bloginfo('name') . '有一条登录失败的记录产生,若登录操作不是您产生的,请及时注意网站安全!</p> <table cellpadding="0" cellspacing="0"> <thead><tr><th colspan="2">失败信息如下</th></tr></thead> <tbody> <tr> <td>登录名</td> <td>' . $_POST['log'] . '</td> </tr> <tr> <td>尝试的密码</td> <td>' . $_POST['pwd'] . '</td> </tr> <tr> <td>登录时间</td> <td>' . date("Y-m-d H:i:s") . '</td> </tr> <tr> <td>登录IP</td> <td>' . $_SERVER['REMOTE_ADDR'] . '</td> </tr> </tbody> </table> '.emailfooter; wp_mail( $to, $subject, $message, "Content-Type: text/html; charset=UTF-8" ); } add_action('wp_login_failed', 'wp_login_failed_notify'); add_filter('logout_url', 'mk_logout_redirect_home', 10, 2); function mk_logout_redirect_home($logouturl, $redir){ $redir = home_url(); return $logouturl . '&redirect_to=' . urlencode($redir); } //用户更新账户通知用户 function user_profile_update( $user_id ) { $site_url = get_bloginfo('wpurl'); $site_name = get_bloginfo('wpname'); $user_info = get_userdata( $user_id ); $to = $user_info->user_email; $subject = "".$site_name."账户更新"; $message = emailheadertop.'您在' .$site_name. '账户资料修改成功!'.emailheaderbot.'<p>亲爱的 ' .$user_info->display_name . '<br/>您的资料修改成功!<br/>谢谢您的光临</p>'.emailfooter; wp_mail( $to, $subject, $message, "Content-Type: text/html; charset=UTF-8"); } add_action( 'profile_update', 'user_profile_update', 10, 2); //用户账户被删除通知用户 function iwilling_delete_user( $user_id ) { global $wpdb; $site_name = get_bloginfo('name'); $user_obj = get_userdata( $user_id ); $email = $user_obj->user_email; $subject = "帐号删除提示:".$site_name.""; $message = emailheadertop.'您在' .$site_name. '的账户已被管理员删除!'.emailheaderbot.'<p>如果您对本次操作有什么异议,请联系管理员反馈!<br/>我们会在第一时间处理您反馈的问题.</p>'.emailfooter; wp_mail( $email, $subject, $message, "Content-Type: text/html; charset=UTF-8"); } add_action( 'delete_user', 'iwilling_delete_user' ); // WordPress 发布新文章/更新文章后邮件通知已注册的用户 function newPostNotify($post_ID) { //如果勾选邮件通知所以用户 if($_POST['I_emaill_report_user'] == 'true'){ //修订版本不通知,以免滥用 if( wp_is_post_revision($post_ID) )return; //获取wp数据操作类 global $wpdb; // 读数据库,获取所有用户的email $wp_user_emails = $wpdb->get_results("SELECT DISTINCT comment_author, comment_author_email FROM $wpdb->comments WHERE TRIM(comment_author_email) IS NOT NULL AND TRIM(comment_author_email) != ''"); // 获取博客名称 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); //文章链接 $post_link = get_permalink($post_ID); //文章标题$post -> post_title $post_title = strip_tags($_POST['post_title']); //文章内容$post->post_content $post_contents = strip_tags($_POST['post_content']); //文章摘要 $output = iowen_strimwidth($post_contents,0,120,'...'); //邮件头,以免乱码 $message_headers = "Content-Type: text/html; charset=\"utf-8\"\n"; // 邮件标题 $subject = 'Hi! ['.$blogname.'] 发布新文章啦!'; foreach ( $wp_user_emails as $wp_user_email ) { // 邮件内容 $message = emailheadertop . $blogname. '发布新文章啦!' . emailheaderbot.' <div>文章标题:' . $post_title . '</div> <p>' . $output . '</p> <p><a href="'http://www.367783.net/jianzhan/%20.%20$post_link%20.%20'">查看全文</a><br /></p> '.emailfooter; wp_mail($wp_user_email->comment_author_email, $subject, $message, $message_headers); } } //如果勾选邮件通知本文所以用户 if($_POST['I_local_emaill_report_user'] == 'true'){ $admin_email = get_bloginfo ('admin_email'); //修订版本不通知,以免滥用 if( wp_is_post_revision($post_ID) )return; //获取wp数据操作类 global $wpdb,$post; // 读数据库,获取文章的所有用户的email并且不重复 $wp_user_emails = $wpdb->get_results("SELECT DISTINCT comment_author, comment_author_email FROM $wpdb->comments WHERE TRIM(comment_author_email) IS NOT NULL AND TRIM(comment_author_email) != '' AND TRIM(comment_author_email) != '$admin_email' AND comment_post_ID = $post->ID"); // 获取博客名称 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); //文章链接 $post_link = get_permalink($post_ID); //文章标题$post -> post_title $post_title = strip_tags($_POST['post_title']); //文章内容$post->post_content $post_contents = strip_tags($_POST['post_content']); //文章摘要 $output = iowen_strimwidth($post_contents,0,120,'...'); $update_data = $_POST['I_article_update_introduction']; //邮件头,以免乱码 $message_headers = "Content-Type: text/html; charset=\"utf-8\"\n"; // 邮件标题 $subject = '您曾经在 [' . $blogname . '] 评论过的文章有更新'; foreach ( $wp_user_emails as $wp_user_email ) { // 邮件内容 $message = emailheadertop.'文章内容有更新!'.emailheaderbot.' <p>' .$wp_user_email->comment_author. ', 您好!</p> <p>您曾经评论的文章有更新,博主觉得有必要通知您,希望没有打扰到您。</p> <p>文章标题:《'.$post_title.'》</p> <p>文章摘要:'.$output.'</p> <p>更新说明:'.$update_data.'</p> <p><a href="'http://www.367783.net/jianzhan/%20.%20$post_link%20.%20'">查看全文</a><br /></p> '.emailfooter; wp_mail($wp_user_email->comment_author_email, $subject, $message, $message_headers); } } } add_action('publish_post', 'newPostNotify'); function iowen_strimwidth($str ,$start , $width ,$trimmarker ){ $output = preg_replace('/^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$start.'}((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$width.'}).*/s','\1',$str); return $output.$trimmarker; } ?> WordPress邮件通知系统美化版,包含功能如下

1、评论审核通过通知用户

2、评论回复通知用户

3、网站后台登录失败通知管理员

4、注册用户资料信息更新通知用户

5、注册用户账户被管理员删除通知用户

6、网站发布新文章通知用户

7、更新文章通知文章评论用户

部署

下载email-notify.php,解压以后放在您的主题文件夹下
在functions.php中进行调用

include_once('email-notify.php');

知更鸟主题可替换主题目录的inc\email-notify.php文件

注意事项

1、注意email-nitify.php的放置位置以及调用路径必须一致

2、第47行可设置头部风格

3、代码111行有广告位,可自己修改或者删除

4、283和320行定义了摘要显示字数,您可以随意换成您自己的哦

新文章通知

可在文章编辑页选择相应功能通知网站的评论者,如下图,如果是更新的文章,可以填写简单的更新介绍。

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。