Make WordPress Core

Ticket #8296: 8296-1.diff

File 8296-1.diff, 1.7 KB (added by ericlewis, 12 years ago)

Updated version of solarissmoke's implementation, as the current doesn't apply cleanly. Remove AJAX dependency.

  • wp-admin/js/user-profile.dev.js

     
    7373                                });
    7474                        });
    7575                }
     76                // auto-generate password
     77                $("#auto_generate_password").click( function() {
     78                        var length = 12;
     79                var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()';
     80                var password = '';
     81
     82                for ( var i = 0; i < length; i++ ) {
     83                start = Math.floor(Math.random()*chars.length);
     84                password = password + chars.substring(start - 1, start);
     85                }
     86
     87                        $("#pass1, #pass2").val(password);
     88                        check_pass_strength();
     89                });
    7690        });
    7791
    7892})(jQuery);
  • wp-admin/user-new.php

     
    342342<?php if ( apply_filters('show_password_fields', true) ) : ?>
    343343        <tr class="form-field form-required">
    344344                <th scope="row"><label for="pass1"><?php _e('Password'); ?> <span class="description"><?php /* translators: password input field */_e('(twice, required)'); ?></span></label></th>
    345                 <td><input name="pass1" type="password" id="pass1" autocomplete="off" />
     345                <td><input name="pass1" type="password" id="pass1" autocomplete="off" /> <span class="hide-if-no-js"><input class="button-secondary" type="button" id="auto_generate_password" value="Generate random password" /> <img class="ajax-loading" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ) ?>" /></span>
    346346                <br />
    347347                <input name="pass2" type="password" id="pass2" autocomplete="off" />
    348348                <br />