Automattic\WooCommerce\EmailEditor\Engine\Renderer
Renderer::apply_html_attributes
Apply document-level language and direction attributes after CSS inlining.
Method of the class: Renderer{}
No Hooks.
Returns
String.
Usage
// private - for code of main (parent) class only $result = $this->apply_html_attributes( $template, $rendering_context ): string;
- $template(string) (required)
- HTML template.
- $rendering_context(Rendering_Context) (required)
- Rendering context.
Renderer::apply_html_attributes() Renderer::apply html attributes code WC 11.0.0
private function apply_html_attributes( string $template, Rendering_Context $rendering_context ): string {
$processor = new \WP_HTML_Tag_Processor( $template );
if ( ! $processor->next_tag( array( 'tag_name' => 'html' ) ) ) {
return $template;
}
$language = $rendering_context->get_language();
if ( $language ) {
$processor->set_attribute( 'lang', str_replace( '_', '-', $language ) );
}
$processor->set_attribute( 'dir', $rendering_context->get_text_direction() );
return $processor->get_updated_html();
}