Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 4ba1bbd

Browse files
authored
Fix Products by Category JSON response error (#2551)
* Fix Products by Category JSON response error * Create wrapper for the 'intval' function * Make get_intval public * Small improvements
1 parent 00d02fb commit 4ba1bbd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/StoreApi/Routes/AbstractTermsRoute.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function get_collection_params() {
4141
'type' => 'integer',
4242
'minimum' => 0,
4343
'maximum' => 100,
44-
'sanitize_callback' => 'intval',
44+
'sanitize_callback' => [ $this, 'get_intval' ],
4545
'validate_callback' => 'rest_validate_request_arg',
4646
);
4747

@@ -156,4 +156,14 @@ protected function get_term_count( $taxonomy, $args ) {
156156
unset( $count_args['number'], $count_args['offset'] );
157157
return (int) wp_count_terms( $taxonomy, $count_args );
158158
}
159+
160+
/**
161+
* Wrapper of the `intval` function that only accepts one parameter.
162+
*
163+
* @param mixed $value Value to convert to an int.
164+
* @return int
165+
*/
166+
public function get_intval( $value ) {
167+
return intval( $value );
168+
}
159169
}

0 commit comments

Comments
 (0)