Version Description
(September 2015) =
- Fixed: Missed to log users switching back on using the User Switching plugin. Fixes https://github.com/bonny/WordPress-Simple-History/issues/89.
Download this release
Release Info
Developer | eskapism |
Plugin | Simple History |
Version | 2.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.2.1
- index.php +2 -2
- loggers/PluginEnableMediaReplaceLogger.php +12 -12
- loggers/PluginUserSwitchingLogger.php +47 -22
- readme.txt +5 -1
index.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://simple-history.com
|
|
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.2
|
9 |
Author: Pär Thernström
|
10 |
Author URI: http://simple-history.com/
|
11 |
License: GPL2
|
@@ -46,7 +46,7 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
|
|
46 |
// register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
47 |
|
48 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
49 |
-
define( 'SIMPLE_HISTORY_VERSION', '2.2' );
|
50 |
}
|
51 |
|
52 |
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.2.1
|
9 |
Author: Pär Thernström
|
10 |
Author URI: http://simple-history.com/
|
11 |
License: GPL2
|
46 |
// register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
47 |
|
48 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
49 |
+
define( 'SIMPLE_HISTORY_VERSION', '2.2.1' );
|
50 |
}
|
51 |
|
52 |
if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
|
loggers/PluginEnableMediaReplaceLogger.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
defined( 'ABSPATH' ) or die();
|
4 |
|
5 |
/**
|
6 |
-
* Logs
|
7 |
* Plugin URL: https://wordpress.org/plugins/enable-media-replace/
|
8 |
-
*
|
9 |
* @since 2.2
|
10 |
*/
|
11 |
class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
@@ -14,12 +14,12 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
|
14 |
|
15 |
/**
|
16 |
* Get array with information about this logger
|
17 |
-
*
|
18 |
* @return array
|
19 |
*/
|
20 |
function getInfo() {
|
21 |
|
22 |
-
$arr_info = array(
|
23 |
"name" => _x("Enable Media Replace Logger", "PluginEnableMediaReplaceLogger", "simple-history"),
|
24 |
"description" => _x("Logs media updates made with the Enable Media Replace Plugin", "PluginEnableMediaReplaceLogger", "simple-history"),
|
25 |
"capability" => "edit_files",
|
@@ -27,7 +27,7 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
|
27 |
'replaced_file' => _x('Replaced attachment "{prev_attachment_title}" with new attachment "{new_attachment_title}"', "PluginEnableMediaReplaceLogger", "simple-history"),
|
28 |
),
|
29 |
);
|
30 |
-
|
31 |
return $arr_info;
|
32 |
|
33 |
}
|
@@ -35,11 +35,11 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
|
35 |
function loaded() {
|
36 |
|
37 |
// Action that is called when Enable Media Replace loads it's admin options page (both when viewing and when posting new file to it)
|
38 |
-
add_action( 'load-media_page_enable-media-replace/enable-media-replace', array( $this, "on_load_plugin_admin_page" ), 10, 1 );
|
39 |
}
|
40 |
|
41 |
function on_load_plugin_admin_page() {
|
42 |
-
|
43 |
if ( empty( $_POST ) ) {
|
44 |
return;
|
45 |
}
|
@@ -56,7 +56,7 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
-
/*
|
60 |
get {
|
61 |
"page": "enable-media-replace\/enable-media-replace.php",
|
62 |
"noheader": "true",
|
@@ -64,11 +64,11 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
|
64 |
"attachment_id": "64085",
|
65 |
"_wpnonce": "1089573e0c"
|
66 |
}
|
67 |
-
|
68 |
post {
|
69 |
"ID": "64085",
|
70 |
"replace_type": "replace"
|
71 |
-
}
|
72 |
|
73 |
files {
|
74 |
"userfile": {
|
@@ -78,7 +78,7 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
|
78 |
"error": 0,
|
79 |
"size": 4325729
|
80 |
}
|
81 |
-
}
|
82 |
*/
|
83 |
|
84 |
$this->infoMessage("replaced_file", array(
|
@@ -96,7 +96,7 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
|
96 |
"old_attachment_meta" => $prev_attachment_meta
|
97 |
*/
|
98 |
));
|
99 |
-
|
100 |
}
|
101 |
|
102 |
}
|
3 |
defined( 'ABSPATH' ) or die();
|
4 |
|
5 |
/**
|
6 |
+
* Logs attachments updated with the great Enable Media Replace plugin
|
7 |
* Plugin URL: https://wordpress.org/plugins/enable-media-replace/
|
8 |
+
*
|
9 |
* @since 2.2
|
10 |
*/
|
11 |
class PluginEnableMediaReplaceLogger extends SimpleLogger {
|
14 |
|
15 |
/**
|
16 |
* Get array with information about this logger
|
17 |
+
*
|
18 |
* @return array
|
19 |
*/
|
20 |
function getInfo() {
|
21 |
|
22 |
+
$arr_info = array(
|
23 |
"name" => _x("Enable Media Replace Logger", "PluginEnableMediaReplaceLogger", "simple-history"),
|
24 |
"description" => _x("Logs media updates made with the Enable Media Replace Plugin", "PluginEnableMediaReplaceLogger", "simple-history"),
|
25 |
"capability" => "edit_files",
|
27 |
'replaced_file' => _x('Replaced attachment "{prev_attachment_title}" with new attachment "{new_attachment_title}"', "PluginEnableMediaReplaceLogger", "simple-history"),
|
28 |
),
|
29 |
);
|
30 |
+
|
31 |
return $arr_info;
|
32 |
|
33 |
}
|
35 |
function loaded() {
|
36 |
|
37 |
// Action that is called when Enable Media Replace loads it's admin options page (both when viewing and when posting new file to it)
|
38 |
+
add_action( 'load-media_page_enable-media-replace/enable-media-replace', array( $this, "on_load_plugin_admin_page" ), 10, 1 );
|
39 |
}
|
40 |
|
41 |
function on_load_plugin_admin_page() {
|
42 |
+
|
43 |
if ( empty( $_POST ) ) {
|
44 |
return;
|
45 |
}
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
+
/*
|
60 |
get {
|
61 |
"page": "enable-media-replace\/enable-media-replace.php",
|
62 |
"noheader": "true",
|
64 |
"attachment_id": "64085",
|
65 |
"_wpnonce": "1089573e0c"
|
66 |
}
|
67 |
+
|
68 |
post {
|
69 |
"ID": "64085",
|
70 |
"replace_type": "replace"
|
71 |
+
}
|
72 |
|
73 |
files {
|
74 |
"userfile": {
|
78 |
"error": 0,
|
79 |
"size": 4325729
|
80 |
}
|
81 |
+
}
|
82 |
*/
|
83 |
|
84 |
$this->infoMessage("replaced_file", array(
|
96 |
"old_attachment_meta" => $prev_attachment_meta
|
97 |
*/
|
98 |
));
|
99 |
+
|
100 |
}
|
101 |
|
102 |
}
|
loggers/PluginUserSwitchingLogger.php
CHANGED
@@ -5,7 +5,7 @@ defined( 'ABSPATH' ) or die();
|
|
5 |
/**
|
6 |
* Logs user switching from the great User Switching plugin
|
7 |
* Plugin URL: https://wordpress.org/plugins/user-switching/
|
8 |
-
*
|
9 |
* @since 2.2
|
10 |
*/
|
11 |
class PluginUserSwitchingLogger extends SimpleLogger {
|
@@ -14,22 +14,23 @@ class PluginUserSwitchingLogger extends SimpleLogger {
|
|
14 |
|
15 |
/**
|
16 |
* Get array with information about this logger
|
17 |
-
*
|
18 |
* @return array
|
19 |
*/
|
20 |
function getInfo() {
|
21 |
|
22 |
-
$arr_info = array(
|
23 |
"name" => _x("User Switching Logger", "PluginUserSwitchingLogger", "simple-history"),
|
24 |
"description" => _x("Logs user switches", "PluginUserSwitchingLogger", "simple-history"),
|
25 |
"capability" => "edit_users",
|
26 |
"messages" => array(
|
27 |
'switched_to_user' => _x('Switched to user "{user_login_to}" from user "{user_login_from}"', "PluginUserSwitchingLogger", "simple-history"),
|
28 |
-
'switched_back_user' => _x('Switched back to user "{user_login_to}" from "{user_login_from}"', "PluginUserSwitchingLogger", "simple-history"),
|
|
|
29 |
'switched_off_user' => _x('Switched off user "{user_login}"', "PluginUserSwitchingLogger", "simple-history"),
|
30 |
),
|
31 |
);
|
32 |
-
|
33 |
return $arr_info;
|
34 |
|
35 |
}
|
@@ -39,7 +40,7 @@ class PluginUserSwitchingLogger extends SimpleLogger {
|
|
39 |
add_action( 'switch_to_user', array( $this, "on_switch_to_user" ), 10, 2 );
|
40 |
add_action( 'switch_back_user', array( $this, "on_switch_back_user" ), 10, 2 );
|
41 |
add_action( 'switch_off_user', array( $this, "on_switch_off_user" ), 10, 1 );
|
42 |
-
|
43 |
}
|
44 |
|
45 |
function on_switch_to_user( $user_id, $old_user_id ) {
|
@@ -67,30 +68,54 @@ class PluginUserSwitchingLogger extends SimpleLogger {
|
|
67 |
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
function on_switch_back_user( $user_id, $old_user_id ) {
|
71 |
|
72 |
$user_to = get_user_by( "id", $user_id );
|
73 |
-
$user_from = get_user_by( "id", $old_user_id );
|
74 |
|
75 |
-
|
|
|
|
|
76 |
return;
|
77 |
}
|
78 |
|
79 |
-
$
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
"old_user_id" => $old_user_id,
|
90 |
-
"user_login_to" => $user_to->user_login,
|
91 |
-
"user_login_from" => $user_from->user_login
|
92 |
-
)
|
93 |
-
);
|
94 |
|
95 |
}
|
96 |
|
5 |
/**
|
6 |
* Logs user switching from the great User Switching plugin
|
7 |
* Plugin URL: https://wordpress.org/plugins/user-switching/
|
8 |
+
*
|
9 |
* @since 2.2
|
10 |
*/
|
11 |
class PluginUserSwitchingLogger extends SimpleLogger {
|
14 |
|
15 |
/**
|
16 |
* Get array with information about this logger
|
17 |
+
*
|
18 |
* @return array
|
19 |
*/
|
20 |
function getInfo() {
|
21 |
|
22 |
+
$arr_info = array(
|
23 |
"name" => _x("User Switching Logger", "PluginUserSwitchingLogger", "simple-history"),
|
24 |
"description" => _x("Logs user switches", "PluginUserSwitchingLogger", "simple-history"),
|
25 |
"capability" => "edit_users",
|
26 |
"messages" => array(
|
27 |
'switched_to_user' => _x('Switched to user "{user_login_to}" from user "{user_login_from}"', "PluginUserSwitchingLogger", "simple-history"),
|
28 |
+
'switched_back_user' => _x('Switched back to user "{user_login_to}" from user "{user_login_from}"', "PluginUserSwitchingLogger", "simple-history"),
|
29 |
+
'switched_back_themself' => _x('Switched back to user "{user_login_to}"', "PluginUserSwitchingLogger", "simple-history"),
|
30 |
'switched_off_user' => _x('Switched off user "{user_login}"', "PluginUserSwitchingLogger", "simple-history"),
|
31 |
),
|
32 |
);
|
33 |
+
|
34 |
return $arr_info;
|
35 |
|
36 |
}
|
40 |
add_action( 'switch_to_user', array( $this, "on_switch_to_user" ), 10, 2 );
|
41 |
add_action( 'switch_back_user', array( $this, "on_switch_back_user" ), 10, 2 );
|
42 |
add_action( 'switch_off_user', array( $this, "on_switch_off_user" ), 10, 1 );
|
43 |
+
|
44 |
}
|
45 |
|
46 |
function on_switch_to_user( $user_id, $old_user_id ) {
|
68 |
|
69 |
}
|
70 |
|
71 |
+
/**
|
72 |
+
* Function is called when a user switches back to their originating account.
|
73 |
+
* When you switch back after being logged off the
|
74 |
+
*
|
75 |
+
* Note: $old_user_id parameter is boolean false because there is no old user.
|
76 |
+
*
|
77 |
+
* @param int $user_id The ID of the user being switched back to.
|
78 |
+
* @param int|false $old_user_id The ID of the user being switched from, or false if the user is switching back
|
79 |
+
* after having been switched off.
|
80 |
+
*/
|
81 |
function on_switch_back_user( $user_id, $old_user_id ) {
|
82 |
|
83 |
$user_to = get_user_by( "id", $user_id );
|
|
|
84 |
|
85 |
+
$user_from = $old_user_id == false ? null : get_user_by( "id", $old_user_id );
|
86 |
+
|
87 |
+
if ( ! is_a( $user_to, "WP_User" ) ) {
|
88 |
return;
|
89 |
}
|
90 |
|
91 |
+
if ( $user_from ) {
|
92 |
+
|
93 |
+
// User switched back from another user
|
94 |
+
$this->infoMessage(
|
95 |
+
"switched_back_user",
|
96 |
+
array(
|
97 |
+
"_initiator" => SimpleLoggerLogInitiators::WP_USER,
|
98 |
+
"_user_id" => $old_user_id,
|
99 |
+
"user_id" => $user_id,
|
100 |
+
"old_user_id" => $old_user_id,
|
101 |
+
"user_login_to" => $user_to->user_login,
|
102 |
+
"user_login_from" => $user_from->user_login
|
103 |
+
)
|
104 |
+
);
|
105 |
+
|
106 |
+
} else {
|
107 |
+
|
108 |
+
// User switched back to themself (no prev user)
|
109 |
+
$this->infoMessage(
|
110 |
+
"switched_back_themself",
|
111 |
+
array(
|
112 |
+
"_initiator" => SimpleLoggerLogInitiators::WP_USER,
|
113 |
+
"_user_id" => $user_id,
|
114 |
+
"user_login_to" => $user_to->user_login,
|
115 |
+
)
|
116 |
+
);
|
117 |
|
118 |
+
}
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
}
|
121 |
|
readme.txt
CHANGED
@@ -119,7 +119,11 @@ initiated by a specific user.
|
|
119 |
|
120 |
## Changelog
|
121 |
|
122 |
-
= 2.2 (September 2015)
|
|
|
|
|
|
|
|
|
123 |
|
124 |
- Added: Support for plugin [User Switching](https://wordpress.org/plugins/user-switching/). The event log will show when a user switched to another user, when they switched back, or when they switched off.
|
125 |
|
119 |
|
120 |
## Changelog
|
121 |
|
122 |
+
= 2.2.1 (September 2015) =
|
123 |
+
|
124 |
+
- Fixed: Missed to log users switching back on using the User Switching plugin. Fixes https://github.com/bonny/WordPress-Simple-History/issues/89.
|
125 |
+
|
126 |
+
= 2.2 (September 2015) =
|
127 |
|
128 |
- Added: Support for plugin [User Switching](https://wordpress.org/plugins/user-switching/). The event log will show when a user switched to another user, when they switched back, or when they switched off.
|
129 |
|