Skip to content

Commit 5fba5f6

Browse files
Handle multiple status sanitization
1 parent f121b3e commit 5fba5f6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ public function get_collection_params() {
16801680
$query_params['status'] = array(
16811681
'default' => 'approve',
16821682
'description' => __( 'Limit result set to comments assigned a specific status. Requires authorization.' ),
1683-
'sanitize_callback' => 'sanitize_key',
1683+
'sanitize_callback' => 'sanitize_comment_statuses',
16841684
'type' => 'array',
16851685
'validate_callback' => 'rest_validate_request_arg',
16861686
);
@@ -1928,4 +1928,16 @@ protected function check_is_comment_content_allowed( $prepared_comment ) {
19281928
*/
19291929
return '' !== $check['comment_content'];
19301930
}
1931+
1932+
/**
1933+
* Sanitize a single comment status or a list of comment statuses with `sanitize_key`.
1934+
*
1935+
* @since 6.8.0
1936+
* @param string|array $statuses Comment status or array of comment statuses.
1937+
* @return array Sanitized array of comment statuses.
1938+
*/
1939+
public function sanitize_comment_statuses( $statuses ) {
1940+
$statuses = wp_parse_list( $statuses );
1941+
return array_unique( array_map( 'sanitize_key', $statuses ) );
1942+
}
19311943
}

0 commit comments

Comments
 (0)