Make WordPress Core

Ticket #42135: 42135.2.patch

File 42135.2.patch, 3.1 KB (added by cmachu, 8 years ago)

Add new function with hook - wpmu_new_site_notification - unify usability with wpmu_welcome_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..a02a871 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_new_site_notification( $id, $current_user->user_login, $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 f2dbbc7..a081659 100644
    a b function install_blog_defaults( $blog_id, $user_id ) { 
    16221622}
    16231623
    16241624/**
     1625 * Notify admin that new site was created.
     1626 *
     1627 * Filter {@see 'wpmu_new_site_notification'} to disable or bypass.
     1628 *
     1629 * @since MU (3.0.0)
     1630 *
     1631 * @param int    $blog_id    Blog ID.
     1632 * @param string $user_login User login.
     1633 * @param string $title Site title.
     1634 * @return bool
     1635 */
     1636function wpmu_new_site_notification($blog_id, $user_login, $title) {
     1637    /**
     1638     * Filters whether to bypass the new site created email for admin.
     1639     *
     1640     * Returning false disables the welcome email.
     1641     *
     1642     * @since MU (3.0.0)
     1643     *
     1644     * @param int|bool $blog_id Blog ID.
     1645     * @param int $user_id User ID.
     1646     * @param string $password User password.
     1647     * @param string $title Site title.
     1648     * @param array $meta Signup meta data. By default, contains the requested privacy setting and lang_id.
     1649     */
     1650    if (!apply_filters('wpmu_new_site_notification', $blog_id, $user_login, $title))
     1651        return false;
     1652
     1653    wp_mail(
     1654        get_site_option('admin_email'),
     1655        sprintf(
     1656        /* translators: %s: network name */
     1657            __('[%s] New Site Created'),
     1658            get_network()->site_name
     1659        ),
     1660        sprintf(
     1661        /* translators: 1: user login, 2: site url, 3: site name/title */
     1662            __('New site created by %1$s
     1663
     1664Address: %2$s
     1665Name: %3$s'),
     1666            $user_login,
     1667            get_site_url($blog_id),
     1668            wp_unslash($title)
     1669        ),
     1670        sprintf(
     1671            'From: "%1$s" <%2$s>',
     1672            _x('Site Admin', 'email "From" field'),
     1673            get_site_option('admin_email')
     1674        )
     1675    );
     1676
     1677    return true;
     1678}
     1679
     1680/**
    16251681 * Notify a user that their blog activation has been successful.
    16261682 *
    16271683 * Filter {@see 'wpmu_welcome_notification'} to disable or bypass.