Ticket #24633: 24633.23.patch
File 24633.23.patch, 7.8 KB (added by , 9 years ago) |
---|
-
src/wp-admin/admin-ajax.php
61 61 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 62 62 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs', 63 63 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail', 64 'parse-media-shortcode', 'destroy-sessions' 64 'parse-media-shortcode', 'destroy-sessions', 'generate_password', 65 65 ); 66 66 67 67 // Register core Ajax calls. -
src/wp-admin/css/forms.css
1004 1004 padding: 0; 1005 1005 line-height: 2; 1006 1006 } 1007 1008 .form-field #domain {1009 max-width: none;1010 }1011 1007 } 1012 1008 1013 1009 @media only screen and (max-width: 768px) { -
src/wp-admin/includes/ajax-actions.php
2828 2828 2829 2829 wp_send_json_success( array( 'message' => $message ) ); 2830 2830 } 2831 2832 /** 2833 * Generates a password via ajax 2834 * 2835 * @since 4.1.0 2836 */ 2837 function wp_ajax_generate_password() { 2838 wp_die( wp_generate_password( 30 ) ); 2839 } -
src/wp-admin/js/user-profile.js
1 1 /* global ajaxurl, pwsL10n */ 2 2 (function($){ 3 3 4 function check_pass_strength() { 5 var pass1 = $('#pass1').val(), pass2 = $('#pass2').val(), strength; 4 var passwords = { 5 6 pass1: '', 7 pass2: '', 8 submit: '', 9 results: $('#pass-strength-result'), 6 10 7 $('#pass-strength-result').removeClass('short bad good strong');8 if ( ! pass1 ) {9 $('#pass-strength-result').html( pwsL10n.empty);10 return;11 }11 init: function( pass1, pass2, submit ) { 12 13 passwords.pass1 = $( pass1 ); 14 passwords.pass2 = $( pass2 ); 15 passwords.submit = $( submit ); 12 16 13 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 ); 17 passwords.pass2.val('').keyup( passwords.check_strength() ); 18 19 // Handle user entering password 20 passwords.pass1.val('').on( 'keyup', function() { 21 passwords.check_strength(); 22 // Ensure fireld type is password 23 if ( 'text' === passwords.pass1.attr( 'type' ) ) { 24 passwords.pass1.attr( 'type', 'password' ); 25 } 26 if ( 'text' === passwords.pass2.attr( 'type' ) ) { 27 passwords.pass2.attr( 'type', 'password' ); 28 } 29 }); 14 30 15 switch ( strength ) { 16 case 2: 17 $('#pass-strength-result').addClass('bad').html( pwsL10n.bad ); 18 break; 19 case 3: 20 $('#pass-strength-result').addClass('good').html( pwsL10n.good ); 21 break; 22 case 4: 23 $('#pass-strength-result').addClass('strong').html( pwsL10n.strong ); 24 break; 25 case 5: 26 $('#pass-strength-result').addClass('short').html( pwsL10n.mismatch ); 27 break; 28 default: 29 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] ); 31 // Handle the Generate Password button 32 $( submit ).on('click', function() { 33 34 passwords.generate(); 35 36 }); 37 38 }, 39 40 generate: function() { 41 42 // Send an ajax request to the server to get a new password 43 $.post( ajaxurl, { action: 'generate_password' }, function(response) { 44 passwords.pass1.val( response ).trigger( 'keyup' ); 45 passwords.pass2.val( response ); 46 passwords.check_strength(); 47 passwords.pass1.attr( 'type', 'text' ); 48 passwords.pass2.attr( 'type', 'text' ); 49 passwords.pass1.focus().select(); 50 }); 51 52 }, 53 54 check_strength: function() { 55 56 var pass1 = passwords.pass1.val(), pass2 = passwords.pass2.val(), strength; 57 58 passwords.results.removeClass('short bad good strong'); 59 if ( ! pass1 ) { 60 passwords.results.html( pwsL10n.empty ); 61 return; 62 } 63 64 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 ); 65 66 switch ( strength ) { 67 case 2: 68 passwords.results.addClass('bad').html( pwsL10n.bad ); 69 break; 70 case 3: 71 passwords.results.addClass('good').html( pwsL10n.good ); 72 break; 73 case 4: 74 passwords.results.addClass('strong').html( pwsL10n.strong ); 75 break; 76 case 5: 77 passwords.results.addClass('short').html( pwsL10n.mismatch ); 78 break; 79 default: 80 passwords.results.addClass('short').html( pwsL10n['short'] ); 81 } 82 83 passwords.results.show(); 84 30 85 } 31 }32 86 87 }; 88 33 89 $(document).ready( function() { 34 90 var $colorpicker, $stylesheet, user_id, current_user_id, 35 91 select = $( '#display_name' ); 36 92 37 $('#pass1').val('').keyup( check_pass_strength ); 38 $('#pass2').val('').keyup( check_pass_strength ); 39 $('#pass-strength-result').show(); 93 /* Passwords */ 94 95 passwords.init( '#pass1', '#pass2', '#generate-password' ); 96 97 /* End Passwords */ 98 40 99 $('.color-palette').click( function() { 41 100 $(this).siblings('input[name="admin_color"]').prop('checked', true); 42 101 }); -
src/wp-admin/user-edit.php
468 468 <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> 469 469 <td> 470 470 <input class="hidden" value=" " /><!-- #24364 workaround --> 471 <input type="password" name="pass1" id="pass1" class="regular-text" size="16"value="" autocomplete="off" />472 < p class="description"><?php _e( 'If you would like to change the password type a new one. Otherwise leave this blank.' ); ?></p>471 <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" /> 472 <input type="button" name="generate-password" id="generate-password" value="<?php _e( 'Generate Password' ); ?>" class="button hide-if-no-js" /> 473 473 </td> 474 474 </tr> 475 <tr class="user-pass2-wrap">476 <th scope="row"><labelfor="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>475 <tr id="password2" class="user-pass2-wrap"> 476 <th><label class="password-repeat" for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> 477 477 <td> 478 <input name="pass2" type="password" id="pass2" class="regular-text" size="16" value="" autocomplete="off" /> 479 <p class="description"><?php _e( 'Type your new password again.' ); ?></p> 480 <br /> 481 <div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div> 482 <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> 478 <div class="password-repeat"> 479 <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" /> 480 <br /> 481 <div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div> 482 <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 ! " ? $ % ^ & ).' ); ?></p> 483 </div> 484 <p class="description"><?php _e( 'If you would like to change the password type or generate a new one. Otherwise leave this blank.' ); ?></p> 485 <?php if( ! IS_PROFILE_PAGE ) { ?> 486 <p class="hide-if-no-js"> 487 <label for="send_password"> 488 <input type="checkbox" name="send_password" id="send_password" value="1" /> <?php _e( 'Send this password to the user by email.' ); ?> 489 </label> 490 <br /> 491 <label for="reset_password"> 492 <input type="checkbox" name="reset_password" id="reset_password" value="1" /> <?php _e( 'Encourage the user to change their password, once logged in.' ); ?> 493 </label> 494 </p> 495 <?php } ?> 483 496 </td> 484 497 </tr> 485 498 <?php endif; ?>