[wp-trac] [WordPress Trac] #35561: function wp_admin_canonical_url() not using configured site url when constructing canonical url link tag

WordPress Trac noreply at wordpress.org
Thu Jan 21 16:00:46 UTC 2016


#35561: function wp_admin_canonical_url() not using configured site url when
constructing canonical url link tag
----------------------------+-----------------------------
 Reporter:  ilude           |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  4.4.1
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 I was having an issue with the  wp_admin_canonical_url() function in wp-
 admin/includes/misc.php and I have a suggested fix

 I am running word press behind a reverse nginx proxy on a different box so
 my main site is at http://www.rammount.com and the blog is at
 http://www.rammount.com/blog

 The blog url is set in the WordPress configuration. But when you log into
 the admin section the wp_admin_canonical_url() function does not pick up
 the configured url instead it constructs the url without the /blog. This
 of course breaks links in the admin section, constantly redirecting things
 to http://www.rammount.com without the /blog

 by changing the following line:
 $current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] .
 $_SERVER['REQUEST_URI'] );

 to:
 $current_url  =
 set_url_scheme(home_url(add_query_arg(array(),$wp->request)) .
 $_SERVER['REQUEST_URI']);

 the problem is solved. the proper url is created and as such the links in
 the admin section that use the canonical url link function correctly.

 Hoping to have this change evaluated for inclusion, so that I don't have
 to remake this edit every time one of my designers updates the WordPress
 installation?

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


More information about the wp-trac mailing list