WordPress.org

Make WordPress Core

Opened 13 days ago

Last modified 6 hours ago

#42115 assigned enhancement

Customize Menus: Add "Your theme already has a basic menu" view

Reported by: melchoyce Owned by: bpayton
Milestone: Future Release Priority: normal
Severity: normal Version: trunk
Component: Customize Keywords:
Focuses: ui Cc:

Description

When your theme creates a menu by default, we should display the following text:

Your theme already has a basic menu, to help readers find all your pages. If you’d like to choose what appears instead, create a new menu to replace the default.

Click the button to start.

[ Replace default menu ]

See screenshot.

Attachments (1)

existing-menu.png (32.1 KB) - added by melchoyce 13 days ago.

Download all attachments as: .zip

Change History (6)

#1 @melchoyce
13 days ago

  • Owner set to bpayton
  • Status changed from new to assigned

#2 @joyously
13 days ago

How would the Customizer know whether the theme has used a fallback menu or not?
(Is that what is meant by "When your theme creates a menu by default", because themes in the repository aren't supposed to create menus?)

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


2 days ago

#4 @westonruter
7 hours ago

This is something we'd be able to sniff for via in the preview. In particular, when wp_nav_menu() is called and falls back to listing pages, then a selective refresh partial will still be created. So in that case, the partial itself could send a message to the parent window to inform it that a given theme location has a fallback populating it.

#5 @westonruter
6 hours ago

  • Milestone changed from 4.9 to Future Release
  • Type changed from task (blessed) to enhancement

Correction: Fallback menus don't yet get selective refresh partials. There is a patch for this in #39665. In that patch there is a echo_preview_nav_menu_args_fallback_with_partial_refresh method that wraps the original fallback_cb and calls it. So inside of this function we'd be able to look to see if a theme_location param is present, and if so, then tally that location similar to how we tally sidebar calls and then export them to JS in the preview, and then it could be sent to the controls window via wp.customize.preview.send( 'nav-menu-locations-with-fallbacks', locations ) which then can be listened to in the controls pane via wp.customize.previewer.bind( 'nav-menu-locations-with-fallbacks', function() { … } ). This listener can then toggle whether or not the additional text should be displayed.

Nevertheless, this isn't going to land in in 4.9 due to the dependency here on #39665.

Note: See TracTickets for help on using tickets.