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

206 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.19.0
8 * Author: Logtivity
9 * Text Domain: logtivity
10 */
11
12 class Logtivity
13 {
14 protected $version = '1.19.0';
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 ];
82
83 public function __construct()
84 {
85 $this->loadDependancies();
86
87 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), [$this, 'addSettingsLinkFromPluginsPage'] );
88
89 register_activation_hook( __FILE__, [$this, 'activated']);
90
91 add_action( 'admin_notices', [$this, 'welcomeMessage']);
92
93 add_action( 'admin_notices', [$this, 'checkForSiteUrlChange']);
94
95 add_action('admin_enqueue_scripts', [$this, 'loadScripts']);
96 }
97
98 public static function log($action = null, $meta = null, $user_id = null)
99 {
100 return Logtivity_Logger::log($action, $meta, $user_id);
101 }
102
103 public function loadDependancies()
104 {
105 foreach ($this->dependancies as $filePath)
106 {
107 $this->loadFile($filePath);
108 }
109
110 add_action('plugins_loaded', function() {
111 $this->maybeLoadLogClasses();
112
113 $this->loadIntegrationDependancies();
114 });
115 }
116
117 public function maybeLoadLogClasses()
118 {
119 if ($this->defaultLoggingDisabled()) {
120 return;
121 }
122
123 foreach ($this->logClasses as $filePath)
124 {
125 $this->loadFile($filePath);
126 }
127 }
128
129 /**
130 * Is the default Event logging from within the plugin enabled
131 *
132 * @return bool
133 */
134 public function defaultLoggingDisabled()
135 {
136 return (new Logtivity_Options)->getOption('logtivity_disable_default_logging');
137 }
138
139 public function loadIntegrationDependancies()
140 {
141 foreach ($this->integrationDependancies as $key => $value)
142 {
143 if (class_exists($key)) {
144 foreach ($value as $filePath)
145 {
146 $this->loadFile($filePath);
147 }
148 }
149 }
150 }
151
152 public function loadFile($filePath)
153 {
154 require_once plugin_dir_path( __FILE__ ) . $filePath .'.php';
155 }
156
157 public function addSettingsLinkFromPluginsPage($links)
158 {
159 if (apply_filters('logtivity_hide_settings_page', false)) {
160 return $links;
161 }
162
163 $settings_links = array(
164 '<a href="' . admin_url( 'admin.php?page=logtivity-settings' ) . '">Settings</a>',
165 );
166
167 return array_merge($settings_links, $links);
168 }
169
170 public function activated()
171 {
172 if (apply_filters('logtivity_hide_settings_page', false)) {
173 return;
174 }
175
176 set_transient( 'logtivity-welcome-notice', true, 5 );
177 }
178
179 public function welcomeMessage()
180 {
181 if(get_transient( 'logtivity-welcome-notice') ) {
182 echo logtivity_view('activation');
183
184 delete_transient( 'logtivity-welcome-notice' );
185 }
186 }
187
188 public function checkForSiteUrlChange()
189 {
190 if ( !current_user_can( 'manage_options' ) ) {
191 return;
192 }
193
194 if(logtivity_has_site_url_changed() && !get_transient( 'dismissed-logtivity-site-url-has-changed-notice')) {
195 echo logtivity_view('site-url-changed-notice');
196 }
197 }
198
199 public function loadScripts()
200 {
201 wp_enqueue_style( 'logtivity_admin_css', plugin_dir_url(__FILE__) . 'assets/admin.css', false, $this->version );
202 wp_enqueue_script( 'logtivity_admin_js', plugin_dir_url(__FILE__) . 'assets/app.js', false, $this->version );
203 }
204 }
205
206 $logtivity = new Logtivity;