firstChild ) { return $content; } /** @var DOMElement $first */ $first = $dom->firstChild; $styles = css_string_to_array( $first->getAttribute( 'style' ) ); if ( ! ( $styles['position'] ?? null ) ) { $styles['position'] = $position; } $first->setAttribute( 'style', css_array_to_string( $styles ) ); $content = $dom->saveHTML(); } if ( $zIndex ) { $dom = dom( $content ); if ( ! $dom->firstChild ) { return $content; } /** @var DOMElement $first */ $first = $dom->firstChild; $styles = css_string_to_array( $first->getAttribute( 'style' ) ); $styles['z-index'] = $zIndex; $first->setAttribute( 'style', css_array_to_string( $styles ) ); $content = $dom->saveHTML(); } if ( $inset ) { $dom = dom( $content ); if ( ! $dom->firstChild ) { return $content; } /** @var DOMElement $first */ $first = $dom->firstChild; $styles = css_string_to_array( $first->getAttribute( 'style' ) ); $styles['top'] = $inset['top'] ?? null; $styles['right'] = $inset['right'] ?? null; $styles['bottom'] = $inset['bottom'] ?? null; $styles['left'] = $inset['left'] ?? null; $first->setAttribute( 'style', css_array_to_string( $styles ) ); $content = $dom->saveHTML(); } return $content; }