WordPress.org

Make WordPress Core

Ticket #33209: 33209-3.diff

File 33209-3.diff, 5.9 KB (added by BjornW, 2 years ago)

Updated patch, using apply_deprecated_filters to deprecate password token

  • wp-admin/includes/schema.php

     
    11881188                $site_admins = get_site_option( 'site_admins' );
    11891189        }
    11901190
    1191         /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
     1191        /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD, RESETLINK: those are placeholders. */
    11921192        $welcome_email = __(
    11931193                'Howdy USERNAME,
    11941194
     
    11981198You can log in to the administrator account with the following information:
    11991199
    12001200Username: USERNAME
    1201 Password: PASSWORD
     1201To set your password, visit the following address: RESETLINK
    12021202Log in here: BLOG_URLwp-login.php
    12031203
    12041204We hope you enjoy your new site. Thanks!
  • wp-includes/ms-default-filters.php

     
    113113
    114114// Whitelist multisite domains for HTTP requests
    115115add_filter( 'http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2 );
     116
     117// Replace PASSWORD token in welcome_email and welcome_user_email for $password
     118add_filter( 'wpmu_replace_password_token', 'wpmu_replace_password_token', 10, 2 );
     119// Replace RESETLINK token in welcome_email and welcome_user_email for password reset url
     120add_filter( 'wpmu_replace_resetlink_token', 'wpmu_replace_resetlink_token', 10, 2);
  • wp-includes/ms-functions.php

     
    15411541
    15421542        $welcome_email = get_site_option( 'welcome_email' );
    15431543        if ( $welcome_email == false ) {
    1544                 /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
     1544                /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD, RESETLINK: those are placeholders. */
    15451545                $welcome_email = __(
    15461546                        'Howdy USERNAME,
    15471547
     
    15511551You can log in to the administrator account with the following information:
    15521552
    15531553Username: USERNAME
    1554 Password: PASSWORD
     1554To set your password, visit the following address: RESETLINK
     1555
    15551556Log in here: BLOG_URLwp-login.php
    15561557
    15571558We hope you enjoy your new site. Thanks!
     
    15661567        $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
    15671568        $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
    15681569        $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
    1569         $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
    1570 
    1571         /**
     1570        $welcome_email = apply_filters_deprecated( 'wpmu_replace_password_token', array($password, $welcome_email), '5.0', null, __("The PASSWORD token in 'Welcome Email' and 'Welcome User Email' New Site Settings (Network Settings) has been deprecated and will be removed in the future. Instead use RESETLINK as token") );
     1571        $welcome_email = apply_filters( 'wpmu_replace_resetlink_token', $user, $welcome_email );
     1572 
     1573  /**
    15721574         * Filters the content of the welcome email after site activation.
    15731575         *
    15741576         * Content should be formatted for transmission via wp_mail().
     
    16171619        return true;
    16181620}
    16191621
     1622/**
     1623 * Replace RESETLINK token with reset password url.
     1624 *
     1625 * Filter {@see 'wpmu_replace_resetlink_token'}
     1626 *
     1627 * @since 5.0.0
     1628 *
     1629 * @param $user User object
     1630 * @return string password reset link
     1631 */
     1632function wpmu_replace_resetlink_token( $user, $text ) {
     1633  $user_login       = $user->user_login;
     1634  $set_password_key = get_password_reset_key( $user );
     1635  $reset_link       = network_site_url( "wp-login.php?action=rp&key=$set_password_key&login=" . rawurlencode( $user_login ), 'login' );
     1636        return str_replace( 'RESETLINK', $reset_link, $text );
     1637}
     1638
     1639/**
     1640 * Case-sensitive replace of PASSWORD token from $text with $password.
     1641 *
     1642 * Filter {@see 'wpmu_replace_password_token'}
     1643 *
     1644 * @since 5.0.0.
     1645 *
     1646 * @param string $text
     1647 * @param string $password
     1648 * @return string with PASSWORD replaced by $password
     1649 *
     1650 */
     1651function wpmu_replace_password_token( $password, $text ) {
     1652        return str_replace( 'PASSWORD', $password, $text );
     1653}
     1654
     1655
    16201656/**
    16211657 * Notify a user that their account activation has been successful.
    16221658 *
     
    16711707        $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
    16721708        $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
    16731709        $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
    1674         $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
     1710        $welcome_email = apply_filters_deprecated( 'wpmu_replace_password_token', array($password, $welcome_email), '5.0', null, __("The PASSWORD token in 'Welcome Email' and 'Welcome User Email' New Site Settings (Network Settings) has been deprecated and will be removed in the future. Instead use RESETLINK as token") );
    16751711        $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
    1676 
    1677         $admin_email = get_site_option( 'admin_email' );
     1712        $welcome_email = apply_filters( 'wpmu_replace_resetlink_token', $user, $welcome_email );
     1713 
     1714  $admin_email = get_site_option( 'admin_email' );
    16781715
    16791716        if ( $admin_email == '' ) {
    16801717                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     
    22722309        if ( ! $text ) {
    22732310                remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
    22742311
    2275                 /* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
     2312                /* translators: Do not translate USERNAME, PASSWORD, RESETLINK, LOGINLINK, SITE_NAME: those are placeholders. */
    22762313                $text = __(
    22772314                        'Howdy USERNAME,
    22782315
     
    22802317
    22812318You can log in with the following information:
    22822319Username: USERNAME
    2283 Password: PASSWORD
     2320Set your password: RESETLINK
    22842321LOGINLINK
    22852322
    22862323Thanks!