Make WordPress Core

Ticket #32589: 32589.diff

File 32589.diff, 6.8 KB (added by markjaquith, 9 years ago)
  • src/wp-admin/css/forms.css

    diff --git src/wp-admin/css/forms.css src/wp-admin/css/forms.css
    index 6b07e51..d01c400 100644
    input[type="number"].small-text { 
    401401        color: #777;
    402402}
    403403
     404button.wp-hide-pw > .dashicons {
     405        position: relative;
     406        top: 3px;
     407}
     408
    404409label,
    405410#your-profile label + a {
    406411        vertical-align: middle;
    fieldset label, 
    434439#pass-strength-result {
    435440        background-color: #eee;
    436441        border: 1px solid #ddd;
    437         float: left;
    438         margin: 13px 5px 5px 1px;
     442        margin: -2px 5px 5px 1px;
    439443        padding: 3px 5px;
    440444        text-align: center;
    441         width: 200px;
    442         display: none;
     445        width: 25em;
     446        box-sizing: border-box;
     447        opacity: 0;
    443448}
    444449
    445450#pass-strength-result.short {
     451        opacity: 1;
    446452        background-color: #ffa0a0;
    447453        border-color: #f04040;
    448454}
    449455
    450456#pass-strength-result.bad {
     457        opacity: 1;
    451458        background-color: #ffb78c;
    452459        border-color: #ff853c;
    453460}
    454461
    455462#pass-strength-result.good {
     463        opacity: 1;
    456464        background-color: #ffec8b;
    457465        border-color: #fc0;
    458466}
    459467
    460468#pass-strength-result.strong {
     469        opacity: 1;
    461470        background-color: #c3ff88;
    462471        border-color: #8dff1c;
    463472}
    464473
     474#pass1.short {
     475        border-color: #f04040;
     476}
     477
     478#pass1.bad {
     479        border-color: #ff853c;
     480}
     481
     482#pass1.good {
     483        border-color: #fc0;
     484}
     485
     486#pass1.strong {
     487        border-color: #8dff1c;
     488}
     489
    465490.indicator-hint {
    466491        padding-top: 8px;
    467492}
  • src/wp-admin/js/user-profile.js

    diff --git src/wp-admin/js/user-profile.js src/wp-admin/js/user-profile.js
    index 72a2465..d4f3e29 100644
     
    11/* global ajaxurl, pwsL10n */
    22(function($){
     3        $(function(){
     4                var pw_new = $('.user-pass1-wrap'),
     5                                pw_line = pw_new.find('.wp-pwd'),
     6                                pw_field = $('#pass1'),
     7                                pw_field2 = $('#pass2'),
     8                                pw_togglebtn = pw_new.find('.wp-hide-pw'),
     9                                pw_generatebtn = pw_new.find('button.wp-generate-pw'),
     10                                pw_2 = $('.user-pass2-wrap'),
     11                                parentform = pw_new.closest('form'),
     12                                pw_strength = $('#pass-strength-result')
     13                ;
     14
     15                pw_2.hide();
     16                pw_line.hide();
     17                pw_togglebtn.show();
     18                pw_generatebtn.show();
     19
     20                parentform.on('submit', function(){
     21                        pw_field2.val( pw_field.val() );
     22                        pw_field.attr('type', 'password');
     23                });
     24
     25
     26                pw_field.on('input propertychange', function(){
     27                        setTimeout( function(){
     28                                var cssClass = pw_strength.attr('class');
     29                                console.log( cssClass );
     30                                pw_field.removeClass( 'short bad good strong' );
     31                                if ( 'undefined' !== typeof cssClass ) {
     32                                        pw_field.addClass( cssClass );
     33                                }
     34                        }, 1 );
     35                });
     36
     37                /**
     38                 * Fix a LastPass mismatch issue, LastPass only changes pass2.
     39                 *
     40                 * This fixes the issue by copying any changes from the hidden
     41                 * pass2 field to the pass1 field.
     42                 */
     43                pw_field2.on( 'input propertychange', function(){
     44                        pw_field.val( pw_field2.val() );
     45                        pw_field.trigger( 'propertychange' );
     46                } );
     47
     48                pw_new.on('click', 'button.wp-generate-pw', function(){
     49                        pw_generatebtn.hide();
     50                        pw_line.show();
     51                        pw_field.val(pw_field.data('pw')).attr('type', 'text');
     52                        pw_field.trigger('propertychange');
     53                });
     54
     55                pw_togglebtn.on('click', function(){
     56                        var show = pw_togglebtn.attr('data-toggle');
     57                        if (show == 1) {
     58                                pw_field.attr('type', 'text');
     59                                pw_togglebtn.attr('data-toggle', 0)
     60                                        .find('.text')
     61                                                .text('hide')
     62                                ;
     63                        } else {
     64                                pw_field.attr('type', 'password');
     65                                pw_togglebtn.attr('data-toggle', 1)
     66                                        .find('.text')
     67                                                .text('show')
     68                                ;
     69                        }
     70                });
     71        });
    372
    473        function check_pass_strength() {
    574                var pass1 = $('#pass1').val(), pass2 = $('#pass2').val(), strength;
  • src/wp-admin/user-edit.php

    diff --git src/wp-admin/user-edit.php src/wp-admin/user-edit.php
    index 6ac4a28..22ebda3 100644
    if ( $show_password_fields ) : 
    457457        <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
    458458        <td>
    459459                <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                <button type="button" class="button button-secondary wp-generate-pw hide-if-no-js"><?php _e( 'Generate new password' ); ?></button>
     461                <div class="wp-pwd hide-if-js">
     462                <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" /> <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0">
     463                        <span class="dashicons dashicons-visibility"></span>
     464                        <span class="text">hide</span>
     465                </button>
     466                <div style="display:none" id="pass-strength-result"></div>
     467                </div>
    462468        </td>
    463469</tr>
    464 <tr class="user-pass2-wrap">
     470<tr class="user-pass2-wrap hide-if-js">
    465471        <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
    466472        <td>
    467         <input name="pass2" type="password" id="pass2" class="regular-text" size="16" value="" autocomplete="off" />
     473        <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
    468474        <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>
    472475        </td>
    473476</tr>
    474477<?php endif; ?>
    475478
    476479<?php
    477 // This is a temporary hook for WordPress 4.3 development. Do not use it or document it.
    478 do_action( '__temp_password_field', $profileuser );
    479 ?>
    480 
    481 <?php
    482480if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
    483481        <tr class="user-sessions-wrap hide-if-no-js">
    484482                <th>&nbsp;</th>
  • src/wp-includes/default-constants.php

    diff --git src/wp-includes/default-constants.php src/wp-includes/default-constants.php
    index 734509a..1e1a35b 100644
    function wp_initial_constants() { 
    8080        if ( !defined('SHORTINIT') )
    8181                define('SHORTINIT', false);
    8282
     83        // Constants for features added to WP that should short-circuit their plugin implementations
     84        define( 'WP_FEATURE_BETTER_PASSWORDS', true );
     85
    8386        // Constants for expressing human-readable intervals
    8487        // in their respective number of seconds.
    8588        define( 'MINUTE_IN_SECONDS', 60 );
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index 5ed1db7..333eb99 100644
    function wp_default_scripts( &$scripts ) { 
    344344
    345345        $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 );
    346346        did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
    347                 'empty' => __('Strength indicator'),
     347                'empty' => __('&nbsp;'),
    348348                'short' => __('Very weak'),
    349349                'bad' => __('Weak'),
    350350                /* translators: password strength */