Make WordPress Core

Ticket #33735: 33735.5.diff

File 33735.5.diff, 10.3 KB (added by dshanske, 6 years ago)

Refreshed patch

  • src/wp-includes/comment-template.php

    diff --git src/wp-includes/comment-template.php src/wp-includes/comment-template.php
    index e2bdaf6..abe535f 100644
    function comment_form( $args = array(), $post_id = null ) { 
    24652465         */
    24662466        do_action( 'comment_form_after' );
    24672467}
     2468
     2469
     2470/**
     2471 * Returns the text used to display comments in notifications.
     2472 *
     2473 * @since 5.0
     2474 *
     2475 * @param int|WP_Comment $comment WP_Comment or the ID of the comment for which to retrieve the author.
     2476 * @return string Comment Text.
     2477 */
     2478function get_comment_notify_text( $comment ) {
     2479        $comment = get_comment( $comment );
     2480        if ( empty( $comment ) || empty( $comment->comment_post_ID ) )
     2481                return false;
     2482        $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
     2483        $type = get_comment_type( $comment );
     2484        $text = wp_specialchars_decode( get_comment_text( $comment ) );
     2485
     2486        if ( in_array( $type, array( 'pingback', 'trackback' ), true ) ) {
     2487                /* translators: 1: website name, 2: website IP, 3: website hostname */
     2488                $notify_text = sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), get_comment_author( $comment ), get_comment_author_ip( $comment ), $comment_author_domain ) . "\r\n";
     2489                $notify_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment ) ) . "\r\n";
     2490                $notify_text .= sprintf( __( 'Excerpt: %s' ), "\r\n" . $text ) . "\r\n\r\n";
     2491        } else {
     2492                /* translators: 1: comment author, 2: author IP, 3: author domain */
     2493                $notify_text = sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), get_comment_author( $comment_id ), get_comment_author_ip ($comment ), $comment_author_domain ) . "\r\n";
     2494                $notify_text .= sprintf( __( 'E-mail: %s' ), get_comment_author_email( $comment ) ) . "\r\n";
     2495                $notify_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment ) ) . "\r\n";
     2496                $notify_text .= sprintf( __('Comment: %s' ), "\r\n" . $text ) . "\r\n\r\n";
     2497        }
     2498        /**
     2499         * Filter the comment text to be used for email notifications.
     2500         *
     2501         * This generates the display of a comment for notifications.
     2502         *
     2503         * @since 5.0
     2504         *
     2505         * @param string $notify_text The Comment Notify Text.
     2506         * @param WP_Comment $comment The comment being notified
     2507         */
     2508        return apply_filters( 'comment_notify_text', $notify_text, $comment );
     2509}
  • src/wp-includes/pluggable.php

    diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
    index 882660a..c3b6659 100644
    function wp_notify_postauthor( $comment_id, $deprecated = null ) { 
    14521452
    14531453        $switched_locale = switch_to_locale( get_locale() );
    14541454
    1455         $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
    1456 
    14571455        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    14581456        // we want to reverse this for the plain text arena of emails.
    14591457        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    1460         $comment_content = wp_specialchars_decode( $comment->comment_content );
    1461 
    1462         switch ( $comment->comment_type ) {
    1463                 case 'trackback':
    1464                         /* translators: 1: Post title */
    1465                         $notify_message  = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
    1466                         /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
    1467                         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1468                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1469                         $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1470                         $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
    1471                         /* translators: 1: blog name, 2: post title */
    1472                         $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
    1473                         break;
    1474                 case 'pingback':
    1475                         /* translators: 1: Post title */
    1476                         $notify_message  = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
    1477                         /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
    1478                         $notify_message .= sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1479                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1480                         $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1481                         $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
    1482                         /* translators: 1: blog name, 2: post title */
    1483                         $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
    1484                         break;
    1485                 default: // Comments
    1486                         $notify_message  = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
    1487                         /* translators: 1: comment author, 2: author IP, 3: author domain */
    1488                         $notify_message .= sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1489                         $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1490                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1491                         $notify_message .= sprintf( __('Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1492                         $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
    1493                         /* translators: 1: blog name, 2: post title */
    1494                         $subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
    1495                         break;
    1496         }
     1458        $notify_message  = sprintf( __( 'New response to your post "%s"' ), get_the_title( $post ) ) . "\r\n";
     1459        $notify_message .= get_comment_notify_text( $comment );
     1460        $notify_message .= __( 'You can see all responses to this post here:' ) . "\r\n";
     1461        /* translators: 1: blog name, 2: post title */
     1462        $subject = sprintf( __('[%1$s] Response: "%2$s"'), $blogname, get_the_title( $post ) );
    14971463        $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
    14981464        $notify_message .= sprintf( __('Permalink: %s'), get_comment_link( $comment ) ) . "\r\n";
    14991465
    function wp_notify_moderator($comment_id) { 
    16181584        // we want to reverse this for the plain text arena of emails.
    16191585        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    16201586        $comment_content = wp_specialchars_decode( $comment->comment_content );
    1621 
    1622         switch ( $comment->comment_type ) {
    1623                 case 'trackback':
    1624                         /* translators: 1: Post title */
    1625                         $notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
    1626                         $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
    1627                         /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
    1628                         $notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1629                         /* translators: 1: Trackback/pingback/comment author URL */
    1630                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1631                         $notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
    1632                         break;
    1633                 case 'pingback':
    1634                         /* translators: 1: Post title */
    1635                         $notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
    1636                         $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
    1637                         /* translators: 1: Trackback/pingback website name, 2: website IP, 3: website hostname */
    1638                         $notify_message .= sprintf( __( 'Website: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1639                         /* translators: 1: Trackback/pingback/comment author URL */
    1640                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1641                         $notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
    1642                         break;
    1643                 default: // Comments
    1644                         /* translators: 1: Post title */
    1645                         $notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
    1646                         $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
    1647                         /* translators: 1: Comment author name, 2: comment author's IP, 3: comment author IP's hostname */
    1648                         $notify_message .= sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1649                         /* translators: 1: Comment author URL */
    1650                         $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1651                         /* translators: 1: Trackback/pingback/comment author URL */
    1652                         $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1653                         /* translators: 1: Comment text */
    1654                         $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1655                         break;
    1656         }
    1657 
     1587        $notify_message  = sprintf( __('A new response to the post "%s" is waiting for your approval'), get_the_title( $post ) ) . "\r\n";     
     1588        $notify_message .= get_comment_notify_text( $comment );
     1589        $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
    16581590        /* translators: Comment moderation. 1: Comment action URL */
    16591591        $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    16601592
    function wp_notify_moderator($comment_id) { 
    16701602        $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    16711603
    16721604        /* translators: Comment moderation. 1: Number of comments awaiting approval */
    1673         $notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:',
    1674                 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
     1605        $notify_message .= sprintf( _n('Currently %s response is waiting for approval. Please visit the moderation panel:',
     1606                'Currently %s responses are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n";
    16751607        $notify_message .= admin_url( "edit-comments.php?comment_status=moderated#wpbody-content" ) . "\r\n";
    16761608
    16771609        /* translators: Comment moderation notification email subject. 1: Site name, 2: Post title */