wc_make_phone_clickable( string $phone )
Convert plaintext phone number to clickable phone number.
Description Description
Remove formatting and allow "+". Example and specs: https://developer.mozilla.org/en/docs/Web/HTML/Element/a#Creating_a_phone_link
Parameters Parameters
- $phone
-
(Required) Content to convert phone number.
Return Return
(string) Content with converted phone number.
Source Source
File: includes/wc-core-functions.php
function wc_make_phone_clickable( $phone ) { $number = trim( preg_replace( '/[^\d|\+]/', '', $phone ) ); return $number ? '<a href="tel:' . esc_attr( $number ) . '">' . esc_html( $phone ) . '</a>' : ''; }
Changelog Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |