Skip to content

Commit 850940a

Browse files
committed
Users: Show a Super Admin label next to Super Admins on all user listing screens when the current user can manage network users.
Fixes #41165 git-svn-id: https://develop.svn.wordpress.org/trunk@41150 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 765445e commit 850940a

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/wp-admin/includes/class-wp-ms-users-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public function column_username( $user ) {
243243

244244
?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
245245
if ( in_array( $user->user_login, $super_admins ) ) {
246-
echo ' - ' . __( 'Super Admin' );
246+
echo ' &mdash; ' . __( 'Super Admin' );
247247
}
248248
?></strong>
249249
<?php

src/wp-admin/includes/class-wp-users-list-table.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,16 +405,24 @@ public function single_row( $user_object, $style = '', $role = '', $numposts = 0
405405
// Set up the hover actions for this user
406406
$actions = array();
407407
$checkbox = '';
408+
$super_admin = '';
409+
410+
if ( is_multisite() && current_user_can( 'manage_network_users' ) ) {
411+
if ( in_array( $user_object->user_login, get_super_admins(), true ) ) {
412+
$super_admin = ' &mdash; ' . __( 'Super Admin' );
413+
}
414+
}
415+
408416
// Check if the user for this row is editable
409417
if ( current_user_can( 'list_users' ) ) {
410418
// Set up the user editing link
411419
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) );
412420

413421
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
414-
$edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
422+
$edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
415423
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
416424
} else {
417-
$edit = "<strong>$user_object->user_login</strong><br />";
425+
$edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
418426
}
419427

420428
if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) )
@@ -453,7 +461,7 @@ public function single_row( $user_object, $style = '', $role = '', $numposts = 0
453461
. "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='{$role_classes}' value='{$user_object->ID}' />";
454462

455463
} else {
456-
$edit = '<strong>' . $user_object->user_login . '</strong>';
464+
$edit = "<strong>{$user_object->user_login}{$super_admin}</strong>";
457465
}
458466
$avatar = get_avatar( $user_object->ID, 32 );
459467

0 commit comments

Comments
 (0)