Advertisement
Guest User

Patch Does not work

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