Version Description
(December 2014) =
- Fix: no message when restoring page from trash
- Fix: use correct width for media attachment
- Add: filter
simple_history/logrowhtmloutput/classes
, to modify HTML classes added to each log row item
Download this release
Release Info
Developer | eskapism |
Plugin | Simple History |
Version | 2.0.7 |
Comparing to | |
See all releases |
Code changes from version 2.0.5 to 2.0.7
- SimpleHistory.php +42 -89
- examples.php +5 -0
- index.php +2 -2
- loggers/SimpleMediaLogger.php +1 -1
- loggers/SimplePostLogger.php +5 -5
- loggers/SimpleUserLogger.php +99 -23
- readme.txt +33 -1
- templates/settings-statsForGeeks.php +22 -9
SimpleHistory.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
class SimpleHistory {
|
7 |
|
8 |
const NAME = "Simple History";
|
9 |
-
const VERSION = "2.0.
|
10 |
|
11 |
/**
|
12 |
* Capability required to view the history log
|
@@ -596,11 +596,29 @@ class SimpleHistory {
|
|
596 |
|
597 |
$arrDropinsToInstantiate = array();
|
598 |
|
599 |
-
foreach ( $dropinsFiles as $oneDropinFile) {
|
600 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
include_once($oneDropinFile);
|
602 |
|
603 |
-
$arrDropinsToInstantiate[] =
|
604 |
|
605 |
}
|
606 |
|
@@ -1312,86 +1330,6 @@ class SimpleHistory {
|
|
1312 |
|
1313 |
}
|
1314 |
|
1315 |
-
/**
|
1316 |
-
* Get history from ajax
|
1317 |
-
*/
|
1318 |
-
/*
|
1319 |
-
function ajax() {
|
1320 |
-
|
1321 |
-
global $simple_history;
|
1322 |
-
|
1323 |
-
$type = isset($_POST["type"]) ? $_POST["type"] : "";
|
1324 |
-
$subtype = isset($_POST["subtype"]) ? $_POST["subtype"] : "";
|
1325 |
-
|
1326 |
-
// We get users by username, so get username from id
|
1327 |
-
$user_id = (int) $_POST["user_id"];
|
1328 |
-
if (empty($user_id)) {
|
1329 |
-
$user = "";
|
1330 |
-
} else {
|
1331 |
-
$user_obj = new WP_User($user_id);
|
1332 |
-
if ( ! $user_obj->exists() ) exit;
|
1333 |
-
$user = $user_obj->user_login;
|
1334 |
-
};
|
1335 |
-
|
1336 |
-
// page to show. 1 = first page.
|
1337 |
-
$page = 0;
|
1338 |
-
if (isset($_POST["page"])) {
|
1339 |
-
$page = (int) $_POST["page"];
|
1340 |
-
}
|
1341 |
-
|
1342 |
-
// number of items to get
|
1343 |
-
$items = (int) (isset($_POST["items"])) ? $_POST["items"] : $simple_history->get_pager_size();
|
1344 |
-
|
1345 |
-
// number of prev added items = number of items to skip before starting to add $items num of new items
|
1346 |
-
$num_added = (int) (isset($_POST["num_added"])) ? $_POST["num_added"] : $simple_history->get_pager_size();
|
1347 |
-
|
1348 |
-
$search = (isset($_POST["search"])) ? $_POST["search"] : "";
|
1349 |
-
|
1350 |
-
$filter_type = $type . "/" . $subtype;
|
1351 |
-
|
1352 |
-
$args = array(
|
1353 |
-
"is_ajax" => true,
|
1354 |
-
"filter_type" => $filter_type,
|
1355 |
-
"filter_user" => $user,
|
1356 |
-
"page" => $page,
|
1357 |
-
"items" => $items,
|
1358 |
-
"num_added" => $num_added,
|
1359 |
-
"search" => $search
|
1360 |
-
);
|
1361 |
-
|
1362 |
-
$arr_json = array(
|
1363 |
-
"status" => "ok",
|
1364 |
-
"error" => "",
|
1365 |
-
"items_li" => "",
|
1366 |
-
"filtered_items_total_count" => 0,
|
1367 |
-
"filtered_items_total_count_string" => "",
|
1368 |
-
"filtered_items_total_pages" => 0
|
1369 |
-
);
|
1370 |
-
|
1371 |
-
// ob_start();
|
1372 |
-
$return = simple_history_print_history($args);
|
1373 |
-
// $return = ob_get_clean();
|
1374 |
-
if ("noMoreItems" == $return) {
|
1375 |
-
$arr_json["status"] = "error";
|
1376 |
-
$arr_json["error"] = "noMoreItems";
|
1377 |
-
} else {
|
1378 |
-
$arr_json["items_li"] = $return;
|
1379 |
-
// total number of event. really bad way since we get them all again. need to fix this :/
|
1380 |
-
$args["items"] = "all";
|
1381 |
-
$all_items = simple_history_get_items_array($args);
|
1382 |
-
$arr_json["filtered_items_total_count"] = sizeof($all_items);
|
1383 |
-
$arr_json["filtered_items_total_count_string"] = sprintf(_n('One item', '%1$d items', sizeof($all_items), "simple-history"), sizeof($all_items));
|
1384 |
-
$arr_json["filtered_items_total_pages"] = ceil($arr_json["filtered_items_total_count"] / $simple_history->get_pager_size());
|
1385 |
-
}
|
1386 |
-
|
1387 |
-
header("Content-type: application/json");
|
1388 |
-
echo json_encode($arr_json);
|
1389 |
-
|
1390 |
-
exit;
|
1391 |
-
|
1392 |
-
}
|
1393 |
-
*/
|
1394 |
-
|
1395 |
/**
|
1396 |
* Get setting if plugin should be visible on dasboard.
|
1397 |
* Defaults to true
|
@@ -1791,9 +1729,15 @@ class SimpleHistory {
|
|
1791 |
|
1792 |
}
|
1793 |
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1797 |
}
|
1798 |
|
1799 |
/*$level_html = sprintf(
|
@@ -1809,10 +1753,19 @@ class SimpleHistory {
|
|
1809 |
|
1810 |
$plain_text_html .= $log_level_tag_html;
|
1811 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1812 |
// Generate the HTML output for a row
|
1813 |
$output = sprintf(
|
1814 |
'
|
1815 |
-
<li %8$s class="
|
1816 |
<div class="SimpleHistoryLogitem__firstcol">
|
1817 |
<div class="SimpleHistoryLogitem__senderImage">%3$s</div>
|
1818 |
</div>
|
@@ -1834,7 +1787,7 @@ class SimpleHistory {
|
|
1834 |
$oneLogRow->logger, // 7
|
1835 |
$data_attrs, // 8 data attributes
|
1836 |
$more_details_html, // 9
|
1837 |
-
$
|
1838 |
);
|
1839 |
|
1840 |
// Get the main message row.
|
6 |
class SimpleHistory {
|
7 |
|
8 |
const NAME = "Simple History";
|
9 |
+
const VERSION = "2.0.7";
|
10 |
|
11 |
/**
|
12 |
* Capability required to view the history log
|
596 |
|
597 |
$arrDropinsToInstantiate = array();
|
598 |
|
599 |
+
foreach ( $dropinsFiles as $oneDropinFile ) {
|
600 |
+
|
601 |
+
// path/path/simplehistory/dropins/SimpleHistoryDonateDropin.php => SimpleHistoryDonateDropin
|
602 |
+
$oneDropinFileBasename = basename($oneDropinFile, ".php");
|
603 |
+
|
604 |
+
/**
|
605 |
+
* Filter to completely skip loading of dropin
|
606 |
+
* complete filer name will be like:
|
607 |
+
* simple_history/dropin/load_dropin_SimpleHistoryRSSDropin
|
608 |
+
*
|
609 |
+
* @since 2.0.6
|
610 |
+
*
|
611 |
+
* @param bool if to load the dropin. return false to not load it.
|
612 |
+
*/
|
613 |
+
$load_dropin = apply_filters( "simple_history/dropin/load_dropin_{$oneDropinFileBasename}", true );
|
614 |
+
|
615 |
+
if ( ! $load_dropin ) {
|
616 |
+
continue;
|
617 |
+
}
|
618 |
+
|
619 |
include_once($oneDropinFile);
|
620 |
|
621 |
+
$arrDropinsToInstantiate[] = $oneDropinFileBasename;
|
622 |
|
623 |
}
|
624 |
|
1330 |
|
1331 |
}
|
1332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1333 |
/**
|
1334 |
* Get setting if plugin should be visible on dasboard.
|
1335 |
* Defaults to true
|
1729 |
|
1730 |
}
|
1731 |
|
1732 |
+
// Classes to add to log item li element
|
1733 |
+
$classes = array(
|
1734 |
+
"SimpleHistoryLogitem",
|
1735 |
+
"SimpleHistoryLogitem--loglevel-{$oneLogRow->level}",
|
1736 |
+
"SimpleHistoryLogitem--logger-{$oneLogRow->logger}"
|
1737 |
+
);
|
1738 |
+
|
1739 |
+
if ( isset( $oneLogRow->initiator ) && ! empty( $oneLogRow->initiator ) ) {
|
1740 |
+
$classes[] = "SimpleHistoryLogitem--initiator-" . esc_attr($oneLogRow->initiator);
|
1741 |
}
|
1742 |
|
1743 |
/*$level_html = sprintf(
|
1753 |
|
1754 |
$plain_text_html .= $log_level_tag_html;
|
1755 |
|
1756 |
+
/**
|
1757 |
+
* Filter to modify classes added to item li element
|
1758 |
+
*
|
1759 |
+
* @since 2.0.7
|
1760 |
+
*
|
1761 |
+
* @param $classes Array with classes
|
1762 |
+
*/
|
1763 |
+
$classes = apply_filters("simple_history/logrowhtmloutput/classes", $classes);
|
1764 |
+
|
1765 |
// Generate the HTML output for a row
|
1766 |
$output = sprintf(
|
1767 |
'
|
1768 |
+
<li %8$s class="%10$s">
|
1769 |
<div class="SimpleHistoryLogitem__firstcol">
|
1770 |
<div class="SimpleHistoryLogitem__senderImage">%3$s</div>
|
1771 |
</div>
|
1787 |
$oneLogRow->logger, // 7
|
1788 |
$data_attrs, // 8 data attributes
|
1789 |
$more_details_html, // 9
|
1790 |
+
join(" ", $classes) // 10
|
1791 |
);
|
1792 |
|
1793 |
// Get the main message row.
|
examples.php
CHANGED
@@ -10,6 +10,11 @@ exit;
|
|
10 |
// Never clear the log (default is 60 days)
|
11 |
add_filter("simple_history/db_purge_days_interval", "__return_zero");
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Example of logging
|
10 |
// Never clear the log (default is 60 days)
|
11 |
add_filter("simple_history/db_purge_days_interval", "__return_zero");
|
12 |
|
13 |
+
// Don't let anyone - even with the correct secret - view the RSS feed
|
14 |
+
add_filter("simple_history/rss_feed_show", "__return_false");
|
15 |
+
|
16 |
+
// Skip loading of a dropin completely (in this case the RSS dropin)
|
17 |
+
add_filter("simple_history/dropin/load_dropin_SimpleHistoryRSSDropin", "__return_false");
|
18 |
|
19 |
/**
|
20 |
* Example of logging
|
index.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Simple History
|
4 |
Plugin URI: http://simple-history.com
|
5 |
Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
6 |
-
Version: 2.0.
|
7 |
Author: Pär Thernström
|
8 |
Author URI: http://simple-history.com/
|
9 |
License: GPL2
|
@@ -25,7 +25,6 @@ License: GPL2
|
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
-
|
29 |
if ( version_compare( phpversion(), "5.3", ">=") ) {
|
30 |
|
31 |
/** Load required files */
|
@@ -59,6 +58,7 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
|
|
59 |
?></p>
|
60 |
</div>
|
61 |
<?php
|
|
|
62 |
}
|
63 |
|
64 |
}
|
3 |
Plugin Name: Simple History
|
4 |
Plugin URI: http://simple-history.com
|
5 |
Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
6 |
+
Version: 2.0.7
|
7 |
Author: Pär Thernström
|
8 |
Author URI: http://simple-history.com/
|
9 |
License: GPL2
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
|
|
28 |
if ( version_compare( phpversion(), "5.3", ">=") ) {
|
29 |
|
30 |
/** Load required files */
|
58 |
?></p>
|
59 |
</div>
|
60 |
<?php
|
61 |
+
|
62 |
}
|
63 |
|
64 |
}
|
loggers/SimpleMediaLogger.php
CHANGED
@@ -146,7 +146,7 @@ class SimpleMediaLogger extends SimpleLogger
|
|
146 |
if ( $full_image_width && $full_image_height ) {
|
147 |
|
148 |
$context["full_image_width"] = $full_image_width;
|
149 |
-
$context["full_image_height"] = $
|
150 |
$context["attachment_thumb"] = sprintf('<div class="SimpleHistoryLogitemThumbnail"><img src="%1$s"></div>', $thumb_src[0] );
|
151 |
|
152 |
}
|
146 |
if ( $full_image_width && $full_image_height ) {
|
147 |
|
148 |
$context["full_image_width"] = $full_image_width;
|
149 |
+
$context["full_image_height"] = $full_image_height;
|
150 |
$context["attachment_thumb"] = sprintf('<div class="SimpleHistoryLogitemThumbnail"><img src="%1$s"></div>', $thumb_src[0] );
|
151 |
|
152 |
}
|
loggers/SimplePostLogger.php
CHANGED
@@ -75,14 +75,14 @@ class SimplePostLogger extends SimpleLogger
|
|
75 |
*/
|
76 |
function on_untrash_post($post_id) {
|
77 |
|
78 |
-
$post = get_post($post_id);
|
79 |
|
80 |
-
$this->
|
81 |
-
|
82 |
array(
|
83 |
"post_id" => $post_id,
|
84 |
-
"post_type" => get_post_type($post),
|
85 |
-
"post_title" => get_the_title($post)
|
86 |
)
|
87 |
);
|
88 |
|
75 |
*/
|
76 |
function on_untrash_post($post_id) {
|
77 |
|
78 |
+
$post = get_post( $post_id );
|
79 |
|
80 |
+
$this->infoMessage(
|
81 |
+
"post_restored",
|
82 |
array(
|
83 |
"post_id" => $post_id,
|
84 |
+
"post_type" => get_post_type( $post ),
|
85 |
+
"post_title" => get_the_title( $post )
|
86 |
)
|
87 |
);
|
88 |
|
loggers/SimpleUserLogger.php
CHANGED
@@ -10,16 +10,16 @@ class SimpleUserLogger extends SimpleLogger
|
|
10 |
|
11 |
/**
|
12 |
* Get array with information about this logger
|
13 |
-
*
|
14 |
* @return array
|
15 |
*/
|
16 |
function getInfo() {
|
17 |
|
18 |
-
$arr_info = array(
|
19 |
"name" => "User Logger",
|
20 |
"description" => "Logs user logins, logouts, and failed logins",
|
21 |
"capability" => "edit_users",
|
22 |
-
"messages" => array(
|
23 |
'user_login_failed' => __('Failed to login to account with username "{login_user_login}" because an incorrect password was entered', "simple-history"),
|
24 |
'user_unknown_login_failed' => __('Failed to login with username "{failed_login_username}" because no user with that username exist', "simple-history"),
|
25 |
'user_logged_in' => __('Logged in', "simple-history"),
|
@@ -28,6 +28,26 @@ class SimpleUserLogger extends SimpleLogger
|
|
28 |
'user_updated_profile' => __("Edited the profile for user {edited_user_login} ({edited_user_email})", "simple-history"),
|
29 |
'user_created' => __("Created user {created_user_login} ({created_user_email}) with role {created_user_role}", "simple-history"),
|
30 |
'user_deleted' => __("Deleted user {deleted_user_login} ({deleted_user_email})", "simple-history"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
),
|
32 |
|
33 |
"labels" => array(
|
@@ -55,7 +75,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
55 |
_x('User deletions', 'User logger: search', 'simple-history') => array(
|
56 |
"user_deleted"
|
57 |
)
|
58 |
-
|
59 |
)
|
60 |
) // end search
|
61 |
|
@@ -86,11 +106,67 @@ class SimpleUserLogger extends SimpleLogger
|
|
86 |
add_action("profile_update", array($this, "on_profile_update"), 10, 2);
|
87 |
|
88 |
// User is created
|
89 |
-
add_action("user_register", array($this, "on_user_register"), 10, 2);
|
90 |
|
91 |
-
//
|
92 |
add_action( 'delete_user', array($this, "on_delete_user"), 10, 2 );
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
/**
|
@@ -120,7 +196,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
120 |
);
|
121 |
|
122 |
// Let's log this as a little bit more significant that just "message"
|
123 |
-
$this->noticeMessage("user_deleted", $context);
|
124 |
|
125 |
}
|
126 |
|
@@ -130,7 +206,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
130 |
public function getLogRowPlainTextOutput($row) {
|
131 |
|
132 |
$context = $row->context;
|
133 |
-
|
134 |
$output = parent::getLogRowPlainTextOutput($row);
|
135 |
$current_user_id = get_current_user_id();
|
136 |
|
@@ -148,7 +224,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
148 |
|
149 |
// User still exist, so link to their profile
|
150 |
if ( $current_user_id === $context["_user_id"] ) {
|
151 |
-
|
152 |
// User that is viewing the log is the same as the edited user
|
153 |
$msg = __('Edited <a href="{edit_profile_link}">your profile</a>', "simple-history");
|
154 |
|
@@ -157,7 +233,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
157 |
$msg = __('Edited <a href="{edit_profile_link}">their profile</a>', "simple-history");
|
158 |
|
159 |
}
|
160 |
-
|
161 |
$output = $this->interpolate($msg, $context);
|
162 |
|
163 |
} else {
|
@@ -186,7 +262,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
186 |
}
|
187 |
|
188 |
} // if user_updated_profile
|
189 |
-
|
190 |
return $output;
|
191 |
}
|
192 |
|
@@ -201,7 +277,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
201 |
|
202 |
// Only log failed attempts
|
203 |
if ( ! wp_check_password($password, $user->user_pass, $user->ID) ) {
|
204 |
-
|
205 |
// Overwrite some vars that Simple History set automagically
|
206 |
$context = array(
|
207 |
"_initiator" => SimpleLoggerLogInitiators::WEB_USER,
|
@@ -229,7 +305,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
229 |
$context["login_user_password"] = $password;
|
230 |
}
|
231 |
|
232 |
-
$this->warningMessage("user_login_failed", $context);
|
233 |
|
234 |
}
|
235 |
|
@@ -263,12 +339,12 @@ class SimpleUserLogger extends SimpleLogger
|
|
263 |
$context["_user_email"] = $user->user_email;
|
264 |
$context["server_http_user_agent"] = $_SERVER["HTTP_USER_AGENT"];
|
265 |
|
266 |
-
$this->infoMessage("user_logged_in", $context);
|
267 |
|
268 |
} else {
|
269 |
|
270 |
// when does this happen?
|
271 |
-
$this->warningMessage("user_unknown_logged_in", $context );
|
272 |
|
273 |
|
274 |
}
|
@@ -289,7 +365,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
289 |
* User is edited
|
290 |
*/
|
291 |
function on_profile_update($user_id) {
|
292 |
-
|
293 |
if ( ! $user_id || ! is_numeric($user_id))
|
294 |
return;
|
295 |
|
@@ -302,7 +378,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
302 |
"server_http_user_agent" => $_SERVER["HTTP_USER_AGENT"],
|
303 |
);
|
304 |
|
305 |
-
$this->infoMessage("user_updated_profile", $context);
|
306 |
|
307 |
}
|
308 |
|
@@ -310,7 +386,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
310 |
* User is created
|
311 |
*/
|
312 |
function on_user_register($user_id) {
|
313 |
-
|
314 |
if ( ! $user_id || ! is_numeric($user_id))
|
315 |
return;
|
316 |
|
@@ -330,7 +406,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
330 |
"server_http_user_agent" => $_SERVER["HTTP_USER_AGENT"],
|
331 |
);
|
332 |
|
333 |
-
$this->infoMessage("user_created", $context);
|
334 |
|
335 |
}
|
336 |
|
@@ -343,18 +419,18 @@ class SimpleUserLogger extends SimpleLogger
|
|
343 |
if ( ! trim($username)) {
|
344 |
return $user;
|
345 |
}
|
346 |
-
|
347 |
// If username is not a user in the system then this
|
348 |
// is consideraded a failed login attempt
|
349 |
$wp_user = get_user_by( "login", $username );
|
350 |
-
|
351 |
if (false === $wp_user) {
|
352 |
|
353 |
$context = array(
|
354 |
"_initiator" => SimpleLoggerLogInitiators::WEB_USER,
|
355 |
"failed_login_username" => $username,
|
356 |
"server_http_user_agent" => $_SERVER["HTTP_USER_AGENT"],
|
357 |
-
// count all failed logins to unknown users as the same occasions,
|
358 |
// to prevent log being flooded with login/hack attempts
|
359 |
"_occasionsID" => __CLASS__ . '/' . __FUNCTION__
|
360 |
);
|
@@ -373,7 +449,7 @@ class SimpleUserLogger extends SimpleLogger
|
|
373 |
$context["failed_login_password"] = $password;
|
374 |
}
|
375 |
|
376 |
-
$this->warningMessage("user_unknown_login_failed", $context);
|
377 |
|
378 |
}
|
379 |
|
10 |
|
11 |
/**
|
12 |
* Get array with information about this logger
|
13 |
+
*
|
14 |
* @return array
|
15 |
*/
|
16 |
function getInfo() {
|
17 |
|
18 |
+
$arr_info = array(
|
19 |
"name" => "User Logger",
|
20 |
"description" => "Logs user logins, logouts, and failed logins",
|
21 |
"capability" => "edit_users",
|
22 |
+
"messages" => array(
|
23 |
'user_login_failed' => __('Failed to login to account with username "{login_user_login}" because an incorrect password was entered', "simple-history"),
|
24 |
'user_unknown_login_failed' => __('Failed to login with username "{failed_login_username}" because no user with that username exist', "simple-history"),
|
25 |
'user_logged_in' => __('Logged in', "simple-history"),
|
28 |
'user_updated_profile' => __("Edited the profile for user {edited_user_login} ({edited_user_email})", "simple-history"),
|
29 |
'user_created' => __("Created user {created_user_login} ({created_user_email}) with role {created_user_role}", "simple-history"),
|
30 |
'user_deleted' => __("Deleted user {deleted_user_login} ({deleted_user_email})", "simple-history"),
|
31 |
+
|
32 |
+
/*
|
33 |
+
Text used in admin:
|
34 |
+
Log Out of All Other Sessions
|
35 |
+
Left your account logged in at a public computer? Lost your phone? This will log you out everywhere except your current browser
|
36 |
+
*/
|
37 |
+
'user_session_destroy_others' => _x(
|
38 |
+
'Logged out from all other sessions',
|
39 |
+
'User destroys other login sessions for themself',
|
40 |
+
'simple-history'
|
41 |
+
),
|
42 |
+
/*
|
43 |
+
Text used in admin:
|
44 |
+
'Log %s out of all sessions' ), $profileuser->display_name );
|
45 |
+
*/
|
46 |
+
'user_session_destroy_everywhere' => _x(
|
47 |
+
'Logged out "{user_display_name}" from all sessions',
|
48 |
+
'User destroys all login sessions for a user',
|
49 |
+
'simple-history'
|
50 |
+
),
|
51 |
),
|
52 |
|
53 |
"labels" => array(
|
75 |
_x('User deletions', 'User logger: search', 'simple-history') => array(
|
76 |
"user_deleted"
|
77 |
)
|
78 |
+
|
79 |
)
|
80 |
) // end search
|
81 |
|
106 |
add_action("profile_update", array($this, "on_profile_update"), 10, 2);
|
107 |
|
108 |
// User is created
|
109 |
+
add_action("user_register", array($this, "on_user_register"), 10, 2);
|
110 |
|
111 |
+
// User is deleted
|
112 |
add_action( 'delete_user', array($this, "on_delete_user"), 10, 2 );
|
113 |
|
114 |
+
// User sessions is destroyed. AJAX call that we hook onto early.
|
115 |
+
add_action("wp_ajax_destroy-sessions", array($this, "on_destroy_user_session"), 0);
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Called when user dessions are destroyed from admin
|
122 |
+
* Can be called for current logged in user = destroy all other sessions
|
123 |
+
* or for another user = destroy alla sessions for that user
|
124 |
+
* Fires from AJAX call
|
125 |
+
*
|
126 |
+
* @since 2.0.6
|
127 |
+
*/
|
128 |
+
function on_destroy_user_session() {
|
129 |
+
|
130 |
+
/*
|
131 |
+
Post params:
|
132 |
+
nonce: a14df12195
|
133 |
+
user_id: 1
|
134 |
+
action: destroy-sessions
|
135 |
+
*/
|
136 |
+
|
137 |
+
$user = get_userdata( (int) $_POST['user_id'] );
|
138 |
+
|
139 |
+
if ( $user ) {
|
140 |
+
if ( ! current_user_can( 'edit_user', $user->ID ) ) {
|
141 |
+
$user = false;
|
142 |
+
} elseif ( ! wp_verify_nonce( $_POST['nonce'], 'update-user_' . $user->ID ) ) {
|
143 |
+
$user = false;
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( ! $user ) {
|
148 |
+
// Could not log out user sessions. Please try again.
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
$sessions = WP_Session_Tokens::get_instance( $user->ID );
|
153 |
+
|
154 |
+
$context = array();
|
155 |
+
|
156 |
+
if ( $user->ID === get_current_user_id() ) {
|
157 |
+
|
158 |
+
$this->infoMessage("user_session_destroy_others");
|
159 |
+
|
160 |
+
} else {
|
161 |
+
|
162 |
+
$context["user_id"] = $user->ID;
|
163 |
+
$context["user_login"] = $user->user_login;
|
164 |
+
$context["user_display_name"] = $user->display_name;
|
165 |
+
|
166 |
+
$this->infoMessage("user_session_destroy_everywhere", $context);
|
167 |
+
|
168 |
+
}
|
169 |
+
|
170 |
}
|
171 |
|
172 |
/**
|
196 |
);
|
197 |
|
198 |
// Let's log this as a little bit more significant that just "message"
|
199 |
+
$this->noticeMessage("user_deleted", $context);
|
200 |
|
201 |
}
|
202 |
|
206 |
public function getLogRowPlainTextOutput($row) {
|
207 |
|
208 |
$context = $row->context;
|
209 |
+
|
210 |
$output = parent::getLogRowPlainTextOutput($row);
|
211 |
$current_user_id = get_current_user_id();
|
212 |
|
224 |
|
225 |
// User still exist, so link to their profile
|
226 |
if ( $current_user_id === $context["_user_id"] ) {
|
227 |
+
|
228 |
// User that is viewing the log is the same as the edited user
|
229 |
$msg = __('Edited <a href="{edit_profile_link}">your profile</a>', "simple-history");
|
230 |
|
233 |
$msg = __('Edited <a href="{edit_profile_link}">their profile</a>', "simple-history");
|
234 |
|
235 |
}
|
236 |
+
|
237 |
$output = $this->interpolate($msg, $context);
|
238 |
|
239 |
} else {
|
262 |
}
|
263 |
|
264 |
} // if user_updated_profile
|
265 |
+
|
266 |
return $output;
|
267 |
}
|
268 |
|
277 |
|
278 |
// Only log failed attempts
|
279 |
if ( ! wp_check_password($password, $user->user_pass, $user->ID) ) {
|
280 |
+
|
281 |
// Overwrite some vars that Simple History set automagically
|
282 |
$context = array(
|
283 |
"_initiator" => SimpleLoggerLogInitiators::WEB_USER,
|
305 |
$context["login_user_password"] = $password;
|
306 |
}
|
307 |
|
308 |
+
$this->warningMessage("user_login_failed", $context);
|
309 |
|
310 |
}
|
311 |
|
339 |
$context["_user_email"] = $user->user_email;
|
340 |
$context["server_http_user_agent"] = $_SERVER["HTTP_USER_AGENT"];
|
341 |
|
342 |
+
$this->infoMessage("user_logged_in", $context);
|
343 |
|
344 |
} else {
|
345 |
|
346 |
// when does this happen?
|
347 |
+
$this->warningMessage("user_unknown_logged_in", $context );
|
348 |
|
349 |
|
350 |
}
|
365 |
* User is edited
|
366 |
*/
|
367 |
function on_profile_update($user_id) {
|
368 |
+
|
369 |
if ( ! $user_id || ! is_numeric($user_id))
|
370 |
return;
|
371 |
|
378 |
"server_http_user_agent" => $_SERVER["HTTP_USER_AGENT"],
|
379 |
);
|
380 |
|
381 |
+
$this->infoMessage("user_updated_profile", $context);
|
382 |
|
383 |
}
|
384 |
|
386 |
* User is created
|
387 |
*/
|
388 |
function on_user_register($user_id) {
|
389 |
+
|
390 |
if ( ! $user_id || ! is_numeric($user_id))
|
391 |
return;
|
392 |
|
406 |
"server_http_user_agent" => $_SERVER["HTTP_USER_AGENT"],
|
407 |
);
|
408 |
|
409 |
+
$this->infoMessage("user_created", $context);
|
410 |
|
411 |
}
|
412 |
|
419 |
if ( ! trim($username)) {
|
420 |
return $user;
|
421 |
}
|
422 |
+
|
423 |
// If username is not a user in the system then this
|
424 |
// is consideraded a failed login attempt
|
425 |
$wp_user = get_user_by( "login", $username );
|
426 |
+
|
427 |
if (false === $wp_user) {
|
428 |
|
429 |
$context = array(
|
430 |
"_initiator" => SimpleLoggerLogInitiators::WEB_USER,
|
431 |
"failed_login_username" => $username,
|
432 |
"server_http_user_agent" => $_SERVER["HTTP_USER_AGENT"],
|
433 |
+
// count all failed logins to unknown users as the same occasions,
|
434 |
// to prevent log being flooded with login/hack attempts
|
435 |
"_occasionsID" => __CLASS__ . '/' . __FUNCTION__
|
436 |
);
|
449 |
$context["failed_login_password"] = $password;
|
450 |
}
|
451 |
|
452 |
+
$this->warningMessage("user_unknown_login_failed", $context);
|
453 |
|
454 |
}
|
455 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://eskapism.se/sida/donate/
|
|
4 |
Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin, syslog, feed, activity, stream
|
5 |
Requires at least: 3.6.0
|
6 |
Tested up to: 4.1
|
7 |
-
Stable tag: 2.0.
|
8 |
|
9 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
10 |
|
@@ -104,6 +104,19 @@ initiated by a specific user.
|
|
104 |
|
105 |
== Changelog ==
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
= 2.0.5 (November 2014) =
|
108 |
|
109 |
- Fix undefined variable in plugin logger. Fixes https://wordpress.org/support/topic/simple-history-201-is-not-working?replies=8#post-6343684.
|
@@ -143,6 +156,25 @@ I've spend hundreds of hours making this update, so if you use it and like it pl
|
|
143 |
- Users see different logs depending on their capability, for example an administrator will see what plugins have been installed, but an editor will not see any plugin related logs
|
144 |
- Much much more.
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
= 1.3.6 =
|
147 |
- Added Polish translation
|
148 |
- Added correct XML encoding and header
|
4 |
Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin, syslog, feed, activity, stream
|
5 |
Requires at least: 3.6.0
|
6 |
Tested up to: 4.1
|
7 |
+
Stable tag: 2.0.7
|
8 |
|
9 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
10 |
|
104 |
|
105 |
== Changelog ==
|
106 |
|
107 |
+
= 2.0.7 (December 2014) =
|
108 |
+
|
109 |
+
- Fix: no message when restoring page from trash
|
110 |
+
- Fix: use correct width for media attachment
|
111 |
+
- Add: filter `simple_history/logrowhtmloutput/classes`, to modify HTML classes added to each log row item
|
112 |
+
|
113 |
+
= 2.0.6 (November 2014) =
|
114 |
+
|
115 |
+
- Added: [WordPress 4.1 added the feature to log out a user from all their sessions](http://codex.wordpress.org/Version_4.1#Users). Simple History now logs when a user is logged out from all their sessions except the current browser, or if an admin destroys all sessions for a user. [View screenshot of new session logout log item](https://dl.dropboxusercontent.com/s/k4cmfmncekmfiib/2014-12-simple-history-changelog-user-sessions.png)
|
116 |
+
|
117 |
+
- Added: filter to shortcut loading of a dropin. Example that completely skips loading the RSS-feed-dropin:
|
118 |
+
`add_filter("simple_history/dropin/load_dropin_SimpleHistoryRSSDropin", "__return_false");`
|
119 |
+
|
120 |
= 2.0.5 (November 2014) =
|
121 |
|
122 |
- Fix undefined variable in plugin logger. Fixes https://wordpress.org/support/topic/simple-history-201-is-not-working?replies=8#post-6343684.
|
156 |
- Users see different logs depending on their capability, for example an administrator will see what plugins have been installed, but an editor will not see any plugin related logs
|
157 |
- Much much more.
|
158 |
|
159 |
+
= 1.3.11 =
|
160 |
+
- Don't use deprecated function get_commentdata(). Fixes https://wordpress.org/support/topic/get_commentdata-function-is-deprecated.
|
161 |
+
- Don't use mysql_query() directly. Fixes https://wordpress.org/support/topic/deprecated-mysql-warning.
|
162 |
+
- Beta testers wanted! I'm working on the next version of Simple History and now I need some beta testers. If you want to try out the shiny new and cool version please download the [v2 branch](https://github.com/bonny/WordPress-Simple-History/tree/v2) over at GitHub. Thanks!
|
163 |
+
|
164 |
+
= 1.3.10 =
|
165 |
+
- Fix: correct usage of "its"
|
166 |
+
- Fix: removed serif font in log. Fixes https://wordpress.org/support/topic/two-irritations-and-pleas-for-change.
|
167 |
+
|
168 |
+
= 1.3.9 =
|
169 |
+
- Fixed strict standards warning
|
170 |
+
- Tested on WordPress 4.0
|
171 |
+
|
172 |
+
= 1.3.8 =
|
173 |
+
- Added filter for rss feed: `simple_history/rss_feed_show`. Fixes more things in this thread: http://wordpress.org/support/topic/more-rss-feed-items.
|
174 |
+
|
175 |
+
= 1.3.7 =
|
176 |
+
- Added filter for rss feed: `simple_history/rss_feed_args`. Fixes http://wordpress.org/support/topic/more-rss-feed-items.
|
177 |
+
|
178 |
= 1.3.6 =
|
179 |
- Added Polish translation
|
180 |
- Added correct XML encoding and header
|
templates/settings-statsForGeeks.php
CHANGED
@@ -100,9 +100,9 @@ echo "<p class='hide-if-no-js'><button class='button js-SimpleHistoryShowsStatsF
|
|
100 |
echo "
|
101 |
<thead>
|
102 |
<tr>
|
103 |
-
<th>Slug</th>
|
104 |
-
<th>Name</th>
|
105 |
<th>Description</th>
|
|
|
106 |
<th>Capability</th>
|
107 |
<th>Rows count</th>
|
108 |
</tr>
|
@@ -143,23 +143,36 @@ echo "<p class='hide-if-no-js'><button class='button js-SimpleHistoryShowsStatsF
|
|
143 |
}
|
144 |
|
145 |
$logger_info = $logger->getInfo();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
printf(
|
148 |
'
|
149 |
<tr class="%6$s">
|
150 |
-
<td
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
<td>%
|
|
|
|
|
|
|
155 |
</tr>
|
156 |
',
|
157 |
$one_logger_count->count,
|
158 |
$one_logger_slug,
|
159 |
esc_html( $logger_info["name"]),
|
160 |
-
esc_html( $logger_info["description"]),
|
161 |
esc_html( $logger_info["capability"]),
|
162 |
-
$loopnum % 2 ? " alt " : "" // 6
|
|
|
163 |
);
|
164 |
|
165 |
$loopnum++;
|
100 |
echo "
|
101 |
<thead>
|
102 |
<tr>
|
103 |
+
<th>Name + Slug</th>
|
|
|
104 |
<th>Description</th>
|
105 |
+
<th>Messages</th>
|
106 |
<th>Capability</th>
|
107 |
<th>Rows count</th>
|
108 |
</tr>
|
143 |
}
|
144 |
|
145 |
$logger_info = $logger->getInfo();
|
146 |
+
$logger_messages = $logger_info["messages"];
|
147 |
+
|
148 |
+
$html_logger_messages = "";
|
149 |
+
foreach ($logger_messages as $message_key => $message) {
|
150 |
+
$html_logger_messages .= sprintf('<li>%1$s</li>', esc_html($message));
|
151 |
+
}
|
152 |
+
if ($html_logger_messages) {
|
153 |
+
$html_logger_messages = "<ul>{$html_logger_messages}</ul>";
|
154 |
+
}
|
155 |
|
156 |
printf(
|
157 |
'
|
158 |
<tr class="%6$s">
|
159 |
+
<td>
|
160 |
+
<p><strong>%3$s</strong>
|
161 |
+
<br><code>%2$s</code></p>
|
162 |
+
</td>
|
163 |
+
<td><p>%4$s</p></td>
|
164 |
+
<td>%7$s</td>
|
165 |
+
<td><p>%5$s</p></td>
|
166 |
+
<td><p>%1$s</p></td>
|
167 |
</tr>
|
168 |
',
|
169 |
$one_logger_count->count,
|
170 |
$one_logger_slug,
|
171 |
esc_html( $logger_info["name"]),
|
172 |
+
esc_html( $logger_info["description"]), // 4
|
173 |
esc_html( $logger_info["capability"]),
|
174 |
+
$loopnum % 2 ? " alt " : "", // 6
|
175 |
+
$html_logger_messages // 7
|
176 |
);
|
177 |
|
178 |
$loopnum++;
|