チェックボックスをラジオボタン(Categoriesメタボクス)に変換するこの関数/スクリプトがありますが、機能を少し拡張する必要がありますそれについて。親カテゴリーのラジオボタンがクリックされないようにする
スクリプト:
function convert_root_cats_to_radio() {
global $post_type;
?>
<script type="text/javascript">
jQuery("#categorychecklist>li>input").each(function(){
this.disabled = "disabled";
});
jQuery("#categorychecklist>li>ul>li>input").each(function(){
this.disabled = "disabled";
});
jQuery("#categorychecklist>li>label input").each(function(){
this.type = 'radio';
});
jQuery("#categorychecklist>li>ul>li>label input").each(function(){
this.type = 'radio';
});
// Hide the 'most used' tab
jQuery("#category-tabs li:odd").hide();
</script> <?php
}
add_action('admin_footer-post.php', 'convert_root_cats_to_radio');
add_action('admin_footer-post-new.php', 'convert_root_cats_to_radio');
今必要なもの:親カテゴリを選択するからユーザーを防ぐために。
たとえばBandicootは親(それは子供がいる)なので、以下の画像ではBandicoot以外のものを選択できるはずです。ああ、Bandicootの子供の項目は選択することができます。
したがって、ルールは次のようにする必要があります。親であれば選択できませんが、子供はできます。
この部分だけレンダリングされたhtmlを共有できますか?トラバーサルを見るのに役立つでしょう。 – Searching