Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer

Content_Renderer::initializeprivateWC 1.0

Initialize the content renderer

Method of the class: Content_Renderer{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->initialize();

Content_Renderer::initialize() code WC 10.7.0

private function initialize() {
	add_filter( 'render_block', array( $this, 'render_block' ), 10, 2 );
	add_filter( 'block_parser_class', array( $this, 'block_parser' ) );
	add_filter( 'woocommerce_email_blocks_renderer_parsed_blocks', array( $this, 'preprocess_parsed_blocks' ) );

	// Swap core/post-content render callback for email rendering.
	// This prevents issues with WordPress's static $seen_ids array when rendering
	// multiple emails in a single request (e.g., MailPoet batch processing).
	$post_content_type = $this->block_type_registry->get_registered( 'core/post-content' );
	if ( $post_content_type ) {
		// Save the original callback (may be null or WordPress's default).
		$this->backup_post_content_callback = $post_content_type->render_callback;

		// Replace with our stateless renderer.
		$post_content_renderer              = new Post_Content();
		$post_content_type->render_callback = array( $post_content_renderer, 'render_stateless' );
	}
}