WP_REST_Search_Controller::sanitize_subtypes()
Sanitizes the list of subtypes, to ensure only subtypes of the passed type are included.
Method of the class: WP_REST_Search_Controller{}
No Hooks.
Return
String[]|WP_Error
. List of valid subtypes, or WP_Error object on failure.
Usage
$WP_REST_Search_Controller = new WP_REST_Search_Controller(); $WP_REST_Search_Controller->sanitize_subtypes( $subtypes, $request, $parameter );
- $subtypes(string|array) (required)
- One or more subtypes.
- $request(WP_REST_Request) (required)
- Full details about the request.
- $parameter(string) (required)
- Parameter name.
Changelog
Since 5.0.0 | Introduced. |
WP_REST_Search_Controller::sanitize_subtypes() WP REST Search Controller::sanitize subtypes code WP 6.6.2
public function sanitize_subtypes( $subtypes, $request, $parameter ) { $subtypes = wp_parse_slug_list( $subtypes ); $subtypes = rest_parse_request_arg( $subtypes, $request, $parameter ); if ( is_wp_error( $subtypes ) ) { return $subtypes; } // 'any' overrides any other subtype. if ( in_array( self::TYPE_ANY, $subtypes, true ) ) { return array( self::TYPE_ANY ); } $handler = $this->get_search_handler( $request ); if ( is_wp_error( $handler ) ) { return $handler; } return array_intersect( $subtypes, $handler->get_subtypes() ); }