Ticket #24633: 24633.28.patch
File 24633.28.patch, 9.8 KB (added by , 10 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', 'install-plugin', 'update-plugin' 64 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 65 'generate-password', 65 66 ); 66 67 67 68 // Register core Ajax calls. -
src/wp-admin/css/forms.css
641 641 width: 25em; 642 642 } 643 643 644 #createuser #generate-password { 645 width: auto; 646 } 647 644 648 .color-option { 645 649 display: inline-block; 646 650 width: 24%; … … 1004 1008 padding: 0; 1005 1009 line-height: 2; 1006 1010 } 1007 1008 .form-field #domain {1009 max-width: none;1010 }1011 1011 } 1012 1012 1013 1013 @media only screen and (max-width: 768px) { -
src/wp-admin/includes/ajax-actions.php
2954 2954 2955 2955 wp_send_json_success( $status ); 2956 2956 } 2957 2958 /** 2959 * Generates a password via ajax 2960 * 2961 * @since 4.1.0 2962 */ 2963 function wp_ajax_generate_password() { 2964 wp_die( wp_generate_password( 30 ) ); 2965 } -
src/wp-admin/js/password-strength-meter.js
72 72 73 73 // Backwards compatibility. 74 74 passwordStrength = wp.passwordStrength.meter; 75 76 /** 77 * Password generation tool. 78 * 79 * @param {sting} pass1 Selector for the first password field. 80 * @param {sting} pass2 Selector for the second password field. 81 * @param {sting} submit Selector for the generate password button. 82 * 83 */ 84 wp.passwordGenerator = { 85 86 self: '', 87 pass1: '', 88 pass2: '', 89 submit: '', 90 results: $('#pass-strength-result'), 91 92 init: function( pass1, pass2, submit ) { 93 94 self = wp.passwordGenerator; 95 96 self.pass1 = $( pass1 ); 97 self.pass2 = $( pass2 ); 98 self.submit = $( submit ); 99 100 self.pass2.val('').keyup( self.checkStrength() ); 101 102 // Handle user entering password 103 self.pass1.val('').on( 'keyup', function() { 104 self.checkStrength(); 105 // Ensure fireld type is password 106 if ( 'text' === self.pass1.attr( 'type' ) ) { 107 self.pass1.attr( 'type', 'password' ); 108 } 109 if ( 'text' === self.pass2.attr( 'type' ) ) { 110 self.pass2.attr( 'type', 'password' ); 111 } 112 }); 113 114 // Handle the Generate Password button 115 $( submit ).on('click', function() { 116 117 self.generate(); 118 119 }); 120 121 }, 122 123 generate: function() { 124 125 // Send an ajax request to the server to get a new password 126 wp.ajax.post( 'generate-password' ).always( function( response ) { 127 self.pass1.val( response ).trigger( 'keyup' ); 128 self.pass2.val( response ); 129 self.checkStrength(); 130 self.pass1.attr( 'type', 'text' ); 131 self.pass2.attr( 'type', 'text' ); 132 self.pass1.focus().select(); 133 }); 134 135 }, 136 137 checkStrength: function() { 138 139 var pass1 = self.pass1.val(), pass2 = self.pass2.val(), strength; 140 141 self.results.removeClass('short bad good strong'); 142 if ( ! pass1 ) { 143 self.results.html( pwsL10n.empty ); 144 return; 145 } 146 147 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 ); 148 149 switch ( strength ) { 150 case 2: 151 self.results.addClass('bad').html( pwsL10n.bad ); 152 break; 153 case 3: 154 self.results.addClass('good').html( pwsL10n.good ); 155 break; 156 case 4: 157 self.results.addClass('strong').html( pwsL10n.strong ); 158 break; 159 case 5: 160 self.results.addClass('short').html( pwsL10n.mismatch ); 161 break; 162 default: 163 self.results.addClass('short').html( pwsL10n['short'] ); 164 } 165 166 self.results.show(); 167 168 } 169 170 }; 171 172 wp.passwordGenerator.init( '#pass1', '#pass2', '#generate-password' ); 173 75 174 })(jQuery); 175 No newline at end of file -
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;6 7 $('#pass-strength-result').removeClass('short bad good strong');8 if ( ! pass1 ) {9 $('#pass-strength-result').html( pwsL10n.empty );10 return;11 }12 13 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 );14 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'] );30 }31 }32 33 4 $(document).ready( function() { 34 5 var $colorpicker, $stylesheet, user_id, current_user_id, 35 6 select = $( '#display_name' ); 36 7 37 $('#pass1').val('').on( 'input propertychange', check_pass_strength );38 $('#pass2').val('').on( 'input propertychange', check_pass_strength );39 $('#pass-strength-result').show();40 8 $('.color-palette').click( function() { 41 9 $(this).siblings('input[name="admin_color"]').prop('checked', true); 42 10 }); -
src/wp-admin/user-edit.php
457 457 <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> 458 458 <td> 459 459 <input class="hidden" value=" " /><!-- #24364 workaround --> 460 <input type="password" name="pass1" id="pass1" class="regular-text" size="16"value="" autocomplete="off" />461 < p class="description"><?php _e( 'If you would like to change the password type a new one. Otherwise leave this blank.' ); ?></p>460 <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" /> 461 <input type="button" name="generate-password" id="generate-password" value="<?php _e( 'Generate Password' ); ?>" class="button hide-if-no-js" /> 462 462 </td> 463 463 </tr> 464 <tr class="user-pass2-wrap">465 <th scope="row"><labelfor="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>464 <tr id="password2" class="user-pass2-wrap"> 465 <th><label class="password-repeat" for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> 466 466 <td> 467 <input name="pass2" type="password" id="pass2" class="regular-text" size="16" value="" autocomplete="off" /> 468 <p class="description"><?php _e( 'Type your new password again.' ); ?></p> 469 <br /> 470 <div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div> 471 <p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p> 467 <div class="password-repeat"> 468 <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" /> 469 <br /> 470 <div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div> 471 <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> 472 </div> 473 <p class="description"><?php _e( 'If you would like to change the password type or generate a new one. Otherwise leave this blank.' ); ?></p> 474 <?php if( ! IS_PROFILE_PAGE ) { ?> 475 <p class="hide-if-no-js"> 476 <label for="send_password"> 477 <input type="checkbox" name="send_password" id="send_password" value="1" /> <?php _e( 'Send this password to the user by email.' ); ?> 478 </label> 479 <br /> 480 <label for="reset_password"> 481 <input type="checkbox" name="reset_password" id="reset_password" value="1" /> <?php _e( 'Encourage the user to change their password, once logged in.' ); ?> 482 </label> 483 </p> 484 <?php } ?> 472 485 </td> 473 486 </tr> 474 487 <?php endif; ?> -
src/wp-admin/user-new.php
390 390 <td> 391 391 <input class="hidden" value=" " /><!-- #24364 workaround --> 392 392 <input name="pass1" type="password" id="pass1" autocomplete="off" /> 393 <input type="button" name="generate-password" id="generate-password" value="<?php _e( 'Generate Password' ); ?>" class="button hide-if-no-js" /> 393 394 </td> 394 395 </tr> 395 396 <tr class="form-field form-required"> -
src/wp-includes/script-loader.php
351 351 ) ); 352 352 353 353 $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 ); 354 $scripts->add( 'user-new', "/wp-admin/js/user-new$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 ); 354 355 $scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 ); 355 356 356 357 $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );