Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks

Quote::render_contentprotectedWC 1.0

Renders the block content

Method of the class: Quote{}

No Hooks.

Returns

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->render_content( $block_content, $parsed_block, $rendering_context ): string;
$block_content(string) (required)
Block content.
$parsed_block(array) (required)
Parsed block.
$rendering_context(Rendering_Context) (required)
Rendering context.

Quote::render_content() code WC 10.9.1

protected function render_content( string $block_content, array $parsed_block, Rendering_Context $rendering_context ): string {
	$dom_helper = new Dom_Document_Helper( $block_content );

	// Extract citation if present, then remove it from the DOM so it isn't
	// also rendered inline as part of the quote content below.
	$citation_content = '';
	$cite_element     = $dom_helper->find_element( 'cite' );
	if ( $cite_element ) {
		$citation_content = $this->get_citation_wrapper(
			$dom_helper->get_element_inner_html( $cite_element ),
			$parsed_block,
			$rendering_context
		);
		if ( $cite_element->parentNode ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
			$cite_element->parentNode->removeChild( $cite_element ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
		}
	}

	// Strip the <blockquote> tag and keep its children. The visual quote indent
	// comes from the email-block-quote table built in get_block_wrapper(); keeping
	// the original blockquote would render a double-bordered quote-within-a-quote.
	// Children have already been re-wrapped in <table>…<div class="email-block-layout">…</div>…</table>
	// by the email editor's per-block render filter, so passing 'div' (the previous default)
	// would only return the first child's inner HTML and drop the rest.
	$blockquote_element = $dom_helper->find_element( 'blockquote' );
	$quote_content      = $blockquote_element
		? $dom_helper->get_element_inner_html( $blockquote_element )
		: $block_content;

	return str_replace(
		array( '{quote_content}', '{citation_content}' ),
		array( $quote_content, $citation_content ),
		$this->get_block_wrapper( $block_content, $parsed_block, $rendering_context )
	);
}