WordPress.org

Make WordPress Core

Ticket #33735: 33735.diff

File 33735.diff, 8.2 KB (added by dshanske, 5 years ago)
  • pluggable.php

     
    14381438        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    14391439        // we want to reverse this for the plain text arena of emails.
    14401440        $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         }
     1441        $notify_message  = sprintf( __( 'New %1s on your post "%2s"' ), get_comment_type( $comment_id ), $post->post_title ) . "\r\n";
     1442        $subject = sprintf( __('[%1$s] %2$s: "%3$s"'), $blogname, get_comment_type( $comment_id ), $post->post_title );
     1443        /* translators: 1: blog name, 2: post title */
     1444        $notify_message .= get_comment_notify_text( $comment_id );
     1445        $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
    14751446        $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
    14761447        $notify_message .= sprintf( __('Permalink: %s'), get_comment_link( $comment ) ) . "\r\n";
    14771448
     
    15731544        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    15741545        // we want to reverse this for the plain text arena of emails.
    15751546        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     1547        $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";
     1548        $notify_message .= get_comment_notify_text( $comment_id );
    15761549
    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 
    16041550        $notify_message .= sprintf( __('Approve it: %s'),  admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n";
    16051551        if ( EMPTY_TRASH_DAYS )
    16061552                $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}