Make WordPress Core

Ticket #33735: 33735.7.diff

File 33735.7.diff, 12.0 KB (added by dshanske, 5 years ago)
  • src/wp-includes/comment-template.php

    diff --git a/src/tags b/src/tags
    new file mode 100644
    index 0000000000..96da1e59b9
    Binary files /dev/null and b/src/tags differ
    diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php
    index d08f5cf62e..2e3ca324dc 100644
    a b function comment_form( $args = array(), $post_id = null ) { 
    26502650         */
    26512651        do_action( 'comment_form_after' );
    26522652}
     2653
     2654
     2655/**
     2656 * Returns a summary of a comment to be used in email notifications.
     2657 *
     2658 * @access private
     2659 * @since 5.4
     2660 *
     2661 * @param int|WP_Comment $comment WP_Comment or the ID of the comment for which to retrieve the author.
     2662 * @return string Comment Text.
     2663 */
     2664function _wp_get_comment_notify_summary( $comment ) {
     2665        $comment = get_comment( $comment );
     2666        if ( empty( $comment ) || empty( $comment->comment_post_ID ) )
     2667                return false;
     2668
     2669        $comment_author_domain = '';
     2670        if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {       
     2671                $comment_author_domain = gethostbyaddr( $comment->comment_author_IP );
     2672        }
     2673
     2674        $type = get_comment_type( $comment );
     2675        $text = wp_specialchars_decode( get_comment_text( $comment ) );
     2676
     2677        if ( in_array( $type, array( 'pingback', 'trackback' ), true ) ) {
     2678                /* translators: 1: website name, 2: website IP, 3: website hostname */
     2679                $summary_text = sprintf( __('Website: %1$s (IP: %2$s, %3$s)'), get_comment_author( $comment ), get_comment_author_ip( $comment ), $comment_author_domain ) . "\r\n";
     2680                $summary_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment ) ) . "\r\n";
     2681                $summary_text .= sprintf( __( 'Excerpt: %s' ), "\r\n" . $text ) . "\r\n\r\n";
     2682        } else {
     2683                /* translators: 1: comment author, 2: author IP, 3: author domain */
     2684                $summary_text = sprintf( __( 'Author: %1$s (IP: %2$s, %3$s)' ), get_comment_author( $comment ), get_comment_author_ip ($comment ), $comment_author_domain ) . "\r\n";
     2685                $summary_text .= sprintf( __( 'E-mail: %s' ), get_comment_author_email( $comment ) ) . "\r\n";
     2686                $summary_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment ) ) . "\r\n";
     2687                $summary_text .= sprintf( __('Comment: %s' ), "\r\n" . $text ) . "\r\n\r\n";
     2688        }
     2689        /**
     2690         * Filter the summary of a comment used in email notifications.
     2691         *
     2692         * @since 5.4
     2693         *
     2694         * @param string $summary_text The comment summary.
     2695         * @param WP_Comment $comment The comment being notified
     2696         */
     2697        return apply_filters( 'comment_notify_summary', $summary_text, $comment );
     2698}
  • src/wp-includes/pluggable.php

    diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php
    index 47bdafd395..ec63a21e16 100644
    a b if ( ! function_exists( 'wp_notify_postauthor' ) ) : 
    15511551
    15521552                $switched_locale = switch_to_locale( get_locale() );
    15531553
    1554                 $comment_author_domain = '';
    1555                 if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
    1556                         $comment_author_domain = gethostbyaddr( $comment->comment_author_IP );
    1557                 }
    15581554
    15591555                // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    15601556                // we want to reverse this for the plain text arena of emails.
    15611557                $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1562                 $comment_content = wp_specialchars_decode( $comment->comment_content );
    1563 
    1564                 switch ( $comment->comment_type ) {
    1565                         case 'trackback':
    1566                                 /* translators: %s: Post title. */
    1567                                 $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
    1568                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1569                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1570                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1571                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1572                                 /* translators: %s: Comment text. */
    1573                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1574                                 $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
    1575                                 /* translators: Trackback notification email subject. 1: Site title, 2: Post title. */
    1576                                 $subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title );
    1577                                 break;
    1578                         case 'pingback':
    1579                                 /* translators: %s: Post title. */
    1580                                 $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
    1581                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1582                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1583                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1584                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1585                                 /* translators: %s: Comment text. */
    1586                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1587                                 $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
    1588                                 /* translators: Pingback notification email subject. 1: Site title, 2: Post title. */
    1589                                 $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title );
    1590                                 break;
    1591                         default: // Comments
    1592                                 /* translators: %s: Post title. */
    1593                                 $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
    1594                                 /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
    1595                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1596                                 /* translators: %s: Comment author email. */
    1597                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1598                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1599                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1600                                 /* translators: %s: Comment text. */
    1601                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1602                                 $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
    1603                                 /* translators: Comment notification email subject. 1: Site title, 2: Post title. */
    1604                                 $subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title );
    1605                                 break;
    1606                 }
     1558
     1559                /* translators: %s: Post title. */
     1560                $notify_message = sprintf( __( 'New response to your post "%s"' ), get_the_title( $post ) ) . "\r\n";
     1561                $notify_message .= _wp_get_comment_notify_summary( $comment );
     1562               
     1563                /* translators: 1: blog name, 2: post title */
     1564                $subject = sprintf( __( '[%1$s] Response: "%2$s"' ), $blogname, get_the_title( $post ) );
     1565               
     1566                $notify_message .= __( 'You can see all responses to this post here:' ) . "\r\n";
    16071567                $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n";
     1568               
    16081569                /* translators: %s: Comment URL. */
    16091570                $notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n";
    16101571
    if ( ! function_exists( 'wp_notify_moderator' ) ) : 
    17291690
    17301691                $switched_locale = switch_to_locale( get_locale() );
    17311692
    1732                 $comment_author_domain = '';
    1733                 if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
    1734                         $comment_author_domain = gethostbyaddr( $comment->comment_author_IP );
    1735                 }
    1736 
    17371693                $comments_waiting = $wpdb->get_var( "SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'" );
    17381694
    17391695                // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    17401696                // we want to reverse this for the plain text arena of emails.
    17411697                $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1742                 $comment_content = wp_specialchars_decode( $comment->comment_content );
    1743 
    1744                 switch ( $comment->comment_type ) {
    1745                         case 'trackback':
    1746                                 /* translators: %s: Post title. */
    1747                                 $notify_message  = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1748                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1749                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1750                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1751                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1752                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1753                                 $notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
    1754                                 break;
    1755                         case 'pingback':
    1756                                 /* translators: %s: Post title. */
    1757                                 $notify_message  = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1758                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1759                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1760                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1761                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1762                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1763                                 $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
    1764                                 break;
    1765                         default: // Comments
    1766                                 /* translators: %s: Post title. */
    1767                                 $notify_message  = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1768                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1769                                 /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
    1770                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1771                                 /* translators: %s: Comment author email. */
    1772                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1773                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1774                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1775                                 /* translators: %s: Comment text. */
    1776                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1777                                 break;
    1778                 }
     1698
     1699                $notify_message  = sprintf( __( 'A new response to the post "%s" is waiting for your approval' ), get_the_title( $post ) ) . "\r\n";
     1700
     1701                $notify_message .= _wp_get_comment_notify_summary( $comment );
    17791702
    17801703                /* translators: Comment moderation. %s: Comment action URL. */
    17811704                $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    if ( ! function_exists( 'wp_notify_moderator' ) ) : 
    17941717                $notify_message .= sprintf(
    17951718                        /* translators: Comment moderation. %s: Number of comments awaiting approval. */
    17961719                        _n(
    1797                                 'Currently %s comment is waiting for approval. Please visit the moderation panel:',
    1798                                 'Currently %s comments are waiting for approval. Please visit the moderation panel:',
     1720                                'Currently %s response is waiting for approval. Please visit the moderation panel:',
     1721                                'Currently %s responses are waiting for approval. Please visit the moderation panel:',
    17991722                                $comments_waiting
    18001723                        ),
    18011724                        number_format_i18n( $comments_waiting )
    if ( ! function_exists( 'wp_notify_moderator' ) ) : 
    18031726                $notify_message .= admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n";
    18041727
    18051728                /* translators: Comment moderation notification email subject. 1: Site title, 2: Post title. */
    1806                 $subject         = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title );
     1729                $subject         = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, get_the_title( $post ) );
    18071730                $message_headers = '';
    18081731
    18091732                /**