getAttribute( 'class' ) ); $classes[] = 'wp-block-heading'; $styles = css_string_to_array( $heading->getAttribute( 'style' ) ); $heading->setAttribute( 'class', implode( ' ', $classes ) ); $heading->setAttribute( 'style', css_array_to_string( $styles ) ); $id = $heading->getAttribute( 'id' ); if ( ! $id ) { $heading->setAttribute( 'id', sanitize_title_with_dashes( $heading->textContent ) ); } if ( ! $heading->getAttribute( 'style' ) ) { $heading->removeAttribute( 'style' ); } return $dom->saveHTML(); }