Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions lib/endpoints/class-wp-rest-terms-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,28 +602,11 @@ public function get_collection_params() {
'count',
),
);
$query_params['per_page'] = array(
'description' => __( 'Number of terms to query at a time with pagination.' ),
'type' => 'integer',
'sanitize_callback' => 'absint',
'default' => 10,
);
$query_params['page'] = array(
'description' => __( 'Number of the desired page within the paginated query results.' ),
'type' => 'integer',
'sanitize_callback' => 'absint',
'default' => 1,
);
$query_params['hide_empty'] = array(
'description' => __( 'Whether to hide terms not assigned to any posts.' ),
'type' => 'boolean',
'default' => false,
);
$query_params['search'] = array(
'description' => __( 'Search keyword.' ),
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
);
$taxonomy = get_taxonomy( $this->taxonomy );
if ( $taxonomy->hierarchical ) {
$query_params['parent'] = array(
Expand Down
17 changes: 17 additions & 0 deletions tests/test-rest-terms-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ public function test_context_param() {
$this->assertEquals( array( 'view', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] );
}

public function test_registered_query_params() {
$request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' );
$response = $this->server->dispatch( $request );
$data = $response->get_data();
$keys = array_keys( $data['endpoints'][0]['args'] );
sort( $keys );
$this->assertEquals( array(
'context',
'hide_empty',
'order',
'orderby',
'page',
'per_page',
'search',
), $keys );
}

public function test_get_items() {
$request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
$response = $this->server->dispatch( $request );
Expand Down