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
This commit is contained in:
Andrew Nacin 2010-03-22 22:26:27 +00:00
parent 94ec7ba0eb
commit 945699faff
2 changed files with 11 additions and 1 deletions

View File

@ -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( '<ul class="sub-menu" />' );

File diff suppressed because one or more lines are too long