WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

_oembed_rest_pre_serve_request() WP 4.4.0

Hooks into the REST API output to print XML instead of JSON.

This is only done for the oEmbed API endpoint, which supports both formats.

Хуков нет.

Возвращает

true.

Использование

_oembed_rest_pre_serve_request( $served, $result, $request, $server );
$served(true/false) (обязательный)
Whether the request has already been served.
$result(WP_HTTP_Responseчислоerface) (обязательный)
Result to send to the client. Usually a WP_REST_Response.
$request(WP_REST_Request) (обязательный)
Request used to generate the response.
$server(WP_REST_Server) (обязательный)
Server instance.

Список изменений

С версии 4.4.0 Введена.

Код _oembed_rest_pre_serve_request() WP 5.5.1

wp-includes/embed.php
<?php
function _oembed_rest_pre_serve_request( $served, $result, $request, $server ) {
	$params = $request->get_params();

	if ( '/oembed/1.0/embed' !== $request->get_route() || 'GET' !== $request->get_method() ) {
		return $served;
	}

	if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) {
		return $served;
	}

	// Embed links inside the request.
	$data = $server->response_to_data( $result, false );

	if ( ! class_exists( 'SimpleXMLElement' ) ) {
		status_header( 501 );
		die( get_status_header_desc( 501 ) );
	}

	$result = _oembed_create_xml( $data );

	// Bail if there's no XML.
	if ( ! $result ) {
		status_header( 501 );
		return get_status_header_desc( 501 );
	}

	if ( ! headers_sent() ) {
		$server->send_header( 'Content-Type', 'text/xml; charset=' . get_option( 'blog_charset' ) );
	}

	echo $result;

	return true;
}