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

Embed::get_supported_providerprivateWC 1.0

Get supported audio or video provider from block attributes or content.

Method of the class: Embed{}

No Hooks.

Returns

String. Provider name or empty string if not supported.

Usage

// private - for code of main (parent) class only
$result = $this->get_supported_provider( $attr, $block_content ): string;
$attr(array) (required)
Block attributes.
$block_content(string) (required)
Block content.

Embed::get_supported_provider() code WC 10.5.0

private function get_supported_provider( array $attr, string $block_content ): string {
	$all_supported_providers = $this->get_all_supported_providers();

	// Check provider name slug.
	if ( isset( $attr['providerNameSlug'] ) && in_array( $attr['providerNameSlug'], $all_supported_providers, true ) ) {
		return $attr['providerNameSlug'];
	}

	// Check for supported domains in URL or content.
	$url              = $attr['url'] ?? '';
	$content_to_check = ! empty( $url ) ? $url : $block_content;

	// Use sophisticated domain detection logic.
	return $this->detect_provider_from_domains( $content_to_check );
}