Make WordPress Core


Ignore:
Timestamp:
09/27/2017 02:16:21 PM (9 years ago)
Author:
johnbillion
Message:

Options, Meta APIs: Require a confirmation link in an email to be clicked when a user attempts to change the network
admin email address on Multisite.

This mirrors the same functionality for the site admin email address and user profile email address.

Fixes #41254

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/settings.php

    r41289 r41617  
    1919$title = __( 'Network Settings' );
    2020$parent_file = 'settings.php';
     21
     22// Handle network admin email change requests
     23if ( ! empty( $_GET[ 'network_admin_hash' ] ) ) {
     24    $new_admin_details = get_site_option( 'network_admin_hash' );
     25    $redirect = 'settings.php?updated=false';
     26    if ( is_array( $new_admin_details ) && hash_equals( $new_admin_details[ 'hash' ], $_GET[ 'network_admin_hash' ] ) && ! empty( $new_admin_details[ 'newemail' ] ) ) {
     27        update_site_option( 'admin_email', $new_admin_details[ 'newemail' ] );
     28        delete_site_option( 'network_admin_hash' );
     29        delete_site_option( 'new_admin_email' );
     30        $redirect = 'settings.php?updated=true';
     31    }
     32    wp_redirect( network_admin_url( $redirect ) );
     33    exit;
     34} elseif ( ! empty( $_GET['dismiss'] ) && 'new_network_admin_email' == $_GET['dismiss'] ) {
     35    check_admin_referer( 'dismiss_new_network_admin_email' );
     36    delete_site_option( 'network_admin_hash' );
     37    delete_site_option( 'new_admin_email' );
     38    wp_redirect( network_admin_url( 'settings.php?updated=true' ) );
     39    exit;
     40}
    2141
    2242add_action( 'admin_head', 'network_settings_add_js' );
     
    5979        'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author',
    6080        'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled',
    61         'illegal_names', 'limited_email_domains', 'banned_email_domains', 'WPLANG', 'admin_email',
     81        'illegal_names', 'limited_email_domains', 'banned_email_domains', 'WPLANG', 'new_admin_email',
    6282        'first_comment_email',
    6383    );
     
    112132                <th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ) ?></label></th>
    113133                <td>
    114                     <input name="admin_email" type="email" id="admin_email" aria-describedby="admin-email-desc" class="regular-text" value="<?php echo esc_attr( get_site_option( 'admin_email' ) ) ?>" />
     134                    <input name="new_admin_email" type="email" id="admin_email" aria-describedby="admin-email-desc" class="regular-text" value="<?php echo esc_attr( get_site_option( 'admin_email' ) ) ?>" />
    115135                    <p class="description" id="admin-email-desc">
    116                         <?php _e( 'This email address will receive notifications. Registration and support emails will also come from this address.' ); ?>
    117                     </p>
     136                        <?php _e( 'This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
     137                    </p>
     138                    <?php
     139                    $new_admin_email = get_site_option( 'new_admin_email' );
     140                    if ( $new_admin_email && $new_admin_email != get_site_option( 'admin_email' ) ) : ?>
     141                        <div class="updated inline">
     142                        <p><?php
     143                            printf(
     144                                /* translators: %s: new network admin email */
     145                                __( 'There is a pending change of the network admin email to %s.' ),
     146                                '<code>' . esc_html( $new_admin_email ) . '</code>'
     147                            );
     148                            printf(
     149                                ' <a href="%1$s">%2$s</a>',
     150                                esc_url( wp_nonce_url( network_admin_url( 'settings.php?dismiss=new_network_admin_email' ), 'dismiss_new_network_admin_email' ) ),
     151                                __( 'Cancel' )
     152                            );
     153                        ?></p>
     154                        </div>
     155                    <?php endif; ?>
    118156                </td>
    119157            </tr>
Note: See TracChangeset for help on using the changeset viewer.