[wp-hackers] plugins_url function

Jeremy Clarke jer at simianuprising.com
Wed Dec 14 18:58:27 UTC 2011


I hit this issue as well. The best solution I've found is to use some code
similar to what John B posted that filters plugins_url and targets the
specific predicable results of __FILE__ on the given system.

One optimization I'd add is to use the mu-plugins folder rather than normal
/plugins/. This way the plugin is always active on that site without having
any references to it in the database (so that when you copy the db to your
local dev site the plugin isn't missing). It also just makes sense to have
it there, as it's party of the 'hard' setup of the site rather than the
'soft' config.

My code is actually a lot simpler. Not sure if there's a case I'm not
accounting for, or if I'm just depending more on plugins_url() to take care
of SSL stuff for me, but feel free to contrast and compare with John B's
code:

http://pastie.org/3017033

On Wed, Dec 14, 2011 at 10:23 AM, Mario Peshev <mario at peshev.net> wrote:

> Is WP_PLUGIN_URL an accepted solution to point to the plugins directory? I
> can't find any positive or negative comments on this nor documentation in
> the codex.
>
>
WP_PLUGIN_URL, along with the other constants, are effectively deprecated.
You should never use them, instead always use the functions like
site_url(). The constants do not currently have any kind of is_ssl()
support so you are just asking for problems. The functions also work better
so why not use them?

--
Jeremy Clarke • jeremyclarke.org
Code & Design • globalvoicesonline.org


More information about the wp-hackers mailing list