PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.20.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.20.0
3.3.9 3.3.8 trunk 1.0 1.1.0 1.10.0 1.11.0 1.11.1 1.12.0 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 All 67 releases
logtivity / Logs / Core / Logtivity_Term.php

Logtivity_Term.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.20.0, at Logs/Core/Logtivity_Term.php

69 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Logtivity_Term
4 {
5 protected $ignoreTaxonomies = [
6 'nav_menu',
7 'edd_log_type',
8 ];
9
10 public function __construct()
11 {
12 add_action( 'edited_terms', [$this, 'termUpdated'], 10, 2 );
13 add_action( 'created_term', [$this, 'termCreated'], 10, 3 );
14 add_action( 'delete_term', [$this, 'termDeleted'], 10, 5);
15 }
16
17 public function termCreated($term_id, $tt_id, $taxonomy)
18 {
19 if (in_array($taxonomy, $this->ignoreTaxonomies)) {
20 return;
21 }
22
23 $term = get_term_by('id', $term_id, $taxonomy);
24
25 return Logtivity_Logger::log()
26 ->setAction('Term Created')
27 ->setContext($term->name)
28 ->addMeta('Term ID', $term->term_id)
29 ->addMeta('Slug', $term->slug)
30 ->addMeta('Taxonomy', $term->taxonomy)
31 ->addMeta('Edit Link', get_edit_term_link($term))
32 ->send();
33 }
34
35 public function termUpdated($term_id, $taxonomy)
36 {
37 if (in_array($taxonomy, $this->ignoreTaxonomies)) {
38 return;
39 }
40
41 $term = get_term_by('id', $term_id, $taxonomy);
42
43 return Logtivity_Logger::log()
44 ->setAction('Term Updated')
45 ->setContext($term->name)
46 ->addMeta('Term ID', $term->term_id)
47 ->addMeta('Slug', $term->slug)
48 ->addMeta('Taxonomy', $term->taxonomy)
49 ->addMeta('Edit Link', get_edit_term_link($term))
50 ->send();
51 }
52
53 public function termDeleted($term, $tt_id, $taxonomy, $deleted_term, $object_ids)
54 {
55 if (in_array($taxonomy, $this->ignoreTaxonomies)) {
56 return;
57 }
58
59 return Logtivity_Logger::log()
60 ->setAction('Term Deleted')
61 ->setContext($deleted_term->name)
62 ->addMeta('Term ID', $deleted_term->term_id)
63 ->addMeta('Slug', $deleted_term->slug)
64 ->addMeta('Taxonomy', $deleted_term->taxonomy)
65 ->send();
66 }
67 }
68
69 $Logtivity_Term = new Logtivity_Term;