//未使用目もこーど//タクソノミ選択とカスタムフィールドのラジオボタンをシンクロさせる
//http://yahss.net/wordpress/1302-synchronize-tax-with-customfield/
function my_print_footer_scripts() {
global $post_type;
if ($post_type == 'estate'): ?>
<script type="text/javascript">
//<![CDATA[
jQuery(function($){
// タクソノミ選択チェックボックスをラジオボタンに
$(".categorychecklist input[type=checkbox]").each(function(){
$(this).attr("type","radio");
});
// タクソノミIDとタクソノミ名を配列に定義
var tax_arr = new Array();
tax_arr['#in-tax_estate-6'] = '売買物件';
tax_arr['#in-tax_estate-7'] = '賃貸物件';
// タクソノミクリック時の処理
$("input[name^=tax_input]").live("click", function(){
$("input[name^=tax_input]").each(function(){
if ( $(this).is(':checked') == true ) {
taxid = $(this).val();
taxname = tax_arr['#in-tax_estate-'+taxid];
return false;
}
});
$("#acf-field-sellrent-"+taxname).attr('checked', 'checked');
});
// カスタムフィールドのラジオボタンクリック時の処理
$("[id^=acf-field-sellrent-]").live("click", function(){
$("[id^=acf-field-sellrent-]").each(function(){
if ( $(this).is(':checked') == true ) {
taxname = $(this).val();
return false;
}
});
for (var key in tax_arr) {
if ( tax_arr[key] == taxname ) taxid = key;
}
$(taxid).attr('checked', 'checked');
});
});
//]]>
</script>
<?php
endif;
}
add_action('admin_print_footer_scripts', 'my_print_footer_scripts', 21);