Last active
August 29, 2015 14:00
-
-
Save reneeschel/11330533 to your computer and use it in GitHub Desktop.
This file contains 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
add_filter( ‘wp_nav_menu_items’, ‘custom_nav_item’, 10, 2 ); | |
/** | |
* Callback for Genesis ‘wp_nav_menu_items’ filter. | |
* | |
* Add custom right nav item to Genesis primary menu. | |
* | |
* @package Genesis | |
* @category Nav Menu | |
* @author Ryan Meier http://www.rfmeier.net | |
* | |
* @param string $menu The menu html | |
* @param stdClass $args the current menu args | |
* @return string $menu The menu html | |
*/ | |
function custom_nav_item( $menu, stdClass $args ){ | |
// make sure we are in the primary menu | |
if ( ‘primary’ != $args->theme_location ) | |
return $menu; | |
// see if a nav extra was already specified with Theme options | |
if( genesis_get_option( ‘nav_extras’ ) ) | |
return $menu; | |
// additional checks? | |
// append your custom code | |
$menu .= sprintf( ‘<li class=”welcome-audio”>%s‘, __( ‘WELCOME: <audio id=”myAudio” <source src=”http://willixhypnosis.com/wp-content/uploads/2014/04/welcome-audio-4.19.14-1.mp3″ type=”audio/mp3″> Your user agent does not support the HTML5 Audio element. </audio> <button type=”button” onclick=”aud_play_pause()” ></button> <script> function aud_play_pause() { var myAudio = document.getElementById(“myAudio”); if (myAudio.paused) { myAudio.play(); } else { myAudio.pause(); } } </script>’) | |
); | |
// return the menu | |
return $menu; | |
} | |
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
/*below is the code I have put into the wordpress menu/link for the last item on the top nav*////// | |
BIENVENIDA: <audio id="myAudio2" <source src="http://willixhypnosis.com/wp-content/uploads/2014/04/audio-de-bienvenida.mp3" type="audio/mp3"> Your user agent does not support the HTML5 Audio element. </audio> <button type="button" onclick="aud_play_pause()" ></button> <script> function aud_play_pause() { var myAudio2 = document.getElementById("myAudio2"); if (myAudio2.paused) { myAudio2.play(); } else { myAudio2.pause(); } } </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using the code from www.rfmeier.net I have two separate audio files that need to got into the sites navigation/menu. I can get one in and working but when I try adding the second one then they both play the same audio clip. I can’t get them to work independently of each other. The first code is in the child theme functions.php file and the The second code am putting it into the wordpress backend menu links area because I can't figure out how to combine the two in the above script, but regardless they are not working independent of each other. so one is spanish welcome audio and the other is english: http://willixhypnosis.com/