Users: Add id="user-{ID}" to rows on WP_MS_Users_List_Table#11600
Users: Add id="user-{ID}" to rows on WP_MS_Users_List_Table#11600dd32 wants to merge 1 commit intoWordPress:trunkfrom
id="user-{ID}" to rows on WP_MS_Users_List_Table#11600Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Brings the network Users list in line with `WP_Users_List_Table::single_row()`,
which has always emitted `<tr id="user-{ID}">`. Without a row id, plugin and
assistive-tech code that targets specific rows has to fall back to walking
from the bulk-action checkbox (`#blog_{ID}`) up via `.closest('tr')`.
Additive: existing consumers of the `class` attribute are unaffected.
See https://core.trac.wordpress.org/ticket/65102.
fbff6cc to
270f96f
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
|
||
| ?> | ||
| <tr class="<?php echo trim( $class ); ?>"> | ||
| <tr id="user-<?php echo (int) $user->ID; ?>" class="<?php echo trim( $class ); ?>"> |
There was a problem hiding this comment.
Casting here not necessary here
There was a problem hiding this comment.
It doesn't hurt though. Since WP_User::$ID doesn't have a PHP property type specified, technically someone could populate a $user->ID = '" onclick="alert(1)'.
Trac ticket: https://core.trac.wordpress.org/ticket/65102
Summary
WP_Users_List_Table::single_row()(per-sitewp-admin/users.php) renders each user row withid="user-{ID}".WP_MS_Users_List_Table::display_rows()(networkwp-admin/network/users.php) does not — it emits<tr class="…">with no row id at all.This one-line change brings the network list in line with the per-site list.
Why
Without a row id, plugin and assistive-tech code that decorates / anchors / focuses specific user rows on the network screen has to fall back to finding the bulk-action checkbox (
#blog_{ID}) and walking.closest('tr')— brittle if the checkbox column is ever moved or renamed.Change
Additive — existing consumers of the
classattribute are unaffected; new consumers gain the same stable hook the per-site list already exposes.Test plan
wp-admin/network/users.phpon a multisite install and confirm each<tr>carriesid="user-{ID}"matching the user's ID.wp-admin/users.phpis unchanged.