Automattic\WooCommerce\EmailEditor\Engine\Renderer
Renderer::render_text_version
Renders the text version of the email template.
Method of the class: Renderer{}
No Hooks.
Returns
String.
Usage
// private - for code of main (parent) class only $result = $this->render_text_version( $template );
- $template(string) (required)
- HTML template.
Renderer::render_text_version() Renderer::render text version code WC 10.9.1
private function render_text_version( $template ) {
$template = ( mb_detect_encoding( $template, 'UTF-8', true ) ) ? $template : mb_convert_encoding( $template, 'UTF-8', mb_list_encodings() );
// Ensure template is a string before processing.
if ( ! is_string( $template ) ) {
return '';
}
// Preserve personalization tags by temporarily replacing them with unique placeholders.
$template = $this->preserve_personalization_tags( $template );
$result = Html2Text::convert( (string) $template, array( 'ignore_errors' => true ) );
if ( ! $result ) {
return '';
}
// Restore personalization tags from placeholders.
$result = $this->restore_personalization_tags( $result );
return $result;
}