_oembed_create_xml()
Creates an XML string from a given array.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
String|false
. XML string on success, false on error.
Usage
_oembed_create_xml( $data, $node );
- $data(array) (required)
- The original oEmbed response data.
- $node(SimpleXMLElement)
- XML node to append the result to recursively.
Default: null
Changelog
Since 4.4.0 | Introduced. |
_oembed_create_xml() oembed create xml code WP 6.6.2
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(); }