Make WordPress Core

Changeset 53501


Ignore:
Timestamp:
06/14/2022 02:41:10 PM (21 months ago)
Author:
SergeyBiryukov
Message:

I18N: Use a translatable string for displaying a user's first name and last name.

That allows locales to switch the order of the first name and last name, should they prefer to do so.

The string was previously used in wp_insert_user() and is now reused in other places for consistency:

  • WP_MS_Users_List_Table::column_name()
  • WP_Users_List_Table::column_name()​
  • wp_list_authors()
  • wp_list_users()

Note: This also removes the wp_list_author_full_name filter, introduced for the same purpose in wp_list_authors(), as redundant for now.

Follow-up to [53486].

See #17025.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r52584 r53501  
    303303    public function column_name( $user ) {
    304304        if ( $user->first_name && $user->last_name ) {
    305             echo "$user->first_name $user->last_name";
     305            printf(
     306                /* translators: 1: User's first name, 2: Last name. */
     307                _x( '%1$s %2$s', 'Display name based on first name and last name' ),
     308                $user->first_name,
     309                $user->last_name
     310            );
    306311        } elseif ( $user->first_name ) {
    307312            echo $user->first_name;
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r53011 r53501  
    569569                    case 'name':
    570570                        if ( $user_object->first_name && $user_object->last_name ) {
    571                             $r .= "$user_object->first_name $user_object->last_name";
     571                            $r .= sprintf(
     572                                /* translators: 1: User's first name, 2: Last name. */
     573                                _x( '%1$s %2$s', 'Display name based on first name and last name' ),
     574                                $user_object->first_name,
     575                                $user_object->last_name
     576                            );
    572577                        } elseif ( $user_object->first_name ) {
    573578                            $r .= $user_object->first_name;
  • trunk/src/wp-includes/author-template.php

    r53486 r53501  
    477477
    478478        if ( $args['show_fullname'] && $author->first_name && $author->last_name ) {
    479 
    480             $full_name = $author->first_name . ' ' . $author->last_name;
    481 
    482             /**
    483              * Filters the author's full name.
    484              *
    485              * @since 6.1.0
    486              *
    487              * @param string $full_name Full Name of the author. Default: The author's first name
    488              *                          and last name, separated by a space.
    489              * @param object $author    Author object.
    490              */
    491              $name = apply_filters( 'wp_list_author_full_name', $full_name, $author );
    492 
     479            $name = sprintf(
     480                /* translators: 1: User's first name, 2: Last name. */
     481                _x( '%1$s %2$s', 'Display name based on first name and last name' ),
     482                $author->first_name,
     483                $author->last_name
     484            );
    493485        } else {
    494486            $name = $author->display_name;
  • trunk/src/wp-includes/user.php

    r53458 r53501  
    828828
    829829        if ( $args['show_fullname'] && '' !== $user->first_name && '' !== $user->last_name ) {
    830             $name = "$user->first_name $user->last_name";
     830            $name = sprintf(
     831                /* translators: 1: User's first name, 2: Last name. */
     832                _x( '%1$s %2$s', 'Display name based on first name and last name' ),
     833                $user->first_name,
     834                $user->last_name
     835            );
    831836        } else {
    832837            $name = $user->display_name;
     
    22432248            $display_name = $user_login;
    22442249        } elseif ( $meta['first_name'] && $meta['last_name'] ) {
    2245             /* translators: 1: User's first name, 2: Last name. */
    2246             $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'] );
     2250            $display_name = sprintf(
     2251                /* translators: 1: User's first name, 2: Last name. */
     2252                _x( '%1$s %2$s', 'Display name based on first name and last name' ),
     2253                $meta['first_name'],
     2254                $meta['last_name']
     2255            );
    22472256        } elseif ( $meta['first_name'] ) {
    22482257            $display_name = $meta['first_name'];
Note: See TracChangeset for help on using the changeset viewer.