WordPress.org

Make WordPress Core

Changeset 40657


Ignore:
Timestamp:
05/12/2017 08:05:07 PM (13 months ago)
Author:
adamsilverstein
Message:

Users: Update name in toolbar when changing user display name.

When changing the user name in Users -> Your Profile, update the name displayed in the toolbar dynamically using JavaScript.

Props menakas, lukecavanagh, maguiar.
Fixes #40342.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/user-profile.js

    r38494 r40657  
    329329    $(document).ready( function() {
    330330        var $colorpicker, $stylesheet, user_id, current_user_id,
    331             select = $( '#display_name' );
     331            select       = $( '#display_name' ),
     332            current_name = select.val(),
     333            greeting     = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
    332334
    333335        $('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength );
     
    371373                });
    372374            });
     375
     376            /**
     377             * Replaces "Howdy, *" in the admin toolbar whenever the display name dropdown is updated for one's own profile.
     378             */
     379            select.on( 'change', function() {
     380                if ( user_id !== current_user_id ) {
     381                    return;
     382                }
     383
     384                var display_name = $.trim( this.value ) || current_name;
     385
     386                greeting.text( display_name );
     387            } );
    373388        }
    374389
  • trunk/src/wp-includes/admin-bar.php

    r40581 r40657  
    215215    $avatar = get_avatar( $user_id, 26 );
    216216    /* translators: %s: current user's display name */
    217     $howdy  = sprintf( __( 'Howdy, %s' ), $current_user->display_name );
     217    $howdy  = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $current_user->display_name . '</span>' );
    218218    $class  = empty( $avatar ) ? '' : 'with-avatar';
    219219
Note: See TracChangeset for help on using the changeset viewer.