REST API: Allow a CSV list of term IDs to be passed to `/posts`.

[39048] added CSV support to array types, this change explicitly parses term lists as IDs, and adds tests.

Props timmydcrawford, pento.
Fixes #38553.


Built from https://develop.svn.wordpress.org/trunk@39055


git-svn-id: http://core.svn.wordpress.org/trunk@38997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2016-10-31 11:06:31 +00:00
parent 33b8bb3cf3
commit 9862543913
2 changed files with 11 additions and 3 deletions

View File

@ -1196,8 +1196,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
continue;
}
$terms = array_map( 'absint', $request[ $base ] );
$result = wp_set_object_terms( $post_id, $terms, $taxonomy->name );
$result = wp_set_object_terms( $post_id, $request[ $base ], $taxonomy->name );
if ( is_wp_error( $result ) ) {
return $result;
@ -1965,11 +1964,20 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
'items' => array(
'type' => 'integer',
),
'arg_options' => array(
'sanitize_callback' => 'wp_parse_id_list',
),
'context' => array( 'view', 'edit' ),
);
$schema['properties'][ $base . '_exclude' ] = array(
'description' => sprintf( __( 'The terms in the %s taxonomy that should not be assigned to the object.' ), $taxonomy->name ),
'type' => 'array',
'items' => array(
'type' => 'integer',
),
'arg_options' => array(
'sanitize_callback' => 'wp_parse_id_list',
),
'context' => array( 'view', 'edit' ),
);
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta1-39054';
$wp_version = '4.7-beta1-39055';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.