Make WordPress Core

Ticket #39117: 39117.5.diff

File 39117.5.diff, 4.1 KB (added by MatheusGimenez, 6 years ago)

Add @since

  • src/wp-admin/includes/admin-filters.php

     
    5555add_action( 'update_option_siteurl',       'update_home_siteurl', 10, 2 );
    5656add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 );
    5757
     58// Send email to old email address on change site admin email
     59add_action( 'update_option_admin_email', 'send_email_on_admin_email_change', 10, 3 );
    5860add_filter( 'heartbeat_received', 'wp_check_locked_posts',  10,  3 );
    5961add_filter( 'heartbeat_received', 'wp_refresh_post_lock',   10,  3 );
    6062add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10,  3 );
  • src/wp-admin/includes/options.php

     
    139139        echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
    140140        echo '<p class="description">' . __( 'The <a href="https://codex.wordpress.org/Glossary#Character_set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>';
    141141}
     142
     143/**
     144 * Send email to old email address on change site admin email
     145 * @param type $old_email
     146 * @param type $new_email
     147 * @param type $option_name
     148 * @since 4.8.0
     149 */
     150function send_email_on_admin_email_change( $old_email, $new_email, $option_name ) {
     151
     152        /**
     153        * Filters whether to send the admin email change.
     154        *
     155        * @since 4.8.0
     156        *
     157        *
     158        * @param bool  $send     Whether to send the email.
     159        * @param array $old_email     The original admin email.
     160        * @param array $new_email The updated admin email.
     161        *
     162        */
     163        $send_admin_email_change_email = apply_filters( 'send_admin_email_change_email', true, $old_email, $new_email );
     164        if ( $send_admin_email_change_email ) {
     165        /* translators: Do not translate ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
     166                $email_change_text = __( 'Hi,
     167
     168                                This notice confirms your site admin e-mail has been changed on ###SITENAME###.
     169                                Your new site admin e-mail is now "###NEWEMAIL###"
     170
     171                                Regards,
     172                                All at ###SITENAME###
     173                                ###SITEURL###' );
     174
     175                $email_change_email = array(
     176                        'to'      => $old_email,
     177                        /* translators: Site admin email change notification email subject. 1: Site name */
     178                        'subject' => __( '[%s] Notice of Admin Email Change' ),
     179                        'message' => $email_change_text,
     180                        'headers' => '',
     181                );
     182                // get blog name
     183                $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     184
     185                /**
     186                * Filters the contents of the email sent when the site admin email is change
     187                *
     188                *
     189                * @since 4.8.0
     190                *
     191                * @param array $email_change_email {
     192                *            Used to build wp_mail().
     193                *            @type string $to      The intended recipients.
     194                *            @type string $subject The subject of the email.
     195                *            @type string $message The content of the email.
     196                *                The following strings have a special meaning and will get replaced dynamically:
     197                *                - ###NEWEMAIL### The admin email in case this was unexpected.
     198                *                - ###SITENAME###    The name of the site.
     199                *                - ###SITEURL###     The URL to the site.
     200                *            @type string $headers Headers.
     201                *        }
     202                * @param array $old_email The original email
     203                * @param array $new_email The updated email.
     204                 */
     205                $email_change_email = apply_filters( 'admin_email_change_email', $email_change_email, $old_email, $new_email );
     206
     207                $email_change_email['message'] = str_replace( '###NEWEMAIL###', $new_email,  $email_change_email[ 'message' ] );
     208                $email_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $email_change_email['message'] );
     209                $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] );
     210
     211                wp_mail( $email_change_email['to'], sprintf( $email_change_email['subject'], $blog_name ), $email_change_email['message'], $email_change_email['headers'] );
     212        }
     213}