I'm trying to use get_bloginfo('url') in a javascript file being generated but any WordPress functions I attempt to use come up undefined.
Sorry if the scenario is slightly confusing. I'll my best to explain.
This is in my main plugin file:
function soundtrack_add_js() {
wp_enqueue_script( 'jquery', '1.3.2' );
wp_enqueue_script( 'soundtrack-js', WP_PLUGIN_URL.'/soundtrack/soundtrack-script.js.php' );
}
add_action('wp_print_scripts', soundtrack_add_js);
This is my js file:
<?php
$forward_url = (isset($_GET['forward_url'])) ? $_GET['forward_url'] : get_bloginfo('url');
$script = 'jQuery(document).ready(function(){';
$script .= ' if (parent.myframe) {';
$script .= ' jQuery("body").prepend("Framed.");';
$script .= ' } else {';
$script .= ' var url = window.location;';
$script .= ' jQuery("body").empty().append(\'<p>New stuff</p><iframe id="myframe" name="myframe" src="\'+url+\'" width="100%" height="100%" frameborder="0" />\');';
$script .= ' }';
$script .= '});';
echo $script;
?>
When php hits get_bloginfo('url') it dies.
Is there a specific time when WordPress functions such as get_option() become available? I would love to understand this more fully.
Thanks for any help on the matter.