Simple History - Version 1.3

Version Description

  • Added: history events can store text description with a more detailed explanation of the history item
  • Added: now logs failed login attempts for existing username. Uses the new text description to store more info, for example user agent and remote ip address (REMOTE_ADDR)
  • Fixed: box did not change height when clicking on occasions
  • Fixed: use on() instead of live() in JavaScript
Download this release

Release Info

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

Code changes from version 1.2 to 1.3

Files changed (7) hide show
  1. index.php +116 -25
  2. readme.txt +39 -16
  3. screenshot-1.png +0 -0
  4. screenshot-2.png +0 -0
  5. screenshot-3.png +0 -0
  6. scripts.js +38 -7
  7. styles.css +82 -15
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Simple History
4
  Plugin URI: http://eskapism.se/code-playground/simple-history/
5
  Description: Get a log/history/audit log/version history of the changes made by users in WordPress.
6
- Version: 1.2
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
@@ -27,8 +27,8 @@ License: GPL2
27
 
28
  load_plugin_textdomain('simple-history', false, "/simple-history/languages");
29
 
30
- define( "SIMPLE_HISTORY_VERSION", "1.2");
31
- define( "SIMPLE_HISTORY_NAME", "Simple History");
32
 
33
  // Find the plugin directory URL
34
  $aa = __FILE__;
@@ -249,10 +249,13 @@ define("SIMPLE_HISTORY_URL", $plugin_dir_url);
249
 
250
  // DB version is 1, upgrade to 2
251
  if ( 1 == intval($db_version) ) {
252
-
253
- // Add column for free text
254
- // require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
255
- // update_option("simple_history_db_version", 2);
 
 
 
256
 
257
  }
258
 
@@ -301,11 +304,51 @@ define("SIMPLE_HISTORY_URL", $plugin_dir_url);
301
 
302
  }
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  function init() {
305
 
306
- // users and stuff
307
  add_action("wp_login", "simple_history_wp_login");
308
  add_action("wp_logout", "simple_history_wp_logout");
 
 
 
 
 
 
309
  add_action("delete_user", "simple_history_delete_user");
310
  add_action("user_register", "simple_history_user_register");
311
  add_action("profile_update", "simple_history_profile_update");
@@ -440,7 +483,7 @@ define("SIMPLE_HISTORY_URL", $plugin_dir_url);
440
  if ( ! $user_obj->exists() ) exit;
441
  $user = $user_obj->user_login;
442
  };
443
-
444
  // page to show. 1 = first page.
445
  $page = 0;
446
  if (isset($_POST["page"])) {
@@ -946,16 +989,18 @@ function simple_history_add($args) {
946
  "object_id" => null,
947
  "object_name" => null,
948
  "user_id" => null,
 
949
  );
950
 
951
  $args = wp_parse_args( $args, $defaults );
952
 
953
  $action = mysql_real_escape_string($args["action"]);
954
- $object_type = $args["object_type"];
955
- $object_subtype = $args["object_subtype"];
956
- $object_id = $args["object_id"];
957
  $object_name = mysql_real_escape_string($args["object_name"]);
958
  $user_id = $args["user_id"];
 
959
 
960
  global $wpdb;
961
  $tableprefix = $wpdb->prefix;
@@ -965,14 +1010,25 @@ function simple_history_add($args) {
965
  $current_user = wp_get_current_user();
966
  $current_user_id = (int) $current_user->ID;
967
  }
968
-
969
  // date, store at utc or local time
970
  // anything is better than now() anyway!
971
  // WP seems to use the local time, so I will go with that too I think
972
  // GMT/UTC-time is: date_i18n($timezone_format, false, 'gmt'));
973
  // local time is: date_i18n($timezone_format));
974
  $localtime = current_time("mysql");
975
- $sql = "INSERT INTO {$tableprefix}simple_history SET date = '$localtime', action = '$action', object_type = '$object_type', object_subtype = '$object_subtype', user_id = '$current_user_id', object_id = '$object_id', object_name = '$object_name'";
 
 
 
 
 
 
 
 
 
 
 
976
  $wpdb->query($sql);
977
  }
978
 
@@ -1514,6 +1570,8 @@ function simple_history_get_items_array($args = "") {
1514
  $do_add = TRUE;
1515
  } else if (strpos(strtolower($one_row->action), $search) !== FALSE) {
1516
  $do_add = TRUE;
 
 
1517
  }
1518
  } else {
1519
  $do_add = TRUE;
@@ -1578,6 +1636,7 @@ function simple_history_print_history($args = null) {
1578
  global $simple_history;
1579
 
1580
  $arr_events = simple_history_get_items_array($args);
 
1581
  #sf_d($args);sf_d($arr_events);
1582
  $defaults = array(
1583
  "page" => 0,
@@ -1608,6 +1667,7 @@ function simple_history_print_history($args = null) {
1608
  $object_name = $one_row->object_name;
1609
  $user_id = $one_row->user_id;
1610
  $action = $one_row->action;
 
1611
  $occasions = $one_row->occasions;
1612
  $num_occasions = sizeof($occasions);
1613
  $object_image_out = "";
@@ -1814,15 +1874,6 @@ function simple_history_print_history($args = null) {
1814
  $user_out .= " \"" . esc_html($object_name) . "\"";
1815
  }
1816
 
1817
- /*
1818
- $user_avatar = get_avatar($user->user_email, "50");
1819
- if ($user_link) {
1820
- $user_out .= "<a class='simple-history-attachment-thumbnail' href='$user_link'>$user_avatar</a>";
1821
- } else {
1822
- $user_out .= "<span class='simple-history-attachment-thumbnail' href='$user_link'>$user_avatar</span>";
1823
- }
1824
- */
1825
-
1826
  $user_out .= " " . esc_html__($action, "simple-history");
1827
 
1828
  $user_out = ucfirst($user_out);
@@ -1868,6 +1919,20 @@ function simple_history_print_history($args = null) {
1868
  $diff_str = sprintf( __('<span class="when">%1$s ago</span> by %2$s', "simple-history"), human_time_diff(strtotime($one_row->date), $now), $who );
1869
  $output .= $diff_str;
1870
  $output .= "<span class='when_detail'>".sprintf(__('%s at %s', 'simple-history'), $date_i18n_date, $date_i18n_time)."</span>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1871
 
1872
  $output .= "</div>";
1873
 
@@ -1895,16 +1960,42 @@ function simple_history_print_history($args = null) {
1895
  $many_occasion = sprintf(__("+ %d occasions", 'simple-history'), $num_occasions);
1896
  $output .= "<a class='simple-history-occasion-show' href='#'>$many_occasion</a>";
1897
  }
 
1898
  $output .= "<ul class='simple-history-occasions hidden'>";
1899
  foreach ($occasions as $one_occasion) {
 
1900
  $output .= "<li>";
 
1901
  $date_i18n_date = date_i18n(get_option('date_format'), strtotime($one_occasion->date), $gmt=false);
1902
  $date_i18n_time = date_i18n(get_option('time_format'), strtotime($one_occasion->date), $gmt=false);
1903
- $output .= sprintf( __('%s ago (%s at %s)', "simple-history"), human_time_diff(strtotime($one_occasion->date), $now), $date_i18n_date, $date_i18n_time );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1904
 
1905
  $output .= "</li>";
1906
  }
 
1907
  $output .= "</ul>";
 
1908
  $output .= "</div>";
1909
  }
1910
 
@@ -1945,7 +2036,7 @@ function simple_history_print_history($args = null) {
1945
  $output .= "</div>";
1946
 
1947
  $output .= "
1948
- <p class='hidden simple-history-no-more-items'>$no_found</p>
1949
  <p class='simple-history-rss-feed-dashboard'><a title='$view_rss' href='$view_rss_link'>$view_rss</a></p>
1950
  <p class='simple-history-rss-feed-page'><a title='$view_rss' href='$view_rss_link'><span></span>$view_rss</a></p>
1951
  ";
3
  Plugin Name: Simple History
4
  Plugin URI: http://eskapism.se/code-playground/simple-history/
5
  Description: Get a log/history/audit log/version history of the changes made by users in WordPress.
6
+ Version: 1.3
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
27
 
28
  load_plugin_textdomain('simple-history', false, "/simple-history/languages");
29
 
30
+ define( "SIMPLE_HISTORY_VERSION", "1.3");
31
+ define( "SIMPLE_HISTORY_NAME", "Simple History");
32
 
33
  // Find the plugin directory URL
34
  $aa = __FILE__;
249
 
250
  // DB version is 1, upgrade to 2
251
  if ( 1 == intval($db_version) ) {
252
+
253
+ // Add column for action description in non-translateable free text
254
+ $sql = "ALTER TABLE {$table_name} ADD COLUMN action_description longtext";
255
+ mysql_query($sql);
256
+
257
+ simple_history_add("action=" . 'upgraded it\'s database' . "&object_type=plugin&object_name=" . SIMPLE_HISTORY_NAME . "&description=Database version is now version 2");
258
+ update_option("simple_history_db_version", 2);
259
 
260
  }
261
 
304
 
305
  }
306
 
307
+ /**
308
+ * Log failed login attempt to username that exists
309
+ */
310
+ function log_wp_authenticate_user($user, $password) {
311
+
312
+ if ( ! wp_check_password($password, $user->user_pass, $user->ID) ) {
313
+
314
+ // call __() to make translation exist
315
+ __("failed to log in because they entered the wrong password", "simple-history");
316
+
317
+ $description = "";
318
+ $description .= "HTTP_USER_AGENT: " . $_SERVER["HTTP_USER_AGENT"];
319
+ $description .= "\nHTTP_REFERER: " . $_SERVER["HTTP_REFERER"];
320
+ $description .= "\nREMOTE_ADDR: " . $_SERVER["REMOTE_ADDR"];
321
+
322
+ $args = array(
323
+ "object_type" => "user",
324
+ "object_name" => $user->user_login,
325
+ "action" => "failed to log in because they entered the wrong password",
326
+ "object_id" => $user->ID,
327
+ "description" => $description
328
+ );
329
+
330
+ simple_history_add($args);
331
+
332
+ }
333
+
334
+ return $user;
335
+
336
+ }
337
+
338
+ /**
339
+ * Init for both public and admin
340
+ */
341
  function init() {
342
 
343
+ // user login and logout
344
  add_action("wp_login", "simple_history_wp_login");
345
  add_action("wp_logout", "simple_history_wp_logout");
346
+
347
+ // user failed login attempt to username that exists
348
+ #$user = apply_filters('wp_authenticate_user', $user, $password);
349
+ add_action("wp_authenticate_user", array($this, "log_wp_authenticate_user"), 10, 2);
350
+
351
+ // user profile page modifications
352
  add_action("delete_user", "simple_history_delete_user");
353
  add_action("user_register", "simple_history_user_register");
354
  add_action("profile_update", "simple_history_profile_update");
483
  if ( ! $user_obj->exists() ) exit;
484
  $user = $user_obj->user_login;
485
  };
486
+
487
  // page to show. 1 = first page.
488
  $page = 0;
489
  if (isset($_POST["page"])) {
989
  "object_id" => null,
990
  "object_name" => null,
991
  "user_id" => null,
992
+ "description" => null
993
  );
994
 
995
  $args = wp_parse_args( $args, $defaults );
996
 
997
  $action = mysql_real_escape_string($args["action"]);
998
+ $object_type = mysql_real_escape_string($args["object_type"]);
999
+ $object_subtype = mysql_real_escape_string($args["object_subtype"]);
1000
+ $object_id = mysql_real_escape_string($args["object_id"]);
1001
  $object_name = mysql_real_escape_string($args["object_name"]);
1002
  $user_id = $args["user_id"];
1003
+ $description = mysql_real_escape_string($args["description"]);
1004
 
1005
  global $wpdb;
1006
  $tableprefix = $wpdb->prefix;
1010
  $current_user = wp_get_current_user();
1011
  $current_user_id = (int) $current_user->ID;
1012
  }
1013
+
1014
  // date, store at utc or local time
1015
  // anything is better than now() anyway!
1016
  // WP seems to use the local time, so I will go with that too I think
1017
  // GMT/UTC-time is: date_i18n($timezone_format, false, 'gmt'));
1018
  // local time is: date_i18n($timezone_format));
1019
  $localtime = current_time("mysql");
1020
+ $sql = "
1021
+ INSERT INTO {$tableprefix}simple_history
1022
+ SET
1023
+ date = '$localtime',
1024
+ action = '$action',
1025
+ object_type = '$object_type',
1026
+ object_subtype = '$object_subtype',
1027
+ user_id = '$current_user_id',
1028
+ object_id = '$object_id',
1029
+ object_name = '$object_name',
1030
+ action_description = '$description'
1031
+ ";
1032
  $wpdb->query($sql);
1033
  }
1034
 
1570
  $do_add = TRUE;
1571
  } else if (strpos(strtolower($one_row->action), $search) !== FALSE) {
1572
  $do_add = TRUE;
1573
+ } else if (strpos(strtolower($one_row->action_description), $search) !== FALSE) {
1574
+ $do_add = TRUE;
1575
  }
1576
  } else {
1577
  $do_add = TRUE;
1636
  global $simple_history;
1637
 
1638
  $arr_events = simple_history_get_items_array($args);
1639
+ #sf_d($arr_events);
1640
  #sf_d($args);sf_d($arr_events);
1641
  $defaults = array(
1642
  "page" => 0,
1667
  $object_name = $one_row->object_name;
1668
  $user_id = $one_row->user_id;
1669
  $action = $one_row->action;
1670
+ $action_description = $one_row->action_description;
1671
  $occasions = $one_row->occasions;
1672
  $num_occasions = sizeof($occasions);
1673
  $object_image_out = "";
1874
  $user_out .= " \"" . esc_html($object_name) . "\"";
1875
  }
1876
 
 
 
 
 
 
 
 
 
 
1877
  $user_out .= " " . esc_html__($action, "simple-history");
1878
 
1879
  $user_out = ucfirst($user_out);
1919
  $diff_str = sprintf( __('<span class="when">%1$s ago</span> by %2$s', "simple-history"), human_time_diff(strtotime($one_row->date), $now), $who );
1920
  $output .= $diff_str;
1921
  $output .= "<span class='when_detail'>".sprintf(__('%s at %s', 'simple-history'), $date_i18n_date, $date_i18n_time)."</span>";
1922
+
1923
+ // action description
1924
+ if ( trim( $action_description ) ) {
1925
+ $output .= sprintf(
1926
+ '
1927
+ <a href="#" class="simple-history-item-description-toggler">%2$s</a>
1928
+ <div class="simple-history-item-description-wrap">
1929
+ <div class="simple-history-action-description">%1$s</div>
1930
+ </div>
1931
+ ',
1932
+ nl2br( esc_attr( $action_description ) ), // 2
1933
+ __("Details", "simple-history") // 2
1934
+ );
1935
+ }
1936
 
1937
  $output .= "</div>";
1938
 
1960
  $many_occasion = sprintf(__("+ %d occasions", 'simple-history'), $num_occasions);
1961
  $output .= "<a class='simple-history-occasion-show' href='#'>$many_occasion</a>";
1962
  }
1963
+
1964
  $output .= "<ul class='simple-history-occasions hidden'>";
1965
  foreach ($occasions as $one_occasion) {
1966
+
1967
  $output .= "<li>";
1968
+
1969
  $date_i18n_date = date_i18n(get_option('date_format'), strtotime($one_occasion->date), $gmt=false);
1970
  $date_i18n_time = date_i18n(get_option('time_format'), strtotime($one_occasion->date), $gmt=false);
1971
+
1972
+ $output .= "<div class='simple-history-occasions-one-when'>";
1973
+ $output .= sprintf(
1974
+ __('%s ago (%s at %s)', "simple-history"),
1975
+ human_time_diff(strtotime($one_occasion->date), $now),
1976
+ $date_i18n_date,
1977
+ $date_i18n_time
1978
+ );
1979
+
1980
+ if ( trim( $one_occasion->action_description ) ) {
1981
+ $output .= "<a href='#' class='simple-history-occasions-details-toggle'>" . __("Details", "simple-history") . "</a>";
1982
+ }
1983
+
1984
+ $output .= "</div>";
1985
+
1986
+ if ( trim( $one_occasion->action_description ) ) {
1987
+ $output .= sprintf(
1988
+ '<div class="simple-history-occasions-one-action-description">%1$s</div>',
1989
+ nl2br( esc_attr( $one_occasion->action_description ) )
1990
+ );
1991
+ }
1992
+
1993
 
1994
  $output .= "</li>";
1995
  }
1996
+
1997
  $output .= "</ul>";
1998
+
1999
  $output .= "</div>";
2000
  }
2001
 
2036
  $output .= "</div>";
2037
 
2038
  $output .= "
2039
+ <p class='simple-history-no-more-items'>$no_found</p>
2040
  <p class='simple-history-rss-feed-dashboard'><a title='$view_rss' href='$view_rss_link'>$view_rss</a></p>
2041
  <p class='simple-history-rss-feed-page'><a title='$view_rss' href='$view_rss_link'><span></span>$view_rss</a></p>
2042
  ";
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
5
  Requires at least: 3.5.1
6
  Tested up to: 3.5.1
7
- Stable tag: 1.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
 
@@ -16,15 +16,26 @@ The plugin works as a log/history/audit log/version history of the most importan
16
 
17
  Out of the box Simple History has support for:
18
 
19
- * **Posts and pages** - see who added, updated or deleted a post or page
20
- * **Attachments** - see who added, updated or deleted an attachment
21
- * **Comments** - see who edited, approved or removed a comment
22
- * **Widgets** - get info when someone adds, updates or removes a widget in a sidebar
23
- * **Plugins** - activation and deactivation
24
- * **User profiles** - info about added, updated or removed users
25
- * **User logins** - see when a user login & logut
26
- * **bbPress** - view changes to forums and topics and view user changes
27
- * **Gravity Forms** - see who created, edited or deleted a form, field, or entry
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  With it's easy to use Extender system, developers can add their own settings and items to track.
30
 
@@ -62,8 +73,8 @@ if (function_exists("simple_history_add")) {
62
  # Log that an email has been sent
63
  simple_history_add(array(
64
  "object_type" => "Email",
65
- "action" => "sent",
66
- "object_name" => "Hi there"
67
  ));
68
 
69
  # Will show “Plugin your_plugin_name Edited” in the history log
@@ -71,7 +82,15 @@ if (function_exists("simple_history_add")) {
71
 
72
  # Will show the history item "Starship USS Enterprise repaired"
73
  simple_history_add("action=repaired&object_type=Starship&object_name=USS Enterprise");
74
-
 
 
 
 
 
 
 
 
75
  ?>
76
  `
77
 
@@ -146,18 +165,22 @@ I can do something about it.
146
 
147
  == Screenshots ==
148
 
149
- 1. Simple History showing som recent changes to my posts, users and attachments.
150
 
151
  2. Simple History settings. Choose to show the plugin on your dashboard, or as a separately page. Or both. Or none, since you can choose
152
  to only use the secret RSS feed to keep track of the changes on you web site/WordPress installation.
153
 
154
  3. The RSS feed with changes, as shown in Firefox.
155
 
156
- 4. Widgets can be tracked too!
157
-
158
 
159
  == Changelog ==
160
 
 
 
 
 
 
 
161
  = 1.2 =
162
  - Fixed: Plugin name is included when plugins is activated or deactivated. Previosuly only folder name and name of php file was included.
163
  - Added: Attachment thumbnails are now visible if history item is an attachment. Also includes some metadata.
4
  Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin, syslog
5
  Requires at least: 3.5.1
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.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
 
16
 
17
  Out of the box Simple History has support for:
18
 
19
+ * **Posts and pages**<br>
20
+ see who added, updated or deleted a post or page
21
+ * **Attachments**<br>
22
+ see who added, updated or deleted an attachment
23
+ * **Comments**<br>
24
+ see who edited, approved or removed a comment
25
+ * **Widgets**<br>
26
+ get info when someone adds, updates or removes a widget in a sidebar
27
+ * **Plugins**<br>
28
+ activation and deactivation
29
+ * **User profiles**<br>
30
+ info about added, updated or removed users
31
+ * **User logins**<br>
32
+ see when a user login & logut
33
+ * **Failed user logins**<br>
34
+ see when someone has tried to log in, but failed. The log will then include ip address of the possible hacker.
35
+ * **bbPress**<br>
36
+ view changes to forums and topics and view user changes
37
+ * **Gravity Forms**<br>
38
+ see who created, edited or deleted a form, field, or entry
39
 
40
  With it's easy to use Extender system, developers can add their own settings and items to track.
41
 
73
  # Log that an email has been sent
74
  simple_history_add(array(
75
  "object_type" => "Email",
76
+ "object_name" => "Hi there",
77
+ "action" => "was sent"
78
  ));
79
 
80
  # Will show “Plugin your_plugin_name Edited” in the history log
82
 
83
  # Will show the history item "Starship USS Enterprise repaired"
84
  simple_history_add("action=repaired&object_type=Starship&object_name=USS Enterprise");
85
+
86
+ # Log with some extra details about the email
87
+ simple_history_add(array(
88
+ "object_type" => "Email",
89
+ "object_name" => "Hi there",
90
+ "action" => "was sent",
91
+ "description" => "The database query to generate the email took .3 seconds. This is email number 4 that is sent to this user"
92
+ ));
93
+
94
  ?>
95
  `
96
 
165
 
166
  == Screenshots ==
167
 
168
+ 1. Simple History showing som recent changes to my posts, users and attachments. Also showing several failed login attempts to one of my users.
169
 
170
  2. Simple History settings. Choose to show the plugin on your dashboard, or as a separately page. Or both. Or none, since you can choose
171
  to only use the secret RSS feed to keep track of the changes on you web site/WordPress installation.
172
 
173
  3. The RSS feed with changes, as shown in Firefox.
174
 
 
 
175
 
176
  == Changelog ==
177
 
178
+ = 1.3 =
179
+ - Added: history events can store text description with a more detailed explanation of the history item
180
+ - Added: now logs failed login attempts for existing username. Uses the new text description to store more info, for example user agent and remote ip address (REMOTE_ADDR)
181
+ - Fixed: box did not change height when clicking on occasions
182
+ - Fixed: use on() instead of live() in JavaScript
183
+
184
  = 1.2 =
185
  - Fixed: Plugin name is included when plugins is activated or deactivated. Previosuly only folder name and name of php file was included.
186
  - Added: Attachment thumbnails are now visible if history item is an attachment. Also includes some metadata.
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
scripts.js CHANGED
@@ -18,11 +18,17 @@ var simple_history = (function($) {
18
  elms.ol_wrapper = elms.wrap.find(".simple-history-ol-wrapper");
19
 
20
  // so wrapper does not collapse when loading new items
21
- elms.ol_wrapper.height( elms.ol_wrapper.height() );
 
22
 
23
  addListeners();
24
 
25
  elms.wrap.addClass("simple-history-is-ready simple-history-has-items");
 
 
 
 
 
26
  }
27
 
28
  function addListeners() {
@@ -57,9 +63,30 @@ var simple_history = (function($) {
57
  }
58
 
59
  // show occasions
60
- $("a.simple-history-occasion-show").live("click", function(e) {
61
- $(this).closest("li").find("ul.simple-history-occasions").toggle("fast");
 
 
 
 
62
  e.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  });
64
 
65
 
@@ -115,7 +142,8 @@ jQuery(document).on("keyup", ".simple-history-filter-search input[type='text'],
115
 
116
  // click on filter-link/change value is filter dropdowns = load new via ajax
117
  // begin at position 0 unless click on pagination then check pagination page
118
- jQuery("select.simple-history-filter, .simple-history-filter a, .simple-history-filter input[type='button'], .simple-history-tablenav a").live("click change", function(e, extraParams) {
 
119
 
120
  var $t = jQuery(this),
121
  $ol = jQuery("ol.simple-history"),
@@ -190,12 +218,13 @@ jQuery("select.simple-history-filter, .simple-history-filter a, .simple-history-
190
  }
191
 
192
  simple_history_jqXHR = jQuery.post(ajaxurl, data, function(data, textStatus, XMLHttpRequest){
193
-
194
  // If no more can be loaded show message about that
195
  if (data.error == "noMoreItems") {
196
-
197
  jQuery(".simple-history-ol-wrapper").height("auto");
198
  $simple_history_wrap.removeClass("simple-history-has-items simple-history-is-loading");
 
199
 
200
  $displaying_num.html(0);
201
  $total_pages.text(1);
@@ -203,6 +232,7 @@ jQuery("select.simple-history-filter, .simple-history-filter a, .simple-history-
203
  } else {
204
 
205
  // Items found, add and show
 
206
 
207
  // update number of existing items and total pages
208
  $displaying_num.html(data.filtered_items_total_count_string);
@@ -211,7 +241,8 @@ jQuery("select.simple-history-filter, .simple-history-filter a, .simple-history-
211
  $ol.html(data.items_li);
212
 
213
  // set wrapper to the height required to show items
214
- $wrapper.height( $ol.height() );
 
215
  $simple_history_wrap.removeClass("simple-history-is-loading");
216
 
217
  }
18
  elms.ol_wrapper = elms.wrap.find(".simple-history-ol-wrapper");
19
 
20
  // so wrapper does not collapse when loading new items
21
+ //elms.ol_wrapper.height( elms.ol_wrapper.height() );
22
+ elms.ol_wrapper.css("max-height", elms.ol_wrapper.height() );
23
 
24
  addListeners();
25
 
26
  elms.wrap.addClass("simple-history-is-ready simple-history-has-items");
27
+
28
+ }
29
+
30
+ function make_wrapper_expandable() {
31
+ elms.ol_wrapper.css("max-height", "1000px");
32
  }
33
 
34
  function addListeners() {
63
  }
64
 
65
  // show occasions
66
+ $(document).on("click", "a.simple-history-occasion-show", function(e) {
67
+
68
+ $(this).closest("li").find("ul.simple-history-occasions").toggle();
69
+
70
+ make_wrapper_expandable();
71
+
72
  e.preventDefault();
73
+
74
+ });
75
+
76
+ // show details for main entry
77
+ $(document).on("click", ".simple-history-item-description-toggler", function(e) {
78
+ e.preventDefault();
79
+ var self = $(this);
80
+ make_wrapper_expandable();
81
+ self.closest("li").toggleClass("simple-history-item-description-wrap-is-open");
82
+ });
83
+
84
+ // show details for occasions
85
+ $(document).on("click", ".simple-history-occasions-details-toggle", function(e) {
86
+ e.preventDefault();
87
+ var self = $(this);
88
+ make_wrapper_expandable();
89
+ self.closest("li").toggleClass("simple-history-occasions-one-description-is-open");
90
  });
91
 
92
 
142
 
143
  // click on filter-link/change value is filter dropdowns = load new via ajax
144
  // begin at position 0 unless click on pagination then check pagination page
145
+ //jQuery("select.simple-history-filter, .simple-history-filter a, .simple-history-filter input[type='button'], .simple-history-tablenav a").live("click change", function(e, extraParams) {
146
+ jQuery(document).on("click change", "select.simple-history-filter, .simple-history-filter a, .simple-history-filter input[type='button'], .simple-history-tablenav a", function(e, extraParams) {
147
 
148
  var $t = jQuery(this),
149
  $ol = jQuery("ol.simple-history"),
218
  }
219
 
220
  simple_history_jqXHR = jQuery.post(ajaxurl, data, function(data, textStatus, XMLHttpRequest){
221
+
222
  // If no more can be loaded show message about that
223
  if (data.error == "noMoreItems") {
224
+
225
  jQuery(".simple-history-ol-wrapper").height("auto");
226
  $simple_history_wrap.removeClass("simple-history-has-items simple-history-is-loading");
227
+ $simple_history_wrap.addClass("simple-history-no-items-found");
228
 
229
  $displaying_num.html(0);
230
  $total_pages.text(1);
232
  } else {
233
 
234
  // Items found, add and show
235
+ $simple_history_wrap.removeClass("simple-history-is-loading simple-history-no-items-found");
236
 
237
  // update number of existing items and total pages
238
  $displaying_num.html(data.filtered_items_total_count_string);
241
  $ol.html(data.items_li);
242
 
243
  // set wrapper to the height required to show items
244
+ //$wrapper.height( $ol.height() );
245
+ $wrapper.css( "max-height", $ol.height() );
246
  $simple_history_wrap.removeClass("simple-history-is-loading");
247
 
248
  }
styles.css CHANGED
@@ -54,15 +54,16 @@ ol.simple-history .first {
54
 
55
  ol.simple-history .second {
56
  color: #999;
 
57
  }
58
 
59
  ol.simple-history .third {
60
  margin-top: .5em;
61
  }
62
- ol.simple-history .third ul {
63
  margin-top: .5em;
64
  }
65
-
66
  .simple-history-who-avatar {
67
  position: absolute;
68
  top: 10px;
@@ -123,6 +124,57 @@ ol.simple-history .simple-history-has-attachment-thumnbail .third
123
  margin: 0 0 .5em 0;
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
  .simple-history-title {
128
  font-weight: bold;
@@ -138,24 +190,17 @@ ol.simple-history .simple-history-has-attachment-thumnbail .third
138
  }
139
 
140
  ul.simple-history-occasions {
141
- margin: 0 0 0 1em;
142
  padding: 0;
143
  list-style-type: none;
144
- color: #999999;
145
  }
146
  ul.simple-history-occasions li {
147
- margin: 0;
148
  padding: 0;
149
  line-height: 1.5;
150
  }
151
 
152
- .simple-history-no-more-items {
153
- padding: .5em;
154
- background-color: #FFFFE0;
155
- border: 1px solid #E6DB55;
156
- font-weight: bold;
157
- }
158
-
159
  .simple-history-rss-feed-dashboard {
160
  display: none;
161
  }
@@ -221,6 +266,22 @@ ul.simple-history-occasions li {
221
  visibility: visible;
222
  }
223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  .simple-history-tablenav .tablenav-pages {
225
  float: none;
226
  }
@@ -289,19 +350,25 @@ ul.simple-history-occasions li {
289
  opacity: .75;
290
  }
291
 
292
-
293
  .simple-history-ol-wrapper {
294
  overflow: hidden;
295
  }
296
 
 
 
 
 
297
  .simple-history-wrap,
298
  .simple-history-ol-wrapper,
299
  ol.simple-history,
300
- .simple-history-tablenav
301
- {
302
  transition: all .15s ease-out;
303
  }
304
 
 
 
 
 
305
  .simple-history-is-loading ol.simple-history {
306
  opacity: 0;
307
  }
54
 
55
  ol.simple-history .second {
56
  color: #999;
57
+ margin-top: .5em;
58
  }
59
 
60
  ol.simple-history .third {
61
  margin-top: .5em;
62
  }
63
+ /*ol.simple-history .third ul {
64
  margin-top: .5em;
65
  }
66
+ */
67
  .simple-history-who-avatar {
68
  position: absolute;
69
  top: 10px;
124
  margin: 0 0 .5em 0;
125
  }
126
 
127
+ .simple-history-item-description-wrap {
128
+ margin: 0.5em 0;
129
+ }
130
+
131
+
132
+ .simple-history-item-description-toggler {
133
+ border-left: 1px solid #bbb;
134
+ padding-left: .75em;
135
+ margin-left: .75em;
136
+ line-height: 1;
137
+ }
138
+
139
+ .simple-history-item-description-toggler:before {
140
+ /*content: "+ ";*/
141
+ }
142
+
143
+ .simple-history-action-description,
144
+ .simple-history-occasions-one-action-description {
145
+ margin: .75em 0 .75em .5ex;
146
+ line-height: 1.4;
147
+ display: none;
148
+ background-color: #ddd;
149
+ padding: .5em;
150
+ }
151
+
152
+ .simple-history-item-description-wrap-is-open .simple-history-item-description-toggler:before {
153
+ /*content: "- ";*/
154
+ }
155
+
156
+ .simple-history-item-description-wrap-is-open .simple-history-action-description{
157
+ display: block;
158
+ }
159
+
160
+ .simple-history-occasions-details-toggle {
161
+ margin-left: .75em;
162
+ padding-left: .75em;
163
+ border-left: 1px solid #bbb;
164
+ }
165
+
166
+
167
+ .simple-history-occasions-one-description-is-open .simple-history-occasions-one-action-description {
168
+ display: block;
169
+ margin-left: 2em;
170
+ }
171
+
172
+
173
+ .simple-history-occasions-one-action-description {
174
+ display: none;
175
+ }
176
+
177
+ .simple-history-occasions-details-toggle
178
 
179
  .simple-history-title {
180
  font-weight: bold;
190
  }
191
 
192
  ul.simple-history-occasions {
193
+ margin: 1em 0 0 1em;
194
  padding: 0;
195
  list-style-type: none;
196
+ color: #999;
197
  }
198
  ul.simple-history-occasions li {
199
+ margin: .5em 0;
200
  padding: 0;
201
  line-height: 1.5;
202
  }
203
 
 
 
 
 
 
 
 
204
  .simple-history-rss-feed-dashboard {
205
  display: none;
206
  }
266
  visibility: visible;
267
  }
268
 
269
+ .simple-history-no-more-items {
270
+ padding: .5em;
271
+ background-color: #FFFFE0;
272
+ border: 1px solid #E6DB55;
273
+ font-weight: bold;
274
+ display: none;
275
+ }
276
+
277
+ .simple-history-no-items-found .simple-history-no-more-items {
278
+ display: block;
279
+ }
280
+
281
+ .simple-history-no-items-found .simple-history-ol-wrapper {
282
+ display: none;
283
+ }
284
+
285
  .simple-history-tablenav .tablenav-pages {
286
  float: none;
287
  }
350
  opacity: .75;
351
  }
352
 
 
353
  .simple-history-ol-wrapper {
354
  overflow: hidden;
355
  }
356
 
357
+ .simple-history-ol-wrapper {
358
+ /*overflow: visible;*/
359
+ }
360
+
361
  .simple-history-wrap,
362
  .simple-history-ol-wrapper,
363
  ol.simple-history,
364
+ .simple-history-tablenav {
 
365
  transition: all .15s ease-out;
366
  }
367
 
368
+ .simple-history-ol-wrapper {
369
+ xtransition: max-height .15s ease-out;
370
+ }
371
+
372
  .simple-history-is-loading ol.simple-history {
373
  opacity: 0;
374
  }