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

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