<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[50157] trunk: REST API: Allow for the posts endpoint include/exclude terms query to `include_children`.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50157">50157</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50157","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>TimothyBlynJacobs</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-02-02 19:23:08 +0000 (Tue, 02 Feb 2021)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>REST API: Allow for the posts endpoint include/exclude terms query to `include_children`.

For example the `categories` or `categories_exclude` parameters can now optionally accept an object with a `terms` property that accepts the list of term ids and a new `include_children` property which controls the Tax Query `include_children` field.

Props jason_the_adams, jnylen0, birgire, dlh.
Fixes <a href="https://core.trac.wordpress.org/ticket/39494">#39494</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpostscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestpostscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php</a></li>
<li><a href="#trunktestsqunitfixtureswpapigeneratedjs">trunk/tests/qunit/fixtures/wp-api-generated.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpostscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php       2021-02-02 19:01:18 UTC (rev 50156)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2021-02-02 19:23:08 UTC (rev 50157)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -280,36 +280,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $args = $this->prepare_tax_query( $args, $request );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! empty( $request['tax_relation'] ) ) {
-                       $args['tax_query'] = array( 'relation' => $request['tax_relation'] );
-               }
-
-               foreach ( $taxonomies as $taxonomy ) {
-                       $base        = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
-                       $tax_exclude = $base . '_exclude';
-
-                       if ( ! empty( $request[ $base ] ) ) {
-                               $args['tax_query'][] = array(
-                                       'taxonomy'         => $taxonomy->name,
-                                       'field'            => 'term_id',
-                                       'terms'            => $request[ $base ],
-                                       'include_children' => false,
-                               );
-                       }
-
-                       if ( ! empty( $request[ $tax_exclude ] ) ) {
-                               $args['tax_query'][] = array(
-                                       'taxonomy'         => $taxonomy->name,
-                                       'field'            => 'term_id',
-                                       'terms'            => $request[ $tax_exclude ],
-                                       'include_children' => false,
-                                       'operator'         => 'NOT IN',
-                               );
-                       }
-               }
-
</del><span class="cx" style="display: block; padding: 0 10px">                 // Force the post_type argument, since it's not a user input variable.
</span><span class="cx" style="display: block; padding: 0 10px">                $args['post_type'] = $this->post_type;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2799,40 +2771,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'sanitize_callback' => array( $this, 'sanitize_post_statuses' ),
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $query_params = $this->prepare_taxonomy_limit_schema( $query_params );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! empty( $taxonomies ) ) {
-                       $query_params['tax_relation'] = array(
-                               'description' => __( 'Limit result set based on relationship between multiple taxonomies.' ),
-                               'type'        => 'string',
-                               'enum'        => array( 'AND', 'OR' ),
-                       );
-               }
-
-               foreach ( $taxonomies as $taxonomy ) {
-                       $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
-
-                       $query_params[ $base ] = array(
-                               /* translators: %s: Taxonomy name. */
-                               'description' => sprintf( __( 'Limit result set to all items that have the specified term assigned in the %s taxonomy.' ), $base ),
-                               'type'        => 'array',
-                               'items'       => array(
-                                       'type' => 'integer',
-                               ),
-                               'default'     => array(),
-                       );
-
-                       $query_params[ $base . '_exclude' ] = array(
-                               /* translators: %s: Taxonomy name. */
-                               'description' => sprintf( __( 'Limit result set to all items except those that have the specified term assigned in the %s taxonomy.' ), $base ),
-                               'type'        => 'array',
-                               'items'       => array(
-                                       'type' => 'integer',
-                               ),
-                               'default'     => array(),
-                       );
-               }
-
</del><span class="cx" style="display: block; padding: 0 10px">                 if ( 'post' === $this->post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $query_params['sticky'] = array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'description' => __( 'Limit result set to items that are sticky.' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2899,4 +2839,168 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                return $statuses;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Prepares the 'tax_query' for a collection of posts.
+        *
+        * @since 5.7.0
+        *
+        * @param array           $args    WP_Query arguments.
+        * @param WP_REST_Request $request Full details about the request.
+        * @return array Updated query arguments.
+        */
+       private function prepare_tax_query( array $args, WP_REST_Request $request ) {
+               $relation = $request['tax_relation'];
+
+               if ( $relation ) {
+                       $args['tax_query'] = array( 'relation' => $relation );
+               }
+
+               $taxonomies = wp_list_filter(
+                       get_object_taxonomies( $this->post_type, 'objects' ),
+                       array( 'show_in_rest' => true )
+               );
+
+               foreach ( $taxonomies as $taxonomy ) {
+                       $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
+
+                       $tax_include = $request[ $base ];
+                       $tax_exclude = $request[ $base . '_exclude' ];
+
+                       if ( $tax_include ) {
+                               $terms            = array();
+                               $include_children = false;
+
+                               if ( rest_is_array( $tax_include ) ) {
+                                       $terms = $tax_include;
+                               } elseif ( rest_is_object( $tax_include ) ) {
+                                       $terms            = empty( $tax_include['terms'] ) ? array() : $tax_include['terms'];
+                                       $include_children = ! empty( $tax_include['include_children'] );
+                               }
+
+                               if ( $terms ) {
+                                       $args['tax_query'][] = array(
+                                               'taxonomy'         => $taxonomy->name,
+                                               'field'            => 'term_id',
+                                               'terms'            => $terms,
+                                               'include_children' => $include_children,
+                                       );
+                               }
+                       }
+
+                       if ( $tax_exclude ) {
+                               $terms            = array();
+                               $include_children = false;
+
+                               if ( rest_is_array( $tax_exclude ) ) {
+                                       $terms = $tax_exclude;
+                               } elseif ( rest_is_object( $tax_exclude ) ) {
+                                       $terms            = empty( $tax_exclude['terms'] ) ? array() : $tax_exclude['terms'];
+                                       $include_children = ! empty( $tax_exclude['include_children'] );
+                               }
+
+                               if ( $terms ) {
+                                       $args['tax_query'][] = array(
+                                               'taxonomy'         => $taxonomy->name,
+                                               'field'            => 'term_id',
+                                               'terms'            => $terms,
+                                               'include_children' => $include_children,
+                                               'operator'         => 'NOT IN',
+                                       );
+                               }
+                       }
+               }
+
+               return $args;
+       }
+
+       /**
+        * Prepares the collection schema for including and excluding items by terms.
+        *
+        * @since 5.7.0
+        *
+        * @param array $query_params Collection schema.
+        * @return array Updated schema.
+        */
+       private function prepare_taxonomy_limit_schema( array $query_params ) {
+               $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
+
+               if ( ! $taxonomies ) {
+                       return $query_params;
+               }
+
+               $query_params['tax_relation'] = array(
+                       'description' => __( 'Limit result set based on relationship between multiple taxonomies.' ),
+                       'type'        => 'string',
+                       'enum'        => array( 'AND', 'OR' ),
+               );
+
+               $limit_schema = array(
+                       'type'  => array( 'object', 'array' ),
+                       'oneOf' => array(
+                               array(
+                                       'title'       => __( 'Term ID List' ),
+                                       'description' => __( 'Match terms with the listed IDs.' ),
+                                       'type'        => 'array',
+                                       'items'       => array(
+                                               'type' => 'integer',
+                                       ),
+                               ),
+                               array(
+                                       'title'                => __( 'Term ID Taxonomy Query' ),
+                                       'description'          => __( 'Perform an advanced term query.' ),
+                                       'type'                 => 'object',
+                                       'properties'           => array(
+                                               'terms'            => array(
+                                                       'description' => __( 'Term IDs.' ),
+                                                       'type'        => 'array',
+                                                       'items'       => array(
+                                                               'type' => 'integer',
+                                                       ),
+                                                       'default'     => array(),
+                                               ),
+                                               'include_children' => array(
+                                                       'description' => __( 'Whether to include child terms in the terms limiting the result set.' ),
+                                                       'type'        => 'boolean',
+                                                       'default'     => false,
+                                               ),
+                                       ),
+                                       'additionalProperties' => false,
+                               ),
+                       ),
+               );
+
+               $include_schema = array_merge(
+                       array(
+                               /* translators: %s: Taxonomy name. */
+                               'description' => __( 'Limit result set to items with specific terms assigned in the %s taxonomy.' ),
+                       ),
+                       $limit_schema
+               );
+               $exclude_schema = array_merge(
+                       array(
+                               /* translators: %s: Taxonomy name. */
+                               'description' => __( 'Limit result set to items except those with specific terms assigned in the %s taxonomy.' ),
+                       ),
+                       $limit_schema
+               );
+
+               foreach ( $taxonomies as $taxonomy ) {
+                       $base         = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
+                       $base_exclude = $base . '_exclude';
+
+                       $query_params[ $base ]                = $include_schema;
+                       $query_params[ $base ]['description'] = sprintf( $query_params[ $base ]['description'], $base );
+
+                       $query_params[ $base_exclude ]                = $exclude_schema;
+                       $query_params[ $base_exclude ]['description'] = sprintf( $query_params[ $base_exclude ]['description'], $base );
+
+                       if ( ! $taxonomy->hierarchical ) {
+                               unset( $query_params[ $base ]['oneOf'][1]['properties']['include_children'] );
+                               unset( $query_params[ $base_exclude ]['oneOf'][1]['properties']['include_children'] );
+                       }
+               }
+
+               return $query_params;
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestpostscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php      2021-02-02 19:01:18 UTC (rev 50156)
+++ trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php        2021-02-02 19:23:08 UTC (rev 50157)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1116,6 +1116,185 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @ticket 39494
+        */
+       public function test_get_items_with_category_including_children() {
+               $taxonomy = get_taxonomy( 'category' );
+
+               $cat1 = static::factory()->term->create( array( 'taxonomy' => $taxonomy->name ) );
+               $cat2 = static::factory()->term->create(
+                       array(
+                               'taxonomy' => $taxonomy->name,
+                               'parent'   => $cat1,
+                       )
+               );
+
+               $post_ids = array(
+                       static::factory()->post->create(
+                               array(
+                                       'post_status'   => 'publish',
+                                       'post_category' => array( $cat1 ),
+                               )
+                       ),
+                       static::factory()->post->create(
+                               array(
+                                       'post_status'   => 'publish',
+                                       'post_category' => array( $cat2 ),
+                               )
+                       ),
+               );
+
+               $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
+               $request->set_param(
+                       $taxonomy->rest_base,
+                       array(
+                               'terms'            => array( $cat1 ),
+                               'include_children' => true,
+                       )
+               );
+               $response = rest_get_server()->dispatch( $request );
+               $data     = $response->get_data();
+
+               $this->assertEqualSets( $post_ids, array_column( $data, 'id' ) );
+       }
+
+       /**
+        * @ticket 39494
+        */
+       public function test_get_items_with_category_excluding_children() {
+               $taxonomy = get_taxonomy( 'category' );
+
+               $cat1 = static::factory()->term->create( array( 'taxonomy' => $taxonomy->name ) );
+               $cat2 = static::factory()->term->create(
+                       array(
+                               'taxonomy' => $taxonomy->name,
+                               'parent'   => $cat1,
+                       )
+               );
+
+               $post_ids = array(
+                       static::factory()->post->create(
+                               array(
+                                       'post_status'   => 'publish',
+                                       'post_category' => array( $cat1 ),
+                               )
+                       ),
+                       static::factory()->post->create(
+                               array(
+                                       'post_status'   => 'publish',
+                                       'post_category' => array( $cat2 ),
+                               )
+                       ),
+               );
+
+               $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
+               $request->set_param(
+                       $taxonomy->rest_base,
+                       array(
+                               'terms'            => array( $cat1 ),
+                               'include_children' => false,
+                       )
+               );
+               $response = rest_get_server()->dispatch( $request );
+               $data     = $response->get_data();
+
+               $this->assertCount( 1, $data );
+               $this->assertEquals( $post_ids[0], $data[0]['id'] );
+       }
+
+       /**
+        * @ticket 39494
+        */
+       public function test_get_items_without_category_or_its_children() {
+               $taxonomy = get_taxonomy( 'category' );
+
+               $cat1 = static::factory()->term->create( array( 'taxonomy' => $taxonomy->name ) );
+               $cat2 = static::factory()->term->create(
+                       array(
+                               'taxonomy' => $taxonomy->name,
+                               'parent'   => $cat1,
+                       )
+               );
+
+               $post_ids = array(
+                       static::factory()->post->create(
+                               array(
+                                       'post_status'   => 'publish',
+                                       'post_category' => array( $cat1 ),
+                               )
+                       ),
+                       static::factory()->post->create(
+                               array(
+                                       'post_status'   => 'publish',
+                                       'post_category' => array( $cat2 ),
+                               )
+                       ),
+               );
+
+               $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
+               $request->set_param(
+                       $taxonomy->rest_base . '_exclude',
+                       array(
+                               'terms'            => array( $cat1 ),
+                               'include_children' => true,
+                       )
+               );
+               $response = rest_get_server()->dispatch( $request );
+               $data     = $response->get_data();
+
+               $this->assertEmpty(
+                       array_intersect(
+                               $post_ids,
+                               array_column( $data, 'id' )
+                       )
+               );
+       }
+
+       /**
+        * @ticket 39494
+        */
+       public function test_get_items_without_category_but_allowing_its_children() {
+               $taxonomy = get_taxonomy( 'category' );
+
+               $cat1 = static::factory()->term->create( array( 'taxonomy' => $taxonomy->name ) );
+               $cat2 = static::factory()->term->create(
+                       array(
+                               'taxonomy' => $taxonomy->name,
+                               'parent'   => $cat1,
+                       )
+               );
+
+               $p1 = static::factory()->post->create(
+                       array(
+                               'post_status'   => 'publish',
+                               'post_category' => array( $cat1 ),
+                       )
+               );
+               $p2 = static::factory()->post->create(
+                       array(
+                               'post_status'   => 'publish',
+                               'post_category' => array( $cat2 ),
+                       )
+               );
+
+               $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
+               $request->set_param(
+                       $taxonomy->rest_base . '_exclude',
+                       array(
+                               'terms'            => array( $cat1 ),
+                               'include_children' => false,
+                       )
+               );
+               $response = rest_get_server()->dispatch( $request );
+               $data     = $response->get_data();
+
+               $found_ids = array_column( $data, 'id' );
+
+               $this->assertNotContains( $p1, $found_ids );
+               $this->assertContains( $p2, $found_ids );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * @ticket 44326
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_get_items_relation_with_no_tax_query() {
</span></span></pre></div>
<a id="trunktestsqunitfixtureswpapigeneratedjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/qunit/fixtures/wp-api-generated.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/qunit/fixtures/wp-api-generated.js    2021-02-02 19:01:18 UTC (rev 50156)
+++ trunk/tests/qunit/fixtures/wp-api-generated.js      2021-02-02 19:23:08 UTC (rev 50157)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -427,39 +427,149 @@
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "categories": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "Limit result set to all items that have the specified term assigned in the categories taxonomy.",
-                            "type": "array",
-                            "items": {
-                                "type": "integer"
-                            },
-                            "default": [],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "Limit result set to items with specific terms assigned in the categories taxonomy.",
+                            "type": [
+                                "object",
+                                "array"
+                            ],
+                            "oneOf": [
+                                {
+                                    "title": "Term ID List",
+                                    "description": "Match terms with the listed IDs.",
+                                    "type": "array",
+                                    "items": {
+                                        "type": "integer"
+                                    }
+                                },
+                                {
+                                    "title": "Term ID Taxonomy Query",
+                                    "description": "Perform an advanced term query.",
+                                    "type": "object",
+                                    "properties": {
+                                        "terms": {
+                                            "description": "Term IDs.",
+                                            "type": "array",
+                                            "items": {
+                                                "type": "integer"
+                                            },
+                                            "default": []
+                                        },
+                                        "include_children": {
+                                            "description": "Whether to include child terms in the terms limiting the result set.",
+                                            "type": "boolean",
+                                            "default": false
+                                        }
+                                    },
+                                    "additionalProperties": false
+                                }
+                            ],
</ins><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "categories_exclude": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "Limit result set to all items except those that have the specified term assigned in the categories taxonomy.",
-                            "type": "array",
-                            "items": {
-                                "type": "integer"
-                            },
-                            "default": [],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "Limit result set to items except those with specific terms assigned in the categories taxonomy.",
+                            "type": [
+                                "object",
+                                "array"
+                            ],
+                            "oneOf": [
+                                {
+                                    "title": "Term ID List",
+                                    "description": "Match terms with the listed IDs.",
+                                    "type": "array",
+                                    "items": {
+                                        "type": "integer"
+                                    }
+                                },
+                                {
+                                    "title": "Term ID Taxonomy Query",
+                                    "description": "Perform an advanced term query.",
+                                    "type": "object",
+                                    "properties": {
+                                        "terms": {
+                                            "description": "Term IDs.",
+                                            "type": "array",
+                                            "items": {
+                                                "type": "integer"
+                                            },
+                                            "default": []
+                                        },
+                                        "include_children": {
+                                            "description": "Whether to include child terms in the terms limiting the result set.",
+                                            "type": "boolean",
+                                            "default": false
+                                        }
+                                    },
+                                    "additionalProperties": false
+                                }
+                            ],
</ins><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "tags": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "Limit result set to all items that have the specified term assigned in the tags taxonomy.",
-                            "type": "array",
-                            "items": {
-                                "type": "integer"
-                            },
-                            "default": [],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "Limit result set to items with specific terms assigned in the tags taxonomy.",
+                            "type": [
+                                "object",
+                                "array"
+                            ],
+                            "oneOf": [
+                                {
+                                    "title": "Term ID List",
+                                    "description": "Match terms with the listed IDs.",
+                                    "type": "array",
+                                    "items": {
+                                        "type": "integer"
+                                    }
+                                },
+                                {
+                                    "title": "Term ID Taxonomy Query",
+                                    "description": "Perform an advanced term query.",
+                                    "type": "object",
+                                    "properties": {
+                                        "terms": {
+                                            "description": "Term IDs.",
+                                            "type": "array",
+                                            "items": {
+                                                "type": "integer"
+                                            },
+                                            "default": []
+                                        }
+                                    },
+                                    "additionalProperties": false
+                                }
+                            ],
</ins><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "tags_exclude": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "Limit result set to all items except those that have the specified term assigned in the tags taxonomy.",
-                            "type": "array",
-                            "items": {
-                                "type": "integer"
-                            },
-                            "default": [],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "Limit result set to items except those with specific terms assigned in the tags taxonomy.",
+                            "type": [
+                                "object",
+                                "array"
+                            ],
+                            "oneOf": [
+                                {
+                                    "title": "Term ID List",
+                                    "description": "Match terms with the listed IDs.",
+                                    "type": "array",
+                                    "items": {
+                                        "type": "integer"
+                                    }
+                                },
+                                {
+                                    "title": "Term ID Taxonomy Query",
+                                    "description": "Perform an advanced term query.",
+                                    "type": "object",
+                                    "properties": {
+                                        "terms": {
+                                            "description": "Term IDs.",
+                                            "type": "array",
+                                            "items": {
+                                                "type": "integer"
+                                            },
+                                            "default": []
+                                        }
+                                    },
+                                    "additionalProperties": false
+                                }
+                            ],
</ins><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "sticky": {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3128,8 +3238,95 @@
</span><span class="cx" style="display: block; padding: 0 10px">                         "POST"
</span><span class="cx" style="display: block; padding: 0 10px">                     ],
</span><span class="cx" style="display: block; padding: 0 10px">                     "args": {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        "src": {
+                            "description": "URL to the edited image file.",
+                            "type": "string",
+                            "format": "uri",
+                            "required": true
+                        },
+                        "modifiers": {
+                            "description": "Array of image edits.",
+                            "type": "array",
+                            "minItems": 1,
+                            "items": {
+                                "description": "Image edit.",
+                                "type": "object",
+                                "required": [
+                                    "type",
+                                    "args"
+                                ],
+                                "oneOf": [
+                                    {
+                                        "title": "Rotation",
+                                        "properties": {
+                                            "type": {
+                                                "description": "Rotation type.",
+                                                "type": "string",
+                                                "enum": [
+                                                    "rotate"
+                                                ]
+                                            },
+                                            "args": {
+                                                "description": "Rotation arguments.",
+                                                "type": "object",
+                                                "required": [
+                                                    "angle"
+                                                ],
+                                                "properties": {
+                                                    "angle": {
+                                                        "description": "Angle to rotate clockwise in degrees.",
+                                                        "type": "number"
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    },
+                                    {
+                                        "title": "Crop",
+                                        "properties": {
+                                            "type": {
+                                                "description": "Crop type.",
+                                                "type": "string",
+                                                "enum": [
+                                                    "crop"
+                                                ]
+                                            },
+                                            "args": {
+                                                "description": "Crop arguments.",
+                                                "type": "object",
+                                                "required": [
+                                                    "left",
+                                                    "top",
+                                                    "width",
+                                                    "height"
+                                                ],
+                                                "properties": {
+                                                    "left": {
+                                                        "description": "Horizontal position from the left to begin the crop as a percentage of the image width.",
+                                                        "type": "number"
+                                                    },
+                                                    "top": {
+                                                        "description": "Vertical position from the top to begin the crop as a percentage of the image height.",
+                                                        "type": "number"
+                                                    },
+                                                    "width": {
+                                                        "description": "Width of the crop as a percentage of the image width.",
+                                                        "type": "number"
+                                                    },
+                                                    "height": {
+                                                        "description": "Height of the crop as a percentage of the image height.",
+                                                        "type": "number"
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                ]
+                            },
+                            "required": false
+                        },
</ins><span class="cx" style="display: block; padding: 0 10px">                         "rotation": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "The amount to rotate the image clockwise in degrees.",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "The amount to rotate the image clockwise in degrees. DEPRECATED: Use `modifiers` instead.",
</ins><span class="cx" style="display: block; padding: 0 10px">                             "type": "integer",
</span><span class="cx" style="display: block; padding: 0 10px">                             "minimum": 0,
</span><span class="cx" style="display: block; padding: 0 10px">                             "exclusiveMinimum": true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3138,7 +3335,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "x": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "As a percentage of the image, the x position to start the crop from.",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "As a percentage of the image, the x position to start the crop from. DEPRECATED: Use `modifiers` instead.",
</ins><span class="cx" style="display: block; padding: 0 10px">                             "type": "number",
</span><span class="cx" style="display: block; padding: 0 10px">                             "minimum": 0,
</span><span class="cx" style="display: block; padding: 0 10px">                             "maximum": 100,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3145,7 +3342,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "y": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "As a percentage of the image, the y position to start the crop from.",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "As a percentage of the image, the y position to start the crop from. DEPRECATED: Use `modifiers` instead.",
</ins><span class="cx" style="display: block; padding: 0 10px">                             "type": "number",
</span><span class="cx" style="display: block; padding: 0 10px">                             "minimum": 0,
</span><span class="cx" style="display: block; padding: 0 10px">                             "maximum": 100,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3152,7 +3349,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "width": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "As a percentage of the image, the width to crop the image to.",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "As a percentage of the image, the width to crop the image to. DEPRECATED: Use `modifiers` instead.",
</ins><span class="cx" style="display: block; padding: 0 10px">                             "type": "number",
</span><span class="cx" style="display: block; padding: 0 10px">                             "minimum": 0,
</span><span class="cx" style="display: block; padding: 0 10px">                             "maximum": 100,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3159,17 +3356,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><span class="cx" style="display: block; padding: 0 10px">                         },
</span><span class="cx" style="display: block; padding: 0 10px">                         "height": {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                            "description": "As a percentage of the image, the height to crop the image to.",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                            "description": "As a percentage of the image, the height to crop the image to. DEPRECATED: Use `modifiers` instead.",
</ins><span class="cx" style="display: block; padding: 0 10px">                             "type": "number",
</span><span class="cx" style="display: block; padding: 0 10px">                             "minimum": 0,
</span><span class="cx" style="display: block; padding: 0 10px">                             "maximum": 100,
</span><span class="cx" style="display: block; padding: 0 10px">                             "required": false
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        },
-                        "src": {
-                            "description": "URL to the edited image file.",
-                            "type": "string",
-                            "format": "uri",
-                            "required": true
</del><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px">                     }
</span><span class="cx" style="display: block; padding: 0 10px">                 }
</span></span></pre>
</div>
</div>

</body>
</html>