On this page
WP_MS_Users_List_Table::column_username( WP_User $user )
Handles the username column output.
Parameters
Source
File: wp-admin/includes/class-wp-ms-users-list-table.php. View all references
public function column_username( $user ) {
$super_admins = get_super_admins();
$avatar = get_avatar( $user->user_email, 32 );
echo $avatar;
if ( current_user_can( 'edit_user', $user->ID ) ) {
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
$edit = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
} else {
$edit = $user->user_login;
}
?>
<strong>
<?php
echo $edit;
if ( in_array( $user->user_login, $super_admins, true ) ) {
echo ' — ' . __( 'Super Admin' );
}
?>
</strong>
<?php
}
Related
Uses
| Uses | Description |
|---|---|
| get_super_admins() wp-includes/capabilities.php | Retrieves a list of super admins. |
| get_avatar() wp-includes/pluggable.php | Retrieves the avatar |
| get_edit_user_link() wp-includes/link-template.php | Retrieves the edit user link. |
| current_user_can() wp-includes/capabilities.php | Returns whether the current user has the specified capability. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| wp_unslash() wp-includes/formatting.php | Removes slashes from a string or recursively removes slashes from strings within an array. |
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
| add_query_arg() wp-includes/functions.php | Retrieves a modified URL query string. |
Changelog
| Version | Description |
|---|---|
| 4.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_ms_users_list_table/column_username