From 9862543913ab41aa1d4773b92e1db7f9ce9700ec Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 31 Oct 2016 11:06:31 +0000 Subject: [PATCH] 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 --- .../endpoints/class-wp-rest-posts-controller.php | 12 ++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index ad55ac748b..e5d623705b 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -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' ), ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 3beb593e43..cd8bb46c4b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.