Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks

Group::get_block_wrapperprivateWC 1.0

Returns the block wrapper.

Method of the class: Group{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->get_block_wrapper( $block_content, $parsed_block, $rendering_context ): string;
$block_content(string) (required)
Block content.
$parsed_block(array) (required)
Parsed block.
$rendering_context(Rendering_Context) (required)
Rendering context.

Group::get_block_wrapper() code WC 10.6.2

private function get_block_wrapper( string $block_content, array $parsed_block, Rendering_Context $rendering_context ): string {
	$original_classname = ( new Dom_Document_Helper( $block_content ) )->get_attribute_value_by_tag_name( 'div', 'class' ) ?? '';
	$block_attributes   = wp_parse_args(
		$parsed_block['attrs'] ?? array(),
		array(
			'style'           => array(),
			'backgroundColor' => '',
			'textColor'       => '',
			'borderColor'     => '',
			'layout'          => array(),
		)
	);

	$table_styles = Styles_Helper::get_block_styles( $block_attributes, $rendering_context, array( 'border', 'background', 'background-color', 'color', 'text-align' ) );
	$table_styles = Styles_Helper::extend_block_styles(
		$table_styles,
		array_filter(
			array(
				'border-collapse' => 'separate',
				'background-size' => $table_styles['background-size'] ?? 'cover',
			)
		)
	);

	// Padding properties need to be added to the table cell.
	$cell_styles = Styles_Helper::get_block_styles( $block_attributes, $rendering_context, array( 'padding' ) );

	$table_attrs = array(
		'class' => 'email-block-group ' . $original_classname,
		'style' => $table_styles['css'],
		'width' => '100%',
	);

	$cell_attrs = array(
		'class' => 'email-block-group-content',
		'style' => $cell_styles['css'],
		'width' => $parsed_block['email_attrs']['width'] ?? '100%',
	);

	return Table_Wrapper_Helper::render_table_wrapper( '{group_content}', $table_attrs, $cell_attrs );
}