Make WordPress Core

Ticket #44781: 44781.diff

File 44781.diff, 4.2 KB (added by dharmin16, 7 years ago)

Added the wpmu_admin_notification.

  • src/wp-admin/network/site-new.php

    diff --git a/src/wp-admin/network/site-new.php b/src/wp-admin/network/site-new.php
    index 70d9f1c..85c44d0 100644
    a b if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) { 
    142142                        update_user_option( $user_id, 'primary_blog', $id, true );
    143143                }
    144144
    145                 wp_mail(
    146                         get_site_option( 'admin_email' ),
    147                         sprintf(
    148                                 /* translators: %s: network name */
    149                                 __( '[%s] New Site Created' ),
    150                                 get_network()->site_name
    151                         ),
    152                         sprintf(
    153                                 /* translators: 1: user login, 2: site url, 3: site name/title */
    154                                 __(
    155                                         'New site created by %1$s
    156 
    157 Address: %2$s
    158 Name: %3$s'
    159                                 ),
    160                                 $current_user->user_login,
    161                                 get_site_url( $id ),
    162                                 wp_unslash( $title )
    163                         ),
    164                         sprintf(
    165                                 'From: "%1$s" <%2$s>',
    166                                 _x( 'Site Admin', 'email "From" field' ),
    167                                 get_site_option( 'admin_email' )
    168                         )
    169                 );
     145                wpmu_admin_notification( $id, $user_id, $title );
    170146                wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );
    171147                wp_redirect(
    172148                        add_query_arg(
  • src/wp-includes/ms-functions.php

    diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php
    index 6e52332..f4634b5 100644
    a b function install_blog_defaults( $blog_id, $user_id ) { 
    15901590}
    15911591
    15921592/**
     1593 * Notify the admin about new site creation.
     1594 *
     1595 * Filter {@see 'wpmu_admin_notification'} to disable or bypass.
     1596 *
     1597 * Filter {@see 'update_admin_notification'} and {@see 'update_admin_notification_subject'} to
     1598 * modify the content and subject line of the notification email.
     1599 *
     1600 * @param int    $blog_id    Site ID.
     1601 * @param int    $user_id    User ID.
     1602 * @param string $title       Site title.
     1603 * @return bool
     1604 */
     1605function wpmu_admin_notification( $blog_id, $user_id, $title ) {
     1606        $current_network = get_network();
     1607
     1608        /**
     1609         * Filters whether to bypass the admin notification email.
     1610         *
     1611         * Returning false disables the admin notification email.
     1612         *
     1613         * @param int|bool  $blog_id    Site ID.
     1614         * @param int       $user_id    User ID.
     1615         * @param string    $title      Site title.
     1616         */
     1617        if ( ! apply_filters( 'wpmu_admin_notification', $blog_id, $user_id, $title ) ) {
     1618                return false;
     1619        }
     1620
     1621        $user = get_userdata( $user_id );
     1622
     1623        $admin_notification = sprintf(
     1624                /* translators: 1: user login, 2: site url, 3: site name/title */
     1625                __(
     1626                        'New site created by %1$s
     1627
     1628Address: %2$s
     1629Name: %3$s'
     1630                ),
     1631                $user->user_login,
     1632                get_site_url( $blog_id ),
     1633                wp_unslash( $title )
     1634        );
     1635
     1636        /**
     1637         * Filters the content of the admin notification email.
     1638         *
     1639         * Content should be formatted for transmission via wp_mail().
     1640         *
     1641         * @param string $admin_notification Message body of the email.
     1642         * @param int    $blog_id            Site ID.
     1643         * @param int    $user_id            User ID.
     1644         * @param string $title              Site title.
     1645         */
     1646        $admin_notification = apply_filters( 'update_admin_notification', $admin_notification, $blog_id, $user_id, $title );
     1647        $admin_email        = get_site_option( 'admin_email' );
     1648
     1649        if ( empty( $admin_email ) ) {
     1650                $admin_email = sanitize_email( 'support@' . $_SERVER['SERVER_NAME'] );
     1651        }
     1652
     1653        $message_headers = sprintf(
     1654                'From: "%1$s" <%2$s>',
     1655                _x( 'Site Admin', 'email "From" field' ),
     1656                sanitize_email( $admin_email )
     1657        );
     1658
     1659        $message = $admin_notification;
     1660
     1661        if ( empty( $current_network->site_name ) ) {
     1662                $current_network->site_name = 'WordPress';
     1663        }
     1664
     1665        /* translators: New site notification email subject. 1: Network name, 2: New site name */
     1666        $subject = sprintf(
     1667                /* translators: %s: network name */
     1668                __( '[%s] New Site Created' ),
     1669                $current_network->site_name
     1670        );
     1671
     1672        /**
     1673         * Filters the subject of the admin notification email.
     1674         *
     1675         * @param string $subject Subject of the email.
     1676         */
     1677        $subject = apply_filters( 'update_admin_notification_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) );
     1678        wp_mail( $admin_email, wp_specialchars_decode( $subject ), $message, $message_headers );
     1679
     1680        return true;
     1681}
     1682
     1683/**
    15931684 * Notify a user that their blog activation has been successful.
    15941685 *
    15951686 * Filter {@see 'wpmu_welcome_notification'} to disable or bypass.