daily pastebin goal
71%
SHARE
TWEET

wp_comment_email.php

a guest Nov 29th, 2018 295 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function wp_comment_mail_notify ($comment_id) {
  3.     $comment        = get_comment($comment_id);
  4.     $parent_id      = $comment->comment_parent ? $comment->comment_parent : '';
  5.     $spam_confirmed = $comment->comment_approved;
  6.  
  7.     $blogname = get_option('blogname');
  8.     if (!empty(get_option('blogdescription'))) $blogname .= '|'.get_option('blogdescription');
  9.  
  10.     if(($parent_id != '') && ($spam_confirmed != 'spam')) {
  11.         $wp_email = 'comment-notify@'.preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
  12.         $to = trim(get_comment($parent_id)->comment_author_email);
  13.         $subject = '你在 '.$blogname.' 的留言有了回应';
  14.         $message = '<p>'.trim(get_comment($parent_id)->comment_author).', 你好!</p>
  15.             <p>你在<a href="'.get_permalink($comment->comment_post_ID).'" target="_blank" style="color:#008BFF;text-decoration:none;">《'.get_the_title($comment->comment_post_ID).'》</a>发表的留言:</p>
  16.             <p style="margin-bottom:20px;margin-top:20px;margin-left:20px;padding-left:7px;border-left:dimgrey 8px solid;font-size:1.15rem;">'.trim(get_comment($parent_id)->comment_content).'</p>
  17.             <p>收到了新回复,'.trim($comment->comment_author).':</p>
  18.             <p style="margin-bottom:20px;margin-top:20px;margin-left:20px;padding-left:7px;border-left:dimgrey 8px solid;font-size:1.15rem;">'.trim($comment->comment_content).'</p>
  19.             <p>欲知详情请点击<a href="'.htmlspecialchars(get_comment_link($parent_id)).'" target="_blank" style="color:#008BFF;text-decoration:none;">这里</a>.</p>
  20.             <p>感谢你对 <a href="'.get_option('home').'" target="_blank" style="color:#008BFF;text-decoration:none;"> '.$blogname.' </a> 的关注与支持.</p>';
  21.         $from = 'From: "'.get_option('blogname').'" <$wp_email>';
  22.         $headers = "$from\nContent-Type: text/html; charset=".get_option('blog_charset')."\n";
  23.         wp_mail($to, $subject, $message, $headers);
  24.     }
  25. }
  26. add_action('comment_post', 'wp_comment_mail_notify');
  27. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top