Retrieve an array mapping allowed vocabulary id to field name for all taxonomy_term_reference fields for which an instance exists for the specified entity type and bundle.
function instanceVocabularies($entity_type, $bundle) {
$instances = array();
foreach (field_info_instances($entity_type, $bundle) as $instance) {
$field = field_info_field($instance['field_name']);
if ($field['type'] == 'taxonomy_term_reference') {
foreach ($field['settings']['allowed_values'] as $tree) {
// Prefer valid taxonomy term reference fields for a given vocabulary
// when they exist.
if (empty($instances[$tree['vocabulary']]) || $instances[$tree['vocabulary']] == 'taxonomyextra') {
$instances[$tree['vocabulary']] = $field['field_name'];
}
}
}
}
return $instances;
}