wp_oembed_ensure_format()WP 4.4.0

Ensures that the specified format is either 'json' or 'xml'.

No Hooks.

Return

String. The format, either 'xml' or 'json'.

Usage

wp_oembed_ensure_format( $format );
$format(string) (required)
The oEmbed response format. Accepts 'json' or 'xml'.

Changelog

Since 4.4.0 Introduced.

wp_oembed_ensure_format() code WP 6.6.2

function wp_oembed_ensure_format( $format ) {
	if ( ! in_array( $format, array( 'json', 'xml' ), true ) ) {
		return 'json';
	}

	return $format;
}