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

Product_Sale_Badge::apply_email_wrapperprivateWC 1.0

Apply email-compatible table wrapper.

Method of the class: Product_Sale_Badge{}

No Hooks.

Returns

String.

Usage

// private - for code of main (parent) class only
$result = $this->apply_email_wrapper( $badge_html, $parsed_block, $rendering_context ): string;
$badge_html(string) (required)
Badge HTML.
$parsed_block(array) (required)
Parsed block.
$rendering_context(Rendering_Context) (required)
Rendering context.

Product_Sale_Badge::apply_email_wrapper() code WC 10.9.4

private function apply_email_wrapper( string $badge_html, array $parsed_block, Rendering_Context $rendering_context ): string {
	$align = $rendering_context->resolve_text_align( $parsed_block['attrs']['align'] ?? null );

	$wrapper_styles = array(
		'border-collapse' => 'collapse',
		'width'           => '100%',
	);

	$cell_styles = array(
		'padding'    => '5px 0',
		'text-align' => $align,
	);

	$table_attrs = array(
		'style' => \WP_Style_Engine::compile_css( $wrapper_styles, '' ),
		'width' => '100%',
	);

	$cell_attrs = array(
		'class' => 'email-product-sale-badge-cell',
		'style' => \WP_Style_Engine::compile_css( $cell_styles, '' ),
		'align' => $align,
	);

	return Table_Wrapper_Helper::render_table_wrapper( $badge_html, $table_attrs, $cell_attrs );
}