在主题函数修改系统通知邮件 美化篇
我觉得有些人说的也对,总贴代码,可能滚去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( __( '<div style="font: 12px 微软雅黑;width: 600px;margin: 20px auto;word-break: break-all;"> <table border="0" style="font: 15px 微软雅黑;border-collapse: collapse;width: 600px;margin: 20px auto;"><tbody> <tr> <td style="text-align: center;padding: 8px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;" colspan="2">您的文章《%s》有新评论' ), $post->post_title ) . '</td>'; $notify_message .= sprintf( __('</tr> <tr> <td style="padding: 8px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;width: 70px;">昵称 :</td> <td style="padding: 8px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;"> %s '), $comment->comment_author ) . '</td>'; $notify_message .= sprintf( __('</tr> <tr> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">IP :</td> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;"> %1$s ( %2$s ) '), $json, $comment->comment_author_IP ) . '</td> </tr> <tr> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">'; $notify_message .= sprintf( __('网站 :</td> <td style="padding: 8px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;"> %s'), $comment->comment_author_url ) . '</td> </tr> <tr> <td style="padding: 8px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">'; $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 : </td> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;"> %s'), $pageRank ) . '</td> </tr> <tr> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">'; } else { $notify_message .= __('PR : </td> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">0 ') . '</td> </tr> <tr> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">'; } $notify_message .= __('<div>评论内容 :</div> </td> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">') . $comment->comment_content . '</td> </tr> <tr> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;">'; $notify_message .= sprintf( __('固定链接 :</td> <td style="padding: 6px 15px;font: 15px 微软雅黑;border: 1px solid #ccc;"> %s'), get_comment_link($comment) ) . '</td> </tr> </tbody></table> <br><div style="margin-left:10px">'; if ( EMPTY_TRASH_DAYS ) $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "<br>"; else $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "<br>"; $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "<br> </div> </div>"; return $notify_message; } add_filter( 'comment_notification_text', 'xhd_mail2admin', 10, 2 );
效果见上一篇附图
原文地址:在主题函数修改系统通知邮件 美化篇, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



On July 29, at the roll-off ceremony of AITO Wenjie's 400,000th new car, Yu Chengdong, Huawei's Managing Director, Chairman of Terminal BG, and Chairman of Smart Car Solutions BU, attended and delivered a speech and announced that Wenjie series models will be launched this year In August, Huawei Qiankun ADS 3.0 version was launched, and it is planned to successively push upgrades from August to September. The Xiangjie S9, which will be released on August 6, will debut Huawei’s ADS3.0 intelligent driving system. With the assistance of lidar, Huawei Qiankun ADS3.0 version will greatly improve its intelligent driving capabilities, have end-to-end integrated capabilities, and adopt a new end-to-end architecture of GOD (general obstacle identification)/PDP (predictive decision-making and control) , providing the NCA function of smart driving from parking space to parking space, and upgrading CAS3.0

Go language provides two dynamic function creation technologies: closure and reflection. closures allow access to variables within the closure scope, and reflection can create new functions using the FuncOf function. These technologies are useful in customizing HTTP routers, implementing highly customizable systems, and building pluggable components.

On April 11, Huawei officially announced the HarmonyOS 4.2 100-machine upgrade plan for the first time. This time, more than 180 devices will participate in the upgrade, covering mobile phones, tablets, watches, headphones, smart screens and other devices. In the past month, with the steady progress of the HarmonyOS4.2 100-machine upgrade plan, many popular models including Huawei Pocket2, Huawei MateX5 series, nova12 series, Huawei Pura series, etc. have also started to upgrade and adapt, which means that there will be More Huawei model users can enjoy the common and often new experience brought by HarmonyOS. Judging from user feedback, the experience of Huawei Mate60 series models has improved in all aspects after upgrading HarmonyOS4.2. Especially Huawei M

In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

The key to writing efficient and maintainable Java functions is: keep it simple. Use meaningful naming. Handle special situations. Use appropriate visibility.

1. The SUM function is used to sum the numbers in a column or a group of cells, for example: =SUM(A1:J10). 2. The AVERAGE function is used to calculate the average of the numbers in a column or a group of cells, for example: =AVERAGE(A1:A10). 3. COUNT function, used to count the number of numbers or text in a column or a group of cells, for example: =COUNT(A1:A10) 4. IF function, used to make logical judgments based on specified conditions and return the corresponding result.

The advantages of default parameters in C++ functions include simplifying calls, enhancing readability, and avoiding errors. The disadvantages are limited flexibility and naming restrictions. Advantages of variadic parameters include unlimited flexibility and dynamic binding. Disadvantages include greater complexity, implicit type conversions, and difficulty in debugging.

Recently, Huawei announced that it will launch a new smart wearable product equipped with Xuanji sensing system in September, which is expected to be Huawei's latest smart watch. This new product will integrate advanced emotional health monitoring functions. The Xuanji Perception System provides users with a comprehensive health assessment with its six characteristics - accuracy, comprehensiveness, speed, flexibility, openness and scalability. The system uses a super-sensing module and optimizes the multi-channel optical path architecture technology, which greatly improves the monitoring accuracy of basic indicators such as heart rate, blood oxygen and respiration rate. In addition, the Xuanji Sensing System has also expanded the research on emotional states based on heart rate data. It is not limited to physiological indicators, but can also evaluate the user's emotional state and stress level. It supports the monitoring of more than 60 sports health indicators, covering cardiovascular, respiratory, neurological, endocrine,
