Opened 11 years ago
Closed 11 years ago
#25315 closed defect (bug) (fixed)
Theme Customizer preview wont load home URL
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | 3.6.1 |
Component: | Customize | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
In the theme-customizer, clicking on the home link (within the preview iframe), does nothing, unless the home link is followed by a trailing slash.
<a href="http://website.com">Home</a> - will not load. stays on current page and does nothing.
<a href="http://website.com/">Home</a> - loads fine.
This can be very confusing, when you are browsing the theme preview, and you attempt to return to the hompage, only to be unable to do so.
The issue is caused in the "wp-admin/customize.php" file. The array $allowed_urls includes the home_url with a trailing slash, but not without.
Attachments (1)
Change History (11)
#3
@
11 years ago
Could not reproduce on a clean install with Twenty Fourteen.
I've changed the link in Twenty Fourteen header to remove the trailing slash, however the URL to be checked in Customizer in the condition mentioned above (tags/3.6.1/wp-admin/js/customize-controls.js#L559) always contains the trailing slash. Tested in Firefox 23, Chrome 29, IE 8, Opera 12.
#4
@
11 years ago
Some more testing: the URL is set in api.Preview
(line 34):
tags/3.6.1/wp-includes/js/customize-preview.js#L20.
Unlike $(this).attr('href')
, $(this).prop('href')
always returns the home URL with a trailing slash.
#5
@
11 years ago
The issue can be reproduced by inserting the following link into your header:
<a href="<?php bloginfo('url'); ?>" >Home</a>
Or alternatively, by creating a link in a custom menu, with the URL set to '/'.
This has been tested in Chrome 29, IE10, and FF 18.
#6
@
11 years ago
Still could not reproduce, both options are working for me.
Does this happen with all plugins deactivated and using a default theme?
#7
@
11 years ago
Ok, I see what was happening. I had Wordpress installed on a subdirectory (localhost/wordpress). The jquery prop('href') method does not add the trailing slash to such links. See - http://jsfiddle.net/RZMwG/2/
At the same time, the "customize.php" file uses home_url('/') to generate the allowed-url, which appends the trailing slash regardless.
Looking at this, the JS does a
0 === test_url.indexOf( allowed_url )
check. The issue here being thatwebsite.com.notmywebsite.com
would match that, unless we look for a trailing slash.I think we can make this work as long as we check
0 === indexOf
for a URL without a trailing slash, but then confirm that the next character is/
,#
,?
, or that there is no last character (as in this example).This check isn't here for security, but it doesn't mean we should make it lax.