WordPress.org

Make WordPress Core

Changeset 6419


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

Password strength meter from MellerTime. see #4470

Location:
trunk
Files:
3 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; ?>
  • trunk/wp-admin/wp-admin.css

    r6303 r6419  
    13571357    color: #036;
    13581358}
     1359
     1360#pass-strength-result {
     1361    padding: 3px 5px 3px 5px;
     1362    margin-top: 3px;
     1363    text-align: center;
     1364    background-color: #e3e3e3;
     1365    border: 1px solid #000000;
     1366}
     1367
     1368#pass-strength-result.short {
     1369    background-color: #e3e3e3;
     1370    border: 1px solid #000000;
     1371}
     1372
     1373#pass-strength-result.bad {
     1374    background-color: #ffeff7;
     1375    border: 1px solid #cc6699;
     1376}
     1377
     1378#pass-strength-result.good {
     1379    background-color: #effff4;
     1380    border: 1px solid #66cc87;
     1381}
     1382
     1383#pass-strength-result.strong {
     1384    background-color: #59ef86;
     1385    border: 1px solid #319f52;
     1386}
     1387
     1388#pass-strength-iesucks {
     1389    font-size: 8pt;
     1390    text-align: center;
     1391}
  • trunk/wp-includes/script-loader.php

    r6312 r6419  
    118118            $this->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20071031' );
    119119            $this->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
     120            $this->add( 'password-strength-meter', '/wp-admin/js/passwordStrengthMeter.js', array('jquery'), '20070405' );
     121            $this->localize( 'password-strength-meter', 'pwsL10n', array(
     122                'short' => __('Too short'),
     123                'bad' => __('Bad'),
     124                'good' => __('Good'),
     125                'strong' => __('Strong')
     126            ) );
    120127            $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20071104' );
    121128            $this->add( 'admin-posts', '/wp-admin/js/edit-posts.js', array('wp-lists'), '20071023' );
Note: See TracChangeset for help on using the changeset viewer.