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 / Logs / Core / Logtivity_Core.php

Logtivity_Core.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.19.0, at Logs/Core/Logtivity_Core.php

164 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Logtivity_Core extends Logtivity_Abstract_Logger
4 {
5 public function registerHooks()
6 {
7 add_action( 'upgrader_process_complete', [$this, 'upgradeProcessComplete'], 10, 2);
8 add_action( 'wp_update_nav_menu', [$this, 'menuUpdated'], 10, 2 );
9 add_filter( 'widget_update_callback', [$this, 'widgetUpdated'], 10, 4);
10 add_action('init', [$this, 'maybeSettingsUpdated']);
11 add_action( 'permalink_structure_changed', [$this, 'permalinksUpdated'], 10, 2);
12 add_action( 'update_option', [$this, 'optionUpdated'], 10, 3);
13
14 // do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
15 }
16
17 public function upgradeProcessComplete( $upgrader_object, $options )
18 {
19 if ( $options['type'] != 'core' ) {
20 return;
21 }
22
23 if ($options['action'] == 'update') {
24 return $this->coreUpdated($upgrader_object, $options);
25 }
26
27 if ($options['action'] == 'install') {
28 return $this->coreInstalled($upgrader_object, $options);
29 }
30 }
31
32 public function coreUpdated($upgrader_object, $options)
33 {
34 return Logtivity_Logger::log('WP Core Updated');
35 }
36
37 public function coreInstalled($upgrader_object, $options)
38 {
39 return Logtivity_Logger::log('WP Core Installed');
40 }
41
42 public function menuUpdated($nav_menu_id, $menuData = [])
43 {
44 if (isset($menuData['menu-name'])) {
45 return Logtivity_Logger::log()
46 ->setAction('Menu Updated')
47 ->setContext($menuData['menu-name'])
48 ->addMeta('Menu ID', $nav_menu_id)
49 ->send();
50 }
51 }
52
53 public function widgetUpdated($instance, $new, $old, $obj)
54 {
55 Logtivity_Logger::log()
56 ->setAction('Widget Updated')
57 ->setContext($obj->name)
58 ->addMeta('New Content', $new)
59 ->addMeta('Old Content', $old)
60 ->send();
61
62 return $instance;
63 }
64
65 public function maybeSettingsUpdated()
66 {
67 if (!isset($_POST['option_page']) || !$_POST['option_page'] || !isset($_POST['action']) || $_POST['action'] != 'update') {
68 return;
69 }
70 if (!in_array($_POST['option_page'], ['writing', 'general', 'reading', 'discussion', 'media'])) {
71 return;
72 }
73
74 Logtivity::log()
75 ->setAction('Settings Updated')
76 ->setContext('Core:'.$_POST['option_page'])
77 ->send();
78 }
79
80 public function optionUpdated($option, $old_value, $value)
81 {
82 if (!is_admin() || $old_value == $value) {
83 return;
84 }
85
86 $ignore = [
87 'cron',
88 'action_scheduler_lock_async-request-runner',
89 'wp_all_export_pro_addons_not_included',
90 'logtivity_latest_response',
91 'logtivity_api_key_check',
92 'logtivity_url_hash',
93 'logtivity_global_disabled_logs',
94 'logtivity_enable_white_label_mode',
95 'recently_activated',
96 'active_plugins',
97 'jp_sync_last_success_sync',
98 'jetpack_sync_settings_dedicated_sync_enabled',
99 'jetpack_plugin_api_action_links',
100 'stats_cache',
101 'admin_email_lifespan',
102 'db_upgraded',
103 'delete_blog_hash',
104 'adminhash',
105 'auto_plugin_theme_update_emails',
106 '_wp_suggested_policy_text_has_changed',
107 'ftp_credentials',
108 'uninstall_plugins',
109 'wp_force_deactivated_plugins',
110 'fresh_site',
111 'allowedthemes',
112 'rxpp_blocked_methods_count',
113 'wordfence_syncAttackDataAttempts',
114 'akismet_spam_count',
115 'jetpack_next_sync_time_sync',
116 'jetpack_updates_sync_checksum',
117 'wpcf7',
118 'gmt_offset',
119 ];
120
121 if (in_array($option, $ignore)) {
122 return;
123 }
124
125 $wildcardIgnores = [
126 'transient',
127 'cache',
128 'auto_updater',
129 'frm_addons',
130 'wpe',
131 'edd_api',
132 'edd_sl',
133 ];
134
135 foreach ($wildcardIgnores as $wildcard) {
136 if (strpos($option, $wildcard) !== false) {
137 return;
138 }
139 }
140
141 Logtivity::log()
142 ->setAction('Option Updated')
143 ->setContext($option)
144 ->addMeta('Old Value', $old_value)
145 ->addMeta('New Value', $value)
146 ->send();
147 }
148
149 public function permalinksUpdated($old_permalink_structure, $permalink_structure)
150 {
151 Logtivity::log()
152 ->setAction('Permalinks Updated')
153 ->setContext($this->getPermalinkStructure($permalink_structure))
154 ->addMeta('Old Structure', $this->getPermalinkStructure($old_permalink_structure))
155 ->send();
156 }
157
158 private function getPermalinkStructure($value)
159 {
160 return ( $value == '' ? 'Plain' : $value);
161 }
162 }
163
164 $Logtivity_Core = new Logtivity_Core;