[wp-trac] [WordPress Trac] #44564: wp_make_link_relative(home_url()) returns empty
WordPress Trac
noreply at wordpress.org
Wed Jul 11 08:19:26 UTC 2018
#44564: wp_make_link_relative(home_url()) returns empty
--------------------------+-----------------------------
Reporter: Fleuv | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version: 4.9.7
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
According to the documentation of the function
[[https://codex.wordpress.org/Function_Reference/wp_make_link_relative|wp_make_link_relative()]]:
> Removes the http or https protocols and the domain. **Keeps the path '/'
at the beginning**, so it isn't a true relative link, but from the web
root base.
Regarding, keeping the path '/' at the beginning. This isn't necessarily
true when there isn't a path after the web root base (e.g. with the
homepage URL this is often the case) resulting in an empty string to be
returned.
Consider the test case in the code block below for a WordPress
installation what uses the web root base. Thus I can confirm this bug to
exists on installation locations such as: http://example.com/ or
http://subdomain.example.com/ but not on http://example.com/subdirectory/
The following code will return an empty string.
{{{#!php
<?php
echo wp_make_link_relative(home_url());
}}}
The expected result is: '/'
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44564>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list