[wp-trac] [WordPress Trac] #35312: Support for transforming REST API request arguments
WordPress Trac
noreply at wordpress.org
Tue Jan 5 00:24:55 UTC 2016
#35312: Support for transforming REST API request arguments
-----------------------------+----------------------------
Reporter: danielbachhuber | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: REST API | Version:
Severity: normal | Keywords: needs-patch
Focuses: |
-----------------------------+----------------------------
The REST API controllers have a fair amount of procedural transformation
code like this:
{{{
/**
* Prepend internal property prefix to query parameters to match our
response fields.
*
* @param string $query_param
* @return string $normalized
*/
protected function normalize_query_param( $query_param ) {
$prefix = 'comment_';
switch ( $query_param ) {
case 'id':
$normalized = $prefix . 'ID';
break;
case 'post':
$normalized = $prefix . 'post_ID';
break;
case 'parent':
$normalized = $prefix . 'parent';
break;
default:
$normalized = $prefix . $query_param;
break;
}
return $normalized;
}
}}}
What if I could just define some `transform_to` argument when registering
my request arguments, and have the request data transformed before it gets
to my callback?
Originally https://github.com/WP-API/WP-API/issues/1236
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35312>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list