Simple History - Version 2.12

Version Description

(September 2016) =

  • You can show a different number of log items in the log on the dashboard and on the dedicated history page. By default the dashboard will show 5 items and the page will show 30.
  • On multisites the user search filter now only search users in the current site.
  • The statistics chart using Chart.js now uses the namespace window.Simple_History_Chart instead of window.Chart, decreasing the risk that two versions of the Chart.js library overwriting each others. Fixes https://wordpress.org/support/topic/comet-cache-breaks-simple-history/. (Note to future me: this was fixed by renaming the window.chart variable to window.chart.Simple_history_chart in the line `window.Chart
Download this release

Release Info

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

Code changes from version 2.11 to 2.12

dropins/SimpleHistoryFilterDropin.php CHANGED
@@ -498,7 +498,7 @@ class SimpleHistoryFilterDropin {
498
 
499
  // user must have list_users capability (default super admin + administrators have this)
500
  if ( ! current_user_can("list_users") ) {
501
- wp_send_json_error();;
502
  }
503
 
504
  // Search both current users and all logged rows,
@@ -506,37 +506,20 @@ class SimpleHistoryFilterDropin {
506
  // search in context: user_id, user_email, user_login
507
  // search in wp_users: login, nicename, user_email
508
 
509
- // Can't get this simple query to work, so using my own query instead
510
- /*
511
- $wp_users = get_users( array(
512
- "search" => "*{$q}*"
513
- ));
514
- */
515
- global $wpdb;
516
-
517
- if ( method_exists($wpdb, "esc_like") ) {
518
- $str_like = $wpdb->esc_like( $q );
519
- } else {
520
- $str_like = like_escape( $q );
521
- }
522
-
523
- $sql_users = $wpdb->prepare(
524
- 'SELECT ID as id, user_login, user_nicename, user_email, display_name FROM %1$s
525
- WHERE
526
- user_login LIKE "%%%2$s%%"
527
- OR user_nicename LIKE "%%%2$s%%"
528
- OR user_email LIKE "%%%2$s%%"
529
- OR display_name LIKE "%%%2$s%%"
530
- LIMIT 20
531
- ',
532
- $wpdb->users,
533
- $str_like
534
- );
535
 
536
- $results_user = $wpdb->get_results( $sql_users );
 
 
 
537
 
538
  // add gravatars to user array
539
- array_walk( $results_user, array($this, "add_gravatar_to_user_array") );
540
 
541
  $data = array(
542
  "results" => array(
498
 
499
  // user must have list_users capability (default super admin + administrators have this)
500
  if ( ! current_user_can("list_users") ) {
501
+ wp_send_json_error();
502
  }
503
 
504
  // Search both current users and all logged rows,
506
  // search in context: user_id, user_email, user_login
507
  // search in wp_users: login, nicename, user_email
508
 
509
+ // search and get users. make sure to use "fields" and "number" or we can get timeout/use lots of memory if we have a large amount of users
510
+ $results_user = get_users( array(
511
+ "search" => "*{$q}*",
512
+ "fields" => array("ID", "user_login", "user_nicename", "user_email", "display_name"),
513
+ "number" => 20
514
+ ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
 
516
+ // add lower case id to user array
517
+ array_walk( $results_user, function( $val ) {
518
+ $val->id = $val->ID;
519
+ } );
520
 
521
  // add gravatars to user array
522
+ array_walk( $results_user, array( $this, "add_gravatar_to_user_array" ) );
523
 
524
  $data = array(
525
  "results" => array(
dropins/SimpleHistorySidebarStats.php CHANGED
@@ -32,7 +32,7 @@ class SimpleHistorySidebarStats {
32
 
33
  public function on_admin_enqueue_scripts() {
34
 
35
- wp_enqueue_script( "chart.js", SIMPLE_HISTORY_DIR_URL . "js/Chart.js", array( "jquery" ), SIMPLE_HISTORY_VERSION, true );
36
 
37
  }
38
 
@@ -58,7 +58,7 @@ class SimpleHistorySidebarStats {
58
  var chartLabelsToDates = JSON.parse( $(".SimpleHistory_SidebarChart_ChartLabelsToDates").val() );
59
  var chartDatasetData = JSON.parse( $(".SimpleHistory_SidebarChart_ChartDatasetData").val() );
60
 
61
- var myChart = new Chart(ctx, {
62
  type: 'bar',
63
  data: {
64
  labels: chartLabels,
32
 
33
  public function on_admin_enqueue_scripts() {
34
 
35
+ wp_enqueue_script( "simple_history_chart.js", SIMPLE_HISTORY_DIR_URL . "js/Chart.js", array( "jquery" ), SIMPLE_HISTORY_VERSION, true );
36
 
37
  }
38
 
58
  var chartLabelsToDates = JSON.parse( $(".SimpleHistory_SidebarChart_ChartLabelsToDates").val() );
59
  var chartDatasetData = JSON.parse( $(".SimpleHistory_SidebarChart_ChartDatasetData").val() );
60
 
61
+ var myChart = new Simple_History_Chart(ctx, {
62
  type: 'bar',
63
  data: {
64
  labels: chartLabels,
inc/SimpleHistory.php CHANGED
@@ -1138,7 +1138,7 @@ class SimpleHistory {
1138
  */
1139
  function get_pager_size() {
1140
 
1141
- $pager_size = get_option( "simple_history_pager_size", 10 );
1142
 
1143
  /**
1144
  * Filter the pager size setting
@@ -1153,6 +1153,31 @@ class SimpleHistory {
1153
 
1154
  }
1155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1156
  /**
1157
  * Show a link to our settings page on the Plugins -> Installed Plugins screen
1158
  */
@@ -1201,7 +1226,7 @@ class SimpleHistory {
1201
  */
1202
  function dashboard_widget_output() {
1203
 
1204
- $pager_size = $this->get_pager_size();
1205
 
1206
  /**
1207
  * Filter the pager size setting for the dashboard
@@ -1822,17 +1847,31 @@ Because Simple History was just recently installed, this feed does not contain m
1822
  register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_show_on_dashboard" );
1823
  register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_show_as_page" );
1824
 
1825
- // Dropdown number if items to show
1826
  add_settings_field(
1827
  "simple_history_number_of_items",
1828
- __( "Number of items per page", "simple-history" ),
1829
  array( $this, "settings_field_number_of_items" ),
1830
  SimpleHistory::SETTINGS_MENU_SLUG,
1831
  $settings_section_general_id
1832
  );
1833
 
1834
  // Nonces for number of items inputs
1835
- register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_pager_size" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1836
 
1837
  // Link to clear log
1838
  add_settings_field(
@@ -1944,7 +1983,7 @@ Because Simple History was just recently installed, this feed does not contain m
1944
  }
1945
 
1946
  /**
1947
- * Settings field for how many rows/items to show in log
1948
  */
1949
  function settings_field_number_of_items() {
1950
 
@@ -1967,6 +2006,30 @@ Because Simple History was just recently installed, this feed does not contain m
1967
 
1968
  }
1969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1970
  /**
1971
  * Settings field for where to show the log, page or dashboard
1972
  */
1138
  */
1139
  function get_pager_size() {
1140
 
1141
+ $pager_size = get_option( "simple_history_pager_size", 20 );
1142
 
1143
  /**
1144
  * Filter the pager size setting
1153
 
1154
  }
1155
 
1156
+
1157
+ /**
1158
+ * Gets the pager size,
1159
+ * i.e. the number of items to show on each page in the history
1160
+ *
1161
+ * @since 2.12
1162
+ * @return int
1163
+ */
1164
+ function get_pager_size_dashboard() {
1165
+
1166
+ $pager_size = get_option( "simple_history_pager_size_dashboard", 5 );
1167
+
1168
+ /**
1169
+ * Filter the pager size setting
1170
+ *
1171
+ * @since 2.12
1172
+ *
1173
+ * @param int $pager_size
1174
+ */
1175
+ $pager_size = apply_filters( "simple_history/pager_size_dashboard", $pager_size );
1176
+
1177
+ return $pager_size;
1178
+
1179
+ }
1180
+
1181
  /**
1182
  * Show a link to our settings page on the Plugins -> Installed Plugins screen
1183
  */
1226
  */
1227
  function dashboard_widget_output() {
1228
 
1229
+ $pager_size = $this->get_pager_size_dashboard();
1230
 
1231
  /**
1232
  * Filter the pager size setting for the dashboard
1847
  register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_show_on_dashboard" );
1848
  register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_show_as_page" );
1849
 
1850
+ // Number if items to show on the history page
1851
  add_settings_field(
1852
  "simple_history_number_of_items",
1853
+ __( "Number of items per page on the log page", "simple-history" ),
1854
  array( $this, "settings_field_number_of_items" ),
1855
  SimpleHistory::SETTINGS_MENU_SLUG,
1856
  $settings_section_general_id
1857
  );
1858
 
1859
  // Nonces for number of items inputs
1860
+ register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_pager_size" );
1861
+
1862
+
1863
+ // Number if items to show on dashboard
1864
+ add_settings_field(
1865
+ "simple_history_number_of_items_dashboard",
1866
+ __( "Number of items per page on the dashboard", "simple-history" ),
1867
+ array( $this, "settings_field_number_of_items_dashboard" ),
1868
+ SimpleHistory::SETTINGS_MENU_SLUG,
1869
+ $settings_section_general_id
1870
+ );
1871
+
1872
+ // Nonces for number of items inputs
1873
+ register_setting( SimpleHistory::SETTINGS_GENERAL_OPTION_GROUP, "simple_history_pager_size_dashboard" );
1874
+
1875
 
1876
  // Link to clear log
1877
  add_settings_field(
1983
  }
1984
 
1985
  /**
1986
+ * Settings field for how many rows/items to show in log on the log page
1987
  */
1988
  function settings_field_number_of_items() {
1989
 
2006
 
2007
  }
2008
 
2009
+ /**
2010
+ * Settings field for how many rows/items to show in log on the dashboard
2011
+ */
2012
+ function settings_field_number_of_items_dashboard() {
2013
+
2014
+ $current_pager_size = $this->get_pager_size_dashboard();
2015
+
2016
+ ?>
2017
+ <select name="simple_history_pager_size_dashboard">
2018
+ <option <?php echo $current_pager_size == 5 ? "selected" : ""?> value="5">5</option>
2019
+ <option <?php echo $current_pager_size == 10 ? "selected" : ""?> value="10">10</option>
2020
+ <option <?php echo $current_pager_size == 15 ? "selected" : ""?> value="15">15</option>
2021
+ <option <?php echo $current_pager_size == 20 ? "selected" : ""?> value="20">20</option>
2022
+ <option <?php echo $current_pager_size == 25 ? "selected" : ""?> value="25">25</option>
2023
+ <option <?php echo $current_pager_size == 30 ? "selected" : ""?> value="30">30</option>
2024
+ <option <?php echo $current_pager_size == 40 ? "selected" : ""?> value="40">40</option>
2025
+ <option <?php echo $current_pager_size == 50 ? "selected" : ""?> value="50">50</option>
2026
+ <option <?php echo $current_pager_size == 75 ? "selected" : ""?> value="75">75</option>
2027
+ <option <?php echo $current_pager_size == 100 ? "selected" : ""?> value="100">100</option>
2028
+ </select>
2029
+ <?php
2030
+
2031
+ }
2032
+
2033
  /**
2034
  * Settings field for where to show the log, page or dashboard
2035
  */
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.11
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.11' );
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.12
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.12' );
46
  }
47
 
48
  if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
js/Chart.js CHANGED
@@ -1638,7 +1638,7 @@ require('./charts/Chart.PolarArea')(Chart);
1638
  require('./charts/Chart.Radar')(Chart);
1639
  require('./charts/Chart.Scatter')(Chart);
1640
 
1641
- window.Chart = module.exports = Chart;
1642
 
1643
  },{"./charts/Chart.Bar":8,"./charts/Chart.Bubble":9,"./charts/Chart.Doughnut":10,"./charts/Chart.Line":11,"./charts/Chart.PolarArea":12,"./charts/Chart.Radar":13,"./charts/Chart.Scatter":14,"./controllers/controller.bar":15,"./controllers/controller.bubble":16,"./controllers/controller.doughnut":17,"./controllers/controller.line":18,"./controllers/controller.polarArea":19,"./controllers/controller.radar":20,"./core/core.animation":21,"./core/core.controller":22,"./core/core.datasetController":23,"./core/core.element":24,"./core/core.helpers":25,"./core/core.js":26,"./core/core.layoutService":27,"./core/core.legend":28,"./core/core.scale":29,"./core/core.scaleService":30,"./core/core.title":31,"./core/core.tooltip":32,"./elements/element.arc":33,"./elements/element.line":34,"./elements/element.point":35,"./elements/element.rectangle":36,"./scales/scale.category":37,"./scales/scale.linear":38,"./scales/scale.logarithmic":39,"./scales/scale.radialLinear":40,"./scales/scale.time":41}],8:[function(require,module,exports){
1644
  "use strict";
1638
  require('./charts/Chart.Radar')(Chart);
1639
  require('./charts/Chart.Scatter')(Chart);
1640
 
1641
+ window.Simple_History_Chart = module.exports = Chart;
1642
 
1643
  },{"./charts/Chart.Bar":8,"./charts/Chart.Bubble":9,"./charts/Chart.Doughnut":10,"./charts/Chart.Line":11,"./charts/Chart.PolarArea":12,"./charts/Chart.Radar":13,"./charts/Chart.Scatter":14,"./controllers/controller.bar":15,"./controllers/controller.bubble":16,"./controllers/controller.doughnut":17,"./controllers/controller.line":18,"./controllers/controller.polarArea":19,"./controllers/controller.radar":20,"./core/core.animation":21,"./core/core.controller":22,"./core/core.datasetController":23,"./core/core.element":24,"./core/core.helpers":25,"./core/core.js":26,"./core/core.layoutService":27,"./core/core.legend":28,"./core/core.scale":29,"./core/core.scaleService":30,"./core/core.title":31,"./core/core.tooltip":32,"./elements/element.arc":33,"./elements/element.line":34,"./elements/element.point":35,"./elements/element.rectangle":36,"./scales/scale.category":37,"./scales/scale.linear":38,"./scales/scale.logarithmic":39,"./scales/scale.radialLinear":40,"./scales/scale.time":41}],8:[function(require,module,exports){
1644
  "use strict";
loggers/SimpleCommentsLogger.php CHANGED
@@ -28,7 +28,9 @@ class SimpleCommentsLogger extends SimpleLogger
28
  */
29
  function maybe_modify_log_query_sql_where($where) {
30
 
31
- $include_spam = false;
 
 
32
 
33
  /**
34
  * Filter option to include spam or not in the gui
28
  */
29
  function maybe_modify_log_query_sql_where($where) {
30
 
31
+ // since 19 sept 2016 we do include spam, to skip the subquery
32
+ // spam comments should not be logged anyway since some time
33
+ $include_spam = true;
34
 
35
  /**
36
  * Filter option to include spam or not in the gui
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, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
5
  Requires at least: 4.5.1
6
  Tested up to: 4.6
7
- Stable tag: 2.11
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
@@ -153,6 +153,13 @@ A simple way to see any uncommon activity, for example an increased number of lo
153
 
154
  ## Changelog
155
 
 
 
 
 
 
 
 
156
  = 2.11 (September 2016) =
157
 
158
  - Added support for plugin [Redirection](https://wordpress.org/plugins/redirection/).
4
  Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
5
  Requires at least: 4.5.1
6
  Tested up to: 4.6
7
+ Stable tag: 2.12
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
153
 
154
  ## Changelog
155
 
156
+ = 2.12 (September 2016) =
157
+
158
+ - You can show a different number of log items in the log on the dashboard and on the dedicated history page. By default the dashboard will show 5 items and the page will show 30.
159
+ - On multisites the user search filter now only search users in the current site.
160
+ - The statistics chart using Chart.js now uses the namespace window.Simple_History_Chart instead of window.Chart, decreasing the risk that two versions of the Chart.js library overwriting each others. Fixes https://wordpress.org/support/topic/comet-cache-breaks-simple-history/. (Note to future me: this was fixed by renaming the `window.chart` variable to `window.chart.Simple_history_chart` in the line `window.Chart = module.exports = Chart;`)
161
+ - If spam comments are logged they are now included in the log. Change made to make sql query shorter and easier. Should not actually show any spam comments anyway because we don't log them since version 2.5.5 anyway. If you want to revert this behavior for some reason you can use the filter `simple_history/comments_logger/include_spam`.
162
+
163
  = 2.11 (September 2016) =
164
 
165
  - Added support for plugin [Redirection](https://wordpress.org/plugins/redirection/).