Forum Replies Created

Viewing 2 replies - 16 through 17 (of 17 total)
  • Thread Starter Edward

    (@edwardmaxi)

    696 /**
    697 * Creates an XML string from a given array.
    698 *
    699 * @since 4.4.0
    700 * @access private
    701 *
    702 * @param array $data The original oEmbed response data.
    703 * @param SimpleXMLElement $node Optional. XML node to append the result to recursively.
    704 * @return string|false XML string on success, false on error.
    705 */
    706 function _oembed_create_xml( $data, $node = null ) {
    707 if ( ! is_array( $data ) || empty( $data ) ) {
    708 return false;
    709 }
    710
    711 if ( null === $node ) {
    712 $node = new SimpleXMLElement( ‘<oembed></oembed>’ );
    713 }
    714
    715 foreach ( $data as $key => $value ) {
    716 if ( is_numeric( $key ) ) {
    717 $key = ‘oembed’;
    718 }
    719 var_dump($value);
    720 if ( is_array( $value ) ) {
    721 $item = $node->addChild( $key );
    722 _oembed_create_xml( $value, $item );
    723 } else {
    724 $node->addChild( $key, esc_html( $value ) );
    725 }
    726 }
    727
    728 return $node->asXML();
    729}
    730

    Thread Starter Edward

    (@edwardmaxi)

    OK!, thanks, I’ll try it and see what happens!

Viewing 2 replies - 16 through 17 (of 17 total)