Make WordPress Core


Ignore:
Timestamp:
09/30/2024 03:50:19 PM (23 months ago)
Author:
swissspidy
Message:

I18N: Switch locale to admin locale when sending admin notifications.

If sending an email to the site administrator's email address, look up if a user with the same email exists and switch to that user's locale.
If not, falls back to the site locale as usual.

Props benniledl, swissspidy, mukesh27.
Fixes #61518.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r59009 r59128  
    17201720                }
    17211721
    1722                 $switched_locale = switch_to_locale( get_locale() );
    1723 
    17241722                $comment_author_domain = '';
    17251723                if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
     
    17331731                $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    17341732                $comment_content = wp_specialchars_decode( $comment->comment_content );
    1735 
    1736                 switch ( $comment->comment_type ) {
    1737                         case 'trackback':
    1738                                 /* translators: %s: Post title. */
    1739                                 $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
    1740                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1741                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1742                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1743                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1744                                 /* translators: %s: Comment text. */
    1745                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1746                                 $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
    1747                                 /* translators: Trackback notification email subject. 1: Site title, 2: Post title. */
    1748                                 $subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title );
    1749                                 break;
    1750 
    1751                         case 'pingback':
    1752                                 /* translators: %s: Post title. */
    1753                                 $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
    1754                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1755                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1756                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1757                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1758                                 /* translators: %s: Comment text. */
    1759                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1760                                 $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
    1761                                 /* translators: Pingback notification email subject. 1: Site title, 2: Post title. */
    1762                                 $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title );
    1763                                 break;
    1764 
    1765                         default: // Comments.
    1766                                 /* translators: %s: Post title. */
    1767                                 $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
    1768                                 /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
    1769                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1770                                 /* translators: %s: Comment author email. */
    1771                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1772                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1773                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1774 
    1775                                 if ( $comment->comment_parent && user_can( $post->post_author, 'edit_comment', $comment->comment_parent ) ) {
    1776                                         /* translators: Comment moderation. %s: Parent comment edit URL. */
    1777                                         $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n";
    1778                                 }
    1779 
    1780                                 /* translators: %s: Comment text. */
    1781                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1782                                 $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
    1783                                 /* translators: Comment notification email subject. 1: Site title, 2: Post title. */
    1784                                 $subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title );
    1785                                 break;
    1786                 }
    1787 
    1788                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n";
    1789                 /* translators: %s: Comment URL. */
    1790                 $notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n";
    1791 
    1792                 if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) {
    1793                         if ( EMPTY_TRASH_DAYS ) {
    1794                                 /* translators: Comment moderation. %s: Comment action URL. */
    1795                                 $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
    1796                         } else {
    1797                                 /* translators: Comment moderation. %s: Comment action URL. */
    1798                                 $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
    1799                         }
    1800                         /* translators: Comment moderation. %s: Comment action URL. */
    1801                         $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
    1802                 }
    18031733
    18041734                $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', wp_parse_url( network_home_url(), PHP_URL_HOST ) );
     
    18241754
    18251755                /**
    1826                  * Filters the comment notification email text.
    1827                  *
    1828                  * @since 1.5.2
    1829                  *
    1830                  * @param string $notify_message The comment notification email text.
    1831                  * @param string $comment_id     Comment ID as a numeric string.
    1832                  */
    1833                 $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID );
    1834 
    1835                 /**
    1836                  * Filters the comment notification email subject.
    1837                  *
    1838                  * @since 1.5.2
    1839                  *
    1840                  * @param string $subject    The comment notification email subject.
    1841                  * @param string $comment_id Comment ID as a numeric string.
    1842                  */
    1843                 $subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID );
    1844 
    1845                 /**
    18461756                 * Filters the comment notification email headers.
    18471757                 *
     
    18541764
    18551765                foreach ( $emails as $email ) {
     1766                        $user = get_user_by( 'email', $email );
     1767
     1768                        if ( $user ) {
     1769                                $switched_locale = switch_to_user_locale( $user->ID );
     1770                        } else {
     1771                                $switched_locale = switch_to_locale( get_locale() );
     1772                        }
     1773
     1774                        switch ( $comment->comment_type ) {
     1775                                case 'trackback':
     1776                                        /* translators: %s: Post title. */
     1777                                        $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
     1778                                        /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
     1779                                        $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1780                                        /* translators: %s: Trackback/pingback/comment author URL. */
     1781                                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
     1782                                        /* translators: %s: Comment text. */
     1783                                        $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
     1784                                        $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
     1785                                        /* translators: Trackback notification email subject. 1: Site title, 2: Post title. */
     1786                                        $subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title );
     1787                                        break;
     1788
     1789                                case 'pingback':
     1790                                        /* translators: %s: Post title. */
     1791                                        $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
     1792                                        /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
     1793                                        $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1794                                        /* translators: %s: Trackback/pingback/comment author URL. */
     1795                                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
     1796                                        /* translators: %s: Comment text. */
     1797                                        $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
     1798                                        $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
     1799                                        /* translators: Pingback notification email subject. 1: Site title, 2: Post title. */
     1800                                        $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title );
     1801                                        break;
     1802
     1803                                default: // Comments.
     1804                                        /* translators: %s: Post title. */
     1805                                        $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
     1806                                        /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
     1807                                        $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1808                                        /* translators: %s: Comment author email. */
     1809                                        $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
     1810                                        /* translators: %s: Trackback/pingback/comment author URL. */
     1811                                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
     1812
     1813                                        if ( $comment->comment_parent && user_can( $post->post_author, 'edit_comment', $comment->comment_parent ) ) {
     1814                                                /* translators: Comment moderation. %s: Parent comment edit URL. */
     1815                                                $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n";
     1816                                        }
     1817
     1818                                        /* translators: %s: Comment text. */
     1819                                        $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
     1820                                        $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
     1821                                        /* translators: Comment notification email subject. 1: Site title, 2: Post title. */
     1822                                        $subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title );
     1823                                        break;
     1824                        }
     1825
     1826                        $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n";
     1827                        /* translators: %s: Comment URL. */
     1828                        $notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n";
     1829
     1830                        if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) {
     1831                                if ( EMPTY_TRASH_DAYS ) {
     1832                                        /* translators: Comment moderation. %s: Comment action URL. */
     1833                                        $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
     1834                                } else {
     1835                                        /* translators: Comment moderation. %s: Comment action URL. */
     1836                                        $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
     1837                                }
     1838                                /* translators: Comment moderation. %s: Comment action URL. */
     1839                                $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
     1840                        }
     1841
     1842                        /**
     1843                         * Filters the comment notification email text.
     1844                         *
     1845                         * @since 1.5.2
     1846                         *
     1847                         * @param string $notify_message The comment notification email text.
     1848                         * @param string $comment_id     Comment ID as a numeric string.
     1849                         */
     1850                        $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID );
     1851
     1852                        /**
     1853                         * Filters the comment notification email subject.
     1854                         *
     1855                         * @since 1.5.2
     1856                         *
     1857                         * @param string $subject    The comment notification email subject.
     1858                         * @param string $comment_id Comment ID as a numeric string.
     1859                         */
     1860                        $subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID );
     1861
    18561862                        wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
    1857                 }
    1858 
    1859                 if ( $switched_locale ) {
    1860                         restore_previous_locale();
     1863
     1864                        if ( $switched_locale ) {
     1865                                restore_previous_locale();
     1866                        }
    18611867                }
    18621868
     
    19091915                }
    19101916
    1911                 $switched_locale = switch_to_locale( get_locale() );
    1912 
    19131917                $comment_author_domain = '';
    19141918                if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
     
    19251929                $comment_content = wp_specialchars_decode( $comment->comment_content );
    19261930
    1927                 switch ( $comment->comment_type ) {
    1928                         case 'trackback':
    1929                                 /* translators: %s: Post title. */
    1930                                 $notify_message  = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1931                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1932                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1933                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1934                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1935                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1936                                 $notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
    1937                                 break;
    1938 
    1939                         case 'pingback':
    1940                                 /* translators: %s: Post title. */
    1941                                 $notify_message  = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1942                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1943                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1944                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1945                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1946                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1947                                 $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
    1948                                 break;
    1949 
    1950                         default: // Comments.
    1951                                 /* translators: %s: Post title. */
    1952                                 $notify_message  = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1953                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1954                                 /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
    1955                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1956                                 /* translators: %s: Comment author email. */
    1957                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1958                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1959                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1960 
    1961                                 if ( $comment->comment_parent ) {
    1962                                         /* translators: Comment moderation. %s: Parent comment edit URL. */
    1963                                         $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n";
    1964                                 }
    1965 
    1966                                 /* translators: %s: Comment text. */
    1967                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1968                                 break;
    1969                 }
    1970 
    1971                 /* translators: Comment moderation. %s: Comment action URL. */
    1972                 $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    1973 
    1974                 if ( EMPTY_TRASH_DAYS ) {
    1975                         /* translators: Comment moderation. %s: Comment action URL. */
    1976                         $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    1977                 } else {
    1978                         /* translators: Comment moderation. %s: Comment action URL. */
    1979                         $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    1980                 }
    1981 
    1982                 /* translators: Comment moderation. %s: Comment action URL. */
    1983                 $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    1984 
    1985                 $notify_message .= sprintf(
    1986                         /* translators: Comment moderation. %s: Number of comments awaiting approval. */
    1987                         _n(
    1988                                 'Currently %s comment is waiting for approval. Please visit the moderation panel:',
    1989                                 'Currently %s comments are waiting for approval. Please visit the moderation panel:',
    1990                                 $comments_waiting
    1991                         ),
    1992                         number_format_i18n( $comments_waiting )
    1993                 ) . "\r\n";
    1994                 $notify_message .= admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n";
    1995 
    1996                 /* translators: Comment moderation notification email subject. 1: Site title, 2: Post title. */
    1997                 $subject         = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title );
    19981931                $message_headers = '';
    19991932
     
    20091942
    20101943                /**
    2011                  * Filters the comment moderation email text.
    2012                  *
    2013                  * @since 1.5.2
    2014                  *
    2015                  * @param string $notify_message Text of the comment moderation email.
    2016                  * @param int    $comment_id     Comment ID.
    2017                  */
    2018                 $notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id );
    2019 
    2020                 /**
    2021                  * Filters the comment moderation email subject.
    2022                  *
    2023                  * @since 1.5.2
    2024                  *
    2025                  * @param string $subject    Subject of the comment moderation email.
    2026                  * @param int    $comment_id Comment ID.
    2027                  */
    2028                 $subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id );
    2029 
    2030                 /**
    20311944                 * Filters the comment moderation email headers.
    20321945                 *
     
    20391952
    20401953                foreach ( $emails as $email ) {
     1954                        $user = get_user_by( 'email', $email );
     1955
     1956                        if ( $user ) {
     1957                                $switched_locale = switch_to_user_locale( $user->ID );
     1958                        } else {
     1959                                $switched_locale = switch_to_locale( get_locale() );
     1960                        }
     1961
     1962                        switch ( $comment->comment_type ) {
     1963                                case 'trackback':
     1964                                        /* translators: %s: Post title. */
     1965                                        $notify_message  = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
     1966                                        $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
     1967                                        /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
     1968                                        $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1969                                        /* translators: %s: Trackback/pingback/comment author URL. */
     1970                                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
     1971                                        $notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
     1972                                        break;
     1973
     1974                                case 'pingback':
     1975                                        /* translators: %s: Post title. */
     1976                                        $notify_message  = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
     1977                                        $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
     1978                                        /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
     1979                                        $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1980                                        /* translators: %s: Trackback/pingback/comment author URL. */
     1981                                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
     1982                                        $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
     1983                                        break;
     1984
     1985                                default: // Comments.
     1986                                        /* translators: %s: Post title. */
     1987                                        $notify_message  = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
     1988                                        $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
     1989                                        /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
     1990                                        $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
     1991                                        /* translators: %s: Comment author email. */
     1992                                        $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
     1993                                        /* translators: %s: Trackback/pingback/comment author URL. */
     1994                                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
     1995
     1996                                        if ( $comment->comment_parent ) {
     1997                                                /* translators: Comment moderation. %s: Parent comment edit URL. */
     1998                                                $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n";
     1999                                        }
     2000
     2001                                        /* translators: %s: Comment text. */
     2002                                        $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
     2003                                        break;
     2004                        }
     2005
     2006                        /* translators: Comment moderation. %s: Comment action URL. */
     2007                        $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     2008
     2009                        if ( EMPTY_TRASH_DAYS ) {
     2010                                /* translators: Comment moderation. %s: Comment action URL. */
     2011                                $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     2012                        } else {
     2013                                /* translators: Comment moderation. %s: Comment action URL. */
     2014                                $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     2015                        }
     2016
     2017                        /* translators: Comment moderation. %s: Comment action URL. */
     2018                        $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     2019
     2020                        $notify_message .= sprintf(
     2021                                /* translators: Comment moderation. %s: Number of comments awaiting approval. */
     2022                                _n(
     2023                                        'Currently %s comment is waiting for approval. Please visit the moderation panel:',
     2024                                        'Currently %s comments are waiting for approval. Please visit the moderation panel:',
     2025                                        $comments_waiting
     2026                                ),
     2027                                number_format_i18n( $comments_waiting )
     2028                        ) . "\r\n";
     2029                        $notify_message .= admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n";
     2030
     2031                        /* translators: Comment moderation notification email subject. 1: Site title, 2: Post title. */
     2032                        $subject = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title );
     2033
     2034                        /**
     2035                         * Filters the comment moderation email text.
     2036                         *
     2037                         * @since 1.5.2
     2038                         *
     2039                         * @param string $notify_message Text of the comment moderation email.
     2040                         * @param int    $comment_id     Comment ID.
     2041                         */
     2042                        $notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id );
     2043
     2044                        /**
     2045                         * Filters the comment moderation email subject.
     2046                         *
     2047                         * @since 1.5.2
     2048                         *
     2049                         * @param string $subject    Subject of the comment moderation email.
     2050                         * @param int    $comment_id Comment ID.
     2051                         */
     2052                        $subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id );
     2053
    20412054                        wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
    2042                 }
    2043 
    2044                 if ( $switched_locale ) {
    2045                         restore_previous_locale();
     2055
     2056                        if ( $switched_locale ) {
     2057                                restore_previous_locale();
     2058                        }
    20462059                }
    20472060
     
    20642077                 */
    20652078                if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
     2079
     2080                        $admin_user = get_user_by( 'email', get_option( 'admin_email' ) );
     2081
     2082                        if ( $admin_user ) {
     2083                                $switched_locale = switch_to_user_locale( $admin_user->ID );
     2084                        } else {
     2085                                $switched_locale = switch_to_locale( get_locale() );
     2086                        }
     2087
    20662088                        /* translators: %s: User name. */
    20672089                        $message = sprintf( __( 'Password changed for user: %s' ), $user->user_login ) . "\r\n";
     
    21042126                                $wp_password_change_notification_email['headers']
    21052127                        );
     2128
     2129                        if ( $switched_locale ) {
     2130                                restore_previous_locale();
     2131                        }
    21062132                }
    21072133        }
     
    21532179
    21542180                if ( 'user' !== $notify && true === $send_notification_to_admin ) {
    2155                         $switched_locale = switch_to_locale( get_locale() );
     2181
     2182                        $admin_user = get_user_by( 'email', get_option( 'admin_email' ) );
     2183
     2184                        if ( $admin_user ) {
     2185                                $switched_locale = switch_to_user_locale( $admin_user->ID );
     2186                        } else {
     2187                                $switched_locale = switch_to_locale( get_locale() );
     2188                        }
    21562189
    21572190                        /* translators: %s: Site title. */
Note: See TracChangeset for help on using the changeset viewer.