[wp-hackers] URLs from DIRs
Stephen Rider
wp-hackers at striderweb.com
Wed Oct 29 02:37:09 GMT 2008
Hi all --
Just a bit of code I came up with that I thought others might find
handy.
function get_url_from_dir( $dir ) {
$home = get_option('home');
$parts = explode( '/', $home );
$domain = implode( '/', array($parts[0], $parts[1], $parts[2]) );
$url = $domain . str_replace( $_SERVER['DOCUMENT_ROOT'], '', $dir );
return $url;
}
Basically, what this will do is take a path and give you the
corresponding WP URL, e.g.:
WP_CONTENT_URL = get_url_from_dir( WP_CONTENT_DIR );
Regards,
Stephen
--
Stephen Rider
<http://striderweb.com/>
More information about the wp-hackers
mailing list