encoding = 'utf-8'; $dom->loadHTML( utf8_decode( $content ) ); $xpath = new DOMXpath($dom); $items = $xpath->query('//div[contains(@class, "carousel-item")]'); $class = trim( areoi_get_class_name_str( array( 'carousel', 'slide', ( !empty( $attributes['className'] ) ? $attributes['className'] : '' ), ( !empty( $attributes['style'] ) ? $attributes['style'] : '' ), ( !empty( $attributes['transition'] ) ? $attributes['transition'] : '' ), ) ) . ' ' . areoi_get_display_class_str( $attributes, 'block' ) ); $buttons = null; if ( !empty( $attributes['controls'] ) && $items->length > 1 ) { $buttons = ' '; } $indicators = null; if ( !empty( $attributes['indicators'] ) && $items->length > 1 ) { $indicators = ''; } $newdoc = new DOMDocument(); if ( !empty( $items ) ) { foreach ( $items as $item_key => $item ) { $cloned = $item->cloneNode(TRUE); if ( $item_key == 0 ) { $cloned->setAttribute( 'class', 'carousel-item active' ); } $newdoc->appendChild($newdoc->importNode($cloned,TRUE)); } $content = $newdoc->saveHTML(); } $output = '
' . $buttons . ' ' . $indicators . ' ' . $content . '
'; return $output; }