Simple History - Version 2.2

Version Description

(September 2015)

  • Added: Support for plugin User Switching. The event log will show when a user switched to another user, when they switched back, or when they switched off.

  • Added: Support for plugin Enable Media Replace. Whenever a user replaces an attachment with a new, you will now know about it and also see the name of both the old and the new attachment. Awesome!

  • Fixed: Mouse over (:hover state) on buttons no longer use blue background. Now works much better with admin themes other than the standard one. Fixes https://wordpress.org/support/topic/pagination-button-design.

Download this release

Release Info

Developer eskapism
Plugin Icon 128x128 Simple History
Version 2.2
Comparing to
See all releases

Code changes from version 2.1.7 to 2.2

css/styles.css CHANGED
@@ -599,8 +599,8 @@ Pagination, below logRows
599
  }
600
 
601
  .SimpleHistoryPaginationLink.SimpleHistoryPaginationLink:hover {
602
- color: rgb(255, 255, 255);
603
- background: rgb(46, 162, 204);
604
  }
605
 
606
  .SimpleHistoryPaginationLink.SimpleHistoryPaginationLink.disabled {
599
  }
600
 
601
  .SimpleHistoryPaginationLink.SimpleHistoryPaginationLink:hover {
602
+ /*color: rgb(255, 255, 255);*/
603
+ /*background: rgb(46, 162, 204);*/
604
  }
605
 
606
  .SimpleHistoryPaginationLink.SimpleHistoryPaginationLink.disabled {
inc/SimpleHistory.php CHANGED
@@ -642,6 +642,10 @@ class SimpleHistory {
642
  $loggersDir . "SimplePostLogger.php",
643
  $loggersDir . "SimpleThemeLogger.php",
644
  $loggersDir . "SimpleUserLogger.php",
 
 
 
 
645
  );
646
 
647
  // SimpleLogger.php must be loaded first and always since the other loggers extend it
@@ -727,7 +731,6 @@ class SimpleHistory {
727
  }
728
 
729
  $loggerInstance = new $oneLoggerName( $this );
730
-
731
  if ( ! is_subclass_of( $loggerInstance, "SimpleLogger" ) && ! is_a( $loggerInstance, "SimpleLogger" ) ) {
732
  continue;
733
  }
@@ -747,7 +750,35 @@ class SimpleHistory {
747
  // LoggerInfo contains all messages, both translated an not, by key.
748
  // Add messages to the loggerInstance
749
  $loopNum = 0;
750
- if ( is_array( $loggerInfo["messages"] ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
751
 
752
  foreach ( $loggerInfo["messages"] as $message_key => $message ) {
753
 
@@ -769,6 +800,7 @@ class SimpleHistory {
769
  }
770
 
771
  }
 
772
 
773
  // Add logger to array of loggers
774
  $this->instantiatedLoggers[$loggerInstance->slug] = array(
642
  $loggersDir . "SimplePostLogger.php",
643
  $loggersDir . "SimpleThemeLogger.php",
644
  $loggersDir . "SimpleUserLogger.php",
645
+
646
+ // Loggers for third party plugins
647
+ $loggersDir . "PluginUserSwitchingLogger.php",
648
+ $loggersDir . "PluginEnableMediaReplaceLogger.php"
649
  );
650
 
651
  // SimpleLogger.php must be loaded first and always since the other loggers extend it
731
  }
732
 
733
  $loggerInstance = new $oneLoggerName( $this );
 
734
  if ( ! is_subclass_of( $loggerInstance, "SimpleLogger" ) && ! is_a( $loggerInstance, "SimpleLogger" ) ) {
735
  continue;
736
  }
750
  // LoggerInfo contains all messages, both translated an not, by key.
751
  // Add messages to the loggerInstance
752
  $loopNum = 0;
753
+
754
+ $arr_messages_by_message_key = array();
755
+
756
+ foreach ( $loggerInfo["messages"] as $message_key => $message_untranslated ) {
757
+
758
+ // Find message in array with both translated and non translated strings
759
+ foreach ( $loggerInstance->messages as $one_message_with_translation_info ) {
760
+
761
+ /*
762
+ [0] => Array
763
+ (
764
+ [untranslated_text] => ...
765
+ [translated_text] => ...
766
+ [domain] => simple-history
767
+ [context] => ...
768
+ )
769
+ */
770
+ if ( $message_untranslated == $one_message_with_translation_info["untranslated_text"] ) {
771
+ $arr_messages_by_message_key[ $message_key ] = $one_message_with_translation_info;
772
+ continue;
773
+ }
774
+
775
+ }
776
+
777
+ }
778
+
779
+ $loggerInstance->messages = $arr_messages_by_message_key;
780
+
781
+ /*if ( is_array( $loggerInfo["messages"] ) ) {
782
 
783
  foreach ( $loggerInfo["messages"] as $message_key => $message ) {
784
 
800
  }
801
 
802
  }
803
+ */
804
 
805
  // Add logger to array of loggers
806
  $this->instantiatedLoggers[$loggerInstance->slug] = array(
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.1.7
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.1.7' );
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
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' );
50
  }
51
 
52
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
loggers/PluginEnableMediaReplaceLogger.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined( 'ABSPATH' ) or die();
4
+
5
+ /**
6
+ * Logs user switching from 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 {
12
+
13
+ public $slug = __CLASS__;
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",
26
+ "messages" => array(
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
+ }
34
+
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
+ }
46
+
47
+ if ( isset( $_GET["action"] ) && $_GET["action"] == "media_replace_upload" ) {
48
+
49
+ $attachment_id = empty( $_POST["ID"] ) ? null : (int) $_POST["ID"];
50
+ $replace_type = empty( $_POST["replace_type"] ) ? null : sanitize_text_field( $_POST["replace_type"] );
51
+ $new_file = empty( $_FILES["userfile"] ) ? null : (array) $_FILES["userfile"];
52
+
53
+ $prev_attachment_post = get_post( $attachment_id );
54
+
55
+ if ( empty( $attachment_id ) || empty( $new_file ) || empty( $prev_attachment_post ) ) {
56
+ return;
57
+ }
58
+
59
+ /*
60
+ get {
61
+ "page": "enable-media-replace\/enable-media-replace.php",
62
+ "noheader": "true",
63
+ "action": "media_replace_upload",
64
+ "attachment_id": "64085",
65
+ "_wpnonce": "1089573e0c"
66
+ }
67
+
68
+ post {
69
+ "ID": "64085",
70
+ "replace_type": "replace"
71
+ }
72
+
73
+ files {
74
+ "userfile": {
75
+ "name": "earth-transparent.png",
76
+ "type": "image\/png",
77
+ "tmp_name": "\/Applications\/MAMP\/tmp\/php\/phpKA2XOo",
78
+ "error": 0,
79
+ "size": 4325729
80
+ }
81
+ }
82
+ */
83
+
84
+ $this->infoMessage("replaced_file", array(
85
+ "attachment_id" => $attachment_id,
86
+ "prev_attachment_title" => get_the_title( $prev_attachment_post ),
87
+ "new_attachment_title" => $new_file["name"],
88
+ "new_attachment_type" => $new_file["type"],
89
+ "new_attachment_size" => $new_file["size"],
90
+ "replace_type" => $replace_type,
91
+ /*
92
+ "get" => $_GET,
93
+ "post" => $_POST,
94
+ "files" => $_FILES,
95
+ "old_attachment_post" => $prev_attachment_post,
96
+ "old_attachment_meta" => $prev_attachment_meta
97
+ */
98
+ ));
99
+
100
+ }
101
+
102
+ }
103
+
104
+ }
loggers/PluginUserSwitchingLogger.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined( 'ABSPATH' ) or die();
4
+
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 {
12
+
13
+ public $slug = __CLASS__;
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
+ }
36
+
37
+ function loaded() {
38
+
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 ) {
46
+
47
+ $user_to = get_user_by( "id", $user_id );
48
+ $user_from = get_user_by( "id", $old_user_id );
49
+
50
+ if ( ! is_a($user_to, "WP_User") || ! is_a($user_from, "WP_User") ) {
51
+ return;
52
+ }
53
+
54
+ $this->infoMessage(
55
+ "switched_to_user",
56
+ array(
57
+ // It is the old user who initiates the switching
58
+ "_initiator" => SimpleLoggerLogInitiators::WP_USER,
59
+ "_user_id" => $old_user_id,
60
+
61
+ "user_id" => $user_id,
62
+ "old_user_id" => $old_user_id,
63
+ "user_login_to" => $user_to->user_login,
64
+ "user_login_from" => $user_from->user_login,
65
+ )
66
+ );
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
+ if ( ! is_a($user_to, "WP_User") || ! is_a($user_from, "WP_User") ) {
76
+ return;
77
+ }
78
+
79
+ $this->infoMessage(
80
+ "switched_back_user",
81
+ array(
82
+ // It is the old user who initiates the switching
83
+ // or probably the new user, but we can't be sure about that.
84
+ // anyway: we log who was logged in as the initiator
85
+ "_initiator" => SimpleLoggerLogInitiators::WP_USER,
86
+ "_user_id" => $old_user_id,
87
+
88
+ "user_id" => $user_id,
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
+
97
+ function on_switch_off_user( $user_id ) {
98
+
99
+ $user = get_user_by( "id", $user_id );
100
+
101
+ if ( ! is_a($user, "WP_User") ) {
102
+ return;
103
+ }
104
+
105
+ $this->infoMessage(
106
+ "switched_off_user",
107
+ array(
108
+ "_initiator" => SimpleLoggerLogInitiators::WP_USER,
109
+ "_user_id" => $user_id,
110
+
111
+ "user_id" => $user_id,
112
+ "user_login" => $user->user_login
113
+ )
114
+ );
115
+
116
+ }
117
+
118
+ }
loggers/SimpleExportLogger.php CHANGED
@@ -18,8 +18,8 @@ class SimpleExportLogger extends SimpleLogger
18
  function getInfo() {
19
 
20
  $arr_info = array(
21
- "name" => "Export Logger",
22
- "description" => "Logs updates to WordPress export",
23
  "capability" => "export",
24
  "messages" => array(
25
  'created_export' => __('Created XML export', "simple-history"),
@@ -51,7 +51,7 @@ class SimpleExportLogger extends SimpleLogger
51
  $this->infoMessage(
52
  "created_export",
53
  array(
54
- "args" => $this->simpleHistory->json_encode($args)
55
  )
56
  );
57
 
18
  function getInfo() {
19
 
20
  $arr_info = array(
21
+ "name" => __("Export Logger", "simple-history"),
22
+ "description" => __("Logs updates to WordPress export", "simple-history"),
23
  "capability" => "export",
24
  "messages" => array(
25
  'created_export' => __('Created XML export', "simple-history"),
51
  $this->infoMessage(
52
  "created_export",
53
  array(
54
+ "args" => $this->simpleHistory->json_encode( $args )
55
  )
56
  );
57
 
loggers/SimpleLogger.php CHANGED
@@ -452,8 +452,7 @@ class SimpleLogger {
452
 
453
  // Message is translated here, but translation must be added in
454
  // plain text before
455
-
456
- if (empty( $message_key )) {
457
 
458
  // Message key did not exist, so check if we should translate using textdomain
459
  if ( ! empty( $row->context["_gettext_domain"] ) ) {
452
 
453
  // Message is translated here, but translation must be added in
454
  // plain text before
455
+ if ( empty( $message_key ) ) {
 
456
 
457
  // Message key did not exist, so check if we should translate using textdomain
458
  if ( ! empty( $row->context["_gettext_domain"] ) ) {
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, audit trail, brute-force
5
  Requires at least: 3.6.0
6
  Tested up to: 4.3
7
- Stable tag: 2.1.6
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
@@ -119,6 +119,14 @@ initiated by a specific user.
119
 
120
  ## Changelog
121
 
 
 
 
 
 
 
 
 
122
  = 2.1.7 (September 2015) =
123
 
124
  - Fixed: Date and time in the log was using GMT time rather than local time. Could be confusing. Even very confusing if living in a time zone far far away from the GMT zone.
4
  Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
5
  Requires at least: 3.6.0
6
  Tested up to: 4.3
7
+ Stable tag: 2.2
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
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
+
126
+ - Added: Support for plugin [Enable Media Replace](https://wordpress.org/plugins/enable-media-replace/). Whenever a user replaces an attachment with a new, you will now know about it and also see the name of both the old and the new attachment. Awesome!
127
+
128
+ - Fixed: Mouse over (:hover state) on buttons no longer use blue background. Now works much better with admin themes other than the standard one. Fixes https://wordpress.org/support/topic/pagination-button-design.
129
+
130
  = 2.1.7 (September 2015) =
131
 
132
  - Fixed: Date and time in the log was using GMT time rather than local time. Could be confusing. Even very confusing if living in a time zone far far away from the GMT zone.