Converts content in Contact Details fields. Ex: {{email}}
<?php
//Converts content in Contact Details fields. Ex: {{email}}
add_filter( 'the_content', function($content){
$contactDetails = get_option('contact');
foreach ( $contactDetails as $key => $detail ) {
if ( !empty($detail) ) {
if(strpos($detail, '@')!==false){
$content = str_replace('{{'.$key.'}}', '<a href="mailto:' . $detail . '">' . $detail . '</a>', $content);
}else if(strpos($detail, 'http://')!==false){
$content = str_replace('{{'.$key.'}}', '<a target="_blank" href="' . $detail . '">' . $detail . '</a>', $content);
}else{
$content = str_replace('{{'.$key.'}}', $detail, $content);
}
}
}
return $content;
});
add_filter('contact_details', function( $details ) {
foreach ($details as $key => $detail) {
$details[$key]['label'].=' - {{'.$key.'}}';
}
return $details;
});
?>