_oembed_create_xml()
Creates an XML string from a given array.
Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
Строку|false. XML string on success, false on error.
Использование
_oembed_create_xml( $data, $node );
- $data(массив) (обязательный)
- The original oEmbed response data.
- $node(SimpleXMLElement)
- XML node to append the result to recursively.
По умолчанию:null
Список изменений
| С версии 4.4.0 | Введена. |
Код _oembed_create_xml() oembed create xml WP 7.0.4
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();
}