wc_make_phone_clickable()
Convert plaintext phone number to clickable phone number.
Remove formatting and allow "+". Example and specs: https://developer.mozilla.org/en/docs/Web/HTML/Element/a#Creating_a_phone_link
No Hooks.
Return
String
. Content with converted phone number.
Usage
wc_make_phone_clickable( $phone );
- $phone(string) (required)
- Content to convert phone number.
Changelog
Since 3.1.0 | Introduced. |
wc_make_phone_clickable() wc make phone clickable code WC 9.7.1
function wc_make_phone_clickable( $phone ) { $number = trim( preg_replace( '/[^\d|\+]/', '', $phone ) ); return $number ? '<a href="tel:' . esc_attr( $number ) . '">' . esc_html( $phone ) . '</a>' : ''; }