# logtivity/1.20.0/Logs/Core/Logtivity_Term.php

Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity, version 1.20.0. 69 lines.

- Page: https://pluginprobe.com/plugins/logtivity/1.20.0/code/Logs/Core/Logtivity_Term.php
- Raw: https://pluginprobe.com/plugins/logtivity/1.20.0/raw/Logs/Core/Logtivity_Term.php
- Modified: 2022-06-17T11:59:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/logtivity/1.20.0/code/Logs/Core/Logtivity_Term.php#L10-L20`.

```php
<?php

class Logtivity_Term
{
	protected $ignoreTaxonomies = [
		'nav_menu',
		'edd_log_type',
	];

	public function __construct()
	{
		add_action( 'edited_terms', [$this, 'termUpdated'], 10, 2 );
		add_action( 'created_term', [$this, 'termCreated'], 10, 3 );
		add_action( 'delete_term', [$this, 'termDeleted'], 10, 5);
	}

	public function termCreated($term_id, $tt_id, $taxonomy)
	{
		if (in_array($taxonomy, $this->ignoreTaxonomies)) {
			return;
		}

		$term = get_term_by('id', $term_id, $taxonomy);

		return Logtivity_Logger::log()
			->setAction('Term Created')
			->setContext($term->name) 
			->addMeta('Term ID', $term->term_id)
			->addMeta('Slug', $term->slug)
			->addMeta('Taxonomy', $term->taxonomy)
			->addMeta('Edit Link', get_edit_term_link($term))
			->send();
	}

	public function termUpdated($term_id, $taxonomy)
	{
		if (in_array($taxonomy, $this->ignoreTaxonomies)) {
			return;
		}

		$term = get_term_by('id', $term_id, $taxonomy);

		return Logtivity_Logger::log()
			->setAction('Term Updated')
			->setContext($term->name) 
			->addMeta('Term ID', $term->term_id)
			->addMeta('Slug', $term->slug)
			->addMeta('Taxonomy', $term->taxonomy)
			->addMeta('Edit Link', get_edit_term_link($term))
			->send();
	}

	public function termDeleted($term, $tt_id, $taxonomy, $deleted_term, $object_ids)
	{
		if (in_array($taxonomy, $this->ignoreTaxonomies)) {
			return;
		}

		return Logtivity_Logger::log()
			->setAction('Term Deleted')
			->setContext($deleted_term->name) 
			->addMeta('Term ID', $deleted_term->term_id)
			->addMeta('Slug', $deleted_term->slug)
			->addMeta('Taxonomy', $deleted_term->taxonomy)
			->send();
	}
}

$Logtivity_Term = new Logtivity_Term;
```
