-
Notifications
You must be signed in to change notification settings - Fork 0
/
cap-audit.php
73 lines (55 loc) · 1.43 KB
/
cap-audit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/*
Plugin Name: WP Audit Plugin
Description: A plugin to audit and track changes to WordPress pages.
Version: 1.0
Author: Lauren Orsini
*/
//avoid direct calls to this file where wp core files not present
if (!function_exists ('add_action')) {
header('Status: 403 Forbidden');
header('HTTP/1.1 403 Forbidden');
exit();
}
if(!class_exists('CAP_Audit')) {
class CAP_Audit
{
/**
* Construct the plugin object
*/
public function __construct()
{
// add a hook to set up an ajax function to display the report
//add_action('wp_insert_post_data', array(&$this, 'page_audit'));
error_log("Test");
add_action('transition_post_status', array(&$this, 'page_audit'), 10, 3);
} // END public function __construct
/**
* Activate the plugin
*/
public static function activate()
{
global $wpdb;
$tpp_table_name = 'cap_audit';
if ($wpdb->get_var("SHOW TABLES LIKE '$tpp_table_name'") != $tpp_table_name) {
$sql = "CREATE TABLE IF NOT EXISTS {$tpp_table_name} (
ID char(8) PRIMARY KEY,
start timestamp NOT NULL,
end timestamp NOT NULL
);";
$result = $wpdb->query($sql);
}
}
function page_audit($new_status, $old_status, $post)
{
error_log("Test");
if ($new_status=='trash') {
$uid = get_current_user_id();
$post_id =
$ip =
$date = get_post_modified_time();
error_log("uuid: $uid");
}
} // END public static function activate
}
}