»WordPress»WordPress Tips: Add comment links to administrator comment emails
Add a link to the comment page quickly in the WordPress webmaster's comment email, and reply to comments directly in the email
preface
Everyone who has used WordPress knows that the email he sent to the webmaster is extremely ugly, but considering that the webmaster's email is only for himself, he has little energy to think about beautification, but Yunluo accidentally finds that there is a very unpleasant part in the webmaster's email of WordPress, and today Yunluo is to solve this problem.
discover problems
Before we talk again, let's take a look at WordPress's default webmaster comment email
First, let's talk about it. If you receive this comment email, you must first want to quickly reply to the visitor, right? But what are the connections WordPress gives us?❓ ❓ ❓ All comments?Haven't I read my comments?Fixed connection?I don't know the content of my posts?Garbage comments and recycle bin?Comments on these two things will not appear here. I just want to reply to comments quickly. Since WordPress does not have a link to the background comment page, we can add one ourselves.
code
I checked the source code of WordPress and found that there is a filter to modify the content of this email/wp-includes/pluggable.php#L1593There are some modifications. After a look, it should be customizable. Of course, we need to add content. The link of the background page is/wp-admin/edit-comments.php, just add this link. Just put the following code into the theme function file function file [Git theme already contains this function, do not add it again]
//Add comment link to webmaster comment emailfunction git_notify_postauthor( $comment_id ) {$notify_message = $comment_id;$notify_message .= 'Quick reply to this comment: '. admin_url ('edit comments. php');return $notify_message;}add_filter( 'comment_notification_text', 'git_notify_postauthor' );
Use effect
Look at the picture💡
There is a link to enter the background comment page. Of course, if you enter from the email, you may need to log in for the first time.
This screenshot is just the first one. It's a bit long, isn't it...
Postscript
Although this function is very simple, it is still important for me, because it lets me know how to modify the default function of WordPress. For example, simply take a chestnut. You will find too many interesting things in the WordPress folder by searching for the keyword [apply_filters]..