Simple History - Version 2.26

Version Description

(July 2018) = - Add support for the Jetpack plugin. To begin with, activation and deactivation of Jetpack modules is logged. - Add logging of translation updates, so now you can see when a plugin or a theme has gotten new translations. Fixes https://github.com/bonny/WordPress-Simple-History/issues/147. - Fix notice in Advanced Custom Fields logger when saving an ACF options page. Fixes https://wordpress.org/support/topic/problem-with-acf-options-pages/, https://wordpress.org/support/topic/problem-with-recent-version-and-acf/, https://github.com/bonny/WordPress-Simple-History/issues/145.

Download this release

Release Info

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

Code changes from version 2.25 to 2.26

composer.json CHANGED
@@ -13,7 +13,7 @@
13
  "require": {
14
  "php": ">=5.3.0"
15
  },
16
- "version": "2.25",
17
  "authors": [
18
  {
19
  "name": "Pär Thernström",
@@ -23,7 +23,7 @@
23
  }
24
  ],
25
  "dist": {
26
- "url": "https://downloads.wordpress.org/plugin/simple-history.2.25.zip",
27
  "type": "zip"
28
  }
29
  }
13
  "require": {
14
  "php": ">=5.3.0"
15
  },
16
+ "version": "2.26",
17
  "authors": [
18
  {
19
  "name": "Pär Thernström",
23
  }
24
  ],
25
  "dist": {
26
+ "url": "https://downloads.wordpress.org/plugin/simple-history.zip",
27
  "type": "zip"
28
  }
29
  }
inc/SimpleHistory.php CHANGED
@@ -998,6 +998,8 @@ class SimpleHistory {
998
  $loggersDir . 'AvailableUpdatesLogger.php',
999
  $loggersDir . 'FileEditsLogger.php',
1000
  $loggersDir . 'class-sh-privacy-logger.php',
 
 
1001
 
1002
  // Loggers for third party plugins.
1003
  $loggersDir . 'PluginUserSwitchingLogger.php',
998
  $loggersDir . 'AvailableUpdatesLogger.php',
999
  $loggersDir . 'FileEditsLogger.php',
1000
  $loggersDir . 'class-sh-privacy-logger.php',
1001
+ $loggersDir . 'class-sh-translations-logger.php',
1002
+ $loggersDir . 'class-sh-jetpack-logger.php',
1003
 
1004
  // Loggers for third party plugins.
1005
  $loggersDir . 'PluginUserSwitchingLogger.php',
index.php CHANGED
@@ -5,7 +5,7 @@
5
  * Text Domain: simple-history
6
  * Domain Path: /languages
7
  * Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
8
- * Version: 2.25
9
  * Author: Pär Thernström
10
  * Author URI: http://simple-history.com/
11
  * License: GPL2
@@ -47,7 +47,7 @@ if ( $ok_php_version && $ok_wp_version ) {
47
  */
48
 
49
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
50
- define( 'SIMPLE_HISTORY_VERSION', '2.25' );
51
  }
52
 
53
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
5
  * Text Domain: simple-history
6
  * Domain Path: /languages
7
  * Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
8
+ * Version: 2.26
9
  * Author: Pär Thernström
10
  * Author URI: http://simple-history.com/
11
  * License: GPL2
47
  */
48
 
49
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
50
+ define( 'SIMPLE_HISTORY_VERSION', '2.26' );
51
  }
52
 
53
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
loggers/Plugin_ACF.php CHANGED
@@ -157,13 +157,19 @@ if ( ! class_exists( 'Plugin_ACF' ) ) {
157
  *
158
  * Called when ACF saves a post.
159
  *
160
- * @param int $post_id ID of post that is being saved.
161
  */
162
  public function on_acf_save_post( $post_id ) {
163
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
164
  return;
165
  }
166
 
 
 
 
 
 
 
167
  // Don't act on post revision.
168
  if ( wp_is_post_revision( $post_id ) ) {
169
  return;
@@ -187,7 +193,8 @@ if ( ! class_exists( 'Plugin_ACF' ) ) {
187
  [_product_images_0_image_related] => field_59aaedbc3ae10
188
  [product_images_1_image] => 574
189
  */
190
- $prev_post_meta = $this->oldPostData['prev_post_meta'];
 
191
  $new_post_meta = get_post_custom( $post_id );
192
  $new_post_meta = array_map( 'reset', $new_post_meta );
193
 
157
  *
158
  * Called when ACF saves a post.
159
  *
160
+ * @param mixed int $post_id ID of post that is being saved. string "option" or "options" when saving an options page.
161
  */
162
  public function on_acf_save_post( $post_id ) {
163
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
164
  return;
165
  }
166
 
167
+ // Only act when $post_id is numeric, can be "options" too when
168
+ // ACF saves an options page.
169
+ if ( ! is_numeric( $post_id ) ) {
170
+ return;
171
+ }
172
+
173
  // Don't act on post revision.
174
  if ( wp_is_post_revision( $post_id ) ) {
175
  return;
193
  [_product_images_0_image_related] => field_59aaedbc3ae10
194
  [product_images_1_image] => 574
195
  */
196
+ $prev_post_meta = isset( $this->oldPostData['prev_post_meta'] ) ? $this->oldPostData['prev_post_meta'] : [];
197
+
198
  $new_post_meta = get_post_custom( $post_id );
199
  $new_post_meta = array_map( 'reset', $new_post_meta );
200
 
loggers/SimpleCoreUpdatesLogger.php CHANGED
@@ -14,18 +14,17 @@ class SimpleCoreUpdatesLogger extends SimpleLogger {
14
  add_action( '_core_updated_successfully', array( $this, 'on_core_updated' ) );
15
  add_action( 'update_feedback', array( $this, 'on_update_feedback' ) );
16
 
17
- // Can't log db updates at the moment, because loaded() is not called yet when the action fires
18
- // add_action( 'wp_upgrade', array( $this, "on_wp_upgrade" ), 10, 2 );
19
  }
20
 
21
-
22
- /**
23
- * Fires after a site is fully upgraded.
24
- * The database, that is.
25
- *
26
- * @param int $wp_db_version The new $wp_db_version.
27
- * @param int $wp_current_db_version The old (current) $wp_db_version.
28
- */
29
  function on_wp_upgrade( $wp_db_version, $wp_current_db_version ) {
30
 
31
  $this->debugMessage(
14
  add_action( '_core_updated_successfully', array( $this, 'on_core_updated' ) );
15
  add_action( 'update_feedback', array( $this, 'on_update_feedback' ) );
16
 
17
+ // Can't log db updates at the moment, because loaded() is not called yet when the action fires
18
+ // add_action( 'wp_upgrade', array( $this, "on_wp_upgrade" ), 10, 2 );
19
  }
20
 
21
+ /**
22
+ * Fires after a site is fully upgraded.
23
+ * The database, that is.
24
+ *
25
+ * @param int $wp_db_version The new $wp_db_version.
26
+ * @param int $wp_current_db_version The old (current) $wp_db_version.
27
+ */
 
28
  function on_wp_upgrade( $wp_db_version, $wp_current_db_version ) {
29
 
30
  $this->debugMessage(
loggers/SimplePostLogger.php CHANGED
@@ -812,7 +812,6 @@ class SimplePostLogger extends SimpleLogger {
812
  $diff_table_output = '';
813
  $has_diff_values = false;
814
 
815
- // @TODO: this is silly. why loop if we know what we're looking for?
816
  foreach ( $context as $key => $val ) {
817
 
818
  if ( strpos( $key, 'post_prev_' ) !== false ) {
@@ -845,12 +844,15 @@ class SimplePostLogger extends SimpleLogger {
845
  // Risks to fill the visual output.
846
  // Maybe solution: use own diff function, that uses none or few context lines.
847
  $has_diff_values = true;
 
848
 
849
- $diff_table_output .= sprintf(
850
- '<tr><td>%1$s</td><td>%2$s</td></tr>',
851
- __( 'Content', 'simple-history' ),
852
- simple_history_text_diff( $post_old_value, $post_new_value )
853
- );
 
 
854
 
855
  } elseif ( 'post_status' == $key_to_diff ) {
856
 
812
  $diff_table_output = '';
813
  $has_diff_values = false;
814
 
 
815
  foreach ( $context as $key => $val ) {
816
 
817
  if ( strpos( $key, 'post_prev_' ) !== false ) {
844
  // Risks to fill the visual output.
845
  // Maybe solution: use own diff function, that uses none or few context lines.
846
  $has_diff_values = true;
847
+ $key_text_diff = simple_history_text_diff( $post_old_value, $post_new_value );
848
 
849
+ if ( $key_text_diff ) {
850
+ $diff_table_output .= sprintf(
851
+ '<tr><td>%1$s</td><td>%2$s</td></tr>',
852
+ __( 'Content', 'simple-history' ),
853
+ $key_text_diff
854
+ );
855
+ }
856
 
857
  } elseif ( 'post_status' == $key_to_diff ) {
858
 
loggers/class-sh-jetpack-logger.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Logger for Automattic Jetpack plugin.
4
+ *
5
+ * @package SimpleHistory
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die();
9
+
10
+ /**
11
+ * Logger for translation related things.
12
+ */
13
+ class SH_Jetpack_Logger extends SimpleLogger {
14
+
15
+ /**
16
+ * Logger slug.
17
+ *
18
+ * @var string
19
+ */
20
+ public $slug = __CLASS__;
21
+
22
+ /**
23
+ * Return info about logger.
24
+ *
25
+ * @return array Array with plugin info.
26
+ */
27
+ public function getInfo() {
28
+ $arr_info = array(
29
+ 'name' => 'Jetpack logger',
30
+ 'description' => _x( 'Log Jetpack settings changes', 'Logger: Jetpack', 'simple-history' ),
31
+ 'capability' => 'manage_options',
32
+ 'name_via' => _x( 'Using plugin Jetpack', 'Logger: Jetpack', 'simple-history' ),
33
+ 'messages' => array(
34
+ 'module_activated' => _x( 'Activated Jetpack module "{module_name}"', 'Logger: Jetpack', 'simple-history' ),
35
+ 'module_deactivated' => _x( 'Deactivated Jetpack module "{module_name}"', 'Logger: Jetpack', 'simple-history' ),
36
+ ),
37
+ );
38
+
39
+ return $arr_info;
40
+ }
41
+
42
+ /**
43
+ * Called when logger is loaded.
44
+ */
45
+ public function loaded() {
46
+ add_action( 'jetpack_activate_module', array($this, 'on_jetpack_activate_module'), 10, 2 );
47
+ add_action( 'jetpack_deactivate_module', array($this, 'on_jetpack_deactivate_module'), 10, 2 );
48
+ }
49
+
50
+ /**
51
+ * Get array with all Jetpack modules and info about them.
52
+ *
53
+ * @return array Array with info.
54
+ */
55
+ private function get_jetpack_modules() {
56
+ // Check that Jetpack has the needed methods.
57
+ if ( ! method_exists('Jetpack', 'get_available_modules') || ! method_exists('Jetpack', 'get_module') ) {
58
+ return false;
59
+ }
60
+
61
+ $available_modules = Jetpack::get_available_modules();
62
+ $available_modules_with_info = array();
63
+
64
+ foreach ($available_modules as $module_slug) {
65
+ $module = Jetpack::get_module( $module_slug );
66
+ if (!$module) {
67
+ continue;
68
+ }
69
+
70
+ $available_modules_with_info[$module_slug] = $module;
71
+ }
72
+
73
+ return $available_modules_with_info;
74
+ }
75
+
76
+ /**
77
+ * Get info about a Jetpack module.
78
+ *
79
+ * @param string $slug Slug of module to get info for.
80
+ *
81
+ * @return Array Array with module info.
82
+ */
83
+ private function get_jetpack_module($slug = null) {
84
+ if ( empty( $slug ) ) {
85
+ return false;
86
+ }
87
+
88
+ $modules = $this->get_jetpack_modules();
89
+
90
+ return isset($modules[$slug]) ? $modules[$slug] : false;
91
+ }
92
+
93
+ /**
94
+ * Called when a module is activated.
95
+ */
96
+ public function on_jetpack_activate_module($module_slug = null, $success = null) {
97
+ if ( true !== $success ) {
98
+ return;
99
+ }
100
+
101
+ $context = array();
102
+
103
+ $module = $this->get_jetpack_module($module_slug);
104
+
105
+ if ($module) {
106
+ $context['module_slug'] = $module_slug;
107
+ $context['module_name'] = $module['name'];
108
+ $context['module_description'] = $module['description'];
109
+ }
110
+
111
+ $this->infoMessage(
112
+ 'module_activated',
113
+ $context
114
+ );
115
+ }
116
+
117
+ /**
118
+ * Called when a module is deactivated.
119
+ */
120
+ public function on_jetpack_deactivate_module($module_slug = null, $success = null) {
121
+ if ( true !== $success ) {
122
+ return;
123
+ }
124
+
125
+ $context = array();
126
+
127
+ $module = $this->get_jetpack_module($module_slug);
128
+
129
+ if ($module) {
130
+ $context['module_slug'] = $module_slug;
131
+ $context['module_name'] = $module['name'];
132
+ $context['module_description'] = $module['description'];
133
+ }
134
+
135
+ $this->infoMessage(
136
+ 'module_deactivated',
137
+ $context
138
+ );
139
+ }
140
+
141
+ } // class
loggers/class-sh-privacy-logger.php CHANGED
@@ -19,10 +19,6 @@ defined( 'ABSPATH' ) || die();
19
  * Set in _wp_personal_data_cleanup_requests()
20
  * - Log when _wp_privacy_resend_request() is called
21
  */
22
-
23
- /**
24
- * Class to log things from the Redirection plugin.
25
- */
26
  class SH_Privacy_Logger extends SimpleLogger {
27
 
28
  /**
19
  * Set in _wp_personal_data_cleanup_requests()
20
  * - Log when _wp_privacy_resend_request() is called
21
  */
 
 
 
 
22
  class SH_Privacy_Logger extends SimpleLogger {
23
 
24
  /**
loggers/class-sh-translations-logger.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Logger for translation related things, like translation updated.
4
+ *
5
+ * @package SimpleHistory
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || die();
9
+
10
+ /**
11
+ * Logger for translation related things.
12
+ */
13
+ class SH_Translations_Logger extends SimpleLogger {
14
+
15
+ /**
16
+ * Logger slug.
17
+ *
18
+ * @var string
19
+ */
20
+ public $slug = __CLASS__;
21
+
22
+ /**
23
+ * Return info about logger.
24
+ *
25
+ * @return array Array with plugin info.
26
+ */
27
+ public function getInfo() {
28
+ $arr_info = array(
29
+ 'name' => 'Translation',
30
+ 'description' => _x( 'Log WordPress translation related things', 'Logger: Translations', 'simple-history' ),
31
+ 'capability' => 'manage_options',
32
+ 'messages' => array(
33
+ 'translations_updated' => _x( 'Updated translations for "{name}" ({language})', 'Logger: Translations', 'simple-history' ),
34
+ ),
35
+ );
36
+
37
+ return $arr_info;
38
+ }
39
+
40
+ /**
41
+ * Called when logger is loaded.
42
+ */
43
+ public function loaded() {
44
+ add_action( 'upgrader_process_complete', array( $this, 'on_upgrader_process_complete' ), 10, 2);
45
+ }
46
+
47
+ public function on_upgrader_process_complete($upgrader, $options) {
48
+ if ('translation' !== $options['type']) {
49
+ return;
50
+ }
51
+
52
+ if ('update' !== $options['action']) {
53
+ return;
54
+ }
55
+
56
+ if ( empty( $options['translations'] ) || ! is_array( $options['translations'] ) ) {
57
+ return;
58
+ }
59
+
60
+ $translations = $options['translations'];
61
+
62
+ foreach ($translations as $translation) {
63
+ $name = $upgrader->get_name_for_update( (object) $translation );
64
+
65
+ $context = array(
66
+ 'name' => $name,
67
+ 'language' => $translation['language'],
68
+ 'translations' => $translation,
69
+ );
70
+
71
+ $this->infoMessage(
72
+ 'translations_updated',
73
+ $context
74
+ );
75
+ }
76
+
77
+ /*
78
+ Array
79
+ (
80
+ [action] => update
81
+ [type] => translation
82
+ [bulk] => 1
83
+ [translations] => Array
84
+ (
85
+ [0] => Array
86
+ (
87
+ [language] => de_DE
88
+ [type] => plugin
89
+ [slug] => akismet
90
+ [version] => 4.0.8
91
+ )
92
+
93
+ [1] => Array
94
+ (
95
+ [language] => sv_SE
96
+ [type] => plugin
97
+ [slug] => akismet
98
+ [version] => 4.0.8
99
+ )
100
+
101
+ [11] => Array
102
+ (
103
+ [language] => sv_SE
104
+ [type] => theme
105
+ [slug] => twentysixteen
106
+ [version] => 1.5
107
+ )
108
+ )
109
+
110
+ )
111
+
112
+ This is how WordPress writes update messages:
113
+ Updating translations for Yoast SEO (de_DE)…
114
+ Translation updated successfully.
115
+
116
+ Updating translations for Yoast SEO (sv_SE)…
117
+ Translation updated successfully.
118
+
119
+ Updating translations for Twenty Fifteen (de_DE)…
120
+ Translation updated successfully.
121
+
122
+ $name = $this->upgrader->get_name_for_update( $this->language_update );
123
+ */
124
+ }
125
+
126
+ } // class
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: history, log, changes, changelog, audit, trail, pages, attachments, users,
5
  Requires at least: 4.5.1
6
  Tested up to: 4.9
7
  Requires PHP: 5.3
8
- Stable tag: 2.25
9
 
10
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
11
 
@@ -50,6 +50,11 @@ see when a user privacy data export request is added and when this request is ap
50
 
51
  By default Simple History comes with built in support for the following plugins:
52
 
 
 
 
 
 
53
  **Advanced Custom Fields (ACF)**<br>
54
  [ACF](https://www.advancedcustomfields.com/) adds fields to your posts and pages.
55
  Simple History will log changes made to the field groups and the fields inside field groups. Your will be able to
@@ -167,6 +172,12 @@ A simple way to see any uncommon activity, for example an increased number of lo
167
 
168
  ## Changelog
169
 
 
 
 
 
 
 
170
  = 2.25 (July 2018) =
171
  - Add `wp_cron_current_filter` to event context when something is logged during a cron job. This can help debugging thing like posts being added or deleted by some plugin and you're trying to figure out which plugin it is.
172
  - Fix for event details not always being shown.
5
  Requires at least: 4.5.1
6
  Tested up to: 4.9
7
  Requires PHP: 5.3
8
+ Stable tag: 2.26
9
 
10
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
11
 
50
 
51
  By default Simple History comes with built in support for the following plugins:
52
 
53
+ **Jetpack**<br>
54
+ The [Jetpack plugin](https://wordpress.org/plugins/jetpack/) is a plugin from Automattic (the creators of WordPress) that lets you supercharge your website by adding a lot of extra functions.
55
+ In Simple History you will see what Jetpack modules that are activated and deactivated.
56
+ (The creator of Simple History recommends this plugin and its [brute force attack protection](https://jetpack.com/features/security/brute-force-attack-protection/) functions btw. It's a really good way to block unwanted login attempts from malicious botnets and distributed attacks.
57
+
58
  **Advanced Custom Fields (ACF)**<br>
59
  [ACF](https://www.advancedcustomfields.com/) adds fields to your posts and pages.
60
  Simple History will log changes made to the field groups and the fields inside field groups. Your will be able to
172
 
173
  ## Changelog
174
 
175
+ = 2.26 (July 2018) =
176
+ - Add support for the [Jetpack plugin](https://wordpress.org/plugins/jetpack/). To begin with, activation and deactivation of Jetpack modules is logged.
177
+ - Add logging of translation updates, so now you can see when a plugin or a theme has gotten new translations. Fixes https://github.com/bonny/WordPress-Simple-History/issues/147.
178
+ - Fix notice in Advanced Custom Fields logger when saving an ACF options page.
179
+ Fixes https://wordpress.org/support/topic/problem-with-acf-options-pages/, https://wordpress.org/support/topic/problem-with-recent-version-and-acf/, https://github.com/bonny/WordPress-Simple-History/issues/145.
180
+
181
  = 2.25 (July 2018) =
182
  - Add `wp_cron_current_filter` to event context when something is logged during a cron job. This can help debugging thing like posts being added or deleted by some plugin and you're trying to figure out which plugin it is.
183
  - Fix for event details not always being shown.