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

Quote::get_block_wrapperprivateWC 1.0

Returns the block wrapper.

Method of the class: Quote{}

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.

Quote::get_block_wrapper() code WC 10.9.1

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( 'blockquote', 'class' ) ?? '';
	$block_attributes   = wp_parse_args(
		$parsed_block['attrs'] ?? array(),
		array(
			'style'           => array(),
			'backgroundColor' => '',
			'textColor'       => '',
			'borderColor'     => '',
		)
	);

	// Layout, background, borders need to be on the outer table element.
	$table_styles = Styles_Helper::get_block_styles( $block_attributes, $rendering_context, array( 'border', 'background', 'background-color', 'color', 'text-align' ) );
	if ( $rendering_context->is_rtl() && ! $this->has_authored_border( $block_attributes ) ) {
		$authored_alignment = $this->get_authored_alignment( $block_attributes, $original_classname );
		$border_width       = array(
			'left'   => '0 0 0 1px',
			'center' => '0',
			'right'  => '0 1px 0 0',
		)[ $authored_alignment ?? 'right' ];
		$table_styles       = Styles_Helper::extend_block_styles(
			$table_styles,
			array_filter(
				array(
					'border-color'  => 'currentColor',
					'border-style'  => 'solid',
					'border-width'  => $border_width,
					'border-inline' => 'center' === $authored_alignment ? '0' : null,
				),
				static function ( $value ) {
					return null !== $value;
				}
			)
		);
	}
	$table_styles = Styles_Helper::extend_block_styles(
		$table_styles,
		array(
			'border-collapse' => 'separate',
			'background-size' => $table_styles['declarations']['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-quote ' . $original_classname,
		'style' => $table_styles['css'],
		'width' => '100%',
	);

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

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