Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateSelectiveApplier::replace_recursive
Recursive worker for {@see self::replace_block_content_at_path()}.
Method of the class: WCEmailTemplateSelectiveApplier{}
No Hooks.
Returns
Array
Usage
$result = WCEmailTemplateSelectiveApplier::replace_recursive( $blocks, $path, $depth, $source_block ): array;
- $blocks(array) (required)
- .
- $path(array<int|string>) (required)
- Path indices.
- $depth(int) (required)
- Current depth.
- $source_block(array) (required)
- .
WCEmailTemplateSelectiveApplier::replace_recursive() WCEmailTemplateSelectiveApplier::replace recursive code WC 10.9.4
private static function replace_recursive( array $blocks, array $path, int $depth, array $source_block ): array {
$idx = (int) $path[ $depth ];
if ( ! isset( $blocks[ $idx ] ) ) {
return $blocks;
}
if ( count( $path ) - 1 === $depth ) {
$blocks[ $idx ]['innerHTML'] = $source_block['innerHTML'] ?? '';
$blocks[ $idx ]['innerContent'] = $source_block['innerContent'] ?? array();
$blocks[ $idx ]['innerBlocks'] = $source_block['innerBlocks'] ?? array();
return $blocks;
}
$inner = $blocks[ $idx ]['innerBlocks'] ?? array();
$blocks[ $idx ]['innerBlocks'] = self::replace_recursive( is_array( $inner ) ? $inner : array(), $path, $depth + 1, $source_block );
return $blocks;
}