Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created April 20, 2016 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/19bfa55b83c3a7e885819ff73bc8c290 to your computer and use it in GitHub Desktop.
Save billerickson/19bfa55b83c3a7e885819ff73bc8c290 to your computer and use it in GitHub Desktop.
<?php
/**
* Phone URL
* @author Bill Erickson
* @link http://www.billerickson.net/phone-number-url
*
* @param string $phone_number, ex: (555) 123-4568
* @return string $phone_url, ex: tel:5551234568
*/
function ea_phone_url( $phone_number = false ) {
$phone_number = str_replace( array( '(', ')', '-', '.', '|', ' ' ), '', $phone_number );
return esc_url( 'tel:' . $phone_number );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment