Make WordPress Core

Ticket #33735: 33735.2.diff

File 33735.2.diff, 8.6 KB (added by dshanske, 10 years ago)

Updated Patch

  • pluggable.php

     
    14331433                $emails = array_flip( $emails );
    14341434        }
    14351435
    1436         $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
    1437 
    14381436        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    14391437        // we want to reverse this for the plain text arena of emails.
    14401438        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    1441 
    1442         switch ( $comment->comment_type ) {
    1443                 case 'trackback':
    1444                         $notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
    1445                         /* translators: 1: website name, 2: website IP, 3: website hostname */
    1446                         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1447                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1448                         $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment->comment_content ) . "\r\n\r\n";
    1449                         $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
    1450                         /* translators: 1: blog name, 2: post title */
    1451                         $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
    1452                         break;
    1453                 case 'pingback':
    1454                         $notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
    1455                         /* translators: 1: website name, 2: website IP, 3: website hostname */
    1456                         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1457                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1458                         $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment->comment_content ) . "\r\n\r\n";
    1459                         $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
    1460                         /* translators: 1: blog name, 2: post title */
    1461                         $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
    1462                         break;
    1463                 default: // Comments
    1464                         $notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
    1465                         /* translators: 1: comment author, 2: author IP, 3: author domain */
    1466                         $notify_message .= sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1467                         $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1468                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1469                         $notify_message .= sprintf( __('Comment: %s' ), "\r\n" . $comment->comment_content ) . "\r\n\r\n";
    1470                         $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
    1471                         /* translators: 1: blog name, 2: post title */
    1472                         $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
    1473                         break;
    1474         }
     1439        $notify_message  = sprintf( __( 'New %1s on your post "%2s"' ), get_comment_type( $comment_id ), $post->post_title ) . "\r\n";
     1440        $subject = sprintf( __('[%1$s] %2$s: "%3$s"'), $blogname, get_comment_type( $comment_id ), $post->post_title );
     1441        /* translators: 1: blog name, 2: post title */
     1442        $notify_message .= get_comment_notify_text( $comment_id );
     1443        $notify_message .= sprintf( __( 'You can see all %s on this post here:' ), get_comment_type( $comment_id ) ) . "\r\n";
    14751444        $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
    14761445        $notify_message .= sprintf( __('Permalink: %s'), get_comment_link( $comment ) ) . "\r\n";
    14771446
     
    15671536                        $emails[] = $user->user_email;
    15681537        }
    15691538
    1570         $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
    15711539        $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'");
    15721540
    15731541        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    15741542        // we want to reverse this for the plain text arena of emails.
    15751543        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     1544        $notify_message  = sprintf( __('A new %1s on the post "%2s" is waiting for your approval'), get_comment_type( $comment_id ), $post->post_title ) . "\r\n";
     1545        $notify_message .= get_comment_notify_text( $comment_id );
    15761546
    1577         switch ( $comment->comment_type ) {
    1578                 case 'trackback':
    1579                         $notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
    1580                         $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
    1581                         /* translators: 1: website name, 2: website IP, 3: website hostname */
    1582                         $notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1583                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1584                         $notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    1585                         break;
    1586                 case 'pingback':
    1587                         $notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
    1588                         $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
    1589                         /* translators: 1: website name, 2: website IP, 3: website hostname */
    1590                         $notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1591                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1592                         $notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    1593                         break;
    1594                 default: // Comments
    1595                         $notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
    1596                         $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
    1597                         $notify_message .= sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1598                         $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1599                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1600                         $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment->comment_content ) . "\r\n\r\n";
    1601                         break;
    1602         }
    1603 
    16041547        $notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
    16051548        if ( EMPTY_TRASH_DAYS )
    16061549                $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
  • comment-template.php

     
    21232123                        do_action( 'comment_form_comments_closed' );
    21242124                endif;
    21252125}
     2126
     2127/**
     2128 * Returns the text used to display comments in notifications.
     2129 *
     2130 * @since 4.x
     2131 *
     2132 * @param int $comment_id The Comment ID.
     2133 * @return string Comment Text.
     2134 */
     2135function get_comment_notify_text( $comment_id ) {
     2136        $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
     2137        $type = get_comment_type( $comment_id );
     2138        if ( in_array ($type, array( 'pingback', 'trackback' ) ) ) {
     2139        /* translators: 1: website name, 2: website IP, 3: website hostname */
     2140                $notify_text = sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), get_comment_author( $comment_id ), get_comment_author_ip( $comment_id ), $comment_author_domain ) . "\r\n";
     2141                $notify_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment_id ) ) . "\r\n";
     2142                $notify_text .= sprintf( __( 'Excerpt: %s' ), "\r\n" . get_comment_text( $comment_id ) ) . "\r\n\r\n";
     2143        }
     2144  else {
     2145        /* translators: 1: comment author, 2: author IP, 3: author domain */
     2146                $notify_text = sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), get_comment_author( $comment_id ), get_comment_author_ip ($comment_id ), $comment_author_domain ) . "\r\n";
     2147                $notify_text .= sprintf( __( 'E-mail: %s' ), get_comment_author_email( $comment_id ) ) . "\r\n";
     2148                $notify_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment_id ) ) . "\r\n";
     2149                $notify_text .= sprintf( __('Comment: %s' ), "\r\n" . get_comment_text( $comment_id ) ) . "\r\n\r\n";
     2150        }
     2151        /**
     2152         * Filter the comment text to be used for email notifications.
     2153   *
     2154   * This generates the display of a comment for notifications.
     2155   *
     2156   * @since 4.4
     2157   *
     2158   * @param string $notify_text The Comment Notify Text.
     2159         * @param int $comment_id The ID of the comment being displayed.
     2160             */
     2161        return apply_filters( 'comment_notify_text', $notify_text, $comment_id );
     2162}