MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors
Spacing_Preprocessor::add_block_gaps()
Adds margin-top to blocks that are not first or last in the columns block.
Method of the class: Spacing_Preprocessor{}
No Hooks.
Return
Array
.
Usage
// private - for code of main (parent) class only $result = $this->add_block_gaps( $parsed_blocks, $gap, $parent_block ): array;
- $parsed_blocks(array) (required)
- Parsed blocks.
- $gap(string)
- Gap.
Default: '' - $parent_block(array|null)
- Parent block.
Default: null
Spacing_Preprocessor::add_block_gaps() Spacing Preprocessor::add block gaps code WC 9.8.1
private function add_block_gaps( array $parsed_blocks, string $gap = '', $parent_block = null ): array { foreach ( $parsed_blocks as $key => $block ) { $parent_block_name = $parent_block['blockName'] ?? ''; // Ensure that email_attrs are set. $block['email_attrs'] = $block['email_attrs'] ?? array(); /** * Do not add a gap to: * - first child * - parent block is a buttons block (where buttons are side by side). */ if ( 0 !== $key && $gap && 'core/buttons' !== $parent_block_name ) { $block['email_attrs']['margin-top'] = $gap; } $block['innerBlocks'] = $this->add_block_gaps( $block['innerBlocks'] ?? array(), $gap, $block ); $parsed_blocks[ $key ] = $block; } return $parsed_blocks; }