PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.6.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.6.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 / logtivity.php

logtivity.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.6.0, at logtivity.php

136 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Logtivity
5 * Plugin URI: https://logtivity.io
6 * Description: Dedicated Event Monitoring for WordPress using Logtivity.io.
7 * Version: 1.6.0
8 * Author: Logtivity
9 */
10
11 class Logtivity
12 {
13 /**
14 * List all classes here with their file paths. Keep class names the same as filenames.
15 *
16 * @var array
17 */
18 private $dependancies = [
19 'Helpers/Helpers',
20 'Helpers/Logtivity_Wp_User',
21 'Admin/Logtivity_Options',
22 'Admin/Logtivity_Admin',
23 'Services/Logtivity_Log_API',
24 'Services/Logtivity_Logger',
25 'Helpers/Logtivity_Log_Global_Function',
26 'Logs/Logtivity_Abstract_Logger',
27 ];
28
29 /**
30 *
31 * Log classes
32 *
33 */
34 private $logClasses = [
35 'Logs/Core/Logtivity_Post',
36 'Logs/Core/Logtivity_User',
37 'Logs/Core/Logtivity_Core',
38 'Logs/Core/Logtivity_Theme',
39 'Logs/Core/Logtivity_Plugin',
40 'Logs/Core/Logtivity_Comment',
41 ];
42
43 /**
44 * List all integration dependancies
45 *
46 * @var array
47 */
48 private $integrationDependancies = [
49 'WP_DLM' => [
50 'Logs/Download_Monitor/Logtivity_Download_Monitor',
51 ],
52 'MeprCtrlFactory' => [
53 'Logs/Memberpress/Logtivity_Memberpress',
54 ],
55 'Easy_Digital_Downloads' => [
56 'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads'
57 ]
58 ];
59
60 public function __construct()
61 {
62 $this->loadDependancies();
63
64 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), [$this, 'addSettingsLinkFromPluginsPage'] );
65 }
66
67 public static function log($action = null, $meta = null, $user_id = null)
68 {
69 return Logtivity_Logger::log($action, $meta, $user_id);
70 }
71
72 public function loadDependancies()
73 {
74 foreach ($this->dependancies as $filePath)
75 {
76 $this->loadFile($filePath);
77 }
78
79 $this->maybeLoadLogClasses();
80
81 $this->loadIntegrationDependancies();
82 }
83
84 public function maybeLoadLogClasses()
85 {
86 if ($this->defaultLoggingDisabled()) {
87 return;
88 }
89
90 foreach ($this->logClasses as $filePath)
91 {
92 $this->loadFile($filePath);
93 }
94 }
95
96 /**
97 * Is the default Event logging from within the plugin enabled
98 *
99 * @return bool
100 */
101 public function defaultLoggingDisabled()
102 {
103 return (new Logtivity_Options)->getOption('logtivity_disable_default_logging');
104 }
105
106 public function loadIntegrationDependancies()
107 {
108 add_action('plugins_loaded', function() {
109 foreach ($this->integrationDependancies as $key => $value)
110 {
111 if (class_exists($key)) {
112 foreach ($value as $filePath)
113 {
114 $this->loadFile($filePath);
115 }
116 }
117 }
118 });
119 }
120
121 public function loadFile($filePath)
122 {
123 require_once plugin_dir_path( __FILE__ ) . $filePath .'.php';
124 }
125
126 public function addSettingsLinkFromPluginsPage($links)
127 {
128 $settings_links = array(
129 '<a href="' . admin_url( 'tools.php?page=logtivity' ) . '">Settings</a>',
130 );
131
132 return array_merge($settings_links, $links);
133 }
134 }
135
136 $logtivity = new Logtivity;