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

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