A common issue when using a symlinked
This function is supposed to generate a path like,
wp-content is symlinked to
plugins_url generates an incorrect path like,
This scenario is quite common in shared hosting environments. Typically these WordPress installations are fixed and individual sites correspond to symlinked
wp-content directories. In such cases the problem is seen even when we did not create any symlinks ourselves.
So should we abandon symlinking
wp-content and go back to copying files back-and-forth again? Or go about fixing every plugin that uses
Fortunately there is a simple fix. WordPress offers a
plugins_url filter hook that can be used to resolve the symlinked path. We need to expand any symlinks in such a filter callback hook. The key is to do this in a plugin that loads before any other plugin.
The wordpress-plugin-symlink is a plugin that does exactly this. It hooks to the
plugins_url filter and expands symlinks to their full paths. Thus all plugins get correct results when calling the
To install it you need to copy this plugin into your plugin directory.
Rename it’s directory to
P.S. There is an ongoing discussion on WordPress Trac about this issue. It will most likely get fixed in future versions of WordPress.