From 945699faff964db7c025e57647abfd12ac82575d Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Mon, 22 Mar 2010 22:26:27 +0000 Subject: [PATCH] Prevent the nav menu walker from walking in circles. Don't allow an object from being a child of itself; if the functionality is desired, a workaround would be custom links. see #11817, see #12566 git-svn-id: https://develop.svn.wordpress.org/trunk@13803 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/nav-menu.dev.js | 10 ++++++++++ wp-admin/js/nav-menu.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-admin/js/nav-menu.dev.js b/wp-admin/js/nav-menu.dev.js index f418962c82..fa5d660c3d 100644 --- a/wp-admin/js/nav-menu.dev.js +++ b/wp-admin/js/nav-menu.dev.js @@ -196,6 +196,16 @@ var wpNavMenu; var li = $(this).parent(); var child = !$(this).hasClass('dropzone'); + var parent_id = li.children('input[name=menu-item-object-id[]]').val(); + var child_id = ui.draggable.children('input[name=menu-item-object-id[]]').val(); + + // An item cannot be a child of itself. Use a custom link for the effect. + if ( parent_id == child_id ) { + ui.draggable.find('dt').animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ) } } ); + $(this).parent().find('dt').removeAttr('style'); + return; + }; + // Append UL to first child if ( child && li.children('ul').length == 0 ) { li.append( '