Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors

Spacing_Preprocessor::contains_post_content │ private │ WC 1.0

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.

Метод класса: Spacing_Preprocessor{}

Хуков нет.

Возвращает

bool. True if the block has a post-content descendant.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->contains_post_content( $block ): bool;
$block(массив) (обязательный)
The block to check.

Код Spacing_Preprocessor::contains_post_content() WC 11.2.2

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;
}