You are here

function simplenews_taxonomy_term_delete in Simplenews 7

Implements hook_taxonomy_term_delete().

Delete simplenews category if taxonomy term is delete.

File

./simplenews.module, line 731
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_taxonomy_term_delete($term) {

  // A simplenews newsletter category can not exist without the associated
  // taxonomy term. So we delete the category. simplenews_category_delete()
  // will also delete the subscriptions to the category.
  if ($term->vocabulary_machine_name == 'newsletter') {

    // Make sure we only try to delete if not already deleted.
    if (($category = simplenews_category_load($term->tid)) !== FALSE) {

      // Add name and description from $term object.
      $category->name = $term->name;
      $category->description = $term->description;
      simplenews_category_delete($category);
    }
  }
}