Skip to content

Instantly share code, notes, and snippets.

@9ete
Created April 8, 2015 16:17
Show Gist options
  • Select an option

  • Save 9ete/13a4e944581ddd2b1603 to your computer and use it in GitHub Desktop.

Select an option

Save 9ete/13a4e944581ddd2b1603 to your computer and use it in GitHub Desktop.
Phone Number Shortcode
// Add [phonenumber] shortcode
function phonenumber_shortcode( $atts ){
//retrieve phone number from database
$lm_array = get_option('lowermedia_phone_number');
//check if user is on mobile if so make the number a link
if (wp_is_mobile())
{
return '<a href="tel:+'.$lm_array["id_number"].'">'.format_phonenumber($lm_array["id_number"]).'</a>';
} else {
return format_phonenumber($lm_array["id_number"]);
}
}
add_shortcode( 'phonenumber', 'phonenumber_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment