Make WordPress Core


Ignore:
Timestamp:
10/31/2016 11:05:37 AM (8 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r39049 r39055  
    11971197            }
    11981198
    1199             $terms  = array_map( 'absint', $request[ $base ] );
    1200             $result = wp_set_object_terms( $post_id, $terms, $taxonomy->name );
     1199            $result = wp_set_object_terms( $post_id, $request[ $base ], $taxonomy->name );
    12011200
    12021201            if ( is_wp_error( $result ) ) {
     
    19661965                    'type'    => 'integer',
    19671966                ),
     1967                'arg_options' => array(
     1968                    'sanitize_callback' => 'wp_parse_id_list',
     1969                ),
    19681970                'context'     => array( 'view', 'edit' ),
    19691971            );
     
    19711973                'description' => sprintf( __( 'The terms in the %s taxonomy that should not be assigned to the object.' ), $taxonomy->name ),
    19721974                'type'        => 'array',
     1975                'items'       => array(
     1976                    'type'    => 'integer',
     1977                ),
     1978                'arg_options' => array(
     1979                    'sanitize_callback' => 'wp_parse_id_list',
     1980                ),
    19731981                'context'     => array( 'view', 'edit' ),
    19741982            );
Note: See TracChangeset for help on using the changeset viewer.