Created
November 29, 2016 17:14
-
-
Save pablo-sg-pacheco/30b94a9dbd93d46ad09b9bfd785ddc00 to your computer and use it in GitHub Desktop.
Converte o menu para o contact details
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 | |
add_filter( 'wp_get_nav_menu_items', function($items, $menu, $args){ | |
if($menu->name!='Rodapé-3'){ | |
return $items; | |
} | |
if(is_admin()){ | |
return $items; | |
} | |
$contactDetails = get_option('contact'); | |
foreach ( $items as $item ) { | |
foreach ( $contactDetails as $key => $detail ) { | |
$originalDetail = $detail; | |
$detail = preg_replace('/http:\/\/.*\//', '', $detail); | |
if($item->title=='{{instagram}}'){ | |
$detail='@'.$detail; | |
$item->url = $originalDetail; | |
$item->target='_blank'; | |
} | |
$item->title = str_replace('{{'.$key.'}}', $detail, $item->title); | |
} | |
} | |
return $items; | |
}, null, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment