WordPress – Return URL
October 2nd, 2008 by Frank • WordPress Hacks • 2 Comments
I already talked in my article Determine Path To Plugin and Content Directories about the possibilities how to keep functions in themes or Plugins free from error if you rename a folder, for example wp-content.
Since version 2.6 you can also solve this problem pretty easy with another function.
More details and information are available in /wp-includes/link-templates.php.
Return the site url
Returns the 'site_url' option with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise.
If $scheme is 'http' or 'https', is_ssl() is overridden.
$path - Optional path relative to the site url
$scheme Optional scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'
site_url($path = '', $scheme = null)
Return the admin url
Returns the url to the admin area.
$path - Optional path relative to the admin url
admin_url($path = '')
Return the includes url
Returns the url to the includes directory.
$path - Optional path relative to the includes url
includes_url($path = '')
Return the content url
Returns the url to the content directory
$path - Optional path relative to the content url
content_url($path = '')
Return the Plugins url
Returns the url to the Plugins directory.
$path - Optional path relative to the Plugins url
plugins_url($path = '')
At version 2.8 of WordPress you can use two parameter. Use $plugin with __FILE__ for scan your folder.
plugins_url($path = '', $plugin = '')
Examble for Pluginpath
The follw code load a javascript from the Plugin in folder examble_plugin_folder.
wp_enqueue_script( 'farbtastic', plugins_url('/examble_plugin_folder/includes/farbtastic/farbtastic.js'), array('jquery'), '1.2' );
I hope you enjoy this alternative. please comment for a better idea or a other ways to do it.
Info
- Published in WordPress Hacks
- Tags: Code, Plugin, WordPress
- Comment feed | Trackback URL
- read: 5482 | today: 9
- leave a Comment



Thank you for this post-it, this is a complete work-sheet for relatives URLs.
May be an example showing how to use it inside the DOM code directly would satisfy the most newbies of us.
Cheers,