A lightbox script. Which has links for flvplayer and mp3player in it like this:
FLVPlayer: "/js/FLVplayer.swf", // URL of the FLV Player
MP3Player: "/js/MP3player.swf", // URL of the MP3 Player
And I need to add <?php bloginfo('template_url'); ?> to the beginning in order to generate the right URL. I cannot write it directly because it will be a template. And I cannot call this part of the script from header.php either. So I need to make the template_tag work inside the script file.
Put this in your theme’s functions.php:
add_action( 'wp_head' , 'my_plugin_wp_head' );
function my_plugin_wp_head()
{
print('<script type="text/javascript">var TEMPLATE_URL = "' . get_bloginfo('template_directory') . '";</script>');
}
and call your javascript file after the <?php wp_head(); ?> in your theme’s header.php
Now you can use the variable TEMPLATE_URL in your script like this:
MP3Player: TEMPLATE_URL + "/js/MP3player.swf", // URL of the MP3 Player