Last active
May 24, 2025 04:11
-
-
Save JoelEadeDesign/5d4afa1b62b4f3748a731329a268c006 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Convert Mobile to tel link | |
add_filter('acf/format_value/name=ACF_MOBILE_FIELD_NAME', 'convert_phone_to_link', 20, 3); | |
function convert_phone_to_link ($value, $post_id, $field) { | |
if (!$value) { | |
return $value; | |
} | |
$tel_link = preg_replace('/[^0-9]/', '', $value); | |
$value = '<a href="tel:'. $tel_link .'">'.$value.'</a>'; | |
return $value; | |
} | |
// Convert Email to mailto link | |
add_filter('acf/format_value/name=ACF_EMAIL_FIELD_NAME', 'convert_email_to_link', 20, 3); | |
function convert_email_to_link ($value, $post_id, $field) { | |
if (!$value) { | |
return $value; | |
} | |
$email_link = $value; | |
$value = '<a href="mailto:'. $email_link .'">'. $value .'</a>'; | |
return $value; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment