PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.15.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.15.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 / Services / Logtivity_Check_For_Disabled_Individual_Logs.php

Logtivity_Check_For_Disabled_Individual_Logs.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.15.0, at Services/Logtivity_Check_For_Disabled_Individual_Logs.php

44 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Logtivity_Check_For_Disabled_Individual_Logs
4 {
5 public function __construct()
6 {
7 add_action('wp_logtivity_instance', [$this, 'handle'], 10, 999);
8 }
9
10 public function handle($Logtivity_Logger)
11 {
12 foreach ($this->getLogsToExclude() as $log) {
13 $array = explode('&&', $log);
14
15 if (isset($array[0]) && isset($array[1])) {
16 if ($this->matches($Logtivity_Logger->action, $array[0]) && $this->matches($Logtivity_Logger->context, $array[1])) {
17 $Logtivity_Logger->stop();
18 }
19 } elseif(isset($array[0])) {
20 if ($this->matches($Logtivity_Logger->action, $array[0])) {
21 $Logtivity_Logger->stop();
22 }
23 }
24 }
25 }
26
27 private function matches($keyword1, $keyword2)
28 {
29 return strpos(trim($keyword1), trim($keyword2)) !== false;
30 }
31
32 private function getLogsToExclude()
33 {
34 $value = (new Logtivity_Options)->getOption('logtivity_disable_individual_logs');
35
36 if ($value == '') {
37 return [];
38 }
39
40 return preg_split("/\\r\\n|\\r|\\n/", $value);
41 }
42 }
43
44 $CheckForDisabledIndividualLogs = new Logtivity_Check_For_Disabled_Individual_Logs;