WordPress.org

Make WordPress Core

Ticket #8296: 8296.diff

File 8296.diff, 2.0 KB (added by solarissmoke, 3 years ago)
  • wp-admin/admin-ajax.php

     
    172172        $return = ( $wp_embed->cache_oembed( $_GET['post'] ) ) ? '1' : '0'; 
    173173        die( $return ); 
    174174        break; 
     175case 'get_random_password' : 
     176        die( wp_generate_password() ); 
     177        break; 
    175178default : 
    176179        do_action( 'wp_ajax_' . $_GET['action'] ); 
    177180        die('0'); 
  • wp-admin/js/user-profile.dev.js

     
    6060                        } 
    6161                        $('#'+sel).attr('selected', 'selected'); 
    6262                }); 
     63                // auto-generate password 
     64                $("#auto_generate_password").click(function(){ 
     65                        var btn = $(this); 
     66                        btn.siblings('img').css('visibility','visible'); 
     67                        $.get(ajaxurl, {action: 'get_random_password'}, function(p){ btn.siblings('img').css('visibility','hidden'); $("#pass1, #pass2").val(p); check_pass_strength() } ); 
     68                }); 
    6369    }); 
    6470 
    6571})(jQuery); 
  • wp-admin/user-new.php

     
    307307<?php if ( apply_filters('show_password_fields', true) ) : ?> 
    308308        <tr class="form-field form-required"> 
    309309                <th scope="row"><label for="pass1"><?php _e('Password'); ?> <span class="description"><?php /* translators: password input field */_e('(twice, required)'); ?></span></label></th> 
    310                 <td><input name="pass1" type="password" id="pass1" autocomplete="off" /> 
     310                <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> 
    311311                <br /> 
    312312                <input name="pass2" type="password" id="pass2" autocomplete="off" /> 
    313313                <br />