Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Commit a205717

Browse files
Move tags and categories to top-level endpoints
Tags are now accessible at `/wp/v2/tags`, and categories accessible at `/wp/v2/categories`. Post terms reside at `/wp/v2/posts/<id>/tags` and `/wp/v2/<id>/categories` Although this introduces the risk of collision between custom post types and custom taxonomies, said collision isn't currently handled in WordPress core. Developers can use `rest_base` to ensure CPTs and taxomonies have distinct slugs.
1 parent d59c05c commit a205717

7 files changed

+90
-90
lines changed

lib/endpoints/class-wp-rest-posts-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ protected function prepare_links( $post ) {
12331233
}
12341234

12351235
$tax_base = ! empty( $taxonomy_obj->rest_base ) ? $taxonomy_obj->rest_base : $tax;
1236-
$terms_url = rest_url( trailingslashit( $base ) . $post->ID . '/terms/' . $tax_base );
1236+
$terms_url = rest_url( trailingslashit( $base ) . $post->ID . '/' . $tax_base );
12371237

12381238
$links['https://api.w.org/term'][] = array(
12391239
'href' => $terms_url,

lib/endpoints/class-wp-rest-posts-terms-controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function register_routes() {
2020
$tax_base = $this->terms_controller->get_taxonomy_base( $this->taxonomy );
2121

2222
$query_params = $this->get_collection_params();
23-
register_rest_route( 'wp/v2', sprintf( '/%s/(?P<post_id>[\d]+)/terms/%s', $base, $tax_base ), array(
23+
register_rest_route( 'wp/v2', sprintf( '/%s/(?P<post_id>[\d]+)/%s', $base, $tax_base ), array(
2424
array(
2525
'methods' => WP_REST_Server::READABLE,
2626
'callback' => array( $this, 'get_items' ),
@@ -30,7 +30,7 @@ public function register_routes() {
3030
'schema' => array( $this, 'get_public_item_schema' ),
3131
) );
3232

33-
register_rest_route( 'wp/v2', sprintf( '/%s/(?P<post_id>[\d]+)/terms/%s/(?P<term_id>[\d]+)', $base, $tax_base ), array(
33+
register_rest_route( 'wp/v2', sprintf( '/%s/(?P<post_id>[\d]+)/%s/(?P<term_id>[\d]+)', $base, $tax_base ), array(
3434
array(
3535
'methods' => WP_REST_Server::READABLE,
3636
'callback' => array( $this, 'get_item' ),

lib/endpoints/class-wp-rest-terms-controller.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function register_routes() {
2121

2222
$base = $this->get_taxonomy_base( $this->taxonomy );
2323
$query_params = $this->get_collection_params();
24-
register_rest_route( 'wp/v2', '/terms/' . $base, array(
24+
register_rest_route( 'wp/v2', '/' . $base, array(
2525
array(
2626
'methods' => WP_REST_Server::READABLE,
2727
'callback' => array( $this, 'get_items' ),
@@ -37,7 +37,7 @@ public function register_routes() {
3737

3838
'schema' => array( $this, 'get_public_item_schema' ),
3939
));
40-
register_rest_route( 'wp/v2', '/terms/' . $base . '/(?P<id>[\d]+)', array(
40+
register_rest_route( 'wp/v2', '/' . $base . '/(?P<id>[\d]+)', array(
4141
array(
4242
'methods' => WP_REST_Server::READABLE,
4343
'callback' => array( $this, 'get_item' ),
@@ -111,7 +111,7 @@ public function get_items( $request ) {
111111
$max_pages = ceil( $total_terms / $request['per_page'] );
112112
$response->header( 'X-WP-TotalPages', (int) $max_pages );
113113

114-
$base = add_query_arg( $request->get_query_params(), rest_url( '/wp/v2/terms/' . $this->get_taxonomy_base( $this->taxonomy ) ) );
114+
$base = add_query_arg( $request->get_query_params(), rest_url( '/wp/v2/' . $this->get_taxonomy_base( $this->taxonomy ) ) );
115115
if ( $request['page'] > 1 ) {
116116
$prev_page = $request['page'] - 1;
117117
if ( $prev_page > $max_pages ) {
@@ -204,7 +204,7 @@ public function create_item( $request ) {
204204

205205
$response = rest_ensure_response( $response );
206206
$response->set_status( 201 );
207-
$response->header( 'Location', rest_url( '/wp/v2/terms/' . $this->get_taxonomy_base( $this->taxonomy ) . '/' . $term['term_taxonomy_id'] ) );
207+
$response->header( 'Location', rest_url( '/wp/v2/' . $this->get_taxonomy_base( $this->taxonomy ) . '/' . $term['term_taxonomy_id'] ) );
208208
return $response;
209209
}
210210

@@ -273,7 +273,7 @@ public function delete_item( $request ) {
273273

274274
// Get the actual term_id
275275
$term = get_term_by( 'term_taxonomy_id', (int) $request['id'], $this->taxonomy );
276-
$get_request = new WP_REST_Request( 'GET', rest_url( 'wp/v2/terms/' . $this->get_taxonomy_base( $term->taxonomy ) . '/' . (int) $request['id'] ) );
276+
$get_request = new WP_REST_Request( 'GET', rest_url( 'wp/v2/' . $this->get_taxonomy_base( $term->taxonomy ) . '/' . (int) $request['id'] ) );
277277
$get_request->set_param( 'context', 'view' );
278278
$response = $this->prepare_item_for_response( $term, $get_request );
279279

@@ -476,7 +476,7 @@ public function prepare_item_for_response( $item, $request ) {
476476
* @return array Links for the given term.
477477
*/
478478
protected function prepare_links( $term ) {
479-
$base = '/wp/v2/terms/' . $this->get_taxonomy_base( $term->taxonomy );
479+
$base = '/wp/v2/' . $this->get_taxonomy_base( $term->taxonomy );
480480
$links = array(
481481
'self' => array(
482482
'href' => rest_url( trailingslashit( $base ) . $term->term_taxonomy_id ),
@@ -490,7 +490,7 @@ protected function prepare_links( $term ) {
490490
$parent_term = get_term_by( 'id', (int) $term->parent, $term->taxonomy );
491491
if ( $parent_term ) {
492492
$links['up'] = array(
493-
'href' => rest_url( sprintf( 'wp/v2/terms/%s/%d', $this->get_taxonomy_base( $parent_term->taxonomy ), $parent_term->term_taxonomy_id ) ),
493+
'href' => rest_url( sprintf( 'wp/v2/%s/%d', $this->get_taxonomy_base( $parent_term->taxonomy ), $parent_term->term_taxonomy_id ) ),
494494
'embeddable' => true,
495495
);
496496
}

plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ function _add_extra_api_taxonomy_arguments() {
133133

134134
if ( isset( $wp_taxonomies['category'] ) ) {
135135
$wp_taxonomies['category']->show_in_rest = true;
136-
$wp_taxonomies['category']->rest_base = 'category';
136+
$wp_taxonomies['category']->rest_base = 'categories';
137137
$wp_taxonomies['category']->rest_controller_class = 'WP_REST_Terms_Controller';
138138
}
139139

140140
if ( isset( $wp_taxonomies['post_tag'] ) ) {
141141
$wp_taxonomies['post_tag']->show_in_rest = true;
142-
$wp_taxonomies['post_tag']->rest_base = 'tag';
142+
$wp_taxonomies['post_tag']->rest_base = 'tags';
143143
$wp_taxonomies['post_tag']->rest_controller_class = 'WP_REST_Terms_Controller';
144144
}
145145
}

tests/test-rest-posts-controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ public function test_get_item_links() {
230230
$this->assertNotEmpty( $tag_link );
231231
$this->assertNotEmpty( $cat_link );
232232

233-
$tags_url = rest_url( '/wp/v2/posts/' . $this->post_id . '/terms/tag' );
233+
$tags_url = rest_url( '/wp/v2/posts/' . $this->post_id . '/tags' );
234234
$this->assertEquals( $tags_url, $tag_link['href'] );
235235

236-
$category_url = rest_url( '/wp/v2/posts/' . $this->post_id . '/terms/category' );
236+
$category_url = rest_url( '/wp/v2/posts/' . $this->post_id . '/categories' );
237237
$this->assertEquals( $category_url, $cat_link['href'] );
238238

239239
$meta_links = $links['https://api.w.org/meta'];

tests/test-rest-posts-terms-controller.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ public function setUp() {
1414
public function test_register_routes() {
1515
$routes = $this->server->get_routes();
1616

17-
$this->assertArrayHasKey( '/wp/v2/posts/(?P<post_id>[\d]+)/terms/tag', $routes );
18-
$this->assertArrayHasKey( '/wp/v2/posts/(?P<post_id>[\d]+)/terms/tag/(?P<term_id>[\d]+)', $routes );
17+
$this->assertArrayHasKey( '/wp/v2/posts/(?P<post_id>[\d]+)/tags', $routes );
18+
$this->assertArrayHasKey( '/wp/v2/posts/(?P<post_id>[\d]+)/tags/(?P<term_id>[\d]+)', $routes );
1919
}
2020

2121
public function test_get_items() {
2222

2323
wp_set_object_terms( $this->post_id, 'test-tag', 'post_tag' );
24-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag', $this->post_id ) );
24+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags', $this->post_id ) );
2525
$response = $this->server->dispatch( $request );
2626

2727
$this->assertFalse( $response->is_error() );
@@ -30,38 +30,38 @@ public function test_get_items() {
3030

3131
public function test_get_items_invalid_post() {
3232

33-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag', 9999 ) );
33+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags', 9999 ) );
3434
$response = $this->server->dispatch( $request );
3535

3636
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
3737
}
3838

3939
public function test_get_items_invalid_taxonomy() {
4040

41-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/%s', $this->public_taxonomy_pages, $this->post_id ) );
41+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/%s', $this->public_taxonomy_pages, $this->post_id ) );
4242
$response = $this->server->dispatch( $request );
4343

4444
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
4545
}
4646

4747
public function test_get_items_orderby() {
4848
wp_set_object_terms( $this->post_id, array( 'Banana', 'Carrot', 'Apple' ), 'post_tag' );
49-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag', $this->post_id ) );
49+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags', $this->post_id ) );
5050
$request->set_param( 'orderby', 'term_order' );
5151
$response = $this->server->dispatch( $request );
5252
$data = $response->get_data();
5353
$this->assertEquals( 'Banana', $data[0]['name'] );
5454
$this->assertEquals( 'Carrot', $data[1]['name'] );
5555
$this->assertEquals( 'Apple', $data[2]['name'] );
56-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag', $this->post_id ) );
56+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags', $this->post_id ) );
5757
$request->set_param( 'orderby', 'name' );
5858
$request->set_param( 'order', 'asc' );
5959
$response = $this->server->dispatch( $request );
6060
$data = $response->get_data();
6161
$this->assertEquals( 'Apple', $data[0]['name'] );
6262
$this->assertEquals( 'Banana', $data[1]['name'] );
6363
$this->assertEquals( 'Carrot', $data[2]['name'] );
64-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag', $this->post_id ) );
64+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags', $this->post_id ) );
6565
$request->set_param( 'orderby', 'name' );
6666
$request->set_param( 'order', 'desc' );
6767
$response = $this->server->dispatch( $request );
@@ -75,7 +75,7 @@ public function test_get_item() {
7575
$tag = wp_insert_term( 'test-tag', 'post_tag' );
7676
wp_set_object_terms( $this->post_id, $tag['term_taxonomy_id'], 'post_tag' );
7777

78-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
78+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
7979
$response = $this->server->dispatch( $request );
8080
$this->assertFalse( $response->is_error() );
8181

@@ -86,7 +86,7 @@ public function test_get_item_invalid_post() {
8686
$tag = wp_insert_term( 'test-tag', 'post_tag' );
8787
wp_set_object_terms( $this->post_id, $tag['term_taxonomy_id'], 'post_tag' );
8888

89-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag/%d', 9999, $tag['term_taxonomy_id'] ) );
89+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags/%d', 9999, $tag['term_taxonomy_id'] ) );
9090
$response = $this->server->dispatch( $request );
9191

9292
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
@@ -96,21 +96,21 @@ public function test_get_item_post_wrong_post_type() {
9696

9797
$page = $this->factory->post->create( array( 'post_type' => 'page' ) );
9898

99-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag', $page ) );
99+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags', $page ) );
100100
$response = $this->server->dispatch( $request );
101101

102102
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
103103
}
104104

105105
public function test_get_item_invalid_taxonomy() {
106-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/invalid_taxonomy/%d', $this->post_id, 123 ) );
106+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/invalid_taxonomy/%d', $this->post_id, 123 ) );
107107
$response = $this->server->dispatch( $request );
108108

109109
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
110110
}
111111

112112
public function test_get_item_invalid_taxonomy_term() {
113-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, 9999 ) );
113+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, 9999 ) );
114114
$response = $this->server->dispatch( $request );
115115

116116
$this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
@@ -120,7 +120,7 @@ public function test_get_item_taxonomy_term_wrong_taxonomy() {
120120

121121
$term = wp_insert_term( 'some-term', $this->public_taxonomy_pages );
122122

123-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $term['term_taxonomy_id'] ) );
123+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $term['term_taxonomy_id'] ) );
124124
$response = $this->server->dispatch( $request );
125125

126126
$this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
@@ -130,15 +130,15 @@ public function test_get_item_unassigned_taxonomy_term() {
130130

131131
$tag = wp_insert_term( 'test-tag', 'post_tag' );
132132

133-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
133+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
134134
$response = $this->server->dispatch( $request );
135135

136136
$this->assertErrorResponse( 'rest_post_not_in_term', $response, 404 );
137137
}
138138

139139
public function test_get_item_term_id_not_added() {
140140
$tag = wp_insert_term( 'test-tag', 'post_tag' );
141-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
141+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
142142
$response = $this->server->dispatch( $request );
143143

144144
$this->assertErrorResponse( 'rest_post_not_in_term', $response, 404 );
@@ -148,7 +148,7 @@ public function test_create_item() {
148148

149149
wp_set_current_user( $this->admin_id );
150150
$tag = wp_insert_term( 'test-tag', 'post_tag' );
151-
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
151+
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
152152
$response = $this->server->dispatch( $request );
153153

154154
$this->assertEquals( 201, $response->get_status() );
@@ -158,7 +158,7 @@ public function test_create_item() {
158158
public function test_create_item_invalid_permission() {
159159

160160
$tag = wp_insert_term( 'test-tag', 'post_tag' );
161-
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
161+
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
162162
$response = $this->server->dispatch( $request );
163163

164164
$this->assertErrorResponse( 'rest_forbidden', $response, 403 );
@@ -168,7 +168,7 @@ public function test_create_item_invalid_post() {
168168

169169
wp_set_current_user( $this->admin_id );
170170
$tag = wp_insert_term( 'test-tag', 'post_tag' );
171-
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/terms/tag/%d', 9999, $tag['term_taxonomy_id'] ) );
171+
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/tags/%d', 9999, $tag['term_taxonomy_id'] ) );
172172
$response = $this->server->dispatch( $request );
173173

174174
$this->assertErrorResponse( 'rest_post_invalid_id', $response, 404 );
@@ -178,7 +178,7 @@ public function test_create_item_invalid_taxonomy() {
178178

179179
wp_set_current_user( $this->admin_id );
180180
$tag = wp_insert_term( 'test-tag', 'post_tag' );
181-
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/terms/invalid_taxonomy/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
181+
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/invalid_taxonomy/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
182182
$response = $this->server->dispatch( $request );
183183

184184
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
@@ -187,7 +187,7 @@ public function test_create_item_invalid_taxonomy() {
187187
public function test_create_item_invalid_taxonomy_term() {
188188

189189
wp_set_current_user( $this->admin_id );
190-
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, 9999 ) );
190+
$request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, 9999 ) );
191191
$response = $this->server->dispatch( $request );
192192

193193
$this->assertErrorResponse( 'rest_term_invalid', $response, 404 );
@@ -198,7 +198,7 @@ public function test_delete_item() {
198198
$tag = wp_insert_term( 'test-tag', 'post_tag' );
199199
wp_set_object_terms( $this->post_id, 'test-tag', 'post_tag' );
200200

201-
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
201+
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
202202
$request['force'] = true;
203203
$response = $this->server->dispatch( $request );
204204

@@ -210,7 +210,7 @@ public function test_delete_item_invalid_permission() {
210210
$tag = wp_insert_term( 'test-tag', 'post_tag' );
211211
wp_set_object_terms( $this->post_id, 'test-tag', 'post_tag' );
212212

213-
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
213+
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
214214
$request['force'] = true;
215215
$response = $this->server->dispatch( $request );
216216

@@ -222,7 +222,7 @@ public function test_delete_item_invalid_taxonomy() {
222222
$tag = wp_insert_term( 'test-tag', 'post_tag' );
223223
wp_set_object_terms( $this->post_id, 'test-tag', 'post_tag' );
224224

225-
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/terms/invalid_taxonomy/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
225+
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/invalid_taxonomy/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
226226
$request['force'] = true;
227227
$response = $this->server->dispatch( $request );
228228

@@ -234,7 +234,7 @@ public function test_delete_item_invalid_taxonomy_term() {
234234
$tag = wp_insert_term( 'test-tag', 'post_tag' );
235235
wp_set_object_terms( $this->post_id, 'test-tag', 'post_tag' );
236236

237-
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/terms/invalid_taxonomy/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
237+
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/invalid_taxonomy/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
238238
$request['force'] = true;
239239
$response = $this->server->dispatch( $request );
240240

@@ -246,7 +246,7 @@ public function test_delete_item_invalid_post() {
246246
$tag = wp_insert_term( 'test-tag', 'post_tag' );
247247
wp_set_object_terms( $this->post_id, 'test-tag', 'post_tag' );
248248

249-
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/terms/tag/%d', 9999, $tag['term_taxonomy_id'] ) );
249+
$request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d/tags/%d', 9999, $tag['term_taxonomy_id'] ) );
250250
$request['force'] = true;
251251
$response = $this->server->dispatch( $request );
252252

@@ -262,15 +262,15 @@ public function test_prepare_item() {
262262
wp_set_object_terms( $this->post_id, 'test-tag', 'post_tag' );
263263
$term = get_term( $tag['term_id'], 'post_tag' );
264264

265-
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/terms/tag/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
265+
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d/tags/%d', $this->post_id, $tag['term_taxonomy_id'] ) );
266266
$response = $this->server->dispatch( $request );
267267
$data = $response->get_data();
268268

269269
$this->check_taxonomy_term( $term, $data );
270270
}
271271

272272
public function test_get_item_schema() {
273-
$request = new WP_REST_Request( 'OPTIONS', sprintf( '/wp/v2/posts/%d/terms/tag', $this->post_id ) );
273+
$request = new WP_REST_Request( 'OPTIONS', sprintf( '/wp/v2/posts/%d/tags', $this->post_id ) );
274274
$response = $this->server->dispatch( $request );
275275

276276
$data = $response->get_data();

0 commit comments

Comments
 (0)