您好,欢迎访问一九零五行业门户网

在主题函数修改系统通知邮件 美化篇

我觉得有些人说的也对,总贴代码,可能滚去github比较好,但是我爱wordpress,我不会离开这里 /**系统原本定义的mail类型不支持html,所以需要挂一个新钩子:comment_notification_headers**/function xhd_mail2admin_2() {if ( '' == $comment-comment_author ) {
我觉得有些人说的也对,总贴代码,可能滚去github比较好,但是我爱wordpress,我不会离开这里
/**系统原本定义的mail类型不支持html,所以需要挂一个新钩子:comment_notification_headers**/function xhd_mail2admin_2() { if ( '' == $comment->comment_author ) { $from = from: \$blogname\ ; if ( '' != $comment->comment_author_email ) $reply_to = reply-to: $comment->comment_author_email; } else { $from = from: \$comment->comment_author\ ; if ( '' != $comment->comment_author_email ) $reply_to = reply-to: \$comment->comment_author_email\ comment_author_email>; } $message_headers = $from\n . content-type: text/html; charset=\ . get_option('blog_charset') . \\n; return $message_headers;}add_filter('comment_notification_headers', 'xhd_mail2admin_2', 10, 2 );/**在昨天代码基础上的美化**/ function xhd_mail2admin( $notify_message, $comment_id ) { $comment = get_comment( $comment_id ); $post = get_post( $comment->comment_post_id ); $author = get_userdata( $post->post_author ); if ( $comment->user_id == $post->post_author ) return false; if ( $post->post_author == get_current_user_id() ) return false; if ( '' == $author->user_email ) return false; $blogname = wp_specialchars_decode(get_option('blogname'), ent_quotes); $ipurl = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip='.$comment->comment_author_ip; $json = file_get_contents($ipurl); $json = json_decode($json, true); $json = $json[country].$json[province].$json[city].$json[district].$json[isp]; $notify_message = sprintf( __( '您的文章《%s》有新评论' ), $post->post_title ) . ' '; $notify_message .= sprintf( __('
昵称 : %s '), $comment->comment_author ) . ' '; $notify_message .= sprintf( __('
ip : %1$s ( %2$s ) '), $json, $comment->comment_author_ip ) . '
'; $notify_message .= sprintf( __('网站 : %s'), $comment->comment_author_url ) . '
'; $domain1 = $comment->comment_author_url ; $domain=substr($domain1,7); $starturl = http://toolbarqueries.google.com/tbr?client=navclient-auto&features=rank&q=info:; $resulturl = $starturl.$domain.&ch=.app_hash_url($domain); $array = get_headers($resulturl,1); if(!preg_match('/403/',$array[0])){ $pagecontent = file_get_contents($resulturl); $pagerank = substr($pagecontent,9); $notify_message .= sprintf( __('pr : %s'), $pagerank ) . '
'; } else { $notify_message .= __('pr : 0 ') . '
'; } $notify_message .= __('评论内容 :
') . $comment->comment_content . '
'; $notify_message .= sprintf( __('固定链接 : %s'), get_comment_link($comment) ) . '
'; if ( empty_trash_days ) $notify_message .= sprintf( __('trash it: %s'), admin_url(comment.php?action=trash&c=$comment_id) ) .
; else $notify_message .= sprintf( __('delete it: %s'), admin_url(comment.php?action=delete&c=$comment_id) ) .
; $notify_message .= sprintf( __('spam it: %s'), admin_url(comment.php?action=spam&c=$comment_id) ) .
; return $notify_message;}add_filter( 'comment_notification_text', 'xhd_mail2admin', 10, 2 );
效果见上一篇附图
原文地址:在主题函数修改系统通知邮件 美化篇, 感谢原作者分享。
其它类似信息

推荐信息