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

Abstract_Block_Renderer::add_spacerprotectedWC 1.0

Add a spacer around the block.

Method of the class: Abstract_Block_Renderer{}

No Hooks.

Returns

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->add_spacer( $content, $email_attrs ): string;
$content(string) (required)
The block content.
$email_attrs(array) (required)
The email attributes.

Abstract_Block_Renderer::add_spacer() code WC 10.5.0

protected function add_spacer( $content, $email_attrs ): string {
	$gap_style     = WP_Style_Engine::compile_css( array_intersect_key( $email_attrs, array_flip( array( 'margin-top' ) ) ), '' ) ?? '';
	$padding_style = WP_Style_Engine::compile_css( array_intersect_key( $email_attrs, array_flip( array( 'padding-left', 'padding-right' ) ) ), '' ) ?? '';

	$table_attrs = array(
		'align' => 'left',
		'width' => '100%',
		'style' => $gap_style,
	);

	$cell_attrs = array(
		'style' => $padding_style,
	);

	$div_content = sprintf(
		'<div class="email-block-layout" style="%1$s %2$s">%3$s</div>',
		esc_attr( $gap_style ),
		esc_attr( $padding_style ),
		$content
	);

	return Table_Wrapper_Helper::render_outlook_table_wrapper( $div_content, $table_attrs, $cell_attrs );
}