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

93 lines 2.5 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 // do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
13 }
14
15 public function upgradeProcessComplete( $upgrader_object, $options )
16 {
17 if ( $options['type'] != 'core' ) {
18 return;
19 }
20
21 if ($options['action'] == 'update') {
22 return $this->coreUpdated($upgrader_object, $options);
23 }
24
25 if ($options['action'] == 'install') {
26 return $this->coreInstalled($upgrader_object, $options);
27 }
28 }
29
30 public function coreUpdated($upgrader_object, $options)
31 {
32 return Logtivity_Logger::log('WP Core Updated');
33 }
34
35 public function coreInstalled($upgrader_object, $options)
36 {
37 return Logtivity_Logger::log('WP Core Installed');
38 }
39
40 public function menuUpdated($nav_menu_id, $menuData = [])
41 {
42 if (isset($menuData['menu-name'])) {
43 return Logtivity_Logger::log()
44 ->setAction('Menu Updated')
45 ->setContext($menuData['menu-name'])
46 ->addMeta('Menu ID', $nav_menu_id)
47 ->send();
48 }
49 }
50
51 public function widgetUpdated($instance, $new, $old, $obj)
52 {
53 Logtivity_Logger::log()
54 ->setAction('Widget Updated')
55 ->setContext($obj->name)
56 ->addMeta('New Content', $new)
57 ->addMeta('Old Content', $old)
58 ->send();
59
60 return $instance;
61 }
62
63 public function maybeSettingsUpdated()
64 {
65 if (!isset($_POST['option_page']) || !$_POST['option_page'] || !isset($_POST['action']) || $_POST['action'] != 'update') {
66 return;
67 }
68 if (!in_array($_POST['option_page'], ['writing', 'general', 'reading', 'discussion', 'media'])) {
69 return;
70 }
71
72 Logtivity::log()
73 ->setAction('Settings Updated')
74 ->setContext('Core:'.$_POST['option_page'])
75 ->send();
76 }
77
78 public function permalinksUpdated($old_permalink_structure, $permalink_structure)
79 {
80 Logtivity::log()
81 ->setAction('Permalinks Updated')
82 ->setContext($this->getPermalinkStructure($permalink_structure))
83 ->addMeta('Old Structure', $this->getPermalinkStructure($old_permalink_structure))
84 ->send();
85 }
86
87 private function getPermalinkStructure($value)
88 {
89 return ( $value == '' ? 'Plain' : $value);
90 }
91 }
92
93 $Logtivity_Core = new Logtivity_Core;