From 3f74637dfebf87f28c85e96ad14f8273988b90e4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 14 Jun 2022 14:43:12 +0000 Subject: [PATCH] I18N: Use a translatable string for displaying a user's first name and last name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Built from https://develop.svn.wordpress.org/trunk@53501 git-svn-id: http://core.svn.wordpress.org/trunk@53090 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-ms-users-list-table.php | 7 ++++++- .../includes/class-wp-users-list-table.php | 7 ++++++- wp-includes/author-template.php | 20 ++++++------------- wp-includes/user.php | 15 +++++++++++--- wp-includes/version.php | 2 +- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php index be72876c36..d2ba7c72b5 100644 --- a/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/wp-admin/includes/class-wp-ms-users-list-table.php @@ -302,7 +302,12 @@ class WP_MS_Users_List_Table extends WP_List_Table { */ public function column_name( $user ) { if ( $user->first_name && $user->last_name ) { - echo "$user->first_name $user->last_name"; + printf( + /* translators: 1: User's first name, 2: Last name. */ + _x( '%1$s %2$s', 'Display name based on first name and last name' ), + $user->first_name, + $user->last_name + ); } elseif ( $user->first_name ) { echo $user->first_name; } elseif ( $user->last_name ) { diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php index 1955e09fbc..19921ae5bc 100644 --- a/wp-admin/includes/class-wp-users-list-table.php +++ b/wp-admin/includes/class-wp-users-list-table.php @@ -568,7 +568,12 @@ class WP_Users_List_Table extends WP_List_Table { break; case 'name': if ( $user_object->first_name && $user_object->last_name ) { - $r .= "$user_object->first_name $user_object->last_name"; + $r .= sprintf( + /* translators: 1: User's first name, 2: Last name. */ + _x( '%1$s %2$s', 'Display name based on first name and last name' ), + $user_object->first_name, + $user_object->last_name + ); } elseif ( $user_object->first_name ) { $r .= $user_object->first_name; } elseif ( $user_object->last_name ) { diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index c71ef7134f..b4ad2906e2 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -476,20 +476,12 @@ function wp_list_authors( $args = '' ) { } if ( $args['show_fullname'] && $author->first_name && $author->last_name ) { - - $full_name = $author->first_name . ' ' . $author->last_name; - - /** - * Filters the author's full name. - * - * @since 6.1.0 - * - * @param string $full_name Full Name of the author. Default: The author's first name - * and last name, separated by a space. - * @param object $author Author object. - */ - $name = apply_filters( 'wp_list_author_full_name', $full_name, $author ); - + $name = sprintf( + /* translators: 1: User's first name, 2: Last name. */ + _x( '%1$s %2$s', 'Display name based on first name and last name' ), + $author->first_name, + $author->last_name + ); } else { $name = $author->display_name; } diff --git a/wp-includes/user.php b/wp-includes/user.php index 1e976f182e..3c0f917bbc 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -827,7 +827,12 @@ function wp_list_users( $args = array() ) { } if ( $args['show_fullname'] && '' !== $user->first_name && '' !== $user->last_name ) { - $name = "$user->first_name $user->last_name"; + $name = sprintf( + /* translators: 1: User's first name, 2: Last name. */ + _x( '%1$s %2$s', 'Display name based on first name and last name' ), + $user->first_name, + $user->last_name + ); } else { $name = $user->display_name; } @@ -2242,8 +2247,12 @@ function wp_insert_user( $userdata ) { if ( $update ) { $display_name = $user_login; } elseif ( $meta['first_name'] && $meta['last_name'] ) { - /* translators: 1: User's first name, 2: Last name. */ - $display_name = sprintf( _x( '%1$s %2$s', 'Display name based on first name and last name' ), $meta['first_name'], $meta['last_name'] ); + $display_name = sprintf( + /* translators: 1: User's first name, 2: Last name. */ + _x( '%1$s %2$s', 'Display name based on first name and last name' ), + $meta['first_name'], + $meta['last_name'] + ); } elseif ( $meta['first_name'] ) { $display_name = $meta['first_name']; } elseif ( $meta['last_name'] ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 868439c597..7c57affcb2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53500'; +$wp_version = '6.1-alpha-53501'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.