Advertisement
Guest User

Untitled

a guest
Jan 19th, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.71 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Custom Comments
  4. Plugin URI: http://www.SlySpyder.com/
  5. Description: Hides private details from comment notification emails, such as IP address and email.
  6. Author: Tosh
  7. Version: 1.0
  8. Author URI: http://www.SlySpyder.com/
  9. */
  10.  
  11. if ( ! function_exists('wp_notify_postauthor') ) :
  12. /**
  13.  * Notify an author of a comment/trackback/pingback to one of their posts.
  14.  *
  15.  * @since 1.0.0
  16.  *
  17.  * @param int $comment_id Comment ID
  18.  * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
  19.  * @return bool False if user email does not exist. True on completion.
  20.  */
  21. function wp_notify_postauthor($comment_id, $comment_type='') {
  22.     $comment = get_comment($comment_id);
  23.     $post    = get_post($comment->comment_post_ID);
  24.     $user    = get_userdata( $post->post_author );
  25.     $current_user = wp_get_current_user();
  26.  
  27.     if ( $comment->user_id == $post->post_author ) return false; // The author moderated a comment on his own post
  28.  
  29.     if ('' == $user->user_email) return false; // If there's no email to send the comment to
  30.  
  31.     $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
  32.    
  33.     // The blogname option is escaped with esc_html on the way into the database in sanitize_option
  34.     // we want to reverse this for the plain text arena of emails.
  35.     $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
  36.  
  37.     if ( empty( $comment_type ) ) $comment_type = 'comment';
  38.  
  39.     if ('comment' == $comment_type) {
  40.         /* translators: 1: post id, 2: post title */
  41.         $notify_message  = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
  42.         /* translators: 1: comment author, 2: author IP, 3: author domain */
  43.         $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  44.         //$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
  45.         $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  46.         //$notify_message .= sprintf( __('Whois  : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
  47.         $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  48.         $notify_message .= __('You can see all comments on this post here: ') . "\r\n";
  49.         /* translators: 1: blog name, 2: post title */
  50.         $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
  51.     } elseif ('trackback' == $comment_type) {
  52.         /* translators: 1: post id, 2: post title */
  53.         $notify_message  = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
  54.         /* translators: 1: website name, 2: author IP, 3: author domain */
  55.         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  56.         $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  57.         $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
  58.         $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
  59.         /* translators: 1: blog name, 2: post title */
  60.         $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
  61.     } elseif ('pingback' == $comment_type) {
  62.         /* translators: 1: post id, 2: post title */
  63.         $notify_message  = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
  64.         /* translators: 1: comment author, 2: author IP, 3: author domain */
  65.         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
  66.         $notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
  67.         $notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
  68.         $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
  69.         /* translators: 1: blog name, 2: post title */
  70.         $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
  71.     }
  72.     $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
  73.     if ( EMPTY_TRASH_DAYS )
  74.         $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
  75.     else
  76.         $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
  77.     $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
  78.  
  79.     $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
  80.  
  81.     if ( '' == $comment->comment_author ) {
  82.         $from = "From: \"$blogname\" <$wp_email>";
  83.         if ( '' != $comment->comment_author_email )
  84.             $reply_to = "Reply-To: $comment->comment_author_email";
  85.     } else {
  86.         $from = "From: \"$comment->comment_author\" <$wp_email>";
  87.         if ( '' != $comment->comment_author_email )
  88.             $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
  89.     }
  90.  
  91.     $message_headers = "$from\n"
  92.         . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
  93.  
  94.     if ( isset($reply_to) )
  95.         $message_headers .= $reply_to . "\n";
  96.  
  97.     $notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
  98.     $subject = apply_filters('comment_notification_subject', $subject, $comment_id);
  99.     $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
  100.  
  101.     @wp_mail($user->user_email, $subject, $notify_message, $message_headers);
  102.  
  103.     return true;
  104. }
  105. endif;
  106. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement