Automattic\WooCommerce\Internal\EmailEditor\WCTransactionalEmails
WCEmailTemplateSelectiveApplier::replace_recursive
Recursive worker for {@see self::replace_block_content_at_path()}.
Метод класса: WCEmailTemplateSelectiveApplier{}
Хуков нет.
Возвращает
array<int|string,. array<string, mixed>>
Использование
$result = WCEmailTemplateSelectiveApplier::replace_recursive( $blocks, $path, $depth, $source_block ): array;
- $blocks(массив) (обязательный)
- .
- $path(array<int|string>) (обязательный)
- Path indices.
- $depth(int) (обязательный)
- Current depth.
- $source_block(array<string, mixed>) (обязательный)
- Source block to copy content from.
Код WCEmailTemplateSelectiveApplier::replace_recursive() WCEmailTemplateSelectiveApplier::replace recursive WC 11.2.2
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;
}