[wp-trac] [WordPress Trac] #44212: Add a new helper function for comma- or space-separated lists
WordPress Trac
noreply at wordpress.org
Thu May 24 14:32:51 UTC 2018
#44212: Add a new helper function for comma- or space-separated lists
--------------------------------------+------------------------------
Reporter: keesiemeijer | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Comment (by keesiemeijer):
In [attachment:44212.2.patch] the function `wp_parse_list()` is introduced
and is used by `wp_parse_id_list()` and `wp_parse_slug_list()`.
With this function it now removes the empty values returned by
`preg_split()`. You can also remove all the values that equal to false by
setting the `$format` parameter to 'filter_false'. We could use this
filter for `wp_parse_id_list()` as IDs are not supposed to have a value of
0. I've left it as is for back compatibility.
The other instances where `preg_split()` is used with the same regex
should get their own ticket for replacing it with `wp_parse_list()`. This
is because sometimes it's expected to have an empty value for empty
strings.
{{{
array(
0 => ''
)
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44212#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list