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

Embed::detect_provider_from_domainsprivateWC 1.0

Detect provider from content by checking against known domains.

Method of the class: Embed{}

No Hooks.

Returns

String. Provider name or empty string if not found.

Usage

// private - for code of main (parent) class only
$result = $this->detect_provider_from_domains( $content ): string;
$content(string) (required)
Content to check for provider domains.

Embed::detect_provider_from_domains() code WC 10.9.3

private function detect_provider_from_domains( string $content ): string {
	$all_providers = $this->get_all_provider_configs();

	foreach ( $all_providers as $provider => $config ) {
		foreach ( $config['domains'] as $domain ) {
			if ( strpos( $content, $domain ) !== false ) {
				return $provider;
			}
		}
	}

	return '';
}