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 / logtivity.php

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

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