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

Quote::get_citation_wrapperprivateWC 1.0

Returns the citation content with a wrapper.

Method of the class: Quote{}

No Hooks.

Returns

String. The wrapped citation HTML or empty string if no citation.

Usage

// private - for code of main (parent) class only
$result = $this->get_citation_wrapper( $citation_content, $parsed_block, $rendering_context ): string;
$citation_content(string) (required)
The citation text.
$parsed_block(array) (required)
Parsed block.
$rendering_context(Rendering_Context) (required)
Rendering context instance.

Quote::get_citation_wrapper() code WC 10.5.0

private function get_citation_wrapper( string $citation_content, array $parsed_block, Rendering_Context $rendering_context ): string {
	if ( empty( $citation_content ) ) {
		return '';
	}

	// The HTML cite tag should use block gap as margin-top.
	$theme_styles    = $rendering_context->get_theme_styles();
	$margin_top      = $theme_styles['spacing']['blockGap'] ?? '0px';
	$citation_styles = Styles_Helper::get_block_styles( $parsed_block['attrs'], $rendering_context, array( 'text-align' ) );
	$citation_styles = Styles_Helper::extend_block_styles( $citation_styles, array( 'margin' => "{$margin_top} 0px 0px 0px" ) );

	return $this->add_spacer(
		sprintf(
			'<p style="%2$s"><cite class="email-block-quote-citation" style="display: block; margin: 0;">%1$s</cite></p>',
			$citation_content,
			$citation_styles['css'],
		),
		$parsed_block['email_attrs'] ?? array()
	);
}