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

209 lines 4.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.20.1
8 * Author: Logtivity
9 * Text Domain: logtivity
10 */
11
12 class Logtivity
13 {
14 protected $version = '1.20.1';
15
16 /**
17 * List all classes here with their file paths. Keep class names the same as filenames.
18 *
19 * @var array
20 */
21 private $dependancies = [
22 'Helpers/Helpers',
23 'Helpers/Logtivity_Wp_User',
24 'Admin/Logtivity_Log_Index_Controller',
25 'Admin/Logtivity_Dismiss_Notice_Controller',
26 'Admin/Logtivity_Options',
27 'Admin/Logtivity_Admin',
28 'Services/Logtivity_Api',
29 'Services/Logtivity_Logger',
30 'Services/Logtivity_Register_Site',
31 'Helpers/Logtivity_Log_Global_Function',
32 'Logs/Logtivity_Abstract_Logger',
33 'Services/Logtivity_Check_For_Disabled_Individual_Logs',
34 ];
35
36 /**
37 *
38 * Log classes
39 *
40 */
41 private $logClasses = [
42 'Logs/Core/Logtivity_Post',
43 'Logs/Core/Logtivity_User',
44 'Logs/Core/Logtivity_Core',
45 'Logs/Core/Logtivity_Theme',
46 'Logs/Core/Logtivity_Plugin',
47 'Logs/Core/Logtivity_Comment',
48 'Logs/Core/Logtivity_Term',
49 'Logs/Core/Logtivity_Meta',
50 ];
51
52 /**
53 * List all integration dependancies
54 *
55 * @var array
56 */
57 private $integrationDependancies = [
58 'WP_DLM' => [
59 'Logs/Download_Monitor/Logtivity_Download_Monitor',
60 ],
61 'MeprCtrlFactory' => [
62 'Logs/Memberpress/Logtivity_Memberpress',
63 ],
64 'Easy_Digital_Downloads' => [
65 'Logs/Easy_Digital_Downloads/Logtivity_Abstract_Easy_Digital_Downloads',
66 'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads'
67 ],
68 'EDD_Software_Licensing' => [
69 'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads_Software_Licensing'
70 ],
71 'EDD_Recurring' => [
72 'Logs/Easy_Digital_Downloads/Logtivity_Easy_Digital_Downloads_Recurring'
73 ],
74 'FrmHooksController' => [
75 'Logs/Formidable/Logtivity_FrmEntryFormatter',
76 'Logs/Formidable/Logtivity_Formidable'
77 ],
78 'PMXI_Plugin' => [
79 'Logs/WP_All_Import/Logtivity_WP_All_Import',
80 ],
81 '\Code_Snippets\Plugin' => [
82 'Logs/Code_Snippets/Logtivity_Code_Snippets',
83 ]
84 ];
85
86 public function __construct()
87 {
88 $this->loadDependancies();
89
90 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), [$this, 'addSettingsLinkFromPluginsPage'] );
91
92 register_activation_hook( __FILE__, [$this, 'activated']);
93
94 add_action( 'admin_notices', [$this, 'welcomeMessage']);
95
96 add_action( 'admin_notices', [$this, 'checkForSiteUrlChange']);
97
98 add_action('admin_enqueue_scripts', [$this, 'loadScripts']);
99 }
100
101 public static function log($action = null, $meta = null, $user_id = null)
102 {
103 return Logtivity_Logger::log($action, $meta, $user_id);
104 }
105
106 public function loadDependancies()
107 {
108 foreach ($this->dependancies as $filePath)
109 {
110 $this->loadFile($filePath);
111 }
112
113 add_action('plugins_loaded', function() {
114 $this->maybeLoadLogClasses();
115
116 $this->loadIntegrationDependancies();
117 });
118 }
119
120 public function maybeLoadLogClasses()
121 {
122 if ($this->defaultLoggingDisabled()) {
123 return;
124 }
125
126 foreach ($this->logClasses as $filePath)
127 {
128 $this->loadFile($filePath);
129 }
130 }
131
132 /**
133 * Is the default Event logging from within the plugin enabled
134 *
135 * @return bool
136 */
137 public function defaultLoggingDisabled()
138 {
139 return (new Logtivity_Options)->getOption('logtivity_disable_default_logging');
140 }
141
142 public function loadIntegrationDependancies()
143 {
144 foreach ($this->integrationDependancies as $key => $value)
145 {
146 if (class_exists($key)) {
147 foreach ($value as $filePath)
148 {
149 $this->loadFile($filePath);
150 }
151 }
152 }
153 }
154
155 public function loadFile($filePath)
156 {
157 require_once plugin_dir_path( __FILE__ ) . $filePath .'.php';
158 }
159
160 public function addSettingsLinkFromPluginsPage($links)
161 {
162 if (apply_filters('logtivity_hide_settings_page', false)) {
163 return $links;
164 }
165
166 $settings_links = array(
167 '<a href="' . admin_url( 'admin.php?page=logtivity-settings' ) . '">Settings</a>',
168 );
169
170 return array_merge($settings_links, $links);
171 }
172
173 public function activated()
174 {
175 if (apply_filters('logtivity_hide_settings_page', false)) {
176 return;
177 }
178
179 set_transient( 'logtivity-welcome-notice', true, 5 );
180 }
181
182 public function welcomeMessage()
183 {
184 if(get_transient( 'logtivity-welcome-notice') ) {
185 echo logtivity_view('activation');
186
187 delete_transient( 'logtivity-welcome-notice' );
188 }
189 }
190
191 public function checkForSiteUrlChange()
192 {
193 if ( !current_user_can( 'manage_options' ) ) {
194 return;
195 }
196
197 if(logtivity_has_site_url_changed() && !get_transient( 'dismissed-logtivity-site-url-has-changed-notice')) {
198 echo logtivity_view('site-url-changed-notice');
199 }
200 }
201
202 public function loadScripts()
203 {
204 wp_enqueue_style( 'logtivity_admin_css', plugin_dir_url(__FILE__) . 'assets/admin.css', false, $this->version );
205 wp_enqueue_script( 'logtivity_admin_js', plugin_dir_url(__FILE__) . 'assets/app.js', false, $this->version );
206 }
207 }
208
209 $logtivity = new Logtivity;