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.

Built from https://develop.svn.wordpress.org/trunk@39333


git-svn-id: http://core.svn.wordpress.org/trunk@39273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-11-21 19:16:32 +00:00
parent 3284f9a989
commit 277d4d0ab0
3 changed files with 13 additions and 3 deletions

View File

@ -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 );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-beta4-39332';
$wp_version = '4.7-beta4-39333';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.