[wp-trac] [WordPress Trac] #60308: Inconsistent return of urls / get_bloginfo() vs get_template_directory_uri()

WordPress Trac noreply at wordpress.org
Sat Jan 20 11:07:32 UTC 2024


#60308: Inconsistent return of urls / get_bloginfo() vs
get_template_directory_uri()
--------------------------+-----------------------------
 Reporter:  luckyfella73  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.4.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 It doesn't seem to happen in all server environments but on a WP instance
 hosted on IONOS (former 1&1) I get unexpected returns when using:
 `get_template_directory_uri()`


 * I'm calling the page including `https:` and `www.` in the browser.
 * I have `WP_HOME` and `WP_SITEURL` configured having the `www.` included.
 * All urls relating to the page in the database have `www.` included.
 * `wp-admin/options-general.php` shows the `www.` in both urls

 When trying to load assets (js files) using `get_template_directory_uri()`
 to build the full url-path the `www.` is omitted. Due to crossdomain
 restrictions the files don't get loaded of course.

 After looking at my configuration to find the error I might have done I
 found out that I get the domain with `www.` included when using
 `get_bloginfo('url')`.

 `get_bloginfo('stylesheet_url')` on the other hand does not return `www.`
 in the url. That is unexpected to me.

 {{{#!php
 <?php
 // returns no 'www.'
 $get_template_directory_uri = get_template_directory_uri();
 echo ("<p><code>get_template_directory_uri()</code>:<br>" .
 $get_template_directory_uri . "</p>");

 // returns 'www.'
 $get_bloginfo_url = get_bloginfo('url');
 echo ("<p><code>get_bloginfo('url')</code>:<br>" . $get_bloginfo_url .
 "</p>");

 // returns no 'www.'
 $stylesheet_url = get_bloginfo('stylesheet_url');
 echo ("<p><code>get_bloginfo('stylesheet_url')</code>:<br>" .
 $stylesheet_url . "</p>");
 }}}


 Environment:
 * WordPress 6.4.2 (latest the time of writing)
 * all plugins deactivated
 * PHP 8.1.27

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60308>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list