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

Embed::extract_provider_urlprivateWC 1.0

Extract provider URL from block attributes or content.

Method of the class: Embed{}

No Hooks.

Returns

String. Provider URL or empty string.

Usage

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

Embed::extract_provider_url() code WC 10.5.0

private function extract_provider_url( array $attr, string $block_content ): string {
	// First, try to get URL from attributes.
	if ( ! empty( $attr['url'] ) ) {
		$url = $attr['url'];
		// Validate the URL from attributes.
		if ( $this->is_valid_url( $url ) ) {
			return $url;
		}
		return '';
	}

	// If not in attributes, extract from block content.
	return $this->extract_url_from_content( $block_content );
}