firstChild; if ( ! is_a( $first_child, DOMElement::class ) ) { return $content; } $styles = []; $original = $first_child->getAttribute( 'style' ); if ( $original ) { foreach ( explode( ';', $original ) as $rule ) { $styles[] = $rule; } } foreach ( $margin as $key => $value ) { $styles[] = "margin-$key:$value"; } foreach ( $padding as $key => $value ) { $styles[] = "padding-$key:$value"; } $first_child->setAttribute( 'style', implode( ';', $styles ) ); $content = $dom->saveHTML(); } return $content; }