Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors
Spacing_Preprocessor::contains_post_content
Checks whether a block contains a core/post-content descendant.
Searches recursively through container blocks (groups) so that deeply nested template structures like group → group → post-content are handled correctly.
Method of the class: Spacing_Preprocessor{}
No Hooks.
Returns
true|false. True if the block has a post-content descendant.
Usage
// private - for code of main (parent) class only $result = $this->contains_post_content( $block ): bool;
- $block(array) (required)
- The block to check.
Spacing_Preprocessor::contains_post_content() Spacing Preprocessor::contains post content code WC 10.8.1
private function contains_post_content( array $block ): bool {
$post_content_block_names = $this->get_post_content_block_names();
foreach ( $block['innerBlocks'] ?? array() as $inner_block ) {
$name = $inner_block['blockName'] ?? '';
if ( in_array( $name, $post_content_block_names, true ) ) {
return true;
}
if ( in_array( $name, self::CONTAINER_BLOCKS, true ) && $this->contains_post_content( $inner_block ) ) {
return true;
}
}
return false;
}