~canonical-sysadmins/wordpress/5.0

« back to all changes in this revision

Viewing changes to wp-includes/pluggable.php

  • Committer: Barry Price
  • Date: 2017-11-17 04:49:02 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: barry.price@canonical.com-20171117044902-5frux4ycbq6g9fyf
Merge WP4.9 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
472
472
         *
473
473
         * @since 2.2.0
474
474
         *
475
 
         * @param PHPMailer &$phpmailer The PHPMailer instance, passed by reference.
 
475
         * @param PHPMailer $phpmailer The PHPMailer instance (passed by reference).
476
476
         */
477
477
        do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
478
478
 
694
694
 * Generate authentication cookie contents.
695
695
 *
696
696
 * @since 2.5.0
 
697
 * @since 4.0.0 The `$token` parameter was added.
697
698
 *
698
699
 * @param int    $user_id    User ID
699
700
 * @param int    $expiration The time the cookie expires as a UNIX timestamp.
726
727
         * Filters the authentication cookie.
727
728
         *
728
729
         * @since 2.5.0
 
730
         * @since 4.0.0 The `$token` parameter was added.
729
731
         *
730
732
         * @param string $cookie     Authentication cookie.
731
733
         * @param int    $user_id    User ID.
874
876
         * Fires immediately before the authentication cookie is set.
875
877
         *
876
878
         * @since 2.5.0
 
879
         * @since 4.9.0 The `$token` parameter was added.
877
880
         *
878
881
         * @param string $auth_cookie Authentication cookie.
879
882
         * @param int    $expire      The time the login grace period expires as a UNIX timestamp.
882
885
         *                            Default is 14 days from now.
883
886
         * @param int    $user_id     User ID.
884
887
         * @param string $scheme      Authentication scheme. Values include 'auth', 'secure_auth', or 'logged_in'.
 
888
         * @param string $token       User's session token to use for this cookie.
885
889
         */
886
 
        do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme );
 
890
        do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme, $token );
887
891
 
888
892
        /**
889
893
         * Fires immediately before the logged-in authentication cookie is set.
890
894
         *
891
895
         * @since 2.6.0
 
896
         * @since 4.9.0 The `$token` parameter was added.
892
897
         *
893
898
         * @param string $logged_in_cookie The logged-in cookie.
894
899
         * @param int    $expire           The time the login grace period expires as a UNIX timestamp.
897
902
         *                                 Default is 14 days from now.
898
903
         * @param int    $user_id          User ID.
899
904
         * @param string $scheme           Authentication scheme. Default 'logged_in'.
 
905
         * @param string $token            User's session token to use for this cookie.
900
906
         */
901
 
        do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
 
907
        do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in', $token );
902
908
 
903
909
        /**
904
910
         * Allows preventing auth cookies from actually being sent to the client.
1463
1469
                case 'trackback':
1464
1470
                        /* translators: 1: Post title */
1465
1471
                        $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";
 
1472
                        /* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */
 
1473
                        $notify_message .= sprintf( __('Website: %1$s (IP address: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1468
1474
                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1469
1475
                        $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
1470
1476
                        $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
1474
1480
                case 'pingback':
1475
1481
                        /* translators: 1: Post title */
1476
1482
                        $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";
 
1483
                        /* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */
 
1484
                        $notify_message .= sprintf( __('Website: %1$s (IP address: %2$s, %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1479
1485
                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1480
1486
                        $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
1481
1487
                        $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
1484
1490
                        break;
1485
1491
                default: // Comments
1486
1492
                        $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";
 
1493
                        /* translators: 1: comment author, 2: comment author's IP address, 3: comment author's hostname */
 
1494
                        $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1489
1495
                        $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
1490
1496
                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1491
1497
                        $notify_message .= sprintf( __('Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
1624
1630
                        /* translators: 1: Post title */
1625
1631
                        $notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
1626
1632
                        $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";
 
1633
                        /* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */
 
1634
                        $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1629
1635
                        /* translators: 1: Trackback/pingback/comment author URL */
1630
1636
                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1631
1637
                        $notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
1634
1640
                        /* translators: 1: Post title */
1635
1641
                        $notify_message  = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
1636
1642
                        $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";
 
1643
                        /* translators: 1: Trackback/pingback website name, 2: website IP address, 3: website hostname */
 
1644
                        $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1639
1645
                        /* translators: 1: Trackback/pingback/comment author URL */
1640
1646
                        $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
1641
1647
                        $notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment_content . "\r\n\r\n";
1644
1650
                        /* translators: 1: Post title */
1645
1651
                        $notify_message  = sprintf( __('A new comment on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n";
1646
1652
                        $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";
 
1653
                        /* translators: 1: Comment author name, 2: comment author's IP address, 3: comment author's hostname */
 
1654
                        $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
1649
1655
                        /* translators: 1: Comment author URL */
1650
1656
                        $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
1651
1657
                        /* translators: 1: Trackback/pingback/comment author URL */
1747
1753
                // The blogname option is escaped with esc_html on the way into the database in sanitize_option
1748
1754
                // we want to reverse this for the plain text arena of emails.
1749
1755
                $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
1750
 
                /* translators: %s: site title */
1751
 
                wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] Password Changed' ), $blogname ), $message );
 
1756
 
 
1757
                $wp_password_change_notification_email = array(
 
1758
                        'to'      => get_option( 'admin_email' ),
 
1759
                        /* translators: Password change notification email subject. %s: Site title */
 
1760
                        'subject' => __( '[%s] Password Changed' ),
 
1761
                        'message' => $message,
 
1762
                        'headers' => '',
 
1763
                );
 
1764
 
 
1765
                /**
 
1766
                 * Filters the contents of the password change notification email sent to the site admin.
 
1767
                 *
 
1768
                 * @since 4.9.0
 
1769
                 *
 
1770
                 * @param array   $wp_password_change_notification_email {
 
1771
                 *     Used to build wp_mail().
 
1772
                 *
 
1773
                 *     @type string $to      The intended recipient - site admin email address.
 
1774
                 *     @type string $subject The subject of the email.
 
1775
                 *     @type string $message The body of the email.
 
1776
                 *     @type string $headers The headers of the email.
 
1777
                 * }
 
1778
                 * @param WP_User $user     User object for user whose password was changed.
 
1779
                 * @param string  $blogname The site title.
 
1780
                 */
 
1781
                $wp_password_change_notification_email = apply_filters( 'wp_password_change_notification_email', $wp_password_change_notification_email, $user, $blogname );
 
1782
 
 
1783
                wp_mail(
 
1784
                        $wp_password_change_notification_email['to'],
 
1785
                        wp_specialchars_decode( sprintf( $wp_password_change_notification_email['subject'], $blogname ) ),
 
1786
                        $wp_password_change_notification_email['message'],
 
1787
                        $wp_password_change_notification_email['headers']
 
1788
                );
1752
1789
        }
1753
1790
}
1754
1791
endif;
1786
1823
 
1787
1824
        if ( 'user' !== $notify ) {
1788
1825
                $switched_locale = switch_to_locale( get_locale() );
 
1826
 
 
1827
                /* translators: %s: site title */
1789
1828
                $message  = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
 
1829
                /* translators: %s: user login */
1790
1830
                $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
 
1831
                /* translators: %s: user email address */
1791
1832
                $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
1792
1833
 
1793
 
                @wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message );
 
1834
                $wp_new_user_notification_email_admin = array(
 
1835
                        'to'      => get_option( 'admin_email' ),
 
1836
                        /* translators: Password change notification email subject. %s: Site title */
 
1837
                        'subject' => __( '[%s] New User Registration' ),
 
1838
                        'message' => $message,
 
1839
                        'headers' => '',
 
1840
                );
 
1841
 
 
1842
                /**
 
1843
                 * Filters the contents of the new user notification email sent to the site admin.
 
1844
                 *
 
1845
                 * @since 4.9.0
 
1846
                 *
 
1847
                 * @param array   $wp_new_user_notification_email {
 
1848
                 *     Used to build wp_mail().
 
1849
                 *
 
1850
                 *     @type string $to      The intended recipient - site admin email address.
 
1851
                 *     @type string $subject The subject of the email.
 
1852
                 *     @type string $message The body of the email.
 
1853
                 *     @type string $headers The headers of the email.
 
1854
                 * }
 
1855
                 * @param WP_User $user     User object for new user.
 
1856
                 * @param string  $blogname The site title.
 
1857
                 */
 
1858
                $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname );
 
1859
 
 
1860
                @wp_mail(
 
1861
                        $wp_new_user_notification_email_admin['to'],
 
1862
                        wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ),
 
1863
                        $wp_new_user_notification_email_admin['message'],
 
1864
                        $wp_new_user_notification_email_admin['headers']
 
1865
                );
1794
1866
 
1795
1867
                if ( $switched_locale ) {
1796
1868
                        restore_previous_locale();
1818
1890
 
1819
1891
        $switched_locale = switch_to_locale( get_user_locale( $user ) );
1820
1892
 
 
1893
        /* translators: %s: user login */
1821
1894
        $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
1822
1895
        $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
1823
1896
        $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
1824
1897
 
1825
1898
        $message .= wp_login_url() . "\r\n";
1826
1899
 
1827
 
        wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
 
1900
        $wp_new_user_notification_email = array(
 
1901
                'to'      => $user->user_email,
 
1902
                /* translators: Password change notification email subject. %s: Site title */
 
1903
                'subject' => __( '[%s] Your username and password info' ),
 
1904
                'message' => $message,
 
1905
                'headers' => '',
 
1906
        );
 
1907
 
 
1908
        /**
 
1909
         * Filters the contents of the new user notification email sent to the new user.
 
1910
         *
 
1911
         * @since 4.9.0
 
1912
         *
 
1913
         * @param array   $wp_new_user_notification_email {
 
1914
         *     Used to build wp_mail().
 
1915
         *
 
1916
         *     @type string $to      The intended recipient - New user email address.
 
1917
         *     @type string $subject The subject of the email.
 
1918
         *     @type string $message The body of the email.
 
1919
         *     @type string $headers The headers of the email.
 
1920
         * }
 
1921
         * @param WP_User $user     User object for new user.
 
1922
         * @param string  $blogname The site title.
 
1923
         */
 
1924
        $wp_new_user_notification_email = apply_filters( 'wp_new_user_notification_email', $wp_new_user_notification_email, $user, $blogname );
 
1925
 
 
1926
        wp_mail(
 
1927
                $wp_new_user_notification_email['to'],
 
1928
                wp_specialchars_decode( sprintf( $wp_new_user_notification_email['subject'], $blogname ) ),
 
1929
                $wp_new_user_notification_email['message'],
 
1930
                $wp_new_user_notification_email['headers']
 
1931
        );
1828
1932
 
1829
1933
        if ( $switched_locale ) {
1830
1934
                restore_previous_locale();
2429
2533
                "<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>",
2430
2534
                esc_attr( $args['alt'] ),
2431
2535
                esc_url( $url ),
2432
 
                esc_attr( "$url2x 2x" ),
 
2536
                esc_url( $url2x ) . ' 2x',
2433
2537
                esc_attr( join( ' ', $class ) ),
2434
2538
                (int) $args['height'],
2435
2539
                (int) $args['width'],