Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#54888 closed defect (bug) (fixed)

Remove Customizer's Menus section when block theme is active.

Reported by: hellofromtonya's profile hellofromTonya Owned by:
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Customize Keywords: has-testing-info has-patch
Focuses: Cc:

Description (last modified by hellofromTonya)

When upgrading to 5.9 and first activating a block theme such as Twenty Twenty-Two (TT2), the Customizer's Menus section shows the existing (classic) menu(s) as though it is still assigned, but the previewer and Site Editor show the default header menu with pages listed (i.e. from the Navigation block with Page List).

This will confuse users.

How will they know that their previous (classic) menu needs to be assigned in the Site Editor when first upgrading? They won't.

To resolve this problem, @noisysocks suggested hiding the Menus section in Customizer as is done with the Widgets section.

Attachments (1)

54888-upgrade-classic-menu-customizer.gif (4.6 MB) - added by hellofromTonya 3 years ago.
See the issue in action: Upgrade to 5.9, activate TT2, refresh Customizer and open Menus section, and open Site Editor. Notice: preview in Customizer is the page listing but Menus still shows classic menu.

Change History (14)

@hellofromTonya
3 years ago

See the issue in action: Upgrade to 5.9, activate TT2, refresh Customizer and open Menus section, and open Site Editor. Notice: preview in Customizer is the page listing but Menus still shows classic menu.

#1 @hellofromTonya
3 years ago

  • Keywords has-testing-info added

Steps to Reproduce:

  1. Start with pre 5.9 version, such as 5.8.3.
  2. Activate a default theme such as TT1 (Twenty Twenty-One).
  3. Add a Main Menu by going to Appearance > Menus and creating a menu and assign it to the primary menu.
  4. Open Customizer's Menu section by going to Appearance > Customize > Menus.
  5. Upgrade to 5.9 RC3.
  6. Activate TT2 (Twenty Twenty-Two) by going to Appearance > Themes.
  7. Refresh Customizer and then reopen Menus section.

Notice the preview is showing the default header nav of page listings, but the Menus section is still showing the previous assigned Main Menu.

  1. Open Site Editor.
  2. Open list view.

Notice the Navigation block and Page List. This is the default setup for TT2.

Last edited 3 years ago by hellofromTonya (previous) (diff)

#2 @hellofromTonya
3 years ago

  • Description modified (diff)

This ticket was mentioned in PR #2217 on WordPress/wordpress-develop by noisysocks.


3 years ago
#3

  • Keywords has-patch added; needs-patch removed

By having WP_Customize_Panel::check_capabilities(), we can ensure that the _Menus_ panel is removed if a theme does not have support for 'menus' nor 'widgets'. (We show the _Menus_ panel when there is support for 'widgets' so that one can use the Menu widget.)

This ensures that the _Menus_ panel does not appear when using a block theme, which is pretty confusing, as the Navigation block is intended to be the sole place for editing a site's navigation when using a block theme.

Trac ticket: https://core.trac.wordpress.org/ticket/54888

#4 @costdev
3 years ago

Test Report

Env

  • WordPress 5.8.3 and PR 2217
  • Chrome 97.0.4692.71
  • Windows 10
  • Theme: Twenty Twenty-One and Twenty Twenty-Two
  • Block Editor
  • Plugin: None activated

Steps to test block themes

  1. Start with pre 5.9 version, such as 5.8.3.
  2. Activate a default theme such as TT1 (Twenty Twenty-One).
  3. Add a Main Menu by going to Appearance > Menus and creating a menu and assign it to the primary menu.
  4. Open Customizer's Menu section by going to Appearance > Customize > Menus.
  5. Upgrade to 5.9 RC3.
  6. Activate TT2 (Twenty Twenty-Two) by going to Appearance > Themes.
  7. Refresh Customizer and then reopen Menus panel.

Notice the preview is showing the default header nav of page listings, but the Menus section is still showing the previous assigned Main Menu. ✅

  1. Apply PR 2217.
  2. Refresh Customizer.
  3. The Menus panel is not shown. ✅

Steps to test classic themes

  1. Switch to Twenty Twenty-One.
  2. Comment out register_nav_menus() and register_sidebar() in wp-content/themes/twentytwentyone/functions.php.
  3. View Customizer.
  4. The Menus panel is shown. ✅
  5. Apply PR 2217.
  6. Refresh Customizer.
  7. The Menus panel is not shown. ✅

Results

PR 2217 successfully removes the Menus panel from the Customizer for block themes and classic themes that do not support menus or widgets. ✅

noisysocks commented on PR #2217:


3 years ago
#5

Edit: Timing. Defer to you and Peter to discuss unneeded code vs consistency.

😅 I want the consistency but, yeah, safest to not fix what isn't broken while in RC. I'll open a seperate patch which adds it and we can commit that to trunk only.

noisysocks commented on PR #2217:


3 years ago
#6

Thanks for reviewing and testing. Feedback addressed. I can commit to both branches today if two devs approve 😀

#7 @noisysocks
3 years ago

In 52621:

Customizer: Remove Menus panel when a theme does not support menus

By overriding check_capabilities(), we can ensure that the Menus panel
is removed if a theme does not have support for 'menus' nor 'widgets'.

This ensures that the Menus panel does not appear when using a block
theme, which is confusing to users.

See #54888.
Props hellofromTonya, costdev, peterwilsoncc.

#8 @noisysocks
3 years ago

In 52622:

Customizer: Remove Widgets panel when a theme does not support widgets

By setting 'theme_supports' on the panel, we ensure that the Widgets panel is
removed if a theme does not have support for 'widgets'.

This makes the behaviour of the Widgets and Menus panels consistent.

Follows [52621].
See #54888.
Props hellofromTonya, costdev, peterwilsoncc.

#9 @noisysocks
3 years ago

In 52623:

Customizer: Remove Menus panel when a theme does not support menus

By overriding check_capabilities(), we can ensure that the Menus panel
is removed if a theme does not have support for 'menus' nor 'widgets'.

This ensures that the Menus panel does not appear when using a block
theme, which is confusing to users.

See #54888.
Props hellofromTonya, costdev, peterwilsoncc.

#11 @noisysocks
3 years ago

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

#12 @SergeyBiryukov
3 years ago

For reference, [52622] was committed to trunk only, per PR 2218.

#13 @westonruter
2 years ago

In 54419:

Customize: Prevent PHP notice in Customizer when using block theme.

Use the customize_panel_active filter to deactivate the Menus panel instead of overriding the check_capabilities method. This ensures the panel remains registered but is still hidden.

See #54888.
Fixes #54905.

Note: See TracTickets for help on using tickets.