Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/user-edit.php

    r15135 r17381  
    2525
    2626wp_enqueue_script('user-profile');
    27 wp_enqueue_script('password-strength-meter');
    2827
    2928$title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
     
    3231else
    3332    $submenu_file = 'profile.php';
    34 $parent_file = 'users.php';
     33
     34if ( current_user_can('edit_users') && !is_user_admin() )
     35    $parent_file = 'users.php';
     36else
     37    $parent_file = 'profile.php';
    3538
    3639// contextual help - choose Help on the top right of admin panel to preview this.
     
    8588        wp_update_user( get_object_vars( $user ) );
    8689        delete_option( $current_user->ID . '_new_email' );
    87         wp_redirect( add_query_arg( array('updated' => 'true'), admin_url( 'profile.php' ) ) );
     90        wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    8891        die();
    8992    }
    9093} elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
    9194    delete_option( $current_user->ID . '_new_email' );
    92     wp_redirect( add_query_arg( array('updated' => 'true'), admin_url( 'profile.php' ) ) );
     95    wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
    9396    die();
    9497}
    9598
    9699switch ($action) {
    97 case 'switchposts':
    98 
    99 check_admin_referer();
    100 
    101 /* TODO: Switch all posts from one user to another user */
    102 
    103 break;
    104 
    105100case 'update':
    106101
     
    129124    if ( $user_id != $current_user->ID ) {
    130125        $cap = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '{$user_id}' AND meta_key = '{$blog_prefix}capabilities' AND meta_value = 'a:0:{}'" );
    131         if ( null == $cap && $_POST[ 'role' ] == '' ) {
     126        if ( !is_network_admin() && null == $cap && $_POST[ 'role' ] == '' ) {
    132127            $_POST[ 'role' ] = 'contributor';
    133128            $delete_role = true;
     
    139134        delete_user_meta( $user_id, $blog_prefix . 'capabilities' );
    140135
    141     if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
     136    if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
    142137        empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
    143138}
     
    145140if ( !is_wp_error( $errors ) ) {
    146141    $redirect = (IS_PROFILE_PAGE ? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
    147     $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
     142    if ( $wp_http_referer )
     143        $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
    148144    wp_redirect($redirect);
    149145    exit;
     
    156152    wp_die(__('You do not have permission to edit this user.'));
    157153
    158 include ('admin-header.php');
     154include (ABSPATH . 'wp-admin/admin-header.php');
    159155?>
    160156
     
    166162    <p><strong><?php _e('User updated.') ?></strong></p>
    167163    <?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?>
    168     <p><a href="users.php"><?php _e('&larr; Back to Authors and Users'); ?></a></p>
     164    <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('&larr; Back to Authors and Users'); ?></a></p>
    169165    <?php endif; ?>
    170166</div>
     
    178174<h2><?php echo esc_html( $title ); ?></h2>
    179175
    180 <form id="your-profile" action="<?php echo esc_url( admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post"<?php do_action('user_edit_form_tag'); ?>>
     176<form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post"<?php do_action('user_edit_form_tag'); ?>>
    181177<?php wp_nonce_field('update-user_' . $user_id) ?>
    182178<?php if ( $wp_http_referer ) : ?>
     
    207203<tr>
    208204<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
    209 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts">More information</a>'); ?></td>
    210 </tr>
    211 <?php
    212 endif;
    213 do_action('personal_options', $profileuser);
    214 ?>
     205<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td>
     206</tr>
     207<?php endif; ?>
     208<tr class="show-admin-bar">
     209<th scope="row"><?php _e('Show Admin Bar')?></th>
     210<td><fieldset><legend class="screen-reader-text"><span><?php _e('Show Admin Bar') ?></span></legend>
     211<label for="admin_bar_front">
     212<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1" <?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
     213<?php /* translators: Show admin bar when viewing site */ _e( 'when viewing site' ); ?></label><br />
     214<label for="admin_bar_admin">
     215<input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" <?php checked( _get_admin_bar_pref( 'admin', $profileuser->ID ) ); ?> />
     216<?php /* translators: Show admin bar in dashboard */ _e( 'in dashboard' ); ?></label>
     217</td>
     218</tr>
     219<?php do_action('personal_options', $profileuser); ?>
    215220</table>
    216221<?php
     
    227232    </tr>
    228233
    229 <?php if ( !IS_PROFILE_PAGE ): ?>
     234<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
    230235<tr><th><label for="role"><?php _e('Role:') ?></label></th>
    231236<td><select name="role" id="role">
     
    246251?>
    247252</select>
    248 <?php if ( is_multisite() && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
    249 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.'); ?></label></p>
     253<?php endif; //!IS_PROFILE_PAGE
     254
     255if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
     256<tr><th><label for="role"><?php _e('Super Admin'); ?></label></th>
     257<td>
     258<?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) ) : ?>
     259<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
     260<?php else : ?>
     261<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
     262<?php endif; ?>
     263</td></tr>
    250264<?php } ?>
    251 </td></tr>
    252 <?php endif; //!IS_PROFILE_PAGE ?>
    253265
    254266<tr>
     
    308320    if ( $new_email && $new_email != $current_user->user_email ) : ?>
    309321    <div class="updated inline">
    310     <p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>
     322    <p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>
    311323    </div>
    312324    <?php endif; ?>
     
    320332
    321333<?php
    322     foreach (_wp_get_user_contactmethods() as $name => $desc) {
     334    foreach (_wp_get_user_contactmethods( $profileuser ) as $name => $desc) {
    323335?>
    324336<tr>
     
    336348<tr>
    337349    <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
    338     <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html($profileuser->description); ?></textarea><br />
     350    <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea><br />
    339351    <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
    340352</tr>
     
    382394<?php } ?>
    383395
    384 <p class="submit">
    385     <input type="hidden" name="action" value="update" />
    386     <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" />
    387     <input type="submit" class="button-primary" value="<?php IS_PROFILE_PAGE ? esc_attr_e('Update Profile') : esc_attr_e('Update User') ?>" name="submit" />
    388 </p>
     396<input type="hidden" name="action" value="update" />
     397<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" />
     398
     399<?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?>
     400
    389401</form>
    390402</div>
     
    399411</script>
    400412<?php
    401 include('./admin-footer.php');
    402 ?>
     413include( ABSPATH . 'wp-admin/admin-footer.php');
     414?>
Note: See TracChangeset for help on using the changeset viewer.