我有两个函数,一个用于删除3个自定义分类法的原始元框,另一个用于在所需位置重新创建它们。问题是,删除所有3个后,没有一个元框正确显示“从最常用的javascript中选择”(它们只会将页面跳转到(接近)顶部)。然而,如果我只注释了remove_meta_box
项目(可以是其中的任何一项),然后其他两项按预期工作。
这“有效”:
function myahts_remove_metabox()
{
remove_meta_box( \'tagsdiv-ahtscollectionmakes\', \'ahtscollection\', \'side\' );
remove_meta_box( \'tagsdiv-ahtscollectionyear\', \'ahtscollection\', \'side\' );
/* remove_meta_box( \'tagsdiv-ahtscollectionos\', \'ahtscollection\', \'side\' ); */
}
add_action( \'add_meta_boxes_ahtscollection\' , \'myahts_remove_metabox\', 1 );
function ahtscollection_metabox()
{
add_meta_box( \'ahtscollectionmakes\', __(\'Make\', \'myahts\'), \'post_tags_meta_box\', \'ahtscollection\', \'normal\', \'high\', array( \'taxonomy\' => \'ahtscollectionmakes\' ) );
add_meta_box( \'ahtscollectionyear\', __(\'Year Produced\', \'myahts\'), \'post_tags_meta_box\', \'ahtscollection\', \'normal\', \'low\', array( \'taxonomy\' => \'ahtscollectionyear\' ) );
add_meta_box( \'ahtscollectionos\', __(\'Operating System\', \'myahts\'), \'post_tags_meta_box\', \'ahtscollection\', \'normal\', \'low\', array( \'taxonomy\' => \'ahtscollectionos\' ) );
}
add_action( \'add_meta_boxes_ahtscollection\', \'ahtscollection_metabox\', 10 );
但这并不是:
function myahts_remove_metabox()
{
remove_meta_box( \'tagsdiv-ahtscollectionmakes\', \'ahtscollection\', \'side\' );
remove_meta_box( \'tagsdiv-ahtscollectionyear\', \'ahtscollection\', \'side\' );
remove_meta_box( \'tagsdiv-ahtscollectionos\', \'ahtscollection\', \'side\' );
}
add_action( \'add_meta_boxes_ahtscollection\' , \'myahts_remove_metabox\', 1 );
function ahtscollection_metabox()
{
add_meta_box( \'ahtscollectionmakes\', __(\'Make\', \'myahts\'), \'post_tags_meta_box\', \'ahtscollection\', \'normal\', \'high\', array( \'taxonomy\' => \'ahtscollectionmakes\' ) );
add_meta_box( \'ahtscollectionyear\', __(\'Year Produced\', \'myahts\'), \'post_tags_meta_box\', \'ahtscollection\', \'normal\', \'low\', array( \'taxonomy\' => \'ahtscollectionyear\' ) );
add_meta_box( \'ahtscollectionos\', __(\'Operating System\', \'myahts\'), \'post_tags_meta_box\', \'ahtscollection\', \'normal\', \'low\', array( \'taxonomy\' => \'ahtscollectionos\' ) );
}
add_action( \'add_meta_boxes_ahtscollection\', \'ahtscollection_metabox\', 10 );
The
add_meta_box
在这两种情况下都显示正确,只是没有按照第二个示例中的预期工作。
我找不到与此相关的任何错误,也找不到任何文档说明为什么在添加第三项时会导致冲突。
我有什么遗漏吗?非常感谢您的帮助。
这是来自load-scripts.php
:
var tagBox,array_unique_noempty;!function(a){array_unique_noempty=function(b){var c=[];return a.each(b,function(b,d){d=a.trim(d),d&&-1===a.inArray(d,c)&&c.push(d)}),c},tagBox={clean:function(a){var b=window.tagsBoxL10n.tagDelimiter;return","!==b&&(a=a.replace(new RegExp(b,"g"),",")),a=a.replace(/\\s*,\\s*/g,",").replace(/,+/g,",").replace(/[,\\s]+$/,"").replace(/^[,\\s]+/,""),","!==b&&(a=a.replace(/,/g,b)),a},parseTags:function(b){var c=b.id,d=c.split("-check-num-")[1],e=a(b).closest(".tagsdiv"),f=e.find(".the-tags"),g=window.tagsBoxL10n.tagDelimiter,h=f.val().split(g),i=[];return delete h[d],a.each(h,function(b,c){c=a.trim(c),c&&i.push(c)}),f.val(this.clean(i.join(g))),this.quickClicks(e),!1},quickClicks:function(b){var c,d,e=a(".the-tags",b),f=a(".tagchecklist",b),g=a(b).attr("id");e.length&&(d=e.prop("disabled"),c=e.val().split(window.tagsBoxL10n.tagDelimiter),f.empty(),a.each(c,function(b,c){var e,h;c=a.trim(c),c&&(e=a("<span />").text(c),d||(h=a(\'<a id="\'+g+"-check-num-"+b+\'" class="ntdelbutton" tabindex="0">X</a>\'),h.on("click keypress",function(b){("click"===b.type||13===b.keyCode)&&(13===b.keyCode&&a(this).closest(".tagsdiv").find("input.newtag").focus(),tagBox.parseTags(this))}),e.prepend(" ").prepend(h)),f.append(e))}))},flushTags:function(b,c,d){var e,f,g,h=a(".the-tags",b),i=a("input.newtag",b),j=window.tagsBoxL10n.tagDelimiter;return c=c||!1,g=c?a(c).text():i.val(),"undefined"==typeof g?!1:(e=h.val(),f=e?e+j+g:g,f=this.clean(f),f=array_unique_noempty(f.split(j)).join(j),h.val(f),this.quickClicks(b),c||i.val(""),"undefined"==typeof d&&i.focus(),!1)},get:function(b){var c=b.substr(b.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:c},function(d,e){0!==d&&"success"==e&&(d=a(\'<p id="tagcloud-\'+c+\'" class="the-tagcloud">\'+d+"</p>"),a("a",d).click(function(){return tagBox.flushTags(a("#"+c),this),!1}),a("#"+b).after(d))})},init:function(){var b=this,c=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)}),a(".tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))}),a("input.newtag",c).keyup(function(b){return 13==b.which?(tagBox.flushTags(a(this).closest(".tagsdiv")),!1):void 0}).keypress(function(a){return 13==a.which?(a.preventDefault(),!1):void 0}).each(function(){var b=a(this).closest("div.tagsdiv").attr("id");a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+b,{delay:500,minchars:2,multiple:!0,multipleSep:window.tagsBoxL10n.tagDelimiter})}),a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,!1,1)})}),a(".tagcloud-link").click(function(){return tagBox.get(a(this).attr("id")),a(this).unbind().click(function(){return a(this).siblings(".the-tagcloud").toggle(),!1}),!1})}}}(jQuery);
我的JS不是很强,但我仍然不明白为什么它不起作用。