Customize: Prevent selective refresh from causing infinite fallback refreshes when nav menu contains invalid items.
Invalid nav menu items are exported as settings in the customize controls since it `is_admin()`, but any such `nav_menu_item` settings are excluded from the preview since it's the frontend. Selective refresh for nav menus needs to ignore the syncing of any such `nav_menu_item` settings that are `_invalid` since they are never rendered, and when a nav menu only contains invalid items, an infinite fallback refresh can ensue. Fixes #38890. git-svn-id: https://develop.svn.wordpress.org/trunk@39333 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f21e17dbf0
commit
ccf9b72446
@ -23,7 +23,17 @@ wp.customize.navMenusPreview = wp.customize.MenusCustomizerPreview = ( function(
|
||||
self.bindSettingListener( setting );
|
||||
} );
|
||||
api.bind( 'add', function( setting ) {
|
||||
self.bindSettingListener( setting, { fire: true } );
|
||||
|
||||
/*
|
||||
* Handle case where an invalid nav menu item (one for which its associated object has been deleted)
|
||||
* is synced from the controls into the preview. Since invalid nav menu items are filtered out from
|
||||
* being exported to the frontend by the _is_valid_nav_menu_item filter in wp_get_nav_menu_items(),
|
||||
* the customizer controls will have a nav_menu_item setting where the preview will have none, and
|
||||
* this can trigger an infinite fallback refresh when the nav menu item lacks any valid items.
|
||||
*/
|
||||
if ( setting.get() && ! setting.get()._invalid ) {
|
||||
self.bindSettingListener( setting, { fire: true } );
|
||||
}
|
||||
} );
|
||||
api.bind( 'remove', function( setting ) {
|
||||
self.unbindSettingListener( setting );
|
||||
|
Loading…
Reference in New Issue
Block a user