Plugin Directory URL for external Javascript file
Posted: Wed Dec 10, 2008 11:56 pm
I feel silly for asking, but rest assured I tried this site's search (which was useless) and a site-specific Google search before asking.
I'm working on a plugin that uses Javascript. Rather than copying the whole script into the <head>, I'd like to just reference the .js file. But there are no guarantees on what directories are writeable; therefore the file will have to be included in the plugin directory during the plugin installation.
But then how will I refer to the javascript file? When I make my link, can I make the reference with $serendipity['serendipityHTTPPath'] . '/plugins/' . MY_PLUGIN_NAME . '/thefile.js'? Is there any condition under which the plugin directory won't be located there? Perhaps there's a plugin already doing this that I could look at?
I could supply the javascript through an external plugin hook, but starting a new instance of Serendipity seems like a lot of overhead just to download a single Javascript file.
I could force the user to enter the plugin URL, but that always confuses them.
I just want a canonical way to reference files in a plugin directory.
I'm working on a plugin that uses Javascript. Rather than copying the whole script into the <head>, I'd like to just reference the .js file. But there are no guarantees on what directories are writeable; therefore the file will have to be included in the plugin directory during the plugin installation.
But then how will I refer to the javascript file? When I make my link, can I make the reference with $serendipity['serendipityHTTPPath'] . '/plugins/' . MY_PLUGIN_NAME . '/thefile.js'? Is there any condition under which the plugin directory won't be located there? Perhaps there's a plugin already doing this that I could look at?
I could supply the javascript through an external plugin hook, but starting a new instance of Serendipity seems like a lot of overhead just to download a single Javascript file.
I could force the user to enter the plugin URL, but that always confuses them.
I just want a canonical way to reference files in a plugin directory.