Version Description
(January 2022) =
- Fixed: Error when uploading images when using WordPress 5.7.0 or earlier.
Download this release
Release Info
Developer | eskapism |
Plugin | Simple History |
Version | 3.1.1 |
Comparing to | |
See all releases |
Code changes from version 3.1.0 to 3.1.1
- codeception.dist.yml +0 -20
- examples/example-dropin.php +0 -56
- examples/example-logger.php +0 -93
- examples/examples.php +0 -465
- index.php +2 -2
- loggers/SimpleMediaLogger.php +4 -5
- readme.txt +5 -1
codeception.dist.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
paths:
|
2 |
-
tests: tests
|
3 |
-
output: tests/_output
|
4 |
-
data: tests/_data
|
5 |
-
support: tests/_support
|
6 |
-
envs: tests/_envs
|
7 |
-
actor_suffix: Tester
|
8 |
-
extensions:
|
9 |
-
enabled:
|
10 |
-
- Codeception\Extension\RunFailed
|
11 |
-
commands:
|
12 |
-
- Codeception\Command\GenerateWPUnit
|
13 |
-
- Codeception\Command\GenerateWPRestApi
|
14 |
-
- Codeception\Command\GenerateWPRestController
|
15 |
-
- Codeception\Command\GenerateWPRestPostTypeController
|
16 |
-
- Codeception\Command\GenerateWPAjax
|
17 |
-
- Codeception\Command\GenerateWPCanonical
|
18 |
-
- Codeception\Command\GenerateWPXMLRPC
|
19 |
-
params:
|
20 |
-
- .env.testing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
examples/example-dropin.php
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// No external calls allowed to test file.
|
4 |
-
// Remove this exit call if you use this file as a template for your own dropin.
|
5 |
-
exit;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* This example shows how to create a simple dropin
|
9 |
-
* that will add a tab to the simple history settings page
|
10 |
-
*/
|
11 |
-
|
12 |
-
// We use the function "register_dropin" to tell tell Simple History that our custom logger exists.
|
13 |
-
// We call it from inside the filter "simple_history/add_custom_logger".
|
14 |
-
add_action(
|
15 |
-
'simple_history/add_custom_dropin',
|
16 |
-
function ( $simpleHistory ) {
|
17 |
-
$simpleHistory->register_dropin( 'AddSettingsPageTab' );
|
18 |
-
}
|
19 |
-
);
|
20 |
-
|
21 |
-
|
22 |
-
/**
|
23 |
-
* This is the class that does the main work!
|
24 |
-
*/
|
25 |
-
class AddSettingsPageTab {
|
26 |
-
|
27 |
-
// This will hold a reference to the simple history instance.
|
28 |
-
private $sh;
|
29 |
-
|
30 |
-
// Simple History will pass itself to the constructor.
|
31 |
-
public function __construct( $sh ) {
|
32 |
-
$this->sh = $sh;
|
33 |
-
$this->init();
|
34 |
-
}
|
35 |
-
|
36 |
-
public function init() {
|
37 |
-
add_action( 'init', array( $this, 'add_settings_tab' ) );
|
38 |
-
}
|
39 |
-
|
40 |
-
public function add_settings_tab() {
|
41 |
-
$this->sh->registerSettingsTab(
|
42 |
-
array(
|
43 |
-
'slug' => 'my_unique_settings_tab_slug',
|
44 |
-
'name' => __( 'Example tab', 'simple-history' ),
|
45 |
-
'function' => array( $this, 'settings_tab_output' ),
|
46 |
-
)
|
47 |
-
);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function settings_tab_output() {
|
51 |
-
?>
|
52 |
-
<h3>Hi there!</h3>
|
53 |
-
<p>I'm the output from on settings tab.</p>
|
54 |
-
<?php
|
55 |
-
}
|
56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
examples/example-logger.php
DELETED
@@ -1,93 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// No external calls allowed to test file
|
4 |
-
exit;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* This example shows how to create a simple logger that will
|
8 |
-
* log 404-errors on your website.
|
9 |
-
*/
|
10 |
-
|
11 |
-
// We use the function "register_logger" to tell tell SimpleHistory that our custom logger exists.
|
12 |
-
// We call it from inside the filter "simple_history/add_custom_logger".
|
13 |
-
add_action(
|
14 |
-
'simple_history/add_custom_logger',
|
15 |
-
function ( $simpleHistory ) {
|
16 |
-
$simpleHistory->register_logger( 'FourOhFourLogger' );
|
17 |
-
}
|
18 |
-
);
|
19 |
-
|
20 |
-
// We make sure that the SimpleLogger class exists before trying to extend it.
|
21 |
-
// This prevents error if the Simple History plugin gets inactivated.
|
22 |
-
if ( class_exists( 'SimpleLogger' ) ) {
|
23 |
-
|
24 |
-
/**
|
25 |
-
* This is the class that does the main work!
|
26 |
-
*/
|
27 |
-
class FourOhFourLogger extends SimpleLogger {
|
28 |
-
|
29 |
-
|
30 |
-
/**
|
31 |
-
* The slug is ised to identify this logger in various places.
|
32 |
-
* We use the name of the class too keep it simple.
|
33 |
-
*/
|
34 |
-
public $slug = __CLASS__;
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Return information about this logger.
|
38 |
-
* Used to show info about the logger at various places.
|
39 |
-
*/
|
40 |
-
public function getInfo() {
|
41 |
-
|
42 |
-
$arr_info = array(
|
43 |
-
'name' => '404 Logger',
|
44 |
-
'description' => 'Logs access to pages that result in page not found errors (error code 404)',
|
45 |
-
'capability' => 'edit_pages',
|
46 |
-
'messages' => array(
|
47 |
-
'page_not_found' => __( 'Got a 404-page when trying to visit "{request_uri}"', 'simple-history' ),
|
48 |
-
),
|
49 |
-
'labels' => array(
|
50 |
-
'search' => array(
|
51 |
-
'label' => _x( 'Pages not found (404 errors)', 'User logger: 404', 'simple-history' ),
|
52 |
-
'options' => array(
|
53 |
-
_x( 'Pages not found', 'User logger: 404', 'simple-history' ) => array(
|
54 |
-
'page_not_found',
|
55 |
-
),
|
56 |
-
),
|
57 |
-
), // end search
|
58 |
-
), // end labels
|
59 |
-
);
|
60 |
-
|
61 |
-
return $arr_info;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* When Simple History has loaded this logger it automagically
|
66 |
-
* calls a loaded() function. This is where you add your actions
|
67 |
-
* and other logger functionality.
|
68 |
-
*/
|
69 |
-
public function loaded() {
|
70 |
-
|
71 |
-
// Call a function when WordPress finds a 404 page
|
72 |
-
add_action( '404_template', array( $this, 'on404Template' ), 10, 1 );
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Function that is called when WordPress finds a 404 page.
|
77 |
-
* It collects some info and then it logs a warning message
|
78 |
-
* to the log.
|
79 |
-
*/
|
80 |
-
public function on404Template( $template ) {
|
81 |
-
|
82 |
-
$context = array(
|
83 |
-
'_initiator' => SimpleLoggerLogInitiators::WEB_USER,
|
84 |
-
'request_uri' => isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '',
|
85 |
-
'http_referer' => isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '',
|
86 |
-
);
|
87 |
-
|
88 |
-
$this->warningMessage( 'page_not_found', $context );
|
89 |
-
|
90 |
-
return $template;
|
91 |
-
}
|
92 |
-
}
|
93 |
-
}// End if().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
examples/examples.php
DELETED
@@ -1,465 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Examples on how to customize Simple History.
|
5 |
-
*
|
6 |
-
* @package SimpleHistory
|
7 |
-
*/
|
8 |
-
|
9 |
-
// No external calls allowed.
|
10 |
-
exit;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Misc
|
14 |
-
*/
|
15 |
-
|
16 |
-
// Add $_GET, $_POST, and more info to each logged event.
|
17 |
-
define( 'SIMPLE_HISTORY_LOG_DEBUG', true );
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Some examples of filter usage and so on
|
22 |
-
*/
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Remove the "Clear log"-button, so a user with admin access can not clear the log
|
26 |
-
* and wipe their mischievous behavior from the log.
|
27 |
-
*/
|
28 |
-
add_filter(
|
29 |
-
'simple_history/user_can_clear_log',
|
30 |
-
function ( $user_can_clear_log ) {
|
31 |
-
$user_can_clear_log = false;
|
32 |
-
return $user_can_clear_log;
|
33 |
-
}
|
34 |
-
);
|
35 |
-
|
36 |
-
// Modify who can read a logger.
|
37 |
-
// Modify the if part to give users access or no access to a logger.
|
38 |
-
add_filter(
|
39 |
-
'simple_history/loggers_user_can_read/can_read_single_logger',
|
40 |
-
function ( $user_can_read_logger, $logger_instance, $user_id ) {
|
41 |
-
|
42 |
-
// in this example user with id 3 gets access to the post logger
|
43 |
-
// while user with id 8 does not get any access to it
|
44 |
-
if ( $logger_instance->slug == 'SimplePostLogger' && $user_id === 3 ) {
|
45 |
-
$user_can_read_logger = true;
|
46 |
-
} elseif ( $logger_instance->slug == 'SimplePostLogger' && $user_id === 9 ) {
|
47 |
-
$user_can_read_logger = false;
|
48 |
-
}
|
49 |
-
|
50 |
-
return $user_can_read_logger;
|
51 |
-
},
|
52 |
-
10,
|
53 |
-
3
|
54 |
-
);
|
55 |
-
|
56 |
-
|
57 |
-
// Do not log some post types, for example pages and attachments in this case
|
58 |
-
add_filter(
|
59 |
-
'simple_history/log/do_log',
|
60 |
-
function ( $do_log = null, $level = null, $message = null, $context = null, $logger = null ) {
|
61 |
-
|
62 |
-
$post_types_to_not_log = array(
|
63 |
-
'page',
|
64 |
-
'attachment',
|
65 |
-
);
|
66 |
-
|
67 |
-
if ( ( isset( $logger->slug ) && ( $logger->slug === 'SimplePostLogger' || $logger->slug === 'SimpleMediaLogger' ) ) && ( isset( $context['post_type'] ) && in_array( $context['post_type'], $post_types_to_not_log ) ) ) {
|
68 |
-
$do_log = false;
|
69 |
-
}
|
70 |
-
|
71 |
-
return $do_log;
|
72 |
-
},
|
73 |
-
10,
|
74 |
-
5
|
75 |
-
);
|
76 |
-
|
77 |
-
// Disable all logging
|
78 |
-
add_filter( 'simple_history/log/do_log', '__return_false' );
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Example that modifies the parameters sent to the message template
|
82 |
-
* This example will change the post type from "post" or "page" or similar to "my own page type"
|
83 |
-
*/
|
84 |
-
add_filter(
|
85 |
-
'simple_history/logger/interpolate/context',
|
86 |
-
function ( $context, $message, $row ) {
|
87 |
-
|
88 |
-
if ( empty( $row ) ) {
|
89 |
-
return $context;
|
90 |
-
}
|
91 |
-
|
92 |
-
if ( $row->logger == 'SimplePostLogger' && $row->context_message_key == 'post_updated' ) {
|
93 |
-
$context['post_type'] = 'my own page type';
|
94 |
-
}
|
95 |
-
|
96 |
-
return $context;
|
97 |
-
},
|
98 |
-
10,
|
99 |
-
3
|
100 |
-
);
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Change capability required to manage the options page of simple history.
|
106 |
-
* Default capability is "manage_options"
|
107 |
-
*/
|
108 |
-
add_filter(
|
109 |
-
'simple_history/view_settings_capability',
|
110 |
-
function ( $capability ) {
|
111 |
-
|
112 |
-
$capability = 'manage_options';
|
113 |
-
return $capability;
|
114 |
-
}
|
115 |
-
);
|
116 |
-
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Change capability required to view main simple history page.
|
120 |
-
* Default capability is "edit_pages". Change to for example "manage options"
|
121 |
-
* to only allow admins to view the history log.
|
122 |
-
*/
|
123 |
-
add_filter(
|
124 |
-
'simple_history/view_history_capability',
|
125 |
-
function ( $capability ) {
|
126 |
-
|
127 |
-
$capability = 'manage_options';
|
128 |
-
return $capability;
|
129 |
-
}
|
130 |
-
);
|
131 |
-
|
132 |
-
|
133 |
-
// Skip adding things to the context table during logging.
|
134 |
-
// Useful if you don't want to add cool and possible super useful info to your logged events.
|
135 |
-
// Also nice to have if you want to make sure your database does not grow.
|
136 |
-
add_filter(
|
137 |
-
'simple_history/log_insert_context',
|
138 |
-
function ( $context, $data ) {
|
139 |
-
|
140 |
-
unset( $context['_user_id'] );
|
141 |
-
unset( $context['_user_login'] );
|
142 |
-
unset( $context['_user_email'] );
|
143 |
-
unset( $context['server_http_user_agent'] );
|
144 |
-
|
145 |
-
return $context;
|
146 |
-
},
|
147 |
-
10,
|
148 |
-
2
|
149 |
-
);
|
150 |
-
|
151 |
-
// Hide some columns from the detailed context view popup window
|
152 |
-
add_filter(
|
153 |
-
'simple_history/log_html_output_details_table/row_keys_to_show',
|
154 |
-
function ( $logRowKeysToShow, $oneLogRow ) {
|
155 |
-
|
156 |
-
$logRowKeysToShow['id'] = false;
|
157 |
-
$logRowKeysToShow['logger'] = false;
|
158 |
-
$logRowKeysToShow['level'] = false;
|
159 |
-
$logRowKeysToShow['message'] = false;
|
160 |
-
|
161 |
-
return $logRowKeysToShow;
|
162 |
-
},
|
163 |
-
10,
|
164 |
-
2
|
165 |
-
);
|
166 |
-
|
167 |
-
|
168 |
-
// Hide some more columns from the detailed context view popup window
|
169 |
-
add_filter(
|
170 |
-
'simple_history/log_html_output_details_table/context_keys_to_show',
|
171 |
-
function ( $logRowContextKeysToShow, $oneLogRow ) {
|
172 |
-
|
173 |
-
$logRowContextKeysToShow['plugin_slug'] = false;
|
174 |
-
$logRowContextKeysToShow['plugin_name'] = false;
|
175 |
-
$logRowContextKeysToShow['plugin_title'] = false;
|
176 |
-
$logRowContextKeysToShow['plugin_description'] = false;
|
177 |
-
|
178 |
-
return $logRowContextKeysToShow;
|
179 |
-
},
|
180 |
-
10,
|
181 |
-
2
|
182 |
-
);
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
// Allow only the users specified in $allowed_users to show the history page, the history widget on the dashboard, or the history settings page
|
187 |
-
add_filter( 'simple_history/show_dashboard_page', 'function_show_history_dashboard_or_page' );
|
188 |
-
add_filter( 'simple_history/show_dashboard_widget', 'function_show_history_dashboard_or_page' );
|
189 |
-
add_filter( 'simple_history/show_settings_page', 'function_show_history_dashboard_or_page' );
|
190 |
-
function function_show_history_dashboard_or_page( $show ) {
|
191 |
-
|
192 |
-
$allowed_users = array(
|
193 |
-
'user1@example.com',
|
194 |
-
'anotheruser@example.com',
|
195 |
-
);
|
196 |
-
|
197 |
-
$user = wp_get_current_user();
|
198 |
-
|
199 |
-
if ( ! in_array( $user->user_email, $allowed_users ) ) {
|
200 |
-
$show = false;
|
201 |
-
}
|
202 |
-
|
203 |
-
return $show;
|
204 |
-
}
|
205 |
-
|
206 |
-
|
207 |
-
// Skip loading of loggers
|
208 |
-
add_filter(
|
209 |
-
'simple_history/logger/load_logger',
|
210 |
-
function ( $load_logger, $oneLoggerFile ) {
|
211 |
-
|
212 |
-
// Don't load loggers for comments or menus, i.e. don't log changes to comments or to menus
|
213 |
-
if ( in_array( $oneLoggerFile, array( 'SimpleCommentsLogger', 'SimpleMenuLogger' ) ) ) {
|
214 |
-
$load_logger = false;
|
215 |
-
}
|
216 |
-
|
217 |
-
return $load_logger;
|
218 |
-
},
|
219 |
-
10,
|
220 |
-
2
|
221 |
-
);
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Load only the loggers that are specified in the $do_log_us array
|
225 |
-
*/
|
226 |
-
add_filter(
|
227 |
-
'simple_history/logger/load_logger',
|
228 |
-
function ( $load_logger, $logger_basename ) {
|
229 |
-
|
230 |
-
$load_logger = false;
|
231 |
-
$do_log_us = array( 'SimplePostLogger', 'SimplePluginLogger', 'SimpleLogger' );
|
232 |
-
|
233 |
-
if ( in_array( $logger_basename, $do_log_us ) ) {
|
234 |
-
$load_logger = true;
|
235 |
-
}
|
236 |
-
|
237 |
-
return $load_logger;
|
238 |
-
},
|
239 |
-
10,
|
240 |
-
2
|
241 |
-
);
|
242 |
-
|
243 |
-
|
244 |
-
// Skip the loading of dropins
|
245 |
-
add_filter(
|
246 |
-
'simple_history/dropin/load_dropin',
|
247 |
-
function ( $load_dropin, $dropinFileBasename ) {
|
248 |
-
|
249 |
-
// Don't load the RSS feed dropin
|
250 |
-
if ( $dropinFileBasename == 'SimpleHistoryRSSDropin' ) {
|
251 |
-
$load_dropin = false;
|
252 |
-
}
|
253 |
-
|
254 |
-
// Don't load the dropin that polls for changes
|
255 |
-
if ( $dropinFileBasename == 'SimpleHistoryNewRowsNotifier' ) {
|
256 |
-
$load_dropin = false;
|
257 |
-
}
|
258 |
-
|
259 |
-
return $load_dropin;
|
260 |
-
},
|
261 |
-
10,
|
262 |
-
2
|
263 |
-
);
|
264 |
-
|
265 |
-
|
266 |
-
// Don't log failed logins
|
267 |
-
add_filter(
|
268 |
-
'simple_history/simple_logger/log_message_key',
|
269 |
-
function ( $doLog, $loggerSlug, $messageKey, $SimpleLoggerLogLevelsLevel, $context ) {
|
270 |
-
|
271 |
-
// Don't log login attempts to non existing users
|
272 |
-
if ( 'SimpleUserLogger' == $loggerSlug && 'user_unknown_login_failed' == $messageKey ) {
|
273 |
-
$doLog = false;
|
274 |
-
}
|
275 |
-
|
276 |
-
// Don't log failed logins to existing users
|
277 |
-
if ( 'SimpleUserLogger' == $loggerSlug && 'user_login_failed' == $messageKey ) {
|
278 |
-
$doLog = false;
|
279 |
-
}
|
280 |
-
|
281 |
-
return $doLog;
|
282 |
-
},
|
283 |
-
10,
|
284 |
-
5
|
285 |
-
);
|
286 |
-
|
287 |
-
// Never clear the log (default is 60 days)
|
288 |
-
add_filter( 'simple_history/db_purge_days_interval', '__return_zero' );
|
289 |
-
|
290 |
-
// Clear items that are older than a 7 days (i.e. keep only the most recent 7 days in the log)
|
291 |
-
add_filter(
|
292 |
-
'simple_history/db_purge_days_interval',
|
293 |
-
function ( $days ) {
|
294 |
-
|
295 |
-
$days = 7;
|
296 |
-
|
297 |
-
return $days;
|
298 |
-
}
|
299 |
-
);
|
300 |
-
|
301 |
-
// Don't let anyone - even with the correct secret - view the RSS feed
|
302 |
-
add_filter( 'simple_history/rss_feed_show', '__return_false' );
|
303 |
-
|
304 |
-
// Skip loading of a dropin completely (in this case the RSS dropin)
|
305 |
-
add_filter( 'simple_history/dropin/load_dropin_SimpleHistoryRSSDropin', '__return_false' );
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Example of logging
|
309 |
-
*/
|
310 |
-
|
311 |
-
// This is the easiest and safest way to add messages to the log:
|
312 |
-
apply_filters( 'simple_history_log', 'This is a logged message' );
|
313 |
-
apply_filters(
|
314 |
-
'simple_history_log',
|
315 |
-
'This is a message with some context added',
|
316 |
-
array(
|
317 |
-
'isATestMessage' => 'yup',
|
318 |
-
'debugRequestData' => $_REQUEST,
|
319 |
-
)
|
320 |
-
);
|
321 |
-
apply_filters( 'simple_history_log', 'This is another logged message, with another severity level', null, 'debug' );
|
322 |
-
|
323 |
-
// Below is the function way of adding things to the log
|
324 |
-
// Remember to check that the SimpleLogger function exists before trying to log anything,
|
325 |
-
// or else your site will break if you disable the Simple History plugin
|
326 |
-
// (Use the apply_filters method above if you want to stay safer!)
|
327 |
-
if ( function_exists( 'SimpleLogger' ) ) {
|
328 |
-
SimpleLogger()->info( 'This is a message added to the log' );
|
329 |
-
}
|
330 |
-
|
331 |
-
// Add a message to the history log
|
332 |
-
SimpleLogger()->info( 'This is a message sent to the log' );
|
333 |
-
|
334 |
-
// Add log entries with different severities
|
335 |
-
SimpleLogger()->warning( "User 'Jessie' deleted user 'Kim'" );
|
336 |
-
SimpleLogger()->debug( 'Ok, cron job is running!' );
|
337 |
-
|
338 |
-
// Add a message to the history log
|
339 |
-
// and then add a second log entry with same info and Simple History
|
340 |
-
// will make these two become an "occasionGroup",
|
341 |
-
// i.e. collapsing their entries into one expandable log item
|
342 |
-
SimpleLogger()->info( 'This is a message sent to the log' );
|
343 |
-
SimpleLogger()->info( 'This is a message sent to the log' );
|
344 |
-
|
345 |
-
// Log entries can have placeholders and context
|
346 |
-
// This makes log entried translatable and filterable
|
347 |
-
SimpleLogger()->notice(
|
348 |
-
'User {username} edited page {pagename}',
|
349 |
-
array(
|
350 |
-
'username' => 'jessie',
|
351 |
-
'pagename' => 'My test page',
|
352 |
-
'_initiator' => SimpleLoggerLogInitiators::WP_USER,
|
353 |
-
'_user_id' => 5,
|
354 |
-
'_user_login' => 'jess',
|
355 |
-
'_user_email' => 'jessie@example.com',
|
356 |
-
)
|
357 |
-
);
|
358 |
-
|
359 |
-
// Log entried can have custom occasionsID
|
360 |
-
// This will group items together and a log entry will only be shown once
|
361 |
-
// in the log overview, even if the logged messages are different
|
362 |
-
for ( $i = 0; $i < rand( 1, 50 ); $i++ ) {
|
363 |
-
SimpleLogger()->notice(
|
364 |
-
'User {username} edited page {pagename}',
|
365 |
-
array(
|
366 |
-
'username' => "example_user_{$i}",
|
367 |
-
'pagename' => 'My test page',
|
368 |
-
'_occasionsID' => 'postID:24884,action:edited',
|
369 |
-
)
|
370 |
-
);
|
371 |
-
}
|
372 |
-
|
373 |
-
// Events can have different "initiators",
|
374 |
-
// i.e. who was responsible for the logged event
|
375 |
-
// Initiator "WORDPRESS" means that WordPress did something on it's own
|
376 |
-
SimpleLogger()->info(
|
377 |
-
'WordPress updated itself from version {from_version} to {to_version}',
|
378 |
-
array(
|
379 |
-
'from_version' => '3.8',
|
380 |
-
'to_version' => '3.8.1',
|
381 |
-
'_initiator' => SimpleLoggerLogInitiators::WORDPRESS,
|
382 |
-
)
|
383 |
-
);
|
384 |
-
|
385 |
-
// Initiator "WP_USER" means that a logged in user did someting
|
386 |
-
SimpleLogger()->info(
|
387 |
-
'Updated plugin {plugin_name} from version {plugin_from_version} to version {plugin_to_version}',
|
388 |
-
array(
|
389 |
-
'plugin_name' => 'Ninja Forms',
|
390 |
-
'plugin_from_version' => '1.1',
|
391 |
-
'plugin_to_version' => '1.1.2',
|
392 |
-
'_initiator' => SimpleLoggerLogInitiators::WP_USER,
|
393 |
-
)
|
394 |
-
);
|
395 |
-
|
396 |
-
// // Initiator "WEB_USER" means that an unknown internet user did something
|
397 |
-
SimpleLogger()->warning(
|
398 |
-
"An attempt to login as user 'administrator' failed to login because the wrong password was entered",
|
399 |
-
array(
|
400 |
-
'_initiator' => SimpleLoggerLogInitiators::WEB_USER,
|
401 |
-
)
|
402 |
-
);
|
403 |
-
|
404 |
-
|
405 |
-
// Use the "context array" to add more data to your logged event
|
406 |
-
// Data can be used later on to show detailed info about a log entry
|
407 |
-
// and does not need to be shown on the overview screen
|
408 |
-
SimpleLogger()->info(
|
409 |
-
"Edited product '{pagename}'",
|
410 |
-
array(
|
411 |
-
'pagename' => 'We are hiring!',
|
412 |
-
'_postType' => 'product',
|
413 |
-
'_userID' => 1,
|
414 |
-
'_userLogin' => 'jessie',
|
415 |
-
'_userEmail' => 'jessie@example.com',
|
416 |
-
'_occasionsID' => 'username:1,postID:24885,action:edited',
|
417 |
-
)
|
418 |
-
);
|
419 |
-
|
420 |
-
|
421 |
-
// Test log cron things
|
422 |
-
/*
|
423 |
-
wp_schedule_event( time(), "hourly", "simple_history_cron_testhook");
|
424 |
-
*/
|
425 |
-
/*
|
426 |
-
wp_clear_scheduled_hook("simple_history_cron_testhook");
|
427 |
-
add_action( 'simple_history_cron_testhook', 'simple_history_cron_testhook_function' );
|
428 |
-
function simple_history_cron_testhook_function() {
|
429 |
-
SimpleLogger()->info("This is a message inside a cron function");
|
430 |
-
}
|
431 |
-
*/
|
432 |
-
|
433 |
-
/*
|
434 |
-
add_action("init", function() {
|
435 |
-
|
436 |
-
global $wp_current_filter;
|
437 |
-
|
438 |
-
$doing_cron = get_transient( 'doing_cron' );
|
439 |
-
$const_doing_cron = defined('DOING_CRON') && DOING_CRON;
|
440 |
-
|
441 |
-
if ($const_doing_cron) {
|
442 |
-
|
443 |
-
$current_filter = current_filter();
|
444 |
-
|
445 |
-
SimpleLogger()->info("This is a message inside init, trying to log crons", array(
|
446 |
-
"doing_cron" => simpleHistory::json_encode($doing_cron),
|
447 |
-
"current_filter" => $current_filter,
|
448 |
-
"wp_current_filter" => $wp_current_filter,
|
449 |
-
"wp_current_filter" => simpleHistory::json_encode( $wp_current_filter ),
|
450 |
-
"const_doing_cron" => simpleHistory::json_encode($const_doing_cron)
|
451 |
-
));
|
452 |
-
|
453 |
-
}
|
454 |
-
|
455 |
-
}, 100);
|
456 |
-
*/
|
457 |
-
|
458 |
-
|
459 |
-
/*
|
460 |
-
add_action("init", function() {
|
461 |
-
|
462 |
-
#SimpleLogger()->info("This is a regular info message" . time());
|
463 |
-
|
464 |
-
}, 100);
|
465 |
-
// */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Text Domain: simple-history
|
7 |
* Domain Path: /languages
|
8 |
* Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
9 |
-
* Version: 3.1.
|
10 |
* Author: Pär Thernström
|
11 |
* Author URI: http://simple-history.com/
|
12 |
* License: GPL2
|
@@ -45,7 +45,7 @@ if ( $ok_php_version && $ok_wp_version ) {
|
|
45 |
* @TODO: make activation multi site aware, as in https://github.com/scribu/wp-proper-network-activation
|
46 |
* register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
47 |
*/
|
48 |
-
define( 'SIMPLE_HISTORY_VERSION', '3.1.
|
49 |
define( 'SIMPLE_HISTORY_PATH', plugin_dir_path( __FILE__ ) );
|
50 |
define( 'SIMPLE_HISTORY_BASENAME', plugin_basename( __FILE__ ) );
|
51 |
define( 'SIMPLE_HISTORY_DIR_URL', plugin_dir_url( __FILE__ ) );
|
6 |
* Text Domain: simple-history
|
7 |
* Domain Path: /languages
|
8 |
* Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
9 |
+
* Version: 3.1.1
|
10 |
* Author: Pär Thernström
|
11 |
* Author URI: http://simple-history.com/
|
12 |
* License: GPL2
|
45 |
* @TODO: make activation multi site aware, as in https://github.com/scribu/wp-proper-network-activation
|
46 |
* register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
47 |
*/
|
48 |
+
define( 'SIMPLE_HISTORY_VERSION', '3.1.1' );
|
49 |
define( 'SIMPLE_HISTORY_PATH', plugin_dir_path( __FILE__ ) );
|
50 |
define( 'SIMPLE_HISTORY_BASENAME', plugin_basename( __FILE__ ) );
|
51 |
define( 'SIMPLE_HISTORY_DIR_URL', plugin_dir_url( __FILE__ ) );
|
loggers/SimpleMediaLogger.php
CHANGED
@@ -266,12 +266,11 @@ class SimpleMediaLogger extends SimpleLogger {
|
|
266 |
);
|
267 |
|
268 |
// Add information about possible parent.
|
269 |
-
$
|
270 |
-
$
|
271 |
-
$
|
272 |
-
$attachment_parent_post_type = $attachment_parent ? get_post_type( $attachment_parent ) : null;
|
273 |
|
274 |
-
if ( $
|
275 |
$context = array_merge(
|
276 |
$context,
|
277 |
array(
|
266 |
);
|
267 |
|
268 |
// Add information about possible parent.
|
269 |
+
$attachment_parent_id = wp_get_post_parent_id( $attachment_post );
|
270 |
+
$attachment_parent_title = $attachment_parent_id ? get_the_title( $attachment_parent_id ) : null;
|
271 |
+
$attachment_parent_post_type = $attachment_parent_id ? get_post_type( $attachment_parent_id ) : null;
|
|
|
272 |
|
273 |
+
if ( $attachment_parent_id ) {
|
274 |
$context = array_merge(
|
275 |
$context,
|
276 |
array(
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: history, log, changes, changelog, audit, audit log, event log, user tracki
|
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.8.2
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 3.1.
|
9 |
|
10 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
11 |
|
@@ -193,6 +193,10 @@ Events in the log are stored for 60 days by default. Events older than this will
|
|
193 |
|
194 |
== Changelog ==
|
195 |
|
|
|
|
|
|
|
|
|
196 |
= 3.1.0 (January 2022) =
|
197 |
|
198 |
- Fixed: Use user selected language instead of selected site language when loading languages for JavaScript libraries. ([#232](https://github.com/bonny/WordPress-Simple-History/issues/232))
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.8.2
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 3.1.1
|
9 |
|
10 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
11 |
|
193 |
|
194 |
== Changelog ==
|
195 |
|
196 |
+
= 3.1.1 (January 2022) =
|
197 |
+
|
198 |
+
- Fixed: Error when uploading images when using WordPress 5.7.0 or earlier.
|
199 |
+
|
200 |
= 3.1.0 (January 2022) =
|
201 |
|
202 |
- Fixed: Use user selected language instead of selected site language when loading languages for JavaScript libraries. ([#232](https://github.com/bonny/WordPress-Simple-History/issues/232))
|