Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#33218 closed defect (bug) (fixed)

Customizer: Does Not Read the Default wp_page_menu fallback_cb for wp_nav_menu

Reported by: davidakennedy's profile davidakennedy Owned by: westonruter's profile westonruter
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.3
Component: Customize Keywords: has-patch commit
Focuses: Cc:

Description

It appears the Customizer does not read the default wp_page_menu fallback_cb for wp_nav_menu.

To reproduce:

  1. Make sure you have test data with pages and menus. The theme unit tests are good for this.
  2. On Trunk, activate Twenty Fourteen. Make sure you do not have a menu assigned in the the primary location.
  3. Next, view the site in the Customizer. You'll see no fallback menu, but an empty nav container where it should be. Like this: https://cloudup.com/cUuNcEaSHse
  4. If you view the site on the front end, the fallback is there.

What I expected? For the fallback to be rendered by the Customizer, like it is on the front end.

Reproduced in Twenty Thirteen and Twenty Twelve as well.

If I declare 'fallback_cb' => ‘wp_page_menu’ as part of wp_nav_menu, it works in the Customizer. But that is the default, so it should work without declaring it.

Attachments (1)

33218.patch (775 bytes) - added by ocean90 10 years ago.

Download all attachments as: .zip

Change History (10)

#1 @atomicjack
10 years ago

I recommend you submit a patch with the fallback_cb implementation as you stated above, then if there's an actual bug with it not being declared by default, that can be worked on later. At least this way we could get the patch, albeit temporary, in time for release. Just my feelings.

#2 @westonruter
10 years ago

We added this recently to wp_nav_menu() in the 4.3 release:

// Prevent a fallback_cb in Customizer Preview to assist with has_nav_menu() and partial refresh.
if ( is_customize_preview() ) {
	$defaults['fallback_cb'] = '';
}

So this is probably what you're noticing here. However, I think that recent changes have made this unnecessary, but I haven't yet verified that. In the mean time, you can just explicitly supply the default fallback_cb as @atomicjack suggested.

This ticket was mentioned in Slack in #core by obenland. View the logs.


10 years ago

#4 @obenland
10 years ago

  • Milestone changed from Awaiting Review to 4.3
  • Owner set to westonruter
  • Status changed from new to assigned

Could you verify ifun setting fallback_cb is necessary?

@ocean90
10 years ago

#5 @ocean90
10 years ago

  • Focuses javascript removed
  • Keywords has-patch added

Tested 33218.patch with Twenty Fourteen and Twenty Eleven and it works as expected. Switching between a fallback and a nav menu does a full refresh but subsequent updates are doing a partial refresh.

#6 @westonruter
10 years ago

  • Keywords commit added

And the full refreshes are expected since the Customizer preview isn't able to wrap the wp_nav_menu() calls for fallback callbacks. In Twenty Fifteen it doesn't appear to work but this is only because the wp_nav_menu() calls are wrapped in has_nav_menu() checks, and so the fallbacks are never called anyway. So yeah, this looks good to remove.

This ticket was mentioned in Slack in #core by westonruter. View the logs.


10 years ago

#8 @azaozz
10 years ago

Looks good, +1 for commit.

#9 @westonruter
10 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 33585:

Customizer: Restore default fallback_cb arg for wp_nav_menu() calls in customizer preview.

Props ocean90, westonruter.
Fixes #33218.

Note: See TracTickets for help on using tickets.