wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
rest_handle_options_request › WordPress Function
Seit4.4.0
Veraltetn/v
› rest_handle_options_request ( $response, $handler, $request )
Parameter: (3) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Handles OPTIONS requests for the server.
This is handled outside of the server code, as it doesn't obey normal route mapping.Ähnliche Funktionen: rest_do_request, rest_ensure_request, rest_sanitize_request_arg, rest_validate_request_arg, _delete_option_fresh_site
Quellcode
function rest_handle_options_request( $response, $handler, $request ) { if ( ! empty( $response ) || $request->get_method() !== 'OPTIONS' ) { return $response; } $response = new WP_REST_Response(); $data = array(); foreach ( $handler->get_routes() as $route => $endpoints ) { $match = preg_match( '@^' . $route . '$@i', $request->get_route(), $matches ); if ( ! $match ) { continue; } $args = array(); foreach ( $matches as $param => $value ) { if ( ! is_int( $param ) ) { $args[ $param ] = $value; } } foreach ( $endpoints as $endpoint ) { // Remove the redundant preg_match() argument. unset( $args[0] ); $request->set_url_params( $args ); $request->set_attributes( $endpoint ); } $data = $handler->get_data_for_route( $route, $endpoints, 'help' ); $response->set_matched_route( $route ); break; } $response->set_data( $data ); return $response; }