Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails

WCEmailTemplateSelectiveApplier::replace_block_content_at_path │ private static │ WC 1.0

Replace the block at the given path with another block's content. Preserves the post block's attrs (no attribute-level apply in v1); copies the source block's innerHTML, innerContent, and innerBlocks over the target.

Method of the class: WCEmailTemplateSelectiveApplier{}

No Hooks.

Returns

array<int|string,. array<string, mixed>>

Usage

$result = WCEmailTemplateSelectiveApplier::replace_block_content_at_path( $blocks, $path, $source_block ): array;
$blocks(array) (required)
.
$path(array<int|string>) (required)
Index path through parse_blocks output.
$source_block(array<string, mixed>) (required)
The block whose content to copy in.

WCEmailTemplateSelectiveApplier::replace_block_content_at_path() code WC 11.1.2

private static function replace_block_content_at_path( array $blocks, array $path, array $source_block ): array {
	if ( empty( $path ) ) {
		return $blocks;
	}
	return self::replace_recursive( $blocks, array_values( $path ), 0, $source_block );
}