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

Embed::render_embed │ private │ WC 1.0

Renders the embed itself (player, thumbnail, card or link fallback) without the caption.

Method of the class: Embed{}

No Hooks.

Returns

string.

Usage

// private - for code of main (parent) class only
$result = $this->render_embed( $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.

Embed::render_embed() code WC 11.1.2

private function render_embed( string $block_content, array $parsed_block, Rendering_Context $rendering_context ): string {
	$attr = $parsed_block['attrs'];

	// Check if this is a supported audio or video provider embed and has a valid URL.
	$provider = $this->get_supported_provider( $attr, $block_content );
	if ( empty( $provider ) ) {
		// For non-supported embeds, try to render as a rich card using oEmbed data.
		// Only attempt the embed page fetch for WordPress embeds (type "wp-embed")
		// to avoid wasted HTTP requests to non-WordPress sites.
		$url         = $this->extract_provider_url( $attr, $block_content );
		$is_wp_embed = isset( $attr['type'] ) && 'wp-embed' === $attr['type'];
		if ( ! empty( $url ) && $is_wp_embed ) {
			$card_result = $this->render_link_embed_card( $url, $parsed_block, $rendering_context );
			if ( ! empty( $card_result ) ) {
				return $card_result;
			}
			// Fetch failed or over the fetch cap — render as compact link card instead of plain link.
			return $this->render_compact_link_card( $url, $parsed_block, $rendering_context );
		}
		return $this->render_link_fallback( $attr, $block_content, $parsed_block, $rendering_context );
	}

	$url = $this->extract_provider_url( $attr, $block_content );
	if ( empty( $url ) ) {
		// Provider was detected but URL extraction failed - provide graceful fallback.
		return $this->render_link_fallback( $attr, $block_content, $parsed_block, $rendering_context );
	}

	// If we have a valid audio or video provider embed, proceed with normal rendering.
	return $this->render_content( $block_content, $parsed_block, $rendering_context );
}