Make WordPress Core


Ignore:
Timestamp:
01/31/2008 09:44:17 PM (17 years ago)
Author:
ryan
Message:

Merge user-edit.php and profile.php. Props nbachiyski. fixes #5736

File:
1 edited

Legend:

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

    r6652 r6697  
    11<?php
     2
     3$is_profile_page = isset($is_profile_page) && $is_profile_page? true : false;
     4
    25require_once('admin.php');
    36
    4 $title = __('Edit User');
    5 if ( current_user_can('edit_users') )
     7function profile_js ( ) {
     8?>
     9<script type="text/javascript">
     10    function check_pass_strength ( ) {
     11
     12        var pass = jQuery('#pass1').val();
     13        var user = jQuery('#user_login').val();
     14
     15        // get the result as an object, i'm tired of typing it
     16        var res = jQuery('#pass-strength-result');
     17
     18        var strength = passwordStrength(pass, user);
     19
     20        jQuery(res).removeClass('short bad good strong');
     21
     22        if ( strength == 'Bad' ) {
     23            jQuery(res).addClass('bad');
     24            jQuery(res).html( pwsL10n.bad );
     25        }
     26        else if ( strength == 'Good' ) {
     27            jQuery(res).addClass('good');
     28            jQuery(res).html( pwsL10n.good );
     29        }
     30        else if ( strength == 'Strong' ) {
     31            jQuery(res).addClass('strong');
     32            jQuery(res).html( pwsL10n.strong );
     33        }
     34        else {
     35            // this catches 'Too short' and the off chance anything else comes along
     36            jQuery(res).addClass('short');
     37            jQuery(res).html( pwsL10n.short );
     38        }
     39
     40    }
     41
     42    jQuery(document).ready( function() { jQuery('#pass1').keyup( check_pass_strength ) } );
     43</script>
     44<?php
     45}
     46
     47if ( $is_profile_page ) {
     48    add_action('admin_head', 'profile_js');
     49    wp_enqueue_script('jquery');
     50    wp_enqueue_script('password-strength-meter');
     51}
     52
     53$title = $is_profile_page? __('Profile') : __('Edit User');
     54if ( current_user_can('edit_users') && !$is_profile_page )
    655    $parent_file = 'users.php';
    756else
     
    1665
    1766if ( !$user_id )
    18     wp_die(__('Invalid user ID.'));
     67    if ( $is_profile_page ) {
     68        $current_user = wp_get_current_user();
     69        $user_id = $current_user->ID;
     70    } else {
     71        wp_die(__('Invalid user ID.'));
     72    }
    1973
    2074switch ($action) {
     
    3488    wp_die(__('You do not have permission to edit this user.'));
    3589
     90if ( $is_profile_page ) {
     91    do_action('personal_options_update');
     92}
     93
    3694$errors = edit_user($user_id);
    3795
    3896if( !is_wp_error( $errors ) ) {
    39     $redirect = "user-edit.php?user_id=$user_id&updated=true";
     97    $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
    4098    $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
    4199    wp_redirect($redirect);
     
    55113<div id="message" class="updated fade">
    56114    <p><strong><?php _e('User updated.') ?></strong></p>
    57     <?php if ( $wp_http_referer ) : ?>
     115    <?php if ( $wp_http_referer && !$is_profile_page ) : ?>
    58116    <p><a href="users.php"><?php _e('&laquo; Back to Authors and Users'); ?></a></p>
    59117    <?php endif; ?>
     
    72130
    73131<div class="wrap">
    74 <h2><?php _e('Edit User'); ?></h2>
    75 
    76 <form name="profile" id="your-profile" action="user-edit.php" method="post">
     132<h2><?php $is_profile_page? _e('Your Profile and Personal Options') : _e('Edit User'); ?></h2>
     133
     134<form name="profile" id="your-profile" action="" method="post">
    77135<?php wp_nonce_field('update-user_' . $user_id) ?>
    78136<?php if ( $wp_http_referer ) : ?>
     
    84142</p>
    85143
     144<h3><?php _e('Personal Options'); ?></h3>
     145
     146<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
    86147<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></p>
    87 
    88 <p class="submit"><input type="submit" value="<?php _e('Update User &raquo;'); ?>" name="submit" /></p>
     148<?php endif; ?>
     149
     150<?php
     151    if ( $is_profile_page ) {
     152        do_action('profile_personal_options');
     153    }
     154?>
     155
     156<p class="submit"><input type="submit" value="<?php $is_profile_page? _e('Update Profile &raquo;') : _e('Update User &raquo;'); ?>" name="submit" /></p>
    89157
    90158<fieldset>
    91159<legend><?php _e('Name'); ?></legend>
    92160<p><label><?php _e('Username: (no editing)'); ?><br />
    93 <input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
    94 </label></p>
    95 
     161<input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
     162</label></p>
     163
     164<?php if ( !$is_profile_page ): ?>
    96165<p><label><?php _e('Role:') ?><br />
    97166<?php
     
    115184echo $role_list . '</select>';
    116185?></label></p>
     186<?php endif; ?>
    117187
    118188<p><label><?php _e('First name:') ?><br />
     
    169239<br clear="all" />
    170240<fieldset>
    171 <legend><?php _e('About the user'); ?></legend>
     241<legend><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></legend>
    172242<p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p>
    173243<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
     
    179249?>
    180250<fieldset>
    181 <legend><?php _e("Update User's Password"); ?></legend>
    182 <p class="desc"><?php _e("If you would like to change the user's password type a new one twice below. Otherwise leave this blank."); ?></p>
     251<legend><?php $is_profile_page? _e('Update Your Password') : _e("Update User's Password"); ?></legend>
     252<p class="desc"><?php _e("If you would like to change the password type a new one twice below. Otherwise leave this blank."); ?></p>
    183253<p><label><?php _e('New Password:'); ?><br />
    184 <input type="password" name="pass1" size="16" value="" />
     254<input type="password" name="pass1" id="pass1" size="16" value="" />
    185255</label></p>
    186256<p><label><?php _e('Type it one more time:'); ?><br />
    187 <input type="password" name="pass2" size="16" value="" />
    188 </label></p>
     257<input type="password" name="pass2" id="pass2" size="16" value="" />
     258</label></p>
     259<?php if ( $is_profile_page ): ?>
     260<p><strong><?php _e('Password Strength:'); ?></strong></p>
     261<div id="pass-strength-result"><?php _e('Too short'); ?></div>
     262<p><?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&( in your password.'); ?></p>
     263<?php endif; ?>
    189264</fieldset>
    190265<?php endif; ?>
    191266
    192 <?php do_action('edit_user_profile'); ?>
     267<?php
     268    if ( $is_profile_page ) {
     269        do_action('show_user_profile');
     270    } else {
     271        do_action('edit_user_profile');
     272    }
     273?>
    193274
    194275<br clear="all" />
     
    217298    <input type="hidden" name="action" value="update" />
    218299    <input type="hidden" name="user_id" id="user_id" value="<?php echo $user_id; ?>" />
    219     <input type="submit" value="<?php _e('Update User &raquo;') ?>" name="submit" />
     300    <input type="submit" value="<?php $is_profile_page? _e('Update Profile &raquo;') : _e('Update User &raquo;') ?>" name="submit" />
    220301 </p>
    221302</form>
Note: See TracChangeset for help on using the changeset viewer.