--- taxonomy_menu.module	2010-08-03 02:45:20.000000000 +0100
+++ taxonomy_menu.module	2011-04-06 17:09:03.000000000 +0100
@@ -23,6 +23,38 @@ require_once(drupal_get_path('module', '
  * our taxonomy_menu options in here on a per-vocab basis.
  */
 function taxonomy_menu_form_alter(&$form, $form_state, $form_id) {
+  // add include in menu field for term form
+  if($form_id == 'taxonomy_form_term'){
+  	// create form field
+  	$form['advanced']['taxonomy_menu'] = array(
+  		'#type' => 'fieldset',
+  		'#title' => t('Menu settings'),
+  	);
+    $include = variable_get('taxonomy_menu_include_'.$form['tid']['#value'], 1);
+    $form['advanced']['taxonomy_menu']['include_in_menu'] = array(
+      '#type' => 'radios',
+      '#title' => t('Include in menu'),
+      '#options' => array('No', 'Yes'),
+      '#default_value' => $include,
+      '#description' => t('Set if this term should be included in the taxonomy menu. If set to NO all child terms will be excluded to.'),
+    );
+    $form['advanced']['taxonomy_menu']['apply_to_children'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Select to apply setting to child terms'),
+      '#default_value' => 0,
+      '#description' => t('Apply include in menu setting to all children of the current term. Note that selecting NO automatically applies to all child terms.'),
+    );
+    $form['advanced']['taxonomy_menu']['exclude_children'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Exclude child terms'),
+      '#default_value' => 0,
+      '#description' => t('Select to exclude all child terms from taxonomy menu. Note that selecting NO automatically applies to all child terms.'),
+    );
+    // add validation function
+    $form['#validate'][] = 'taxonomy_menu_include_validate';
+    // add submit process button
+    $form['#submit'][] = 'taxonomy_menu_include_submit';
+  }
   if ($form_id == 'taxonomy_form_vocabulary') {
     // choose a menu to add link items to.
     $menus = menu_get_menus();
@@ -87,6 +119,49 @@ function taxonomy_menu_form_alter(&$form
 }
 
 /**
+ * Validation handler for include in menu field added to taxonomy term form
+ *
+ * Check if parent is included for term before allowing term to be included
+ */
+function taxonomy_menu_include_validate($form, &$form_state){
+  if($form_state['values']['include_in_menu'] == 1){
+    $valid = (empty($form_state['values']['parent']))? true : false;
+    if(is_array($form_state['values']['parent'])){
+      foreach($form_state['values']['parent'] as $parent){
+        if(variable_get('taxonomy_menu_include_'.$parent, 1) == 1){
+          $valid = true;
+        }
+      }
+    }
+    if(!$valid){
+      form_set_error('include_in_menu', t('Parent term needs to be included in menu before this term can be.'));
+    }
+  }
+}
+
+/**
+ * Submit handler for include in menu field added to taxonomy term form
+ *
+ * Set value for term and child terms if excluding, then rebuild menu
+ */
+function taxonomy_menu_include_submit($form, &$form_state){
+  variable_set('taxonomy_menu_include_'.$form_state['values']['tid'], $form_state['values']['include_in_menu']);
+  if($form_state['values']['include_in_menu'] == 0 || $form_state['values']['apply_to_children'] == 1 || $form_state['values']['exclude_children'] == 1){
+    $children = taxonomy_get_tree($form_state['values']['vid'], $form_state['values']['tid']);
+    $include = ($form_state['values']['exclude_children'] == 1)? 0 : $form_state['values']['include_in_menu'];
+    if(is_array($children)){
+      foreach($children as $child){
+        variable_set('taxonomy_menu_include_'.$child->tid, $include);
+      }
+    }
+  }
+  // do a full menu rebuild incase we have changed the include setting
+  $message = _taxonomy_menu_rebuild($form_state['values']['vid']);
+  variable_set('menu_rebuild_needed', TRUE);
+  drupal_set_message($message, 'status');
+}
+
+/**
  * Submit handler for the extra settings added to the taxonomy vocab form.
  *
  * Check to see if the user has selected a different menu, and only rebuild
@@ -800,6 +875,12 @@ function _taxonomy_menu_item($item) {
         $item['remove'] = TRUE;
         return $item;
     }
+    
+    //if term is not included in menu
+    if(variable_get('taxonomy_menu_include_'.$item['tid'], 1) == 0){
+      $item['remove'] = TRUE;
+      return $item;
+    }
 
     //if display number is selected and $num > 0 then change the title
     if (variable_get('taxonomy_menu_display_num_'. $item['vid'], FALSE)) {
