Is there any equivalent to functions like plugins_url()
and content_url()
that give you either the relative paths or the file path.
For instance, instead of
I want:
/Users/username/Sites/wordpress-3.2/wp-content
I know that I can build this path using the ABSPATH
constant, but I’m specifically interested in learning if there are built in functions to handle this.
In the meantime, I’ll probably just write a function to swap the url for the abspath.
EDIT: Here’s the simple function that I wrote to handle this:
function get_file_path($url)
{
return str_replace(site_url(), ABSPATH, $url);
}
Seems to do the trick, but I’d much rather use built in functions if available.
There aren’t any for plugins, but you can (and should) use WP_CONTENT_DIR, instead of ABSPATH.
For themes you have locate_template().
There is
plugin_dir_path()
, but it’s not exact analogue ofplugins_url()
.Also
ABSPATH
is unreliable for how you use it, related paths can be easily redefined. Seedefault-constants.php
file.Namely there are:
WP_CONTENT_DIR
WP_PLUGIN_DIR
WPMU_PLUGIN_DIR