Version Description
(December 2018) =
- Make log welcome message translateable.
-
Add two filters to make it more ease to control via filters if a logger and the combination logger + message should be logged.
-
"simple_history/log/do_log/{$this->slug}"
controls if any messages for a specific logger should be logged. Simply return false to this filter to disable all logging to that logger. -
"simple_history/log/do_log/{$this->slug}/{$message_key}"
controls if a specific message for a specific logger should be logged. Simply return false to this filter to disable all logging to that logger. -
Code examples for the two filters above: ``` // Disable logging of any user message, i.e. any message from the logger SimpleUserLogger. add_filter( 'simple_history/log/do_log/SimpleUserLogger', '__return_false' );
// Disable logging of updated posts, i.e. the message "post_updated" from the logger SimplePostLogger. add_filter( 'simple_history/log/do_log/SimplePostLogger/post_updated', '__return_false' ); ```
-
add_filter('simple_history/log/do_log/SimpleUserLogger', '__return_false');
Fix notice in Redirection plugin logger due because redirection plugin can have multiple target types. Props @MaximVanhove.
Fix warning because of missing logging messages in the categories/tags logger. Props @JeroenSormani.
Fix warning in the next version of PHP, PHP 7.3.
Release Info
Developer | eskapism |
Plugin | Simple History |
Version | 2.29 |
Comparing to | |
See all releases |
Code changes from version 2.28.1 to 2.29
- README.md +2 -2
- composer.json +1 -1
- dropins/SimpleHistoryPluginPatchesDropin.php +0 -3
- freemius/assets/img/simple-history.svg +0 -6
- inc/SimpleHistory.php +4 -10
- index.php +2 -2
- loggers/Plugin_Redirection.php +6 -6
- loggers/SimpleCategoriesLogger.php +13 -9
- loggers/SimpleLogger.php +52 -31
- loggers/SimplePluginLogger.php +2 -2
- readme.txt +20 -1
@@ -1,6 +1,6 @@
|
|
1 |
# Simple History 2 – a simple, lightweight, extendable logger for WordPress
|
2 |
|
3 |
-
Simple History is a WordPress plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI. It's great way to view user activity and keep an eye on what the users are doing.
|
4 |
|
5 |
Download from WordPress.org:
|
6 |
https://wordpress.org/plugins/simple-history/
|
@@ -58,7 +58,7 @@ apply_filters(
|
|
58 |
// Or just debug a message quickly
|
59 |
apply_filters('simple_history_log_debug', 'My debug message');
|
60 |
|
61 |
-
// You can
|
62 |
SimpleLogger()->info("This is a message sent to the log");
|
63 |
|
64 |
// Add events of different severity
|
1 |
# Simple History 2 – a simple, lightweight, extendable logger for WordPress
|
2 |
|
3 |
+
Simple History is a WordPress audit log plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI. It's great way to view user activity and keep an eye on what the admin users of a website are doing.
|
4 |
|
5 |
Download from WordPress.org:
|
6 |
https://wordpress.org/plugins/simple-history/
|
58 |
// Or just debug a message quickly
|
59 |
apply_filters('simple_history_log_debug', 'My debug message');
|
60 |
|
61 |
+
// You can also use functions/methods to add events to the log
|
62 |
SimpleLogger()->info("This is a message sent to the log");
|
63 |
|
64 |
// Add events of different severity
|
@@ -13,7 +13,7 @@
|
|
13 |
"require": {
|
14 |
"php": ">=5.3.0"
|
15 |
},
|
16 |
-
"version": "2.
|
17 |
"authors": [
|
18 |
{
|
19 |
"name": "Pär Thernström",
|
13 |
"require": {
|
14 |
"php": ">=5.3.0"
|
15 |
},
|
16 |
+
"version": "2.29",
|
17 |
"authors": [
|
18 |
{
|
19 |
"name": "Pär Thernström",
|
@@ -207,9 +207,6 @@ class SimpleHistoryPluginPatchesDropin {
|
|
207 |
// Same context as in SimpleUserLogger
|
208 |
$context = array(
|
209 |
'_initiator' => SimpleLoggerLogInitiators::WEB_USER,
|
210 |
-
// "login_user_id" => $user->ID,
|
211 |
-
// "login_user_email" => $user->user_email,
|
212 |
-
// "login_user_login" => $user->user_login,
|
213 |
'server_http_user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
214 |
'_occasionsID' => 'SimpleUserLogger' . '/failed_user_login',
|
215 |
'patch_using_patch' => true,
|
207 |
// Same context as in SimpleUserLogger
|
208 |
$context = array(
|
209 |
'_initiator' => SimpleLoggerLogInitiators::WEB_USER,
|
|
|
|
|
|
|
210 |
'server_http_user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null,
|
211 |
'_occasionsID' => 'SimpleUserLogger' . '/failed_user_login',
|
212 |
'patch_using_patch' => true,
|
@@ -1,6 +0,0 @@
|
|
1 |
-
<svg width="48" height="48" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
|
2 |
-
<g>
|
3 |
-
<path stroke="null" id="svg_1" fill="none" d="m0,0l48,0l0,48l-48,0l0,-48z"/>
|
4 |
-
<path fill="#3f9349" id="svg_2" d="m25.99,6c-9.949999,0 -17.99,8.06 -17.99,18l-6,0l7.79,7.790001l0.14,0.290001l8.07,-8.080002l-6,0c0,-7.73 6.27,-14 14,-14s14,6.27 14,14s-6.27,14 -14,14c-3.870001,0 -7.360001,-1.580002 -9.889999,-4.110001l-2.830001,2.830002c3.250001,3.259998 7.740001,5.279999 12.71,5.279999c9.949999,0 18.01,-8.060001 18.01,-18s-8.060001,-18 -18.01,-18zm-1.99,10l0,10l8.560001,5.08l1.439999,-2.43l-7,-4.15l0,-8.5l-3,0z" opacity="0.9"/>
|
5 |
-
</g>
|
6 |
-
</svg>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1787,15 +1787,15 @@ class SimpleHistory {
|
|
1787 |
|
1788 |
if ( ! $db_data_exists ) {
|
1789 |
|
1790 |
-
$welcome_message_1 = '
|
1791 |
Welcome to Simple History!
|
1792 |
|
1793 |
This is the main history feed. It will contain events that this plugin has logged.
|
1794 |
-
';
|
1795 |
|
1796 |
-
$welcome_message_2 = '
|
1797 |
Because Simple History was just recently installed, this feed does not contain much events yet. But keep the plugin activated and soon you will see detailed information about page edits, plugin updates, user logins, and much more.
|
1798 |
-
';
|
1799 |
|
1800 |
SimpleLogger()->info(
|
1801 |
$welcome_message_2,
|
@@ -1816,15 +1816,11 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
1816 |
}
|
1817 |
|
1818 |
public function registerSettingsTab( $arr_tab_settings ) {
|
1819 |
-
|
1820 |
$this->arr_settings_tabs[] = $arr_tab_settings;
|
1821 |
-
|
1822 |
}
|
1823 |
|
1824 |
public function getSettingsTabs() {
|
1825 |
-
|
1826 |
return $this->arr_settings_tabs;
|
1827 |
-
|
1828 |
}
|
1829 |
|
1830 |
/**
|
@@ -1832,9 +1828,7 @@ Because Simple History was just recently installed, this feed does not contain m
|
|
1832 |
* Called from add_options_page
|
1833 |
*/
|
1834 |
function settings_page_output() {
|
1835 |
-
|
1836 |
$arr_settings_tabs = $this->getSettingsTabs();
|
1837 |
-
|
1838 |
?>
|
1839 |
<div class="wrap">
|
1840 |
|
1787 |
|
1788 |
if ( ! $db_data_exists ) {
|
1789 |
|
1790 |
+
$welcome_message_1 = __('
|
1791 |
Welcome to Simple History!
|
1792 |
|
1793 |
This is the main history feed. It will contain events that this plugin has logged.
|
1794 |
+
', 'simple-history');
|
1795 |
|
1796 |
+
$welcome_message_2 = __('
|
1797 |
Because Simple History was just recently installed, this feed does not contain much events yet. But keep the plugin activated and soon you will see detailed information about page edits, plugin updates, user logins, and much more.
|
1798 |
+
', 'simple-history');
|
1799 |
|
1800 |
SimpleLogger()->info(
|
1801 |
$welcome_message_2,
|
1816 |
}
|
1817 |
|
1818 |
public function registerSettingsTab( $arr_tab_settings ) {
|
|
|
1819 |
$this->arr_settings_tabs[] = $arr_tab_settings;
|
|
|
1820 |
}
|
1821 |
|
1822 |
public function getSettingsTabs() {
|
|
|
1823 |
return $this->arr_settings_tabs;
|
|
|
1824 |
}
|
1825 |
|
1826 |
/**
|
1828 |
* Called from add_options_page
|
1829 |
*/
|
1830 |
function settings_page_output() {
|
|
|
1831 |
$arr_settings_tabs = $this->getSettingsTabs();
|
|
|
1832 |
?>
|
1833 |
<div class="wrap">
|
1834 |
|
@@ -5,7 +5,7 @@
|
|
5 |
* Text Domain: simple-history
|
6 |
* Domain Path: /languages
|
7 |
* Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
8 |
-
* Version: 2.
|
9 |
* Author: Pär Thernström
|
10 |
* Author URI: http://simple-history.com/
|
11 |
* License: GPL2
|
@@ -47,7 +47,7 @@ if ( $ok_php_version && $ok_wp_version ) {
|
|
47 |
*/
|
48 |
|
49 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
50 |
-
define( 'SIMPLE_HISTORY_VERSION', '2.
|
51 |
}
|
52 |
|
53 |
if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
|
5 |
* Text Domain: simple-history
|
6 |
* Domain Path: /languages
|
7 |
* Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
8 |
+
* Version: 2.29
|
9 |
* Author: Pär Thernström
|
10 |
* Author URI: http://simple-history.com/
|
11 |
* License: GPL2
|
47 |
*/
|
48 |
|
49 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
50 |
+
define( 'SIMPLE_HISTORY_VERSION', '2.29' );
|
51 |
}
|
52 |
|
53 |
if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
|
@@ -326,7 +326,7 @@ if ( ! class_exists( 'Plugin_Redirection' ) ) {
|
|
326 |
|
327 |
$context = array(
|
328 |
'new_source_url' => $req->get_param( 'url' ),
|
329 |
-
'
|
330 |
'redirection_id' => $redirection_id,
|
331 |
);
|
332 |
|
@@ -335,7 +335,7 @@ if ( ! class_exists( 'Plugin_Redirection' ) ) {
|
|
335 |
|
336 |
if ( false !== $redirection_item ) {
|
337 |
$context['prev_source_url'] = $redirection_item->get_url();
|
338 |
-
$context['
|
339 |
}
|
340 |
|
341 |
$this->infoMessage(
|
@@ -373,7 +373,7 @@ if ( ! class_exists( 'Plugin_Redirection' ) ) {
|
|
373 |
$out .= '<table class="SimpleHistoryLogitem__keyValueTable">' . $diff_table_output . '</table>';
|
374 |
}
|
375 |
|
376 |
-
if ( $context['
|
377 |
$diff_table_output = sprintf(
|
378 |
'<tr>
|
379 |
<td>%1$s</td>
|
@@ -382,9 +382,9 @@ if ( ! class_exists( 'Plugin_Redirection' ) ) {
|
|
382 |
<del class="SimpleHistoryLogitem__keyValueTable__removedThing">%3$s</del>
|
383 |
</td>
|
384 |
</tr>',
|
385 |
-
esc_html_x( 'Target
|
386 |
-
esc_html( $context['
|
387 |
-
esc_html( $context['
|
388 |
);
|
389 |
|
390 |
$out .= '<table class="SimpleHistoryLogitem__keyValueTable">' . $diff_table_output . '</table>';
|
326 |
|
327 |
$context = array(
|
328 |
'new_source_url' => $req->get_param( 'url' ),
|
329 |
+
'new_target' => $action_data,
|
330 |
'redirection_id' => $redirection_id,
|
331 |
);
|
332 |
|
335 |
|
336 |
if ( false !== $redirection_item ) {
|
337 |
$context['prev_source_url'] = $redirection_item->get_url();
|
338 |
+
$context['prev_target'] = maybe_unserialize($redirection_item->get_action_data());
|
339 |
}
|
340 |
|
341 |
$this->infoMessage(
|
373 |
$out .= '<table class="SimpleHistoryLogitem__keyValueTable">' . $diff_table_output . '</table>';
|
374 |
}
|
375 |
|
376 |
+
if ( $context['new_target'] !== $context['prev_target'] ) {
|
377 |
$diff_table_output = sprintf(
|
378 |
'<tr>
|
379 |
<td>%1$s</td>
|
382 |
<del class="SimpleHistoryLogitem__keyValueTable__removedThing">%3$s</del>
|
383 |
</td>
|
384 |
</tr>',
|
385 |
+
esc_html_x( 'Target', 'Logger: Redirection', 'simple-history' ), // 1
|
386 |
+
esc_html( $context['new_target'] ), // 2
|
387 |
+
esc_html( $context['prev_target'] ) // 3
|
388 |
);
|
389 |
|
390 |
$out .= '<table class="SimpleHistoryLogitem__keyValueTable">' . $diff_table_output . '</table>';
|
@@ -24,19 +24,23 @@ class SimpleCategoriesLogger extends SimpleLogger {
|
|
24 |
'deleted_term' => __( 'Deleted term "{term_name}" from taxonomy "{term_taxonomy}"', 'simple-history' ),
|
25 |
'edited_term' => __( 'Edited term "{to_term_name}" in taxonomy "{to_term_taxonomy}"', 'simple-history' ),
|
26 |
),
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
_x(
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
35 |
),
|
36 |
)
|
37 |
) // end search array
|
38 |
) // end labels
|
39 |
-
*/
|
40 |
);
|
41 |
|
42 |
return $arr_info;
|
24 |
'deleted_term' => __( 'Deleted term "{term_name}" from taxonomy "{term_taxonomy}"', 'simple-history' ),
|
25 |
'edited_term' => __( 'Edited term "{to_term_name}" in taxonomy "{to_term_taxonomy}"', 'simple-history' ),
|
26 |
),
|
27 |
+
'labels' => array(
|
28 |
+
'search' => array(
|
29 |
+
'label' => _x( 'Categories', 'Categories logger: search', 'simple-history'),
|
30 |
+
'label_all' => _x( 'All category activity', 'Category logger: search', 'simple-history' ),
|
31 |
+
'options' => array(
|
32 |
+
_x( 'Term created', 'Category logger: search', 'simple-history' ) => array(
|
33 |
+
'created_term'
|
34 |
+
),
|
35 |
+
_x( 'Term deleted', 'Category logger: search', 'simple-history' ) => array(
|
36 |
+
'deleted_term'
|
37 |
+
),
|
38 |
+
_x( 'Term edited', 'Category logger: search', 'simple-history' ) => array(
|
39 |
+
'edited_term'
|
40 |
),
|
41 |
)
|
42 |
) // end search array
|
43 |
) // end labels
|
|
|
44 |
);
|
45 |
|
46 |
return $arr_info;
|
@@ -984,15 +984,48 @@ class SimpleLogger {
|
|
984 |
return $this;
|
985 |
}
|
986 |
|
987 |
-
|
988 |
* Filter that makes it possible to shortcut this log.
|
989 |
* Return bool false to cancel.
|
990 |
*
|
991 |
* @since 2.3.1
|
992 |
*/
|
993 |
$do_log = apply_filters( 'simple_history/log/do_log', true, $level, $message, $context, $this );
|
|
|
|
|
|
|
994 |
|
995 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
996 |
return $this;
|
997 |
}
|
998 |
|
@@ -1054,19 +1087,19 @@ class SimpleLogger {
|
|
1054 |
'message' => $message,
|
1055 |
);
|
1056 |
|
1057 |
-
// Allow date to be
|
1058 |
-
// Date must be in format 'Y-m-d H:i:s'
|
1059 |
if ( isset( $context['_date'] ) ) {
|
1060 |
$data['date'] = $context['_date'];
|
1061 |
unset( $context['_date'] );
|
1062 |
}
|
1063 |
|
1064 |
-
// Add occasions id
|
1065 |
$occasions_id = null;
|
1066 |
if ( isset( $context['_occasionsID'] ) ) {
|
1067 |
|
1068 |
// Minimize risk of similar loggers logging same messages and such and resulting in same occasions id
|
1069 |
-
// by always adding logger slug
|
1070 |
$occasions_data = array(
|
1071 |
'_occasionsID' => $context['_occasionsID'],
|
1072 |
'_loggerSlug' => $this->slug,
|
@@ -1076,29 +1109,18 @@ class SimpleLogger {
|
|
1076 |
|
1077 |
} else {
|
1078 |
|
1079 |
-
// No occasions id specified, create one bases on the data array
|
1080 |
$occasions_data = $data + $context;
|
1081 |
|
1082 |
-
// Don't include date in context data
|
1083 |
unset( $occasions_data['date'] );
|
1084 |
|
1085 |
-
// sf_d($occasions_data);exit;
|
1086 |
$occasions_id = md5( json_encode( $occasions_data ) );
|
1087 |
|
1088 |
}
|
1089 |
|
1090 |
$data['occasionsID'] = $occasions_id;
|
1091 |
|
1092 |
-
// Log event type, defaults to other if not set
|
1093 |
-
/*
|
1094 |
-
if ( isset( $context["_type"] ) ) {
|
1095 |
-
$data["type"] = $context["_type"];
|
1096 |
-
unset( $context["_type"] );
|
1097 |
-
} else {
|
1098 |
-
$data["type"] = SimpleLoggerLogTypes::OTHER;
|
1099 |
-
}
|
1100 |
-
*/
|
1101 |
-
|
1102 |
// Log initiator, defaults to current user if exists, or other if not user exist
|
1103 |
if ( isset( $context['_initiator'] ) ) {
|
1104 |
|
@@ -1161,11 +1183,11 @@ class SimpleLogger {
|
|
1161 |
|
1162 |
}
|
1163 |
|
1164 |
-
// Trim message
|
1165 |
$data['message'] = trim( $data['message'] );
|
1166 |
|
1167 |
/**
|
1168 |
-
* Filter data to be saved to db
|
1169 |
*
|
1170 |
* @since 2.0
|
1171 |
*
|
@@ -1173,13 +1195,12 @@ class SimpleLogger {
|
|
1173 |
*/
|
1174 |
$data = apply_filters( 'simple_history/log_insert_data', $data );
|
1175 |
|
1176 |
-
// Insert data into db
|
1177 |
-
// sf_d($db_table, '$db_table');exit;
|
1178 |
$result = $wpdb->insert( $db_table, $data );
|
1179 |
|
1180 |
$data_parent_row = null;
|
1181 |
|
1182 |
-
// Only save context if able to store row
|
1183 |
if ( false === $result ) {
|
1184 |
|
1185 |
$history_inserted_id = null;
|
@@ -1191,7 +1212,7 @@ class SimpleLogger {
|
|
1191 |
$db_table_contexts = $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS;
|
1192 |
|
1193 |
/**
|
1194 |
-
* Filter table name for contexts
|
1195 |
*
|
1196 |
* @since 2.0
|
1197 |
*
|
@@ -1203,10 +1224,10 @@ class SimpleLogger {
|
|
1203 |
$context = array();
|
1204 |
}
|
1205 |
|
1206 |
-
// Append user id to context, if not already added
|
1207 |
if ( ! isset( $context['_user_id'] ) ) {
|
1208 |
|
1209 |
-
// wp_get_current_user is
|
1210 |
// http://codex.wordpress.org/Function_Reference/wp_get_current_user
|
1211 |
// https://core.trac.wordpress.org/ticket/14024
|
1212 |
if ( function_exists( 'wp_get_current_user' ) ) {
|
@@ -1229,14 +1250,14 @@ class SimpleLogger {
|
|
1229 |
/**
|
1230 |
* Filter to control if ip addresses should be anonymized or not.
|
1231 |
*
|
1232 |
-
* @since 2.
|
1233 |
*
|
1234 |
* @param bool true to anonymize ip address, false to keep original ip address.
|
1235 |
* @return bool
|
1236 |
*/
|
1237 |
$anonymize_ip_address = apply_filters( 'simple_history/privacy/anonymize_ip_address', true );
|
1238 |
|
1239 |
-
if ( $anonymize_ip_address && function_exists('wp_privacy_anonymize_ip') ) {
|
1240 |
$remote_addr = wp_privacy_anonymize_ip( $remote_addr );
|
1241 |
}
|
1242 |
|
@@ -1270,7 +1291,7 @@ class SimpleLogger {
|
|
1270 |
// valid, add to context, with loop index appended so we can store many IPs.
|
1271 |
$key_lower = strtolower( $key );
|
1272 |
|
1273 |
-
if ( $anonymize_ip_address && function_exists('wp_privacy_anonymize_ip') ) {
|
1274 |
$ip = wp_privacy_anonymize_ip( $ip );
|
1275 |
}
|
1276 |
|
@@ -1297,7 +1318,7 @@ class SimpleLogger {
|
|
1297 |
*
|
1298 |
* @param array $context Array with all context data to store. Modify and return this.
|
1299 |
* @param array $data Array with data used for parent row.
|
1300 |
-
* @param array $this Reference to this logger instance
|
1301 |
*/
|
1302 |
$context = apply_filters( 'simple_history/log_insert_context', $context, $data, $this );
|
1303 |
$data_parent_row = $data;
|
984 |
return $this;
|
985 |
}
|
986 |
|
987 |
+
/**
|
988 |
* Filter that makes it possible to shortcut this log.
|
989 |
* Return bool false to cancel.
|
990 |
*
|
991 |
* @since 2.3.1
|
992 |
*/
|
993 |
$do_log = apply_filters( 'simple_history/log/do_log', true, $level, $message, $context, $this );
|
994 |
+
if ( false === $do_log ) {
|
995 |
+
return $this;
|
996 |
+
}
|
997 |
|
998 |
+
/**
|
999 |
+
* Easy shortcut method to disable logging of messages from
|
1000 |
+
* a specific logger.
|
1001 |
+
*
|
1002 |
+
* Example filter name:
|
1003 |
+
* simple_history/log/do_log/SimpleUserLogger
|
1004 |
+
* simple_history/log/do_log/SimplePostLogger
|
1005 |
+
*
|
1006 |
+
* Example to disable logging of any user login/logout/failed login activity:
|
1007 |
+
* add_filter('simple_history/log/do_log/SimpleUserLogger', '__return_false')
|
1008 |
+
*
|
1009 |
+
* @since 2.nn
|
1010 |
+
*/
|
1011 |
+
$do_log = apply_filters( "simple_history/log/do_log/{$this->slug}", true );
|
1012 |
+
if ( false === $do_log ) {
|
1013 |
+
return $this;
|
1014 |
+
}
|
1015 |
+
|
1016 |
+
/**
|
1017 |
+
* Easy shortcut method to disable logging of messages from
|
1018 |
+
* a specific logger and message.
|
1019 |
+
*
|
1020 |
+
* Example filter name:
|
1021 |
+
* simple_history/log/do_log/SimpleUserLogger/user_logged_in
|
1022 |
+
* simple_history/log/do_log/SimplePostLogger/post_updated
|
1023 |
+
*
|
1024 |
+
* @since 2.nn
|
1025 |
+
*/
|
1026 |
+
$message_key = isset( $context['_message_key'] ) ? $context['_message_key'] : null;
|
1027 |
+
$do_log = apply_filters( "simple_history/log/do_log/{$this->slug}/{$message_key}", true );
|
1028 |
+
if ( false === $do_log ) {
|
1029 |
return $this;
|
1030 |
}
|
1031 |
|
1087 |
'message' => $message,
|
1088 |
);
|
1089 |
|
1090 |
+
// Allow date to be overriden.
|
1091 |
+
// Date must be in format 'Y-m-d H:i:s'.
|
1092 |
if ( isset( $context['_date'] ) ) {
|
1093 |
$data['date'] = $context['_date'];
|
1094 |
unset( $context['_date'] );
|
1095 |
}
|
1096 |
|
1097 |
+
// Add occasions id.
|
1098 |
$occasions_id = null;
|
1099 |
if ( isset( $context['_occasionsID'] ) ) {
|
1100 |
|
1101 |
// Minimize risk of similar loggers logging same messages and such and resulting in same occasions id
|
1102 |
+
// by always adding logger slug.
|
1103 |
$occasions_data = array(
|
1104 |
'_occasionsID' => $context['_occasionsID'],
|
1105 |
'_loggerSlug' => $this->slug,
|
1109 |
|
1110 |
} else {
|
1111 |
|
1112 |
+
// No occasions id specified, create one bases on the data array.
|
1113 |
$occasions_data = $data + $context;
|
1114 |
|
1115 |
+
// Don't include date in context data.
|
1116 |
unset( $occasions_data['date'] );
|
1117 |
|
|
|
1118 |
$occasions_id = md5( json_encode( $occasions_data ) );
|
1119 |
|
1120 |
}
|
1121 |
|
1122 |
$data['occasionsID'] = $occasions_id;
|
1123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1124 |
// Log initiator, defaults to current user if exists, or other if not user exist
|
1125 |
if ( isset( $context['_initiator'] ) ) {
|
1126 |
|
1183 |
|
1184 |
}
|
1185 |
|
1186 |
+
// Trim message.
|
1187 |
$data['message'] = trim( $data['message'] );
|
1188 |
|
1189 |
/**
|
1190 |
+
* Filter data to be saved to db.
|
1191 |
*
|
1192 |
* @since 2.0
|
1193 |
*
|
1195 |
*/
|
1196 |
$data = apply_filters( 'simple_history/log_insert_data', $data );
|
1197 |
|
1198 |
+
// Insert data into db.
|
|
|
1199 |
$result = $wpdb->insert( $db_table, $data );
|
1200 |
|
1201 |
$data_parent_row = null;
|
1202 |
|
1203 |
+
// Only save context if able to store row.
|
1204 |
if ( false === $result ) {
|
1205 |
|
1206 |
$history_inserted_id = null;
|
1212 |
$db_table_contexts = $wpdb->prefix . SimpleHistory::DBTABLE_CONTEXTS;
|
1213 |
|
1214 |
/**
|
1215 |
+
* Filter table name for contexts.
|
1216 |
*
|
1217 |
* @since 2.0
|
1218 |
*
|
1224 |
$context = array();
|
1225 |
}
|
1226 |
|
1227 |
+
// Append user id to context, if not already added.
|
1228 |
if ( ! isset( $context['_user_id'] ) ) {
|
1229 |
|
1230 |
+
// wp_get_current_user is not available early.
|
1231 |
// http://codex.wordpress.org/Function_Reference/wp_get_current_user
|
1232 |
// https://core.trac.wordpress.org/ticket/14024
|
1233 |
if ( function_exists( 'wp_get_current_user' ) ) {
|
1250 |
/**
|
1251 |
* Filter to control if ip addresses should be anonymized or not.
|
1252 |
*
|
1253 |
+
* @since 2.22
|
1254 |
*
|
1255 |
* @param bool true to anonymize ip address, false to keep original ip address.
|
1256 |
* @return bool
|
1257 |
*/
|
1258 |
$anonymize_ip_address = apply_filters( 'simple_history/privacy/anonymize_ip_address', true );
|
1259 |
|
1260 |
+
if ( $anonymize_ip_address && function_exists( 'wp_privacy_anonymize_ip' ) ) {
|
1261 |
$remote_addr = wp_privacy_anonymize_ip( $remote_addr );
|
1262 |
}
|
1263 |
|
1291 |
// valid, add to context, with loop index appended so we can store many IPs.
|
1292 |
$key_lower = strtolower( $key );
|
1293 |
|
1294 |
+
if ( $anonymize_ip_address && function_exists( 'wp_privacy_anonymize_ip' ) ) {
|
1295 |
$ip = wp_privacy_anonymize_ip( $ip );
|
1296 |
}
|
1297 |
|
1318 |
*
|
1319 |
* @param array $context Array with all context data to store. Modify and return this.
|
1320 |
* @param array $data Array with data used for parent row.
|
1321 |
+
* @param array $this Reference to this logger instance.
|
1322 |
*/
|
1323 |
$context = apply_filters( 'simple_history/log_insert_context', $context, $data, $this );
|
1324 |
$data_parent_row = $data;
|
@@ -1074,7 +1074,7 @@ class SimplePluginLogger extends SimpleLogger {
|
|
1074 |
|
1075 |
case 'plugin_install_source':
|
1076 |
if ( ! isset( $context[ $key ] ) ) {
|
1077 |
-
|
1078 |
}
|
1079 |
|
1080 |
if ( 'web' == $context[ $key ] ) {
|
@@ -1102,7 +1102,7 @@ class SimplePluginLogger extends SimpleLogger {
|
|
1102 |
|
1103 |
break;
|
1104 |
|
1105 |
-
default
|
1106 |
$desc_output = esc_html( $context[ $key ] );
|
1107 |
break;
|
1108 |
}// End switch().
|
1074 |
|
1075 |
case 'plugin_install_source':
|
1076 |
if ( ! isset( $context[ $key ] ) ) {
|
1077 |
+
break;
|
1078 |
}
|
1079 |
|
1080 |
if ( 'web' == $context[ $key ] ) {
|
1102 |
|
1103 |
break;
|
1104 |
|
1105 |
+
default:
|
1106 |
$desc_output = esc_html( $context[ $key ] );
|
1107 |
break;
|
1108 |
}// End switch().
|
@@ -5,7 +5,7 @@ Tags: history, log, changes, changelog, audit, audit log, event log, user tracki
|
|
5 |
Requires at least: 4.5.1
|
6 |
Tested up to: 4.9
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 2.
|
9 |
|
10 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
11 |
|
@@ -181,6 +181,25 @@ A simple way to see any uncommon activity, for example an increased number of lo
|
|
181 |
|
182 |
## Changelog
|
183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
= 2.28.1 (September 2018) =
|
185 |
|
186 |
- Remove a debug message that was left in the code.
|
5 |
Requires at least: 4.5.1
|
6 |
Tested up to: 4.9
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 2.29
|
9 |
|
10 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
11 |
|
181 |
|
182 |
## Changelog
|
183 |
|
184 |
+
= 2.29 (December 2018) =
|
185 |
+
|
186 |
+
- Make log welcome message translateable.
|
187 |
+
- Add two filters to make it more ease to control via filters if a logger and the combination logger + message should be logged.
|
188 |
+
- `"simple_history/log/do_log/{$this->slug}"` controls if any messages for a specific logger should be logged. Simply return false to this filter to disable all logging to that logger.
|
189 |
+
- `"simple_history/log/do_log/{$this->slug}/{$message_key}"` controls if a specific message for a specific logger should be logged. Simply return false to this filter to disable all logging to that logger.
|
190 |
+
- Code examples for the two filters above:
|
191 |
+
```
|
192 |
+
// Disable logging of any user message, i.e. any message from the logger SimpleUserLogger.
|
193 |
+
add_filter( 'simple_history/log/do_log/SimpleUserLogger', '__return_false' );
|
194 |
+
|
195 |
+
// Disable logging of updated posts, i.e. the message "post_updated" from the logger SimplePostLogger.
|
196 |
+
add_filter( 'simple_history/log/do_log/SimplePostLogger/post_updated', '__return_false' );
|
197 |
+
```
|
198 |
+
- add_filter('simple_history/log/do_log/SimpleUserLogger', '__return_false');
|
199 |
+
- Fix notice in Redirection plugin logger due because redirection plugin can have multiple target types. Props @MaximVanhove.
|
200 |
+
- Fix warning because of missing logging messages in the categories/tags logger. Props @JeroenSormani.
|
201 |
+
- Fix warning in the next version of PHP, PHP 7.3.
|
202 |
+
|
203 |
= 2.28.1 (September 2018) =
|
204 |
|
205 |
- Remove a debug message that was left in the code.
|