WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/19/2007 09:53:10 PM (14 years ago)
Author:
ryan
Message:

Password strength meter from MellerTime. see #4470

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/profile.php

    r5689 r6419  
    11<?php
    22require_once('admin.php');
     3
     4function profile_js ( ) {
     5?>
     6<script type="text/javascript">
     7    function check_pass_strength ( ) {
     8
     9        var pass = jQuery('#pass1').val();
     10        var user = jQuery('#user_login').val();
     11
     12        // get the result as an object, i'm tired of typing it
     13        var res = jQuery('#pass-strength-result');
     14
     15        var strength = passwordStrength(pass, user);
     16
     17        jQuery(res).removeClass('short bad good strong');
     18
     19        if ( strength == 'Bad' ) {
     20            jQuery(res).addClass('bad');
     21            jQuery(res).html( pwsL10n.bad );
     22        }
     23        else if ( strength == 'Good' ) {
     24            jQuery(res).addClass('good');
     25            jQuery(res).html( pwsL10n.good );
     26        }
     27        else if ( strength == 'Strong' ) {
     28            jQuery(res).addClass('strong');
     29            jQuery(res).html( pwsL10n.strong );
     30        }
     31        else {
     32            // this catches 'Too short' and the off chance anything else comes along
     33            jQuery(res).addClass('short');
     34            jQuery(res).html( pwsL10n.short );
     35        }
     36
     37    }
     38
     39    jQuery(document).ready( function() { jQuery('#pass1').keyup( check_pass_strength ) } );
     40</script>
     41<?php
     42}
     43
     44add_action('admin_head', 'profile_js');
     45
     46wp_enqueue_script('jquery');
     47wp_enqueue_script('password-strength-meter');
    348
    449$title = __('Profile');
     
    4388<legend><?php _e('Name'); ?></legend>
    4489<p><label><?php _e('Username: (no editing)'); ?><br />
    45 <input type="text" name="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
     90<input type="text" name="user_login" id="user_login" value="<?php echo $profileuser->user_login; ?>" disabled="disabled" />
    4691</label></p>
    4792
     
    115160<input type="password" name="pass2" id="pass2" size="16" value="" />
    116161</label></p>
     162<p><strong><?php _e('Password Strength:'); ?></strong></p>
     163<div id="pass-strength-result"><?php _e('Too short'); ?></div>
     164<!--[if IE 6]><div id="pass-strength-iesucks"><?php _e("If you weren&#8217;t using this sucky IE6, there would be pretty colors... and cookies!"); ?></div><![endif]-->
     165<p><?php _e('Hint: Use upper and lower case characters, numbers and symbols like !"£$%^&( in your password.'); ?></p>
    117166</fieldset>
    118167<?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.