WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#39449 new enhancement

`customize_loaded_components` filter is too late for themes

Reported by: danielbachhuber Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Customize Keywords: needs-patch
Focuses: Cc:
PR Number:

Description

As a WordPress theme developer, I want to remove nav menus from the Customizer when the theme doesn't make use of widgets or menus.

The customize_loaded_components filter fires on plugins_loaded though, which mean my theme can't use it to filter components to load. Instead, I have to use an imprecise set of remove_action and remove_filter calls.

It would be better to have an explicit API for themes to filter which components to load.

Previously #33552

Change History (3)

#1 follow-up: @dd32
3 years ago

I want to remove nav menus from the Customizer when the theme doesn't make use of widgets or menus.

For that specific use-case of what you're requesting here, wouldn't it be better for the Customizer to just not register the menu components if ( ! $supports_widgets && ! $menu_locations )?

#2 in reply to: ↑ 1 @danielbachhuber
3 years ago

Replying to dd32:

For that specific use-case of what you're requesting here, wouldn't it be better for the Customizer to just not register the menu components if ( ! $supports_widgets && ! $menu_locations )?

Yes, I think this is sensible behavior.

I know the menu components are still loaded if no menus are registered when the menu widget is present, but it doesn't make sense to load the menu components if widgets aren't available either.

#3 @westonruter
3 years ago

  • Keywords needs-patch added; dev-feedback removed
  • Milestone changed from Awaiting Review to Future Release

It may be possible to defer the initialization of the components until after_setup_theme, which is what would be required if we're to let the theme configure which components are loaded. There may be some unintended dependencies on the current early init, however. Will need investigation.

See also http://wordpress.stackexchange.com/q/250349/8521

Note: See TracTickets for help on using tickets.