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

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