[wp-hackers] plugins_url function

Phillip Lord phillip.lord at newcastle.ac.uk
Tue Dec 13 14:30:00 UTC 2011

John Blackbourn <johnbillion+wp at gmail.com> writes:

> 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.

Okay, that's not ideal for me. In practice, I think it's easier to
unwind the symlinks -- or just turn them around, so that the real
directory is under wp-content/plugins then I symlink to this for ease. 

Glad it wasn't just me though:-)


More information about the wp-hackers mailing list