Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors

Quote_Preprocessor::process_blocksprivateWC 1.0

Recursively process blocks to handle quote block alignment and typography

Method of the class: Quote_Preprocessor{}

No Hooks.

Returns

Array. The processed blocks.

Usage

// private - for code of main (parent) class only
$result = $this->process_blocks( $blocks, $styles ): array;
$blocks(array) (required)
The blocks to process.
$styles(array) (required)
The styles from the theme.

Quote_Preprocessor::process_blocks() code WC 9.9.5

private function process_blocks( array $blocks, array $styles ): array {
	foreach ( $blocks as &$block ) {
		if ( ! isset( $block['innerBlocks'] ) ) {
			continue;
		}
		if ( 'core/quote' === $block['blockName'] ) {
			$quote_align      = $block['attrs']['textAlign'] ?? null;
			$quote_typography = $block['attrs']['style']['typography'] ?? array();

			// Apply quote's text alignment to its children.
			$block['innerBlocks'] = $this->apply_alignment_to_children( $block['innerBlocks'], $quote_align );
			// Apply quote's typography to its children.
			$block['innerBlocks'] = $this->apply_typography_to_children( $block['innerBlocks'], $quote_typography, $styles );
		}

		$block['innerBlocks'] = $this->process_blocks( $block['innerBlocks'], $styles );
	}

	return $blocks;
}