Opened 9 years ago
Closed 9 years ago
#41261 closed enhancement (fixed)
Ensure list table column titles are "clean" when reused in the Screen Options
| Reported by: | afercia | Owned by: | afercia |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9 |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-screenshots has-patch |
| Cc: | Focuses: |
Description
The list table column "titles" are then reused (except for some "special" columns) in the Screen Option tabs, as labels for the Columns checkboxes. Ideally, the column titles should be just plain text. However, even WordPress uses some HTML for the Comments column title, in order to have a nice icon with some screen-reader-text in the table header:
The Comments "display name" gets later cleaned up in a couple places:
- for the Screen Options, with a hardcoded conditional, see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-screen.php?rev=40800&marks=1088#L1062
- for the
data-colnameattribute used in the responsive view, usingwp_strip_all_tags(), see https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-list-table.php?rev=40960&marks=1282#L1267
Plugins might want to do the same thing WordPress does for the Comments column and use icons/HTML for their custom column titles. For example:
In this case, while any HTML gets stripped out for the data-colname attribute, there's no easy way I can think of to clean up the title for the Screen Options checkboxes. Maybe worth considering a more solid and standardized way to ensure column titles can use custom HTML but also be cleaned up for later reuse in other places. Not sure what the best option would be. There are probably a few different ones:
- introduce a standardized way to use some visually hidden (screen-reader-text) title for the columns plus HTML to be cleaned up later; this could also be done in an accessible way, hiding the HTML content with aria-hidden (or providing an option for that)
- introduce a filter somewhere to clean up the column titles
- just use
wp_strip_all_tags()inWP_Screen->render_list_table_columns_preferences()instead of the special case for the Comments column
Any thoughts welcome!
Attachments (1)
Change History (5)
#1
in reply to: ↑ description
@
9 years ago
#2
@
9 years ago
Worth noting that also the Users table uses wp_strip_all_tags() even if the default column titles used there don't contain HTML. See https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-users-list-table.php?rev=40956&marks=461#L448
Added in [33016]. See also [33270] for some related refactoring of the list tables.
#3
@
9 years ago
- Keywords has-patch added
- Milestone Awaiting Review → 4.9
- Owner set to
- Status new → assigned
41261.diff takes the simplest approach, using wp_strip_all_tags().
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)


Replying to afercia:
Seems good to me, would be consistent with what we're doing for
data-colnameinWP_List_Table::single_row_columns().