Make WordPress Core

Ticket #39117: 39117.9.diff

File 39117.9.diff, 8.7 KB (added by johnbillion, 6 years ago)
  • src/wp-admin/includes/admin-filters.php

    diff --git src/wp-admin/includes/admin-filters.php src/wp-admin/includes/admin-filters.php
    index 24b42c16fe..240474949c 100644
    add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_j 
    5454add_action( 'update_option_home',          'update_home_siteurl', 10, 2 );
    5555add_action( 'update_option_siteurl',       'update_home_siteurl', 10, 2 );
    5656add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 );
     57add_action( 'update_option_admin_email',   'wp_site_admin_email_change_notification', 10, 3 );
    5758
    5859add_filter( 'heartbeat_received', 'wp_check_locked_posts',  10,  3 );
    5960add_filter( 'heartbeat_received', 'wp_refresh_post_lock',   10,  3 );
  • src/wp-admin/includes/ms-admin-filters.php

    diff --git src/wp-admin/includes/ms-admin-filters.php src/wp-admin/includes/ms-admin-filters.php
    index 619ef0963b..20dc77e7c2 100644
    add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10 
    2222// Site Hooks.
    2323add_action( 'wpmueditblogaction', 'upload_space_setting' );
    2424
     25// Network hooks
     26add_action( 'update_site_option_admin_email', 'wp_network_admin_email_change_notification', 10, 4 );
     27
    2528// Taxonomy Hooks
    2629add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
    2730
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index 2b4fe56e16..770e5fe19d 100644
    function wp_cache_get_last_changed( $group ) { 
    56495649
    56505650        return $last_changed;
    56515651}
     5652
     5653/**
     5654 * Send an email to the old site admin email address when the site admin email address changes.
     5655 *
     5656 * @since 4.9.0
     5657 *
     5658 * @param string $old_email   The old site admin email address.
     5659 * @param string $new_email   The new site admin email address.
     5660 * @param string $option_name The relevant database option name.
     5661 */
     5662function wp_site_admin_email_change_notification( $old_email, $new_email, $option_name ) {
     5663        /**
     5664         * Filters whether to send the site admin email change notification email.
     5665         *
     5666         * @since 4.9.0
     5667         *
     5668         * @param bool   $send      Whether to send the email notification.
     5669         * @param string $old_email The old site admin email address.
     5670         * @param string $new_email The new site admin email address.
     5671         */
     5672        $send = apply_filters( 'send_site_admin_email_change_email', true, $old_email, $new_email );
     5673
     5674        if ( ! $send ) {
     5675                return;
     5676        }
     5677
     5678        /* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */
     5679        $email_change_text = __( 'Hi,
     5680
     5681This notice confirms that the admin email address was changed on ###SITENAME###.
     5682
     5683The new admin email address is ###NEW_EMAIL###.
     5684
     5685This email has been sent to ###OLD_EMAIL###
     5686
     5687Regards,
     5688All at ###SITENAME###
     5689###SITEURL###' );
     5690
     5691        $email_change_email = array(
     5692                'to'      => $old_email,
     5693                /* translators: Site admin email change notification email subject. %s: Site title */
     5694                'subject' => __( '[%s] Notice of Admin Email Change' ),
     5695                'message' => $email_change_text,
     5696                'headers' => '',
     5697        );
     5698        // get site name
     5699        $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     5700
     5701        /**
     5702         * Filters the contents of the email notification sent when the site admin email address is changed.
     5703         *
     5704         * @since 4.9.0
     5705         *
     5706         * @param array $email_change_email {
     5707         *            Used to build wp_mail().
     5708         *
     5709         *            @type string $to      The intended recipient.
     5710         *            @type string $subject The subject of the email.
     5711         *            @type string $message The content of the email.
     5712         *                The following strings have a special meaning and will get replaced dynamically:
     5713         *                - ###OLD_EMAIL### The old site admin email address.
     5714         *                - ###NEW_EMAIL### The new site admin email address.
     5715         *                - ###SITENAME###  The name of the site.
     5716         *                - ###SITEURL###   The URL to the site.
     5717         *            @type string $headers Headers.
     5718         *        }
     5719         * @param string $old_email The old site admin email address.
     5720         * @param string $new_email The new site admin email address.
     5721         */
     5722        $email_change_email = apply_filters( 'site_admin_email_change_email', $email_change_email, $old_email, $new_email );
     5723
     5724        $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] );
     5725        $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] );
     5726        $email_change_email['message'] = str_replace( '###SITENAME###',  $site_name, $email_change_email['message'] );
     5727        $email_change_email['message'] = str_replace( '###SITEURL###',   home_url(), $email_change_email['message'] );
     5728
     5729        wp_mail( $email_change_email['to'], sprintf(
     5730                $email_change_email['subject'],
     5731                $blog_name
     5732        ), $email_change_email['message'], $email_change_email['headers'] );
     5733}
  • src/wp-includes/ms-functions.php

    diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php
    index 3308c07ed0..103955e9b6 100644
    function get_subdirectory_reserved_names() { 
    25572557         */
    25582558        return apply_filters( 'subdirectory_reserved_names', $names );
    25592559}
     2560
     2561/**
     2562 * Send an email to the old network admin email address when the network admin email address changes.
     2563 *
     2564 * @since 4.9.0
     2565 *
     2566 * @param string $option_name The relevant database option name.
     2567 * @param string $new_email   The new network admin email address.
     2568 * @param string $old_email   The old network admin email address.
     2569 * @param int    $network_id  ID of the network.
     2570 */
     2571function wp_network_admin_email_change_notification( $option_name, $new_email, $old_email, $network_id ) {
     2572        /**
     2573         * Filters whether to send the network admin email change notification email.
     2574         *
     2575         * @since 4.9.0
     2576         *
     2577         * @param bool   $send       Whether to send the email notification.
     2578         * @param string $old_email  The old network admin email address.
     2579         * @param string $new_email  The new network admin email address.
     2580         * @param int    $network_id ID of the network.
     2581         */
     2582        $send = apply_filters( 'send_network_admin_email_change_email', true, $old_email, $new_email, $network_id );
     2583
     2584        if ( ! $send ) {
     2585                return;
     2586        }
     2587
     2588        /* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */
     2589        $email_change_text = __( 'Hi,
     2590
     2591This notice confirms that the network admin email address was changed on ###SITENAME###.
     2592
     2593The new network admin email address is ###NEW_EMAIL###.
     2594
     2595This email has been sent to ###OLD_EMAIL###
     2596
     2597Regards,
     2598All at ###SITENAME###
     2599###SITEURL###' );
     2600
     2601        $email_change_email = array(
     2602                'to'      => $old_email,
     2603                /* translators: Network admin email change notification email subject. %s: Network title */
     2604                'subject' => __( '[%s] Notice of Network Admin Email Change' ),
     2605                'message' => $email_change_text,
     2606                'headers' => '',
     2607        );
     2608        // get network name
     2609        $network_name = wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES );
     2610
     2611        /**
     2612         * Filters the contents of the email notification sent when the network admin email address is changed.
     2613         *
     2614         * @since 4.9.0
     2615         *
     2616         * @param array $email_change_email {
     2617         *            Used to build wp_mail().
     2618         *
     2619         *            @type string $to      The intended recipient.
     2620         *            @type string $subject The subject of the email.
     2621         *            @type string $message The content of the email.
     2622         *                The following strings have a special meaning and will get replaced dynamically:
     2623         *                - ###OLD_EMAIL### The old network admin email address.
     2624         *                - ###NEW_EMAIL### The new network admin email address.
     2625         *                - ###SITENAME###  The name of the network.
     2626         *                - ###SITEURL###   The URL to the site.
     2627         *            @type string $headers Headers.
     2628         *        }
     2629         * @param string $old_email  The old network admin email address.
     2630         * @param string $new_email  The new network admin email address.
     2631         * @param int    $network_id ID of the network.
     2632         */
     2633        $email_change_email = apply_filters( 'network_admin_email_change_email', $email_change_email, $old_email, $new_email, $network_id );
     2634
     2635        $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email,    $email_change_email['message'] );
     2636        $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email,    $email_change_email['message'] );
     2637        $email_change_email['message'] = str_replace( '###SITENAME###',  $network_name, $email_change_email['message'] );
     2638        $email_change_email['message'] = str_replace( '###SITEURL###',   home_url(),    $email_change_email['message'] );
     2639
     2640        wp_mail( $email_change_email['to'], sprintf(
     2641                $email_change_email['subject'],
     2642                $network_name
     2643        ), $email_change_email['message'], $email_change_email['headers'] );
     2644}