Simple History - Version 2.5.4

Version Description

(March 2016) =

  • Added: Support for new key in info array from logger: "name_via". Set this value in a logger and the string will be shown next to the date of the logged event. Useful when logging actions from third party plugins, or any kind of other logging that is not from WordPress core.
  • Added: Method getInfoValueByKey added to the SimpleLogger class, for easier retrieval of values from the info array of a logger.
  • Fixed: Themes could no be deleted. Fixes https://github.com/bonny/WordPress-Simple-History/issues/98 and https://wordpress.org/support/topic/deleting-theme-1.
  • Fixed: Notice error when generating permalink for event.
  • Fixed: Removed a console.log().
  • Changed: Check that array key is integer or string. Hopefully fixes https://wordpress.org/support/topic/error-in-wp-adminerror_log.
Download this release

Release Info

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

Code changes from version 2.5.3 to 2.5.4

examples/examples.php CHANGED
@@ -16,6 +16,8 @@ define("SIMPLE_HISTORY_LOG_DEBUG", true);
16
  * Some examples of filter usage and so on
17
  */
18
 
 
 
19
 
20
  /**
21
  * Example that modifies the parameters sent to the message template
16
  * Some examples of filter usage and so on
17
  */
18
 
19
+ // Disable all logging
20
+ add_filter( "simple_history/log/do_log", "__return_false" );
21
 
22
  /**
23
  * Example that modifies the parameters sent to the message template
inc/SimpleHistory.php CHANGED
@@ -112,7 +112,7 @@ class SimpleHistory {
112
  add_filter( 'gettext', array( $this, "filter_gettext_storeLatestTranslations" ), 10, 3 );
113
 
114
  if ( is_admin() ) {
115
-
116
  $this->add_admin_actions();
117
 
118
  }
@@ -172,7 +172,7 @@ class SimpleHistory {
172
 
173
  add_action( 'admin_head', array( $this, "onAdminHead" ) );
174
  add_action( 'admin_footer', array( $this, "onAdminFooter" ) );
175
-
176
  add_action( 'simple_history/history_page/before_gui', array( $this, "output_quick_stats" ) );
177
  add_action( 'simple_history/dashboard/before_gui', array( $this, "output_quick_stats" ) );
178
 
@@ -200,12 +200,17 @@ class SimpleHistory {
200
 
201
  function filter_gettext_storeLatestTranslations( $translation, $text, $domain ) {
202
 
 
 
 
 
 
203
  $array_max_size = 5;
204
 
205
  // Keep a listing of the n latest translation
206
  // when SimpleLogger->log() is called from anywhere we can then search for the
207
  // translated string among our n latest things and find it there, if it's translated
208
- //global $sh_latest_translations;
209
  $sh_latest_translations = $this->gettextLatestTranslations;
210
 
211
  $sh_latest_translations[$translation] = array(
@@ -847,7 +852,7 @@ class SimpleHistory {
847
  }
848
 
849
  $loggerInstance->messages = $arr_messages_by_message_key;
850
-
851
  // Add logger to array of loggers
852
  $this->instantiatedLoggers[$loggerInstance->slug] = array(
853
  "name" => $loggerInfo["name"],
@@ -1354,7 +1359,7 @@ class SimpleHistory {
1354
  if ( 4 == intval( $db_version ) ) {
1355
 
1356
  if ( ! $this->does_database_have_data() ) {
1357
-
1358
  // not ok, decrease db number so installs will run again and hopefully fix things
1359
  $db_version = 0;
1360
 
@@ -1938,7 +1943,7 @@ Because Simple History was just recently installed, this feed does not contain m
1938
  }
1939
 
1940
  $days = $this->get_clear_history_interval();
1941
-
1942
  // Never clear log if days = 0
1943
  if ( 0 == $days ) {
1944
  return;
@@ -2587,7 +2592,7 @@ Because Simple History was just recently installed, this feed does not contain m
2587
  if ( "sql" == $format ) {
2588
 
2589
  $str_return = "(";
2590
-
2591
  if ( sizeof( $arr_loggers_user_can_view ) ) {
2592
 
2593
  foreach ( $arr_loggers_user_can_view as $one_logger ) {
@@ -2600,14 +2605,14 @@ Because Simple History was just recently installed, this feed does not contain m
2600
  }
2601
 
2602
  $str_return = rtrim( $str_return, " ," );
2603
-
2604
  } else {
2605
-
2606
  // user was not allowed to read any loggers, return in (NULL) to return nothing
2607
  $str_return .= 'NULL';
2608
-
2609
  }
2610
-
2611
  $str_return .= ")";
2612
 
2613
  return $str_return;
@@ -3086,4 +3091,3 @@ function simple_history_text_diff( $left_string, $right_string, $args = null ) {
3086
 
3087
  return $r;
3088
  }
3089
-
112
  add_filter( 'gettext', array( $this, "filter_gettext_storeLatestTranslations" ), 10, 3 );
113
 
114
  if ( is_admin() ) {
115
+
116
  $this->add_admin_actions();
117
 
118
  }
172
 
173
  add_action( 'admin_head', array( $this, "onAdminHead" ) );
174
  add_action( 'admin_footer', array( $this, "onAdminFooter" ) );
175
+
176
  add_action( 'simple_history/history_page/before_gui', array( $this, "output_quick_stats" ) );
177
  add_action( 'simple_history/dashboard/before_gui', array( $this, "output_quick_stats" ) );
178
 
200
 
201
  function filter_gettext_storeLatestTranslations( $translation, $text, $domain ) {
202
 
203
+ // Check that translation is a string or integer, i.ex. the valid values for an array key
204
+ if ( ! is_string( $translation ) || ! is_integer( $translation ) ) {
205
+ return $translation;
206
+ }
207
+
208
  $array_max_size = 5;
209
 
210
  // Keep a listing of the n latest translation
211
  // when SimpleLogger->log() is called from anywhere we can then search for the
212
  // translated string among our n latest things and find it there, if it's translated
213
+ // global $sh_latest_translations;
214
  $sh_latest_translations = $this->gettextLatestTranslations;
215
 
216
  $sh_latest_translations[$translation] = array(
852
  }
853
 
854
  $loggerInstance->messages = $arr_messages_by_message_key;
855
+
856
  // Add logger to array of loggers
857
  $this->instantiatedLoggers[$loggerInstance->slug] = array(
858
  "name" => $loggerInfo["name"],
1359
  if ( 4 == intval( $db_version ) ) {
1360
 
1361
  if ( ! $this->does_database_have_data() ) {
1362
+
1363
  // not ok, decrease db number so installs will run again and hopefully fix things
1364
  $db_version = 0;
1365
 
1943
  }
1944
 
1945
  $days = $this->get_clear_history_interval();
1946
+
1947
  // Never clear log if days = 0
1948
  if ( 0 == $days ) {
1949
  return;
2592
  if ( "sql" == $format ) {
2593
 
2594
  $str_return = "(";
2595
+
2596
  if ( sizeof( $arr_loggers_user_can_view ) ) {
2597
 
2598
  foreach ( $arr_loggers_user_can_view as $one_logger ) {
2605
  }
2606
 
2607
  $str_return = rtrim( $str_return, " ," );
2608
+
2609
  } else {
2610
+
2611
  // user was not allowed to read any loggers, return in (NULL) to return nothing
2612
  $str_return .= 'NULL';
2613
+
2614
  }
2615
+
2616
  $str_return .= ")";
2617
 
2618
  return $str_return;
3091
 
3092
  return $r;
3093
  }
 
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.5.3
9
  Author: Pär Thernström
10
  Author URI: http://simple-history.com/
11
  License: GPL2
@@ -42,7 +42,7 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
42
  // register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
43
 
44
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
45
- define( 'SIMPLE_HISTORY_VERSION', '2.5.3' );
46
  }
47
 
48
  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.5.4
9
  Author: Pär Thernström
10
  Author URI: http://simple-history.com/
11
  License: GPL2
42
  // register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
43
 
44
  if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
45
+ define( 'SIMPLE_HISTORY_VERSION', '2.5.4' );
46
  }
47
 
48
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
js/scripts.js CHANGED
@@ -764,9 +764,7 @@ jQuery(".js-SimpleHistory-Settings-ClearLog").on("click", function(e) {
764
 
765
 
766
  function addTimeAgo() {
767
-
768
- console.log("addTimeAgo()");
769
-
770
  $(".SimpleHistoryLogitem__when time").timeago();
771
 
772
  }
764
 
765
 
766
  function addTimeAgo() {
767
+
 
 
768
  $(".SimpleHistoryLogitem__when time").timeago();
769
 
770
  }
loggers/PluginEnableMediaReplaceLogger.php CHANGED
@@ -22,6 +22,7 @@ class PluginEnableMediaReplaceLogger extends SimpleLogger {
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"),
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
+ "name_via" => _x("Using plugin Enable Media Replace", "PluginUserSwitchingLogger", "simple-history"),
26
  "capability" => "edit_files",
27
  "messages" => array(
28
  'replaced_file' => _x('Replaced attachment "{prev_attachment_title}" with new attachment "{new_attachment_title}"', "PluginEnableMediaReplaceLogger", "simple-history"),
loggers/PluginUserSwitchingLogger.php CHANGED
@@ -22,6 +22,8 @@ class PluginUserSwitchingLogger extends SimpleLogger {
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"),
22
  $arr_info = array(
23
  "name" => _x("User Switching Logger", "PluginUserSwitchingLogger", "simple-history"),
24
  "description" => _x("Logs user switches", "PluginUserSwitchingLogger", "simple-history"),
25
+ // Definition of via: by way of, through the medium or agency of; also : by means of
26
+ "name_via" => _x("Using plugin User Switching", "PluginUserSwitchingLogger", "simple-history"),
27
  "capability" => "edit_users",
28
  "messages" => array(
29
  'switched_to_user' => _x('Switched to user "{user_login_to}" from user "{user_login_from}"', "PluginUserSwitchingLogger", "simple-history"),
loggers/SimpleLogger.php CHANGED
@@ -93,6 +93,21 @@ class SimpleLogger {
93
 
94
  }
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  /**
97
  * Returns the capability required to read log rows from this logger
98
  *
@@ -424,7 +439,9 @@ class SimpleLogger {
424
  }
425
 
426
  $item_permalink = admin_url("index.php?page=simple_history_page");
427
- $item_permalink .= "#item/{$row->id}";
 
 
428
 
429
  $date_format = get_option('date_format') . ' - '. get_option('time_format');
430
  $str_datetime_title = sprintf(
@@ -445,6 +462,7 @@ class SimpleLogger {
445
  $date_html .= "</a>";
446
  $date_html .= "</span>";
447
 
 
448
  /**
449
  * Filter the output of the date section of the header.
450
  *
@@ -455,6 +473,20 @@ class SimpleLogger {
455
  */
456
  $date_html = apply_filters("simple_history/row_header_date_output", $date_html, $row);
457
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  // Loglevel
459
  // SimpleHistoryLogitem--loglevel-warning
460
  /*
@@ -465,7 +497,11 @@ class SimpleLogger {
465
  */
466
 
467
  // Glue together final result
468
- $template = '%1$s%2$s';
 
 
 
 
469
  #if ( ! $initiator_html ) {
470
  # $template = '%2$s';
471
  #}
@@ -473,8 +509,8 @@ class SimpleLogger {
473
  $html = sprintf(
474
  $template,
475
  $initiator_html, // 1
476
- $date_html // 2
477
- // $level_html // 3
478
  );
479
 
480
  /**
93
 
94
  }
95
 
96
+ /**
97
+ * Return single array entry from the array in getInfo()
98
+ * Returns the value of the key if value exists, or null
99
+ *
100
+ * @since 2.5.4
101
+ * @return Mixed
102
+ */
103
+ function getInfoValueByKey( $key ) {
104
+
105
+ $arr_info = $this->getInfo();
106
+
107
+ return isset( $arr_info[ $key ] ) ? $arr_info[ $key ] : null;
108
+
109
+ }
110
+
111
  /**
112
  * Returns the capability required to read log rows from this logger
113
  *
439
  }
440
 
441
  $item_permalink = admin_url("index.php?page=simple_history_page");
442
+ if ( ! empty( $row->id ) ) {
443
+ $item_permalink .= "#item/{$row->id}";
444
+ }
445
 
446
  $date_format = get_option('date_format') . ' - '. get_option('time_format');
447
  $str_datetime_title = sprintf(
462
  $date_html .= "</a>";
463
  $date_html .= "</span>";
464
 
465
+
466
  /**
467
  * Filter the output of the date section of the header.
468
  *
473
  */
474
  $date_html = apply_filters("simple_history/row_header_date_output", $date_html, $row);
475
 
476
+ // Logger "via" info in header, i.e. output some extra
477
+ // info next to the time to make it more clear what plugin etc.
478
+ // that "caused" this event
479
+ $via_html = "";
480
+ $logger_name_via = $this->getInfoValueByKey("name_via");
481
+
482
+ if ( $logger_name_via ) {
483
+
484
+ $via_html = "<span class='SimpleHistoryLogitem__inlineDivided SimpleHistoryLogitem__via'>";
485
+ $via_html .= $logger_name_via;
486
+ $via_html .= "</span>";
487
+
488
+ }
489
+
490
  // Loglevel
491
  // SimpleHistoryLogitem--loglevel-warning
492
  /*
497
  */
498
 
499
  // Glue together final result
500
+ $template = '
501
+ %1$s
502
+ %2$s
503
+ %3$s
504
+ ';
505
  #if ( ! $initiator_html ) {
506
  # $template = '%2$s';
507
  #}
509
  $html = sprintf(
510
  $template,
511
  $initiator_html, // 1
512
+ $date_html, // 2
513
+ $via_html // 3
514
  );
515
 
516
  /**
loggers/SimplePluginLogger.php CHANGED
@@ -274,9 +274,6 @@ class SimplePluginLogger extends SimpleLogger
274
  wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
275
  }
276
 
277
- // Same as in plugins.php
278
- check_admin_referer('bulk-plugins');
279
-
280
  // Verify delete must be set
281
  if ( ! isset( $_POST["verify-delete"] ) || ! $_POST["verify-delete"] ) {
282
  return;
274
  wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
275
  }
276
 
 
 
 
277
  // Verify delete must be set
278
  if ( ! isset( $_POST["verify-delete"] ) || ! $_POST["verify-delete"] ) {
279
  return;
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.4
7
- Stable tag: 2.5.3
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
@@ -109,7 +109,8 @@ So far Simple History is translated to:
109
  * Finnish
110
  * French
111
 
112
- I'm looking for translations of Simple History in more languages! If you're interested please check out the [localization](https://developer.wordpress.org/plugins/internationalization/localization/) part of the Plugin Handbook for info on how to translate plugins. When you're done with your translation email it to me at par.thernstrom@gmail.com, or [add a pull request](https://github.com/bonny/WordPress-Simple-History/).
 
113
 
114
  #### Contribute at GitHub
115
 
@@ -143,6 +144,15 @@ initiated by a specific user.
143
 
144
  ## Changelog
145
 
 
 
 
 
 
 
 
 
 
146
  = 2.5.3 (February 2016) =
147
 
148
  - Fixed: Old entries was not correctly removed. Fixes https://github.com/bonny/WordPress-Simple-History/issues/108.
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.4
7
+ Stable tag: 2.5.4
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
109
  * Finnish
110
  * French
111
 
112
+ I'm looking for translations of Simple History in more languages! If you want to translate Simple History
113
+ to your language then read about how this is done over at the [Polyglots handbook](https://make.wordpress.org/polyglots/handbook/rosetta/theme-plugin-directories/#translating-themes-plugins).
114
 
115
  #### Contribute at GitHub
116
 
144
 
145
  ## Changelog
146
 
147
+ = 2.5.4 (March 2016) =
148
+
149
+ - Added: Support for new key in info array from logger: "name_via". Set this value in a logger and the string will be shown next to the date of the logged event. Useful when logging actions from third party plugins, or any kind of other logging that is not from WordPress core.
150
+ - Added: Method `getInfoValueByKey` added to the SimpleLogger class, for easier retrieval of values from the info array of a logger.
151
+ - Fixed: Themes could no be deleted. Fixes https://github.com/bonny/WordPress-Simple-History/issues/98 and https://wordpress.org/support/topic/deleting-theme-1.
152
+ - Fixed: Notice error when generating permalink for event.
153
+ - Fixed: Removed a `console.log()`.
154
+ - Changed: Check that array key is integer or string. Hopefully fixes https://wordpress.org/support/topic/error-in-wp-adminerror_log.
155
+
156
  = 2.5.3 (February 2016) =
157
 
158
  - Fixed: Old entries was not correctly removed. Fixes https://github.com/bonny/WordPress-Simple-History/issues/108.
tests/test-simplehistory.php CHANGED
@@ -262,7 +262,24 @@ class SimpleHistoryTest extends WP_UnitTestCase {
262
  $this->assertObjectHasAttribute( "occasionsIDType", $queryResults["log_rows"][0] );
263
  $this->assertObjectHasAttribute( "context", $queryResults["log_rows"][0] );
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
 
 
 
 
266
 
267
  }
268
 
262
  $this->assertObjectHasAttribute( "occasionsIDType", $queryResults["log_rows"][0] );
263
  $this->assertObjectHasAttribute( "context", $queryResults["log_rows"][0] );
264
 
265
+ }
266
+
267
+ function test_get_info() {
268
+
269
+ $sh = SimpleHistory::get_instance();
270
+
271
+ $postlogger = $sh->getInstantiatedLoggerBySlug( "SimplePostLogger" );
272
+ $info = $postlogger->getInfo();
273
+
274
+ $this->assertArrayHasKey( "name", $info );
275
+ $this->assertArrayHasKey( "description", $info );
276
+ $this->assertArrayHasKey( "capability", $info );
277
+ $this->assertArrayHasKey( "messages", $info );
278
 
279
+ $this->assertTrue( is_array( $info["messages"] ) );
280
+ $this->assertTrue( is_array( $info["labels"] ) );
281
+ $this->assertTrue( is_array( $info["labels"]["search"] ) );
282
+ $this->assertTrue( is_array( $info["labels"]["search"]["options"] ) );
283
 
284
  }
285