#33916 closed defect (bug) (fixed)
Menus Customizer does not work when WP is in a sub-directory
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | Customize | Keywords: | has-patch commit fixed-major |
Focuses: | javascript | Cc: |
Description
Fast previewing changes to Menus in the Customizer does not work when WP is in a sub-directory.
My WordPress local installation is http://mysite.localhost/subdir/ (WordPress is installed there, this is not a multisites install). I use TwentyFifteen with no plugin. When I change the main menu using the customizer, the menu becomes greyed but nothing changes. When I inspect the HTTP traffic, I see that the request is done to http://mysite.localhost/subdir/subdir/ instead of http://mysite.localhost/subdir/
The faulty request has those parameters :
- wp_customize_menu_render :"1"
- wp_customize :"on"
and should normally return a JSON answer containing the new rendered menu.
Attachments (1)
Change History (11)
#1
@
10 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.3.2
- Version changed from trunk to 4.3
#2
follow-ups:
↓ 3
↓ 4
@
10 years ago
- Keywords has-patch dev-feedback needs-testing added; needs-patch removed
33916.diff: Implements @westonruter's fix:
Weston, thanks for the quick solution: I wasn't sure about the home_url removal in the second hunk, can you please review and advise if that is needed?
@Fab1en Can you test the patch to see if it resolves your issue? I don't have a subdirectory install setup, so only verified change didn't break preview in default install.
#3
in reply to:
↑ 2
@
10 years ago
- Keywords dev-feedback removed
Replying to adamsilverstein:
Weston, thanks for the quick solution: I wasn't sure about the home_url removal in the second hunk, can you please review and advise if that is needed?
Yeah, looks good. Normally the REQUEST_URI
is *always* set, so the initial requestUri
value just gets overridden. The second if
statement could even be consolidated with the initial array, for instance:
$exports = array(
/* ... */
'requestUri' => esc_url_raw( home_url( empty( $_SERVER['REQUEST_URI'] ) ? '/' : wp_unslash( $_SERVER['REQUEST_URI'] ) ) ),
/* ... */
);
But I think I originally kept them separate for readability.
#4
in reply to:
↑ 2
;
follow-up:
↓ 5
@
10 years ago
- Keywords needs-testing removed
Replying to adamsilverstein:
33916.diff: Implements @westonruter's fix:
@Fab1en Can you test the patch to see if it resolves your issue? I don't have a subdirectory install setup, so only verified change didn't break preview in default install.
I can confirm that this patch fixes the issue, thanks for the quick work.
#5
in reply to:
↑ 4
@
10 years ago
Thanks for the bug report!
Replying to Fab1en:
Replying to adamsilverstein:
33916.diff: Implements @westonruter's fix:
@Fab1en Can you test the patch to see if it resolves your issue? I don't have a subdirectory install setup, so only verified change didn't break preview in default install.
I can confirm that this patch fixes the issue, thanks for the quick work.
I'm certain this is the exact same issue that came up for the Partial Refresh feature plugin, and the patch for that plugin can be adapted for menus in the customizer: https://github.com/xwp/wp-customize-partial-refresh/commit/618ad6fc0d04451101d93f5d85e1008367061d04