Make WordPress Core


Ignore:
Timestamp:
05/16/2009 06:29:10 AM (17 years ago)
Author:
azaozz
Message:

Clean up user-edit.php, add password strength meter to Add User and Edit User

File:
1 edited

Legend:

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

    r11330 r11359  
    1010require_once('admin.php');
    1111
    12 if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE )
    13         $is_profile_page = true;
    14 else
    15         $is_profile_page = false;
    16 
    17 if ( $is_profile_page ) {
    18         wp_enqueue_script('user-profile');
    19         wp_enqueue_script('password-strength-meter');
    20 }
    21 
    22 $title = $is_profile_page? __('Profile') : __('Edit User');
    23 if ( current_user_can('edit_users') && !$is_profile_page )
     12if ( !defined('IS_PROFILE_PAGE') )
     13        define('IS_PROFILE_PAGE', false);
     14
     15wp_enqueue_script('user-profile');
     16wp_enqueue_script('password-strength-meter');
     17
     18$title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
     19if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
    2420        $submenu_file = 'users.php';
    2521else
    … …  
    3430
    3531if ( !$user_id ) {
    36         if ( $is_profile_page ) {
     32        if ( IS_PROFILE_PAGE ) {
    3733                $current_user = wp_get_current_user();
    3834                $user_id = $current_user->ID;
    … …  
    7672        wp_die(__('You do not have permission to edit this user.'));
    7773
    78 if ($is_profile_page)
     74if ( IS_PROFILE_PAGE )
    7975        do_action('personal_options_update', $user_id);
    8076else
    … …  
    8480
    8581if ( !is_wp_error( $errors ) ) {
    86         $redirect = ($is_profile_page? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
     82        $redirect = (IS_PROFILE_PAGE ? "profile.php?" : "user-edit.php?user_id=$user_id&"). "updated=true";
    8783        $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
    8884        wp_redirect($redirect);
    … …  
    10298<div id="message" class="updated fade">
    10399        <p><strong><?php _e('User updated.') ?></strong></p>
    104         <?php if ( $wp_http_referer && !$is_profile_page ) : ?>
     100        <?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?>
    105101        <p><a href="users.php"><?php _e('&larr; Back to Authors and Users'); ?></a></p>
    106102        <?php endif; ?>
    … …  
    174170</table>
    175171<?php
    176         if ( $is_profile_page )
     172        if ( IS_PROFILE_PAGE )
    177173                do_action('profile_personal_options', $profileuser);
    178174?>
    … …  
    186182        </tr>
    187183
    188 <?php if ( !$is_profile_page ): ?>
     184<?php if ( !IS_PROFILE_PAGE ): ?>
    189185<tr><th><label for="role"><?php _e('Role:') ?></label></th>
    190186<td><select name="role" id="role">
    … …  
    205201?>
    206202</select></td></tr>
    207 <?php endif; //!$is_profile_page ?>
     203<?php endif; //!IS_PROFILE_PAGE ?>
    208204
    209205<tr>
    … …  
    281277</table>
    282278
    283 <h3><?php $is_profile_page? _e('About Yourself') : _e('About the user'); ?></h3>
     279<h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
    284280
    285281<table class="form-table">
    … …  
    298294        <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?></span><br />
    299295                <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br />
    300         <?php if ( $is_profile_page ): ?>
    301296                <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
    302                 <p class="description indicator-hint"><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
    303         <?php endif; ?></td>
     297                <p class="description indicator-hint"><?php _e('Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
     298        </td>
    304299</tr>
    305300<?php endif; ?>
    … …  
    307302
    308303<?php
    309         if ( $is_profile_page ) {
     304        if ( IS_PROFILE_PAGE ) {
    310305                do_action('show_user_profile', $profileuser);
    311306        } else {
    … …  
    336331        <input type="hidden" name="action" value="update" />
    337332        <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" />
    338         <input type="submit" class="button-primary" value="<?php $is_profile_page? esc_attr_e('Update Profile') : esc_attr_e('Update User') ?>" name="submit" />
     333        <input type="submit" class="button-primary" value="<?php IS_PROFILE_PAGE ? esc_attr_e('Update Profile') : esc_attr_e('Update User') ?>" name="submit" />
    339334</p>
    340335</form>
Note: See TracChangeset for help on using the changeset viewer.