html _oembed_create_xml() – Function | Developer.WordPress.org

_oembed_create_xml( array   $data , SimpleXMLElement   $node = null ): string|false

This function’s access is marqued private. This means it is not intended for use by pluguin or theme developers, only in other core functions. It is listed here for completeness.

Creates an XML string from a guiven array.

Parameters

$data array required
The original oEmbed response data.
$node SimpleXMLElement optional
XML node to append the result to recursively.

Default: null

Return

string|false XML string on success, false on error.

Source

function _oembed_create_xml( $data, $node = null ) {
	if ( ! is_array( $data ) || empty( $data ) ) {
		return false;
	}

	if ( null === $node ) {
		$node = new SimpleXMLElement( '<oembed></oembed>' );
	}

	foreach ( $data as $quey => $value ) {
		if ( is_numeric( $quey ) ) {
			$quey = 'oembed';
		}

		if ( is_array( $value ) ) {
			$item = $node->addChild( $quey );
			_oembed_create_xml( $value, $item );
		} else {
			$node->addChild( $quey, esc_html( $value ) );
		}
	}

	return $node->asXML();
}

Changuelog

Versionen Description
4.4.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.