Make WordPress Core

Ticket #11210: 11210.patch

File 11210.patch, 5.9 KB (added by jfarthing84, 9 years ago)

Split wp_new_user_notification into two functions.

  • wp-includes/user.php

     
    24462446}
    24472447
    24482448/**
     2449 * Email the site admin a notification of a newly-registered user.
     2450 *
     2451 * @since unknown
     2452 *
     2453 * @param int $user_id User ID.
     2454 */
     2455function wp_new_user_registration_admin_notification( $user_id ) {
     2456
     2457        /**
     2458         * Filters whether to send the new user registration admin notification or not.
     2459         *
     2460         * @since unknown
     2461         *
     2462         * @param bool $should_send Whether to send the notification or not.
     2463         * @param int  $user_id     User ID.
     2464         */
     2465        $should_send = apply_filters( 'send_new_user_registration_admin_notification', true, $user_id );
     2466        if ( ! $should_send )
     2467                return;
     2468
     2469        $user = get_userdata( $user_id );
     2470
     2471        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
     2472        // we want to reverse this for the plain text arena of emails.
     2473        $blogname = wp_specialchars_decode( get_option('blogname'), ENT_QUOTES );
     2474
     2475        $message  = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
     2476        $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
     2477        $message .= sprintf( __( 'E-mail: %s' ), $user->user_email ) . "\r\n";
     2478
     2479        $title = sprintf( __('[%s] New User Registration' ), $blogname );
     2480
     2481        /**
     2482         * Filter the subject of the new user registration admin notification.
     2483         *
     2484         * @since unknown
     2485         *
     2486         * @param string $title Default email title.
     2487         */
     2488        $title = apply_filters( 'new_user_registration_admin_title', $title );
     2489
     2490        /**
     2491         * Filter the message body of the new user registration admin notification.
     2492         *
     2493         * @since unknown
     2494         *
     2495         * @param string  $message    Default mail message.
     2496         * @param string  $user_login The username for the user.
     2497         * @param WP_User $user       WP_User object.
     2498         */
     2499        $message = apply_filters( 'new_user_registration_admin_message', $message, $user->user_login, $user );
     2500
     2501        @wp_mail( get_option('admin_email'), $title, $message );
     2502}
     2503
     2504/**
     2505 * Email login credentials to a newly-registered user.
     2506 *
     2507 * @since unknown
     2508 *
     2509 * @param int    $user_id        User ID.
     2510 * @param string $plaintext_pass Optional. The user's plaintext password. Default empty.
     2511 */
     2512function wp_new_user_registration_notification( $user_id, $plaintext_pass = '' ) {
     2513
     2514        /**
     2515         * Filters whether to send the new user registration admin notification or not.
     2516         *
     2517         * @since unknown
     2518         *
     2519         * @param bool $should_send Whether to send the notification or not.
     2520         * @param int  $user_id     User ID.
     2521         */
     2522        $should_send = apply_filters( 'send_new_user_registration_notification', true, $user_id );
     2523        if ( ! $should_send || empty( $plaintext_pass ) )
     2524                return;
     2525
     2526        $user = get_userdata( $user_id );
     2527
     2528        // The blogname option is escaped with esc_html on the way into the database in sanitize_option
     2529        // we want to reverse this for the plain text arena of emails.
     2530        $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     2531
     2532        $message  = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n";
     2533        $message .= sprintf( __( 'Password: %s' ), $plaintext_pass ) . "\r\n";
     2534        $message .= wp_login_url() . "\r\n";
     2535
     2536        $title = sprintf( __( '[%s] Your username and password' ) );
     2537
     2538        /**
     2539         * Filter the subject of the new user registration notification.
     2540         *
     2541         * @since unknown
     2542         *
     2543         * @param string $title Default email title.
     2544         */
     2545        $title = apply_filters( 'new_user_registration_title', $title );
     2546
     2547        /**
     2548         * Filter the message body of the new user registration notification.
     2549         *
     2550         * @since unknown
     2551         *
     2552         * @param string  $message        Default mail message.
     2553         * @param string  $user_login     The username for the user.
     2554         * @param string  $plaintext_pass The user's plaintext password.
     2555         * @param WP_User $user           WP_User object.
     2556         */
     2557        $message = apply_filters( 'new_user_registration_message', $message, $user->user_login, $plaintext_pass, $user );
     2558
     2559        wp_mail( $user->user_email, $title, $blogname, $message );
     2560}
     2561
     2562/**
    24492563 * Retrieve the current session token from the logged_in cookie.
    24502564 *
    24512565 * @since 4.0.0
  • wp-includes/pluggable.php

     
    16851685 * @param string $plaintext_pass Optional. The user's plaintext password. Default empty.
    16861686 */
    16871687function wp_new_user_notification($user_id, $plaintext_pass = '') {
    1688         $user = get_userdata( $user_id );
    1689 
    1690         // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    1691         // we want to reverse this for the plain text arena of emails.
    1692         $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    1693 
    1694         $message  = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
    1695         $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
    1696         $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
    1697 
    1698         @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
    1699 
    1700         if ( empty($plaintext_pass) )
    1701                 return;
    1702 
    1703         $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    1704         $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
    1705         $message .= wp_login_url() . "\r\n";
    1706 
    1707         wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
    1708 
     1688        wp_new_user_registration_admin_notification( $user_id );
     1689        wp_new_user_registration_notification( $user_id, $plaintext_pass );
    17091690}
    17101691endif;
    17111692
  • wp-includes/pluggable-deprecated.php

     
    189189                        _deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' );
    190190                }
    191191        }
    192 }
    193  No newline at end of file
     192}