[wp-trac] [WordPress Trac] #40473: Allow array of sanitize_callback parameters in register_rest_route()
WordPress Trac
noreply at wordpress.org
Tue Apr 18 00:51:22 UTC 2017
#40473: Allow array of sanitize_callback parameters in register_rest_route()
-------------------------+-----------------------------
Reporter: GunGeekATX | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
By allowing an array of sanitize callbacks when registering a route, we
can easily add support for multiple sanitize functions. For example,
registering with the following callbacks would allow a color to be trimmed
and then sanitized.
{{{
'sanitize_callback' => array(
'normalize_whitespace',
'sanitize_hex_color_no_hash',
),
}}}
Example: http://src.wordpress-develop.dev/wp-
json/test/multisanitize?color=%20ff0000
Another example may be someone parsing post IDs from a list, then
sanitizing it down to valid post IDs with a custom function.
{{{
'sanitize_callback' => array(
'wp_parse_id_list',
'sanitize_post_ids',
),
}}}
The attached patch adds support for multiple sanitize_callback handlers.
The same logic could be applied to validate_callback handlers.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40473>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list