WordPress.org

Make WordPress Core

Ticket #33735: 33735.6.diff

File 33735.6.diff, 11.2 KB (added by dshanske, 3 years ago)
  • src/wp-includes/comment-template.php

     
    25362536         */
    25372537        do_action( 'comment_form_after' );
    25382538}
     2539
     2540
     2541/**
     2542 * Returns the text used to display comments in notifications.
     2543 *
     2544 * @since 5.0
     2545 *
     2546 * @param int|WP_Comment $comment WP_Comment or the ID of the comment for which to retrieve the author.
     2547 * @return string Comment Text.
     2548 */
     2549function get_comment_notify_text( $comment ) {
     2550        $comment = get_comment( $comment );
     2551        if ( empty( $comment ) || empty( $comment->comment_post_ID ) )
     2552                return false;
     2553        $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
     2554        $type = get_comment_type( $comment );
     2555        $text = wp_specialchars_decode( get_comment_text( $comment ) );
     2556
     2557        if ( in_array( $type, array( 'pingback', 'trackback' ), true ) ) {
     2558                /* translators: 1: website name, 2: website IP, 3: website hostname */
     2559                $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";
     2560                $notify_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment ) ) . "\r\n";
     2561                $notify_text .= sprintf( __( 'Excerpt: %s' ), "\r\n" . $text ) . "\r\n\r\n";
     2562        } else {
     2563                /* translators: 1: comment author, 2: author IP, 3: author domain */
     2564                $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";
     2565                $notify_text .= sprintf( __( 'E-mail: %s' ), get_comment_author_email( $comment ) ) . "\r\n";
     2566                $notify_text .= sprintf( __( 'URL: %s' ), get_comment_author_url( $comment ) ) . "\r\n";
     2567                $notify_text .= sprintf( __('Comment: %s' ), "\r\n" . $text ) . "\r\n\r\n";
     2568        }
     2569        /**
     2570         * Filter the comment text to be used for email notifications.
     2571         *
     2572         * This generates the display of a comment for notifications.
     2573         *
     2574         * @since 5.0
     2575         *
     2576         * @param string $notify_text The Comment Notify Text.
     2577         * @param WP_Comment $comment The comment being notified
     2578         */
     2579        return apply_filters( 'comment_notify_text', $notify_text, $comment );
     2580}
  • src/wp-includes/pluggable.php

     
    15171517
    15181518                $switched_locale = switch_to_locale( get_locale() );
    15191519
    1520                 $comment_author_domain = @gethostbyaddr( $comment->comment_author_IP );
    1521 
    15221520                // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    15231521                // we want to reverse this for the plain text arena of emails.
    15241522                $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1525                 $comment_content = wp_specialchars_decode( $comment->comment_content );
    15261523
    1527                 switch ( $comment->comment_type ) {
    1528                         case 'trackback':
    1529                                 /* translators: %s: post title */
    1530                                 $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
    1531                                 /* translators: 1: trackback/pingback website name, 2: website IP address, 3: website hostname */
    1532                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1533                                 /* translators: %s: trackback/pingback/comment author URL */
    1534                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1535                                 /* translators: %s: comment text */
    1536                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1537                                 $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
    1538                                 /* translators: 1: blog name, 2: post title */
    1539                                 $subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title );
    1540                                 break;
    1541                         case 'pingback':
    1542                                 /* translators: %s: post title */
    1543                                 $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
    1544                                 /* translators: 1: trackback/pingback website name, 2: website IP address, 3: website hostname */
    1545                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1546                                 /* translators: %s: trackback/pingback/comment author URL */
    1547                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1548                                 /* translators: %s: comment text */
    1549                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1550                                 $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
    1551                                 /* translators: 1: blog name, 2: post title */
    1552                                 $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title );
    1553                                 break;
    1554                         default: // Comments
    1555                                 /* translators: %s: post title */
    1556                                 $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
    1557                                 /* translators: 1: comment author, 2: comment author's IP address, 3: comment author's hostname */
    1558                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1559                                 /* translators: %s: comment author email */
    1560                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1561                                 /* translators: %s: trackback/pingback/comment author URL */
    1562                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1563                                 /* translators: %s: comment text */
    1564                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1565                                 $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
    1566                                 /* translators: 1: blog name, 2: post title */
    1567                                 $subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title );
    1568                                 break;
    1569                 }
     1524                $notify_message  = sprintf( __( 'New response to your post "%s"' ), get_the_title( $post ) ) . "\r\n";
     1525                $notify_message .= get_comment_notify_text( $comment );
     1526                $notify_message .= __( 'You can see all responses to this post here:' ) . "\r\n";
     1527
     1528                /* translators: 1: blog name, 2: post title */
     1529                $subject = sprintf( __('[%1$s] Response: "%2$s"'), $blogname, get_the_title( $post ) );
     1530
    15701531                $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n";
    15711532                $notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n";
    15721533
     
    16911652
    16921653                $switched_locale = switch_to_locale( get_locale() );
    16931654
    1694                 $comment_author_domain = @gethostbyaddr( $comment->comment_author_IP );
    16951655                $comments_waiting      = $wpdb->get_var( "SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'" );
    16961656
    16971657                // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    16981658                // we want to reverse this for the plain text arena of emails.
    16991659                $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1700                 $comment_content = wp_specialchars_decode( $comment->comment_content );
    17011660
    1702                 switch ( $comment->comment_type ) {
    1703                         case 'trackback':
    1704                                 /* translators: %s: post title */
    1705                                 $notify_message  = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1706                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1707                                 /* translators: 1: trackback/pingback website name, 2: website IP address, 3: website hostname */
    1708                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1709                                 /* translators: %s: trackback/pingback/comment author URL */
    1710                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1711                                 $notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
    1712                                 break;
    1713                         case 'pingback':
    1714                                 /* translators: %s: post title */
    1715                                 $notify_message  = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1716                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1717                                 /* translators: 1: trackback/pingback website name, 2: website IP address, 3: website hostname */
    1718                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1719                                 /* translators: %s: trackback/pingback/comment author URL */
    1720                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1721                                 $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
    1722                                 break;
    1723                         default: // Comments
    1724                                 /* translators: %s: post title */
    1725                                 $notify_message  = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1726                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1727                                 /* translators: 1: comment author name, 2: comment author's IP address, 3: comment author's hostname */
    1728                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1729                                 /* translators: %s: comment author email */
    1730                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1731                                 /* translators: %s: trackback/pingback/comment author URL */
    1732                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1733                                 /* translators: %s: comment text */
    1734                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1735                                 break;
    1736                 }
     1661                $notify_message  = sprintf( __('A new response to the post "%s" is waiting for your approval'), get_the_title( $post ) ) . "\r\n";     
     1662                $notify_message .= get_comment_notify_text( $comment );
     1663                $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n";
     1664
    17371665
    17381666                /* translators: Comment moderation. %s: Comment action URL */
    17391667                $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     
    17521680                /* translators: Comment moderation. %s: Number of comments awaiting approval */
    17531681                $notify_message .= sprintf(
    17541682                        _n(
    1755                                 'Currently %s comment is waiting for approval. Please visit the moderation panel:',
    1756                                 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting
     1683                                'Currently %s response is waiting for approval. Please visit the moderation panel:',
     1684                                'Currently %s responses are waiting for approval. Please visit the moderation panel:', $comments_waiting
    17571685                        ), number_format_i18n( $comments_waiting )
    17581686                ) . "\r\n";
    17591687                $notify_message .= admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n";
    17601688
    17611689                /* translators: Comment moderation notification email subject. 1: Site name, 2: Post title */
    1762                 $subject         = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title );
     1690                $subject         = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, get_the_title( $post ) );
    17631691                $message_headers = '';
    17641692
    17651693                /**