mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
REST API: Add missing sanitization callback for the hide_empty parameter of the Terms Controller.
Fixes a bug where the boolean parameter `hide_empty` was not being properly sanitized in the Terms controller. Props websupporter. Fixes #38465. git-svn-id: https://develop.svn.wordpress.org/trunk@38942 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -867,6 +867,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
||||
'description' => __( 'Whether to hide resources not assigned to any posts.' ),
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
'sanitize_callback' => 'rest_sanitize_request_arg',
|
||||
'validate_callback' => 'rest_validate_request_arg',
|
||||
);
|
||||
if ( $taxonomy->hierarchical ) {
|
||||
|
||||
@@ -92,6 +92,12 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertEquals( 2, count( $data ) );
|
||||
$this->assertEquals( 'Season 5', $data[0]['name'] );
|
||||
$this->assertEquals( 'The Be Sharps', $data[1]['name'] );
|
||||
|
||||
// Confirm the empty category "Uncategorized" category appears.
|
||||
$request->set_param( 'hide_empty', 'false' );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertEquals( 3, count( $data ) );
|
||||
}
|
||||
|
||||
public function test_get_items_parent_zero_arg() {
|
||||
|
||||
Reference in New Issue
Block a user