[wp-hackers] plugins_url function

John Blackbourn johnbillion+wp at gmail.com
Tue Dec 13 11:48:07 UTC 2011


On 13 December 2011 11:40, Phillip Lord <phillip.lord at newcastle.ac.uk> wrote:
> This fails rather badly as this call
>
> plugins_url( "kcite-citeproc/kcite.js",__FILE__  )
>
> which should be interpreted as
>
> http://server/wp-content/plugins/kcite/kcite-citeproc/kcite.js
>
> is actually interpreted as
>
> http://server/wp-content/plugins/home/myusername/wordpress-plugins/kcite/kcite-citeproc/kcite.js

Yeah the problem is that PHP resolves symlinks, so __FILE__ points to
the symlink target instead of the link file. I've written a plugin
which I use for my installs to correct it on a plugin-by-plugin basis.
Check it out here:

http://lud.icro.us/wp-plugins/symlinked-plugins.phps

You'll need to enter the filenames of your symlinked plugins into the
switch statement. You could probably swap it out for a nice system
that uses WordPress filters if you wanted to improve it.

John


More information about the wp-hackers mailing list