Automattic\WooCommerce\EmailEditor\Integrations\Utils
Html_Processing_Helper::extract_url_from_text
Extract the first HTTP/HTTPS URL from a text string.
Метод класса: Html_Processing_Helper{}
Хуков нет.
Возвращает
Строку. Extracted URL or empty string if not found.
Использование
$result = Html_Processing_Helper::extract_url_from_text( $text ): string;
- $text(строка) (обязательный)
- Text to search for URLs.
Код Html_Processing_Helper::extract_url_from_text() Html Processing Helper::extract url from text WC 11.0.1
public static function extract_url_from_text( string $text ): string {
if ( preg_match( '/(?<![a-zA-Z0-9.-])https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}[a-zA-Z0-9\/?=&%_.~+#-]*(?![a-zA-Z0-9._~+#-])/', $text, $matches ) ) {
return $matches[0];
}
return '';
}