Would you care to share a little more than that? How DO you set variables in a js file?
Is there any way to set JavaScript variables in an external .js file (ie, edit/generate an external text file) from a WordPress plugin?
Have the plugin insert a <script src="url-to-plugin?get_script=1"> tag into the page to make a script call to itself, then have it check for calls with a $_GET["get_script"] variable to make it generate the necessary javascript code.
I am assuming you are interested in using internal WP variables?
I’ve managed to do it the same way if I were simply using js within <script> tags
function blah()
{
var thing = prompt('blahblahblah:', '<?php if (empty($paged)) { echo "1";} else { echo $paged; } ?>'); ... and so on
You just need to enclose php properly.
Cheers, just using PHP directly in the script file will probably be best. But how do I go about including the appropriate WordPress functions so I can use get_option() to read from the database?
markwheeler: require_once('../../../wp-blog-header.php');
HOLY CRAP… I’ve been looking for wp-blog-headers for at least 3 hours. Thanks guys.