WordPress.org

Make WordPress Core

Ticket #11817: menu_item_bug.diff

File menu_item_bug.diff, 24.7 KB (added by ptahdunbar, 12 years ago)

bugfix: objects can't directly have childs of itself.

  • wp-admin/js/nav-menu.dev.js

     
    195195                                drop: function(e, ui) {
    196196                                        var li = $(this).parent();
    197197                                        var child = !$(this).hasClass('dropzone');
    198 
     198                                       
     199                                        var parent_id = li.children('input[name=menu-item-object-id[]]').val();
     200                                        var child_id = ui.draggable.children('input[name=menu-item-object-id[]]').val();
     201                                       
     202                                        // An item cannot be a child of itself
     203                                        if ( parent_id == child_id ) {
     204                                                ui.draggable.find('dt').animate( { backgroundColor: '#FF3333' }, { duration: 'normal', complete: function() { $(this).css( 'backgroundColor', '' ) } } );
     205                                               
     206                                                $(this).parent().find('dt').removeAttr('style');
     207                                                return;
     208                                        };
     209                                       
    199210                                        // Append UL to first child
    200211                                        if ( child && li.children('ul').length == 0 ) {
    201212                                                li.append( '<ul class="sub-menu" />' );
     
    215226                                        li.find('#menu-' + draggablevalue).find('#parent' + draggablevalue).val(droppablevalue);
    216227                                        $(this).parent().find('dt').removeAttr('style');
    217228                                        $(this).parent().find('div:first').removeAttr('style');
    218 
    219229                                },
    220230                                over: function(e) {
    221231                                // Add child
  • wp-admin/js/nav-menu.js

     
    1 var wpNavMenu;(function(a){wpNavMenu={init:function(){wpNavMenu.initial_meta_boxes();wpNavMenu.drag_and_drop();a("#update-nav-menu .deletion").click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});a("#update-nav-menu").submit(function(){wpNavMenu.update_post_data()});a("#create-menu-name").keypress(function(b){if(13==b.keyCode){a("#create-menu-button").click();return false}});a("#custom-menu-item-url, #custom-menu-item-name").keypress(function(b){if(13==b.keyCode){a("#add-custom-links a.button").click();return false}}).focus(function(){if(a(this).val()==a(this).attr("defaultValue")&&a(this).attr("id")!="custom-menu-item-url"){a(this).val("")}}).blur(function(){if(a(this).val()==""){a(this).val(a(this).attr("defaultValue"))}});a("#create-menu-name").focus(function(){if(a(this).val()==a(this).attr("defaultValue")){a(this).val("")}}).blur(function(){if(a(this).val()==""){a(this).val(a(this).attr("defaultValue"))}});a(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("nav-menus");a(".quick-search").click(function(){a(this).attr("value","")});a(".quick-search-submit").click(function(){a(this).siblings(".quick-search").search()});a("#menu-container .item-edit").click(function(){wpNavMenu.edit_menu_item(a(this).attr("value"))});a("#menu-container .item-delete").click(function(){wpNavMenu.remove_menu_item(a(this).attr("value"))});a("#update-menu-item").click(function(){wpNavMenu.update_menu_item();tb_remove()});a("#cancel-save").click(function(){tb_remove()});a(".show-all").click(function(b){a(b.currentTarget).parent().parent().siblings(".list-wrap").css("display","block");a(b.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","block");a(b.currentTarget).hide();a(b.currentTarget).siblings(".hide-all").show()});a(".hide-all").click(function(b){a(b.currentTarget).parent().parent().siblings(".list-wrap").css("display","none");a(b.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","none");a(b.currentTarget).hide();a(b.currentTarget).siblings(".show-all").show()});a(".add-to-menu").click(function(b){wpNavMenu.add_checked_items_to_menu(b.currentTarget)});a("#add-custom-links .add-to-menu a").click(function(b){if(a("#custom-menu-item-url").val()==a("#custom-menu-item-url").attr("defaultValue")){return}wpNavMenu.add_custom_link(a("#custom-menu-item-name").val(),a("#custom-menu-item-url").val());a("#custom-menu-item-name").val(a("#custom-menu-item-name").attr("defaultValue"));a("#custom-menu-item-url").val(a("#custom-menu-item-url").attr("defaultValue")).focus()})},add_custom_link:function(c,b){var d={action:"save-custom-link",link_name:c,link_url:b};a.post(ajaxurl,d,function(e){if("-1"==e){return}wpNavMenu.add_to_menu(e,e,"custom","custom",navMenuL10n.custom,0,c,b,"","","_self","","")},"json")},initial_meta_boxes:function(){var c=a("#hidden-metaboxes").val().split(",");if(""!=c){for(var b=0;b<c.length;b++){a("#"+c[b]).attr("style","display: none;");a("#"+c[b]+"-hide").attr("checked",false)}}},drag_and_drop:function(){a(".menu li").each(function(){if(!a(this).children(".dropzone").attr("class")){a(this).prepend('<div class="dropzone"></div>')}});a(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});a(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(g,f){var b=a(this).parent();var h=!a(this).hasClass("dropzone");if(h&&b.children("ul").length==0){b.append('<ul class="sub-menu" />')}if(h){b.children("ul").append(f.draggable)}else{b.before(f.draggable)}b.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var d=f.draggable.attr("value");var c=b.attr("value");b.find("#menu-"+d).find("#parent"+d).val(c);a(this).parent().find("dt").removeAttr("style");a(this).parent().find("div:first").removeAttr("style")},over:function(b){if(a(this).attr("class")=="dropzone ui-droppable"){a(this).parent().find("div:first").css({background:"#f5f5f5",border:"1px dashed #bbb",margin:"10px 0px",height:"40px"})}else{if(a(this).attr("class")=="ui-droppable"){a(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}},out:function(){a(this).parent().find("dt").removeAttr("style");a(this).parent().find("div:first").removeAttr("style");a(this).filter(".dropzone").css({borderColor:""})}})},update_post_data:function(){var b=0;a(".menu li").each(function(){b=b+1;var d=a(this).attr("value");var e=a(this).children("input[name=menu-item-db-id[]]").val();a(this).attr("value",b);a(this).children("input[name=menu-item-position[]]").attr("value",b);var c=a(this).parent(".sub-menu").siblings("input[name=menu-item-object-id[]]").val();if(undefined==c){c=0}a(this).children("input[name=menu-item-parent-id[]]").attr("value",c);a("#li-count").attr("value",b)})},autocomplete:function(b){a("#add-"+b+" .quick-search").autocomplete(a("#add-"+b+" .autocomplete").val().split("|"));a("#add-"+b+" .quick-search").result(function(c,e,d){a("#add-"+b+" .list-wrap").css("display","block");a("#add-"+b+" .list-wrap li:contains('"+e+"')").css("display","block");a("#add-"+b+" .show-all").hide();a("#add-"+b+" .hide-all").show()})},edit_menu_item:function(b){var g=a("#menu-item-"+b).children("input[name=menu-item-type[]]").val();var c=a("#menu-item-"+b).children("input[name=menu-item-title[]]").val();var h=a("#menu-item-"+b).children("input[name=menu-item-url[]]").val();var d=a("#menu-item-"+b).children("input[name=menu-item-attr-title[]]").val();var e=a("#menu-item-"+b).children("input[name=menu-item-target[]]").val();var i=a("#menu-item-"+b).children("input[name=menu-item-description[]]").val();var f=a("#menu-item-"+b).children("input[name=menu-item-classes[]]").val();var j=a("#menu-item-"+b).children("input[name=menu-item-xfn[]]").val();if("custom"!=g){a("#edit-menu-item-url").attr("disabled","disabled")}a("#edit-menu-item-id").val(b);a("#edit-menu-item-title").val(c);a("#edit-menu-item-url").val(h);a("#edit-menu-item-attr-title").val(d);a("#edit-menu-item-target").val(e);a("#edit-menu-item-target option[value='"+e+"']").attr("selected","selected");a("#edit-menu-item-description").val(i);a("#edit-menu-item-classes").val(f);a("#edit-menu-item-xfn").val(j)},update_menu_item:function(){var i=a("#edit-menu-item-id").val();var g=a("#edit-menu-item-title").val();var c=a("#edit-menu-item-url").val();var h=a("#edit-menu-item-attr-title").val();var e=a("#edit-menu-item-target").val();var d=a("#edit-menu-item-description").val();var b=a("#edit-menu-item-classes").val();var f=a("#edit-menu-item-xfn").val();a(".menu #menu-item-"+i).find("span.item-title:first").html(g);a("#menu-item-"+i).children("input[name=menu-item-title[]]").val(g);a("#menu-item-"+i).children("input[name=menu-item-url[]]").val(c);a("#menu-item-"+i).children("input[name=menu-item-attr-title[]]").val(h);a("#menu-item-"+i).children("input[name=menu-item-target[]]").val(e);a("#menu-item-"+i).children("input[name=menu-item-description[]]").val(d);a("#menu-item-"+i).children("input[name=menu-item-classes[]]").val(b);a("#menu-item-"+i).children("input[name=menu-item-xfn[]]").val(f);a(".menu #menu-item-"+i+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){a(this).css("backgroundColor","")}})},remove_menu_item:function(c){var b=a("#menu-item-"+c);if(b){a(b).find("dt").each(function(){a(this).animate({backgroundColor:"#FF3333"},{duration:"normal",complete:function(){a(this).parent().parent().remove()}})})}},add_to_menu:function(b,m,c,h,p,n,d,o,j,g,f,e,k){var l=a(".menu li").length+1;var i=wpNavMenu.get_hidden_inputs(l,b,m,c,h,n,d,o,j,g,f,e,k);a(".menu").append('<li id="menu-item-'+l+'" value="'+l+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+d+'</span><span class="item-controls"><span class="item-type">'+p+'</span><a class="item-edit thickbox" id="edit'+l+'" value="'+l+'" onclick="wpNavMenu.edit_menu_item('+l+');" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+l+'" value="'+l+'" onclick="wpNavMenu.remove_menu_item('+l+');">Delete</a></span></dt></dl>'+i+"</li>");a(".menu #menu-item-"+l+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){a(this).css("backgroundColor","")}});wpNavMenu.drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")},add_checked_items_to_menu:function(c){var b=a(c).parent().siblings(".list-wrap").find(":checked");if(0==b.length){return false}a(b).each(function(){var j=a(this).parent().siblings(".menu-item-type").val();if("custom"==j){var g=a(this).parent().siblings(".menu-item-attr-title").val();var h=a(this).parent().siblings(".menu-item-target").val();var i=a(this).parent().siblings(".menu-item-classes").val();var l=a(this).parent().siblings(".menu-item-xfn").val()}else{var g="";var h="_self";var i="";var l=""}var d=a(this).parent().siblings(".menu-item-db-id").val();var m=a(this).parent().siblings(".menu-item-object-id").val();var e=a(this).parent().siblings(".menu-item-object").val();var p=a(this).parent().siblings(".menu-item-append").val();var n=a(this).parent().siblings(".menu-item-parent-id").val();var f=a(this).parent().siblings(".menu-item-title").val();var o=a(this).parent().siblings(".menu-item-url").val();var k=a(this).parent().siblings(".menu-item-description").val();if(undefined==k){k=""}if(undefined==g){g=""}wpNavMenu.add_to_menu(d,m,e,j,p,n,f,o,k,g,h,i,l);a(this).attr("checked",false)})},get_hidden_inputs:function(l,b,m,c,h,n,d,o,j,g,f,e,k){var i="";i+='<input type="hidden" name="menu-item-db-id[]" value="'+b+'" />';i+='<input type="hidden" name="menu-item-object-id[]" value="'+m+'" />';i+='<input type="hidden" name="menu-item-object[]" value="'+c+'" />';i+='<input type="hidden" name="menu-item-type[]" value="'+h+'" />';i+='<input type="hidden" name="menu-item-parent-id[]" value="'+n+'" />';i+='<input type="hidden" name="menu-item-position[]" value="'+l+'" />';i+='<input type="hidden" name="menu-item-title[]" value="'+d+'" />';i+='<input type="hidden" name="menu-item-attr-title[]" value="'+g+'" />';i+='<input type="hidden" name="menu-item-url[]" value="'+o+'" />';i+='<input type="hidden" name="menu-item-target[]" value="'+f+'" />';i+='<input type="hidden" name="menu-item-description[]" value="'+j+'" />';i+='<input type="hidden" name="menu-item-classes[]" value="'+e+'" />';i+='<input type="hidden" name="menu-item-xfn[]" value="'+k+'" />';return i}};a(document).ready(function(b){wpNavMenu.init()})})(jQuery);
    2  No newline at end of file
     1var wpNavMenu;(function($){wpNavMenu={init:function(){wpNavMenu.initial_meta_boxes();wpNavMenu.drag_and_drop();$("#update-nav-menu .deletion").click(function(){if(confirm(navMenuL10n.warnDelete)){return true}else{return false}});$("#update-nav-menu").submit(function(){wpNavMenu.update_post_data()});$("#create-menu-name").keypress(function(e){if(13==e.keyCode){$("#create-menu-button").click();return false}});$("#custom-menu-item-url, #custom-menu-item-name").keypress(function(e){if(13==e.keyCode){$("#add-custom-links a.button").click();return false}}).focus(function(){if($(this).val()==$(this).attr("defaultValue")&&$(this).attr("id")!="custom-menu-item-url"){$(this).val("")}}).blur(function(){if($(this).val()==""){$(this).val($(this).attr("defaultValue"))}});$("#create-menu-name").focus(function(){if($(this).val()==$(this).attr("defaultValue")){$(this).val("")}}).blur(function(){if($(this).val()==""){$(this).val($(this).attr("defaultValue"))}});$(".if-js-closed").removeClass("if-js-closed").addClass("closed");postboxes.add_postbox_toggles("nav-menus");$(".quick-search").click(function(){$(this).attr("value","")});$(".quick-search-submit").click(function(){$(this).siblings(".quick-search").search()});$("#menu-container .item-edit").click(function(){wpNavMenu.edit_menu_item($(this).attr("value"))});$("#menu-container .item-delete").click(function(){wpNavMenu.remove_menu_item($(this).attr("value"))});$("#update-menu-item").click(function(){wpNavMenu.update_menu_item();tb_remove()});$("#cancel-save").click(function(){tb_remove()});$(".show-all").click(function(e){$(e.currentTarget).parent().parent().siblings(".list-wrap").css("display","block");$(e.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","block");$(e.currentTarget).hide();$(e.currentTarget).siblings(".hide-all").show()});$(".hide-all").click(function(e){$(e.currentTarget).parent().parent().siblings(".list-wrap").css("display","none");$(e.currentTarget).parent().parent().siblings(".list-wrap").find("li").css("display","none");$(e.currentTarget).hide();$(e.currentTarget).siblings(".show-all").show()});$(".add-to-menu").click(function(e){wpNavMenu.add_checked_items_to_menu(e.currentTarget)});$("#add-custom-links .add-to-menu a").click(function(e){if($("#custom-menu-item-url").val()==$("#custom-menu-item-url").attr("defaultValue")){return}wpNavMenu.add_custom_link($("#custom-menu-item-name").val(),$("#custom-menu-item-url").val());$("#custom-menu-item-name").val($("#custom-menu-item-name").attr("defaultValue"));$("#custom-menu-item-url").val($("#custom-menu-item-url").attr("defaultValue")).focus()})},add_custom_link:function(link_name,link_url){var params={action:"save-custom-link",link_name:link_name,link_url:link_url};$.post(ajaxurl,params,function(link_id){if("-1"==link_id){return}wpNavMenu.add_to_menu(link_id,link_id,"custom","custom",navMenuL10n.custom,0,link_name,link_url,"","","_self","","")},"json")},initial_meta_boxes:function(){var hidden=$("#hidden-metaboxes").val().split(",");if(""!=hidden){for(var i=0;i<hidden.length;i++){$("#"+hidden[i]).attr("style","display: none;");$("#"+hidden[i]+"-hide").attr("checked",false)}}},drag_and_drop:function(){$(".menu li").each(function(){if(!$(this).children(".dropzone").attr("class")){$(this).prepend('<div class="dropzone"></div>')}});$(".menu li").draggable({handle:" > dl",opacity:0.8,addClasses:false,helper:"clone",zIndex:100});$(".menu li dl, .menu li .dropzone").droppable({accept:".menu li",tolerance:"pointer",drop:function(e,ui){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();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}if(child&&li.children("ul").length==0){li.append('<ul class="sub-menu" />')}if(child){li.children("ul").append(ui.draggable)}else{li.before(ui.draggable)}li.find("dl,.dropzone").css({backgroundColor:"",borderColor:""});var draggablevalue=ui.draggable.attr("value");var droppablevalue=li.attr("value");li.find("#menu-"+draggablevalue).find("#parent"+draggablevalue).val(droppablevalue);$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style")},over:function(e){if($(this).attr("class")=="dropzone ui-droppable"){$(this).parent().find("div:first").css({background:"#f5f5f5",border:"1px dashed #bbb",margin:"10px 0px",height:"40px"})}else{if($(this).attr("class")=="ui-droppable"){$(this).parent().find("dt:first").css("background","#d8d8d8")}else{}}},out:function(){$(this).parent().find("dt").removeAttr("style");$(this).parent().find("div:first").removeAttr("style");$(this).filter(".dropzone").css({borderColor:""})}})},update_post_data:function(){var i=0;$(".menu li").each(function(){i=i+1;var j=$(this).attr("value");var id=$(this).children("input[name=menu-item-db-id[]]").val();$(this).attr("value",i);$(this).children("input[name=menu-item-position[]]").attr("value",i);var pid=$(this).parent(".sub-menu").siblings("input[name=menu-item-object-id[]]").val();if(undefined==pid){pid=0}$(this).children("input[name=menu-item-parent-id[]]").attr("value",pid);$("#li-count").attr("value",i)})},autocomplete:function(id){$("#add-"+id+" .quick-search").autocomplete($("#add-"+id+" .autocomplete").val().split("|"));$("#add-"+id+" .quick-search").result(function(event,data,formatted){$("#add-"+id+" .list-wrap").css("display","block");$("#add-"+id+" .list-wrap li:contains('"+data+"')").css("display","block");$("#add-"+id+" .show-all").hide();$("#add-"+id+" .hide-all").show()})},edit_menu_item:function(id){var item_type=$("#menu-item-"+id).children("input[name=menu-item-type[]]").val();var item_title=$("#menu-item-"+id).children("input[name=menu-item-title[]]").val();var item_link=$("#menu-item-"+id).children("input[name=menu-item-url[]]").val();var item_attr_title=$("#menu-item-"+id).children("input[name=menu-item-attr-title[]]").val();var item_target=$("#menu-item-"+id).children("input[name=menu-item-target[]]").val();var item_description=$("#menu-item-"+id).children("input[name=menu-item-description[]]").val();var item_classes=$("#menu-item-"+id).children("input[name=menu-item-classes[]]").val();var item_xfn=$("#menu-item-"+id).children("input[name=menu-item-xfn[]]").val();if("custom"!=item_type){$("#edit-menu-item-url").attr("disabled","disabled")}$("#edit-menu-item-id").val(id);$("#edit-menu-item-title").val(item_title);$("#edit-menu-item-url").val(item_link);$("#edit-menu-item-attr-title").val(item_attr_title);$("#edit-menu-item-target").val(item_target);$("#edit-menu-item-target option[value='"+item_target+"']").attr("selected","selected");$("#edit-menu-item-description").val(item_description);$("#edit-menu-item-classes").val(item_classes);$("#edit-menu-item-xfn").val(item_xfn)},update_menu_item:function(){var id=$("#edit-menu-item-id").val();var item_title=$("#edit-menu-item-title").val();var item_link=$("#edit-menu-item-url").val();var item_attr_title=$("#edit-menu-item-attr-title").val();var item_target=$("#edit-menu-item-target").val();var item_description=$("#edit-menu-item-description").val();var item_classes=$("#edit-menu-item-classes").val();var item_xfn=$("#edit-menu-item-xfn").val();$(".menu #menu-item-"+id).find("span.item-title:first").html(item_title);$("#menu-item-"+id).children("input[name=menu-item-title[]]").val(item_title);$("#menu-item-"+id).children("input[name=menu-item-url[]]").val(item_link);$("#menu-item-"+id).children("input[name=menu-item-attr-title[]]").val(item_attr_title);$("#menu-item-"+id).children("input[name=menu-item-target[]]").val(item_target);$("#menu-item-"+id).children("input[name=menu-item-description[]]").val(item_description);$("#menu-item-"+id).children("input[name=menu-item-classes[]]").val(item_classes);$("#menu-item-"+id).children("input[name=menu-item-xfn[]]").val(item_xfn);$(".menu #menu-item-"+id+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){$(this).css("backgroundColor","")}})},remove_menu_item:function(id){var todelete=$("#menu-item-"+id);if(todelete){$(todelete).find("dt").each(function(){$(this).animate({backgroundColor:"#FF3333"},{duration:"normal",complete:function(){$(this).parent().parent().remove()}})})}},add_to_menu:function(item_db_id,item_object_id,item_object,item_type,item_append,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn){var randomnumber=$(".menu li").length+1;var hidden=wpNavMenu.get_hidden_inputs(randomnumber,item_db_id,item_object_id,item_object,item_type,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn);$(".menu").append('<li id="menu-item-'+randomnumber+'" value="'+randomnumber+'"><div class="dropzone ui-droppable"></div><dl class="ui-droppable"><dt><span class="item-title">'+item_title+'</span><span class="item-controls"><span class="item-type">'+item_append+'</span><a class="item-edit thickbox" id="edit'+randomnumber+'" value="'+randomnumber+'" onclick="wpNavMenu.edit_menu_item('+randomnumber+');" title="'+navMenuL10n.thickbox+'" href="#TB_inline?height=540&width=300&inlineId=menu-item-settings">'+navMenuL10n.edit+'</a> | <a class="item-delete" id="delete'+randomnumber+'" value="'+randomnumber+'" onclick="wpNavMenu.remove_menu_item('+randomnumber+');">Delete</a></span></dt></dl>'+hidden+"</li>");$(".menu #menu-item-"+randomnumber+" dt:first").animate({backgroundColor:"#FFFF33"},{duration:"normal",complete:function(){$(this).css("backgroundColor","")}});wpNavMenu.drag_and_drop();tb_init("a.thickbox, area.thickbox, input.thickbox")},add_checked_items_to_menu:function(button){var items=$(button).parent().siblings(".list-wrap").find(":checked");if(0==items.length){return false}$(items).each(function(){var item_type=$(this).parent().siblings(".menu-item-type").val();if("custom"==item_type){var item_attr_title=$(this).parent().siblings(".menu-item-attr-title").val();var item_target=$(this).parent().siblings(".menu-item-target").val();var item_classes=$(this).parent().siblings(".menu-item-classes").val();var item_xfn=$(this).parent().siblings(".menu-item-xfn").val()}else{var item_attr_title="";var item_target="_self";var item_classes="";var item_xfn=""}var item_db_id=$(this).parent().siblings(".menu-item-db-id").val();var item_object_id=$(this).parent().siblings(".menu-item-object-id").val();var item_object=$(this).parent().siblings(".menu-item-object").val();var item_append=$(this).parent().siblings(".menu-item-append").val();var item_parent_id=$(this).parent().siblings(".menu-item-parent-id").val();var item_title=$(this).parent().siblings(".menu-item-title").val();var item_url=$(this).parent().siblings(".menu-item-url").val();var item_description=$(this).parent().siblings(".menu-item-description").val();if(undefined==item_description){item_description=""}if(undefined==item_attr_title){item_attr_title=""}wpNavMenu.add_to_menu(item_db_id,item_object_id,item_object,item_type,item_append,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn);$(this).attr("checked",false)})},get_hidden_inputs:function(randomnumber,item_db_id,item_object_id,item_object,item_type,item_parent_id,item_title,item_url,item_description,item_attr_title,item_target,item_classes,item_xfn){var hidden="";hidden+='<input type="hidden" name="menu-item-db-id[]" value="'+item_db_id+'" />';hidden+='<input type="hidden" name="menu-item-object-id[]" value="'+item_object_id+'" />';hidden+='<input type="hidden" name="menu-item-object[]" value="'+item_object+'" />';hidden+='<input type="hidden" name="menu-item-type[]" value="'+item_type+'" />';hidden+='<input type="hidden" name="menu-item-parent-id[]" value="'+item_parent_id+'" />';hidden+='<input type="hidden" name="menu-item-position[]" value="'+randomnumber+'" />';hidden+='<input type="hidden" name="menu-item-title[]" value="'+item_title+'" />';hidden+='<input type="hidden" name="menu-item-attr-title[]" value="'+item_attr_title+'" />';hidden+='<input type="hidden" name="menu-item-url[]" value="'+item_url+'" />';hidden+='<input type="hidden" name="menu-item-target[]" value="'+item_target+'" />';hidden+='<input type="hidden" name="menu-item-description[]" value="'+item_description+'" />';hidden+='<input type="hidden" name="menu-item-classes[]" value="'+item_classes+'" />';hidden+='<input type="hidden" name="menu-item-xfn[]" value="'+item_xfn+'" />';return hidden}};$(document).ready(function($){wpNavMenu.init()})})(jQuery);
     2 No newline at end of file
  • wp-admin/nav-menus.php

     
    102102                        }
    103103                       
    104104                        // Update menu items
    105                        
     105
    106106                        // @todo: wrap update logic into wp_update_nav_menu();
    107107                        $update_count = isset( $_POST['li-count'] ) ? (int) $_POST['li-count'] : 0;
    108108                        $update_nav_menu = is_nav_menu( $nav_menu_selected_id );