WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#33916 closed defect (bug) (fixed)

Menus Customizer does not work when WP is in a sub-directory

Reported by: Fab1en Owned by: westonruter
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.3
Component: Customize Keywords: has-patch commit fixed-major
Focuses: javascript Cc:
PR Number:

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)

33916.diff (1.0 KB) - added by adamsilverstein 4 years ago.

Download all attachments as: .zip

Change History (11)

#1 @westonruter
4 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.3.2
  • Version changed from trunk to 4.3

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

#2 follow-ups: @adamsilverstein
4 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 @westonruter
4 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: @Fab1en
4 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 @adamsilverstein
4 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.

#6 @adamsilverstein
4 years ago

  • Keywords commit added

#7 @westonruter
4 years ago

  • Owner set to westonruter
  • Resolution set to fixed
  • Status changed from new to closed

In 34278:

Customize: Fix live previewing of menu changes on subdirectory installs.

Props adamsilverstein, westonruter.
Fixes #33916.

#8 @westonruter
4 years ago

In 34279:

Customize: Fix live previewing of menu changes on subdirectory installs.

Merges [34278] from trunk.

Props adamsilverstein, westonruter.
Fixes #33916 for 4.3.

#9 @westonruter
4 years ago

  • Keywords fixed-major added

#10 @johnbillion
4 years ago

  • Milestone changed from 4.3.2 to 4.4
Note: See TracTickets for help on using tickets.