Make WordPress Core

Ticket #24633: 24633.19.patch

File 24633.19.patch, 7.4 KB (added by mordauk, 10 years ago)
  • src/wp-admin/admin-ajax.php

     
    6161        'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
    6262        'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
    6363        'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
    64         'parse-media-shortcode'
     64        'parse-media-shortcode', 'generate_password',
    6565);
    6666
    6767// Register core Ajax calls.
  • src/wp-admin/css/forms.css

     
    462462        border-color: #8dff1c;
    463463}
    464464
    465 .indicator-hint {
    466         padding-top: 8px;
     465#password2 .indicator-hint {
     466        padding: 4px 0 0 220px;
    467467}
    468468
    469469p.search-box {
     
    666666        cursor: pointer;
    667667}
    668668
     669.form-table tr#password td,
     670.form-table tr#password2 td {
     671        padding: 0 10px;
     672}
     673.form-table tr#password2 th,
     674.form-table tr#password th {
     675        padding: 0 10px 20px 0px;
     676}
     677
    669678/*------------------------------------------------------------------------------
    670679  19.0 - Tools
    671680------------------------------------------------------------------------------*/
     
    963972                padding: 0;
    964973                line-height: 2;
    965974        }
     975
     976        #password2 .indicator-hint {
     977                padding-left: 0;
     978        }
    966979}
    967980
    968981@media only screen and (max-width: 768px) {
  • src/wp-admin/includes/ajax-actions.php

     
    27602760                'body' => ob_get_clean()
    27612761        ) );
    27622762}
     2763
     2764/**
     2765 * Generates a password via ajax
     2766 *
     2767 * @since 4.1.0
     2768 */
     2769function wp_ajax_generate_password() {
     2770        wp_die( wp_generate_password( 30 ) );
     2771}
  • src/wp-admin/includes/user.php

     
    174174
    175175        if ( $update ) {
    176176                $user_id = wp_update_user( $user );
     177
     178                // Encourage the user to reset their password
     179                if( ! empty( $_POST['reset_password'] ) ) {
     180                        update_user_option( $user_id, 'default_password_nag', true, true );
     181                }
     182
     183                // Send the new, plaintext password to the user
     184                if( ! empty( $_POST['send_password'] ) ) {
     185                        $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     186                        $message  = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n";
     187                        $message .= sprintf( __( 'Password: %s' ), $pass1 ) . "\r\n";
     188                        $message .= wp_login_url() . "\r\n";
     189
     190                        wp_mail( $user->user_email, sprintf( __( '[%s] Your username and password' ), $blogname ), $message );
     191                }
     192
    177193        } else {
    178194                $user_id = wp_insert_user( $user );
    179195                wp_new_user_notification( $user_id, isset( $_POST['send_password'] ) ? wp_unslash( $pass1 ) : '' );
  • src/wp-admin/js/user-profile.js

     
    3232
    3333        $(document).ready( function() {
    3434                var $colorpicker, $stylesheet, user_id, current_user_id,
    35                         select = $( '#display_name' );
     35                        select = $( '#display_name' ),
    3636
    37                 $('#pass1').val('').keyup( check_pass_strength );
    38                 $('#pass2').val('').keyup( check_pass_strength );
     37                /* Passwords */
     38
     39                /**
     40                 * Add a Generate Password button
     41                 * Add a show password icon to view password when editing own profile
     42                 * @since 4.1.0
     43                 */
     44                $pass1 = $( '#pass1' ),
     45                $pass2 = $( '#pass2' ),
     46                password_repeat = $( '.password-repeat' );
     47
     48                $pass2.val('').keyup( check_pass_strength );
     49
     50                // Handle user entering password
     51                $pass1.val('').on( 'blur', function() {
     52                        check_pass_strength();
     53                        // Ensure fireld type is password
     54                        if ( 'text' === $pass1.attr( 'type' ) ) {
     55                                $pass1.attr( 'type', 'password' );
     56                        }
     57                        if ( 'text' === $pass2.attr( 'type' ) ) {
     58                                $pass2.attr( 'type', 'password' );
     59                        }
     60                });
     61
     62                // Handle the Generate Password button
     63                $( '#generate-password' ).on('click', function() {
     64                        // Send an ajax request to the server to get a new password
     65                        $.post( ajaxurl, { action: 'generate_password' }, function(response) {
     66                                $pass1.val( response ).trigger( 'keyup' );
     67                                $pass2.val( response );
     68                                check_pass_strength();
     69                                $pass1.attr( 'type', 'text' );
     70                                $pass2.attr( 'type', 'text' );
     71                                $pass1.focus().select();
     72                        });
     73                });
     74
    3975                $('#pass-strength-result').show();
     76
     77                /* End Passwords */
     78
    4079                $('.color-palette').click( function() {
    4180                        $(this).siblings('input[name="admin_color"]').prop('checked', true);
    4281                });
  • src/wp-admin/user-edit.php

     
    458458<tr id="password" class="user-pass1-wrap">
    459459        <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
    460460        <td>
    461                 <input class="hidden" value=" " /><!-- #24364 workaround -->
    462                 <input type="password" name="pass1" id="pass1" class="regular-text" size="16" value="" autocomplete="off" />
    463                 <p class="description"><?php _e( 'If you would like to change the password type a new one. Otherwise leave this blank.' ); ?></p>
     461                <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" />
     462                <input type="button" name="generate-password" id="generate-password" value="<?php _e( 'Generate Password' ); ?>" class="button hide-if-no-js" />
    464463        </td>
    465464</tr>
    466 <tr class="user-pass2-wrap">
    467         <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
     465<tr id="password2" class="user-pass2-wrap">
     466        <th><label class="password-repeat" for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
    468467        <td>
    469         <input name="pass2" type="password" id="pass2" class="regular-text" size="16" value="" autocomplete="off" />
    470         <p class="description"><?php _e( 'Type your new password again.' ); ?></p>
    471         <br />
    472         <div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div>
    473         <p class="description indicator-hint"><?php echo _wp_get_password_hint(); ?></p>
     468                <div class="password-repeat">
     469                        <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
     470                        <br />
     471                        <div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div>
     472                        <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 ! " ? $ % ^ &amp; ).' ); ?></p>
     473                </div>
     474                <p class="description"><?php _e( 'If you would like to change the password type or generate a new one. Otherwise leave this blank.' ); ?></p>
     475                <?php if( ! IS_PROFILE_PAGE ) { ?>
     476                <p class="hide-if-no-js">
     477                        <label for="send_password">
     478                                <input type="checkbox" name="send_password" id="send_password" value="1" /> <?php _e( 'Send this password to the user by email.' ); ?>
     479                        </label>
     480                        <br />
     481                        <label for="reset_password">
     482                                <input type="checkbox" name="reset_password" id="reset_password" value="1" /> <?php _e( 'Encourage the user to change their password, once logged in.' ); ?>
     483                        </label>
     484                </p>
     485                <?php } ?>
    474486        </td>
    475487</tr>
    476488<?php endif; ?>