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

_oembed_create_xml() WordPress Function

The oembed_create_xml() function is used to create an XML file for an oEmbed provider.

_oembed_create_xml( array $data, SimpleXMLElement $node = null ) #

Creates an XML string from a given array.


Parameters

$data

(array)(Required)The original oEmbed response data.

$node

(SimpleXMLElement)(Optional) XML node to append the result to recursively.

Default value: null


Top ↑

Return

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


Top ↑

Source

File: wp-includes/embed.php

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 $key => $value ) {
		if ( is_numeric( $key ) ) {
			$key = 'oembed';
		}

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

	return $node->asXML();
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.