Created
June 7, 2017 08:57
-
-
Save gabrielmerovingi/a23193fa4883231518211602ea8032ca to your computer and use it in GitHub Desktop.
When someone clicks on a myCRED link, we play an audio file. (HTML5)
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
/** | |
* Play Audio on Link Click | |
* @version 1.0 | |
*/ | |
function mycred_pro_insert_link_click_audio() { | |
global $mycred_link_points; | |
if ( $mycred_link_points === true ) { | |
?> | |
<audio src="http://labs.mycred.me/wp-content/uploads/applause.wav" id="link-link-audio" style="display: none !important;"></audio> | |
<script type="text/javascript"> | |
var linkclickapplause = document.getElementById('link-link-audio'); | |
jQuery(function($){ | |
$( '.mycred-points-link' ).click(function(){ | |
linkclickapplause.currentTime = 0; | |
linkclickapplause.play(); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'mycred_front_enqueue_footer', 'mycred_pro_insert_link_click_audio', 999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment