[wp-hackers] Why always absolute paths?

John Bloch jbloch at olympianetworks.com
Wed Apr 21 13:26:34 UTC 2010


This doesn't get rid of the problem that Vinicius initially complained about. Right now you use a php function to get the correct url to the theme directory, etc. Changing the methodology to relative urls rather than absolute urls only changes what the function returns. It doesn't get rid of the function. The functions are there to give a uniform solution across all possible configurations so that theme and plugin developers can release products that will work no matter what the configuration is (even if an installation has changed the location of its wp-content folder). So the relative path way of doing it would have to return the relative path to the WP installation. So, if using relative uris for http://www.example.com/, bloginfo('wpurl') would echo '/' instead of 'http://www.example.com'. For http://www.example.com/blog, it would echo '/blog/'. The thing is, you haven't changed anything except the length of the string echoed by the function. This is because you can't depend on any single configuration being present.

How, if Vinicius is developing a custom theme, the configuration for which he already knows (and knows that it won't change), then there's absolutely no problem with developing a theme or plugin with relative urls. But WP will never get rid of those handy functions that allow developers to publicly release their work (unless it gets rid of permalinks).

On Apr 21, 2010, at 9:12 AM, Stas Sușcov wrote:

> În data de Mi, 21-04-2010 la 07:58 -0500, Stephen Rider a scris:
>> On Apr 21, 2010, at 6:46 AM, Bumbu Alex wrote:
>> 
>>> if you use sef url and you'll give relative path for the image (ex.
>>> images/top.jpg)
>>> 
>>> so on page _http://page.com/ you'll have src to _
>>> http://page.com/images/top.jpg
>> 
>> Correct.
>> 
>>> you can use such src as /images/top.jpg and for the above examples you'll
>>> have tha same link _http://page.com/images/top.jpg
>>> but when somebody will have WP installed in subdirectory, but he will use
>>> default template, instead of getting
>>> _http://page.com/blog/images/top.jpg
>>> he will have
>>> _http://page.com/images/top.jpg
>> 
>> ???  If WP is installed in a subdirectory, the root path would include the subdirectory.  I still don't see the problem with root paths.
>> 
>> I've wondered this myself regarding links to media put on a site with the uploader.  Why full URL with the path?  If I move domains or something I have to go into the database and change the URLs for all those links.
>> 
>> Stephen
>> 
> 
> Didn't study in depth the cause, but I think saving media files uri in
> db helps a lot writing plugins for cdn plugins. This is an issue, but
> it's not wrong at all.
> 
> -- 
> ()  Campania Panglicii în ASCII
> /\  http://stas.nerd.ro/ascii/
> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list