[wp-trac] [WordPress Trac] #41146: Add filter for a site's class (WP_MS_Users_List_Table)
WordPress Trac
noreply at wordpress.org
Mon Mar 11 16:06:50 UTC 2019
#41146: Add filter for a site's class (WP_MS_Users_List_Table)
--------------------------------+-----------------------------
Reporter: kraftbj | Owner: kraftbj
Type: enhancement | Status: accepted
Priority: normal | Milestone: 5.2
Component: Networks and Sites | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: administration
--------------------------------+-----------------------------
Comment (by johnjamesjacoby):
I am +1 to this change.
I think the patch is acceptable as is (given the current standard of how
core handles this elsewhere.)
----
That said, here is what I wish core would enforce (in more places than
this):
* The `ms_user_list_site_class` filter may not return an array, but the
line of code immediately after the filter is applied trusts that it will
be by using `array_unique()` and `implode()` on it. ''I'd like to cast the
results of `apply_filters()` as an `(array)` to avoid errors''.
* If `$site_classes` is empty, a single space will be used in the class
attribute. ''This is not valid.''
* `sanitize_html_class()` exists, but isn't used in so many places. Right
now, `$site_classes` could include invalid strings, or quotes that break
out of the HTML attribute entirely. ''I'd like for each class in the array
to be properly sanitized''.
* `esc_attr( implode( ' ', array_unique( $site_classes ) ) )` is 3 nested,
inline, function calls; it ''feels'' excessive to me (when not inside a
dedicated helper/convenience function.) ''Core does not have a standard
for this, but 2 feels like the max before it gets too busy for the logical
order of things to be clearly understood.''
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41146#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list