[wp-trac] [WordPress Trac] #44564: wp_make_link_relative(home_url()) returns empty

WordPress Trac noreply at wordpress.org
Wed Jul 18 08:55:44 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               |  Resolution:
 Keywords:  needs-testing close  |     Focuses:
---------------------------------+------------------------------

Comment (by Fleuv):

 Replying to [comment:3 SergeyBiryukov]:
 > Hi @Fleuv, thanks for the ticket!
 >
 > > The following code will return an empty string.
 > > {{{#!php
 > > <?php
 > > echo wp_make_link_relative(home_url());
 > > }}}
 > >
 > >
 > > The expected result is: '/'
 >
 > That's because `home_url()` generally does not have a trailing slash.
 >
 > This should work as expected:
 > {{{
 > echo wp_make_link_relative( home_url( '/' ) );
 > }}}

 Same goes for site_url(). Although it is confusing to note "Keeps the path
 '/' at the beginning" in the documentation if that isn't always true.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44564#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list