WordPress.org

WordPress MU

Changeset 1581


Ignore:
Timestamp:
12/19/08 10:20:06 (6 years ago)
Author:
donncha
Message:

Fix dupe blogname showing in admin email change email
Users must confirm their change of email address in their profile page.
Fixes to the menu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/mu.php

    r1580 r1581  
    233233    $content = str_replace('###SITEURL###', 'http://' . $current_site->domain . $current_site->path, $content); 
    234234     
    235     wp_mail( $value, "[ " . get_option( 'blogname' ) . " ]" . sprintf(__('[%s] New Admin Email Address'), get_option('blogname')), $content ); 
     235    wp_mail( $value, sprintf(__('[%s] New Admin Email Address'), get_option('blogname')), $content ); 
    236236} 
    237237add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2); 
     238 
     239function profile_page_email_warning_ob_start() { 
     240    ob_start( 'profile_page_email_warning_ob_content' ); 
     241} 
     242 
     243function profile_page_email_warning_ob_content( $content ) { 
     244    $content = str_replace( ' class="regular-text" /> Required.</td>', ' class="regular-text" /> Required. (You will be sent an email to confirm the change)</td>', $content ); 
     245    return $content; 
     246} 
     247 
     248function update_profile_email() { 
     249    global $current_user; 
     250    if( $_GET[ 'newuseremail' ] && $current_user->ID ) { 
     251        $new_email = get_option( $current_user->ID . '_new_email' ); 
     252        if( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) { 
     253            $user->ID = $current_user->ID; 
     254            $user->user_email = wp_specialchars( trim( $new_email[ 'newemail' ] ) ); 
     255            wp_update_user( get_object_vars( $user ) ); 
     256            delete_option( $current_user->ID . '_new_email' ); 
     257            wp_redirect( add_query_arg( array('updated' => 'true'), admin_url( 'profile.php' ) ) ); 
     258            die(); 
     259        } 
     260    } 
     261} 
     262if( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) ) { 
     263    add_action( 'admin_init', 'update_profile_email' ); 
     264    add_action( 'admin_init', 'profile_page_email_warning_ob_start' ); 
     265} 
     266 
     267function send_confirmation_on_profile_email() { 
     268    global $current_user, $current_site; 
     269    if( $current_user->user_email != $_POST[ 'email' ] ) { 
     270        if ( !is_email( $_POST[ 'email' ] ) ) 
     271            return; 
     272 
     273        $hash = md5( $_POST[ 'email' ] . time() . mt_rand() ); 
     274        $new_user_email = array( 
     275                "hash" => $hash, 
     276                "newemail" => $_POST[ 'email' ] 
     277                ); 
     278        update_option( $current_user->ID . '_new_email', $new_user_email ); 
     279 
     280        $content = apply_filters( 'new_user_email_content', __("Dear user, 
     281 
     282You recently requested to have the email address on your account changed. 
     283If this is correct, please click on the following link to change it: 
     284###ADMIN_URL### 
     285 
     286You can safely ignore and delete this email if you do not want to 
     287take this action. 
     288 
     289This email has been sent to ###EMAIL### 
     290 
     291Regards, 
     292All at ###SITENAME### 
     293###SITEURL###"), $new_user_email ); 
     294 
     295        $content = str_replace('###ADMIN_URL###', clean_url(get_option( "siteurl" ).'/wp-admin/profile.php?newuseremail='.$hash), $content); 
     296        $content = str_replace('###EMAIL###', $_POST[ 'email' ], $content); 
     297        $content = str_replace('###SITENAME###', get_site_option( 'site_name' ), $content); 
     298        $content = str_replace('###SITEURL###', 'http://' . $current_site->domain . $current_site->path, $content); 
     299 
     300        wp_mail( $_POST[ 'email' ], sprintf(__('[%s] New Email Address'), get_option('blogname')), $content ); 
     301        $_POST[ 'email' ] = $current_user->user_email; 
     302    } 
     303} 
     304add_action( 'personal_options_update', 'send_confirmation_on_profile_email' ); 
     305 
     306function new_user_email_admin_notice() { 
     307    global $current_user; 
     308    if( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && $_GET[ 'updated' ] && $email = get_option( $current_user->ID . '_new_email' ) ) 
     309        echo "<div id='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email[ 'newemail' ] ) . "</div>"; 
     310} 
     311add_action( 'admin_notices', 'new_user_email_admin_notice' ); 
    238312 
    239313function get_site_allowed_themes() { 
     
    354428*/ 
    355429function wpmu_checkAvailableSpace() { 
    356     $spaceAllowed = get_space_allowed();  
     430    $spaceAllowed = get_space_allowed(); 
    357431 
    358432    $dirName = trailingslashit( BLOGUPLOADDIR ); 
     
    417491 
    418492    if( is_site_admin() ) { 
    419         $menu[3] = array( '', 'read', '', '', 'wp-menu-separator' ); 
    420         $menu[4] = array(__('Site Admin'), '10', 'wpmu-admin.php', '', 'wp-menu-open menu-top', 'menu-site', 'div'); 
     493        $menu[2] = array(__('Site Admin'), '10', 'wpmu-admin.php', '', 'wp-menu-open menu-top', 'menu-dashboard', 'div'); 
    421494        $submenu[ 'wpmu-admin.php' ][1] = array( __('Admin'), '10', 'wpmu-admin.php' ); 
    422495        $submenu[ 'wpmu-admin.php' ][5] = array( __('Blogs'), '10', 'wpmu-blogs.php' ); 
     
    432505    if( $menu_perms[ 'plugins' ] != 1 ) { 
    433506        if( !is_site_admin() ) { 
    434             unset( $submenu['plugins.php'][5] ); 
    435             unset( $menu['35'] ); // Plugins 
     507            unset( $menu['45'] ); // Plugins 
    436508        } else { 
    437             $menu[ '35' ][0] .= ' <strong>*</strong>'; 
    438             $menu[ '35' ][2] = 'wpmu-options.php#menu'; 
     509            $menu[ '45' ][0] .= ' <strong>*</strong>'; 
     510            $menu[ '45' ][2] = 'wpmu-options.php#menu'; 
    439511        } 
    440512    } 
     
    451523        } 
    452524    } 
     525    unset( $submenu['tools.php'][20] ); // core upgrade 
     526    unset( $submenu['options-general.php'][45] ); // Misc 
    453527 
    454528} 
Note: See TracChangeset for help on using the changeset viewer.