Yoast\WP\SEO\Schema_Aggregator\User_Interface
Site_Schema_Response_Header_Integration::serve_custom_response
Serve custom responses (XML or JSON) for schemamap endpoints
Intercepts schemamap index endpoints to serve either XML or JSON with proper content types and formatting. For XML responses (from /schema), outputs raw XML. For JSON responses (from /schema.json or post-type endpoints), outputs JSON with unescaped slashes for cleaner URLs.
Only affects /yoast/v1/schema-aggregator endpoints. Other endpoints are unaffected.
Метод класса: Site_Schema_Response_Header_Integration{}
Хуков нет.
Возвращает
true|false. True if we served the request, false otherwise.
Использование
$Site_Schema_Response_Header_Integration = new Site_Schema_Response_Header_Integration(); $Site_Schema_Response_Header_Integration->serve_custom_response( $served, $result, $request ): bool;
- $served(true|false) (обязательный)
- Whether the request has already been served.
- $result(WP_REST_Response) (обязательный)
- Result to send to the client.
- $request(WP_REST_Request) (обязательный)
- Request object.
Код Site_Schema_Response_Header_Integration::serve_custom_response() Site Schema Response Header Integration::serve custom response Yoast 28.3
public function serve_custom_response( $served, $result, $request ): bool {
if ( ! $request instanceof WP_REST_Request || \strpos( $request->get_route(), '/yoast/v1/schema-aggregator' ) !== 0 ) {
return (bool) $served;
}
if ( ! $result instanceof WP_REST_Response || $result->is_error() ) {
return (bool) $served;
}
$this->schema_map_header_adapter->set_header_for_request( $result );
return true;
}