PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.20.1
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.20.1
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.20.1, at Logs/Core/Logtivity_Core.php

166 lines 4.1 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 '_edd_table_check',
120 'woocommerce_marketplace_suggestions',
121 ];
122
123 if (in_array($option, $ignore)) {
124 return;
125 }
126
127 $wildcardIgnores = [
128 'transient',
129 'cache',
130 'auto_updater',
131 'wpe',
132 'edd_api',
133 'edd_sl',
134 'frm_',
135 ];
136
137 foreach ($wildcardIgnores as $wildcard) {
138 if (strpos($option, $wildcard) !== false) {
139 return;
140 }
141 }
142
143 Logtivity::log()
144 ->setAction('Option Updated')
145 ->setContext($option)
146 ->addMeta('Old Value', $old_value)
147 ->addMeta('New Value', $value)
148 ->send();
149 }
150
151 public function permalinksUpdated($old_permalink_structure, $permalink_structure)
152 {
153 Logtivity::log()
154 ->setAction('Permalinks Updated')
155 ->setContext($this->getPermalinkStructure($permalink_structure))
156 ->addMeta('Old Structure', $this->getPermalinkStructure($old_permalink_structure))
157 ->send();
158 }
159
160 private function getPermalinkStructure($value)
161 {
162 return ( $value == '' ? 'Plain' : $value);
163 }
164 }
165
166 $Logtivity_Core = new Logtivity_Core;