Simple History - Version 1.3.4

Version Description

  • Changed the way post types show in the dropdown. Now uses plural names + not prefixed with main post type. Looks better I think. Thank to Hassan for the suggestion!
  • Added "bytes" to size units that an attachment can have. Also fixes undefined notice warning when attachment had a size less that 1 KB.
Download this release

Release Info

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

Code changes from version 1.3.3 to 1.3.4

Files changed (2) hide show
  1. index.php +26 -49
  2. readme.txt +5 -1
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.3.3
7
  Author: Pär Thernström
8
  Author URI: http://eskapism.se/
9
  License: GPL2
@@ -27,7 +27,7 @@ License: GPL2
27
 
28
  load_plugin_textdomain('simple-history', false, "/simple-history/languages");
29
 
30
- define( "SIMPLE_HISTORY_VERSION", "1.3.3");
31
  define( "SIMPLE_HISTORY_NAME", "Simple History");
32
 
33
  // Find the plugin directory URL
@@ -1188,10 +1188,6 @@ function simple_history_print_nav() {
1188
  $css = "class='selected'";
1189
  }
1190
 
1191
- // Begin list
1192
- $str_types = "";
1193
- $str_types .= "<ul class='simple-history-filter simple-history-filter-type'>";
1194
-
1195
  // Begin select
1196
  $str_types_select = "";
1197
  $str_types_select .= "<select name='' class='simple-history-filter simple-history-filter-type'>";
@@ -1204,7 +1200,6 @@ function simple_history_print_nav() {
1204
  // First filter is "all types"
1205
  $link = esc_html(add_query_arg("simple_history_type_to_show", ""));
1206
  $str_types_desc = __("All types", 'simple-history');
1207
- $str_types .= "<li $css><a data-simple-history-filter-type='' href='$link'>" . esc_html($str_types_desc) . " <span>($total_object_num_count)</span></a> | </li>";
1208
 
1209
  $str_types_select .= sprintf('<option data-simple-history-filter-type="" data-simple-history-filter-subtype="" value="%1$s">%2$s (%3$d)</option>', $link, esc_html($str_types_desc), $total_object_num_count );
1210
 
@@ -1224,9 +1219,6 @@ function simple_history_print_nav() {
1224
  $option_selected = " selected ";
1225
  }
1226
 
1227
- // Begin LI
1228
- $str_types .= sprintf('<li %1$s data-simple-history-filter-type="%2$s" data-simple-history-filter-subtype="%3$s" >', $css, $one_type->object_type, $one_type->object_subtype);
1229
-
1230
  // Create link to filter this type + subtype
1231
  $arg = "";
1232
  if ($one_type->object_subtype) {
@@ -1235,7 +1227,6 @@ function simple_history_print_nav() {
1235
  $arg = $one_type->object_type;
1236
  }
1237
  $link = esc_html(add_query_arg("simple_history_type_to_show", $arg));
1238
- $str_types .= "<a href='$link'>";
1239
 
1240
  // Begin option
1241
  $str_types_select .= sprintf(
@@ -1248,7 +1239,6 @@ function simple_history_print_nav() {
1248
 
1249
  // Some built in types we translate with built in translation, the others we use simple history for
1250
  // TODO: use WP-function to get all built in types?
1251
- $arr_built_in_types_with_translation = array("page", "post");
1252
  $object_type_translated = "";
1253
  $object_subtype_translated = "";
1254
 
@@ -1257,14 +1247,18 @@ function simple_history_print_nav() {
1257
 
1258
  $object_type_translated = "";
1259
  $object_subtype_translated = "";
 
 
1260
  if ( in_array( $one_type->object_type, $arr_built_in_post_types ) ) {
1261
 
 
1262
  $object_post_type_object = get_post_type_object( $one_type->object_type );
1263
- $object_type_translated = $object_post_type_object->labels->singular_name;
1264
-
 
1265
  $object_subtype_post_type_object = get_post_type_object( $one_type->object_subtype );
1266
  if ( ! is_null( $object_subtype_post_type_object ) ) {
1267
- $object_subtype_translated = $object_subtype_post_type_object->labels->singular_name;;
1268
  }
1269
 
1270
  }
@@ -1278,23 +1272,25 @@ function simple_history_print_nav() {
1278
  }
1279
 
1280
  // Add name of type (post / attachment / user / etc.)
1281
- $str_types .= $object_type_translated;
1282
- $str_types_select .= $object_type_translated;
 
1283
 
1284
- // And subtype, if different from main type
1285
- if ($object_subtype_translated && $object_subtype_translated != $object_type_translated) {
1286
- $str_types .= "/". $object_subtype_translated;
1287
- $str_types_select .= "/" . $object_subtype_translated;
1288
- }
1289
 
 
 
 
 
 
 
1290
  // Add object count
1291
- $str_types .= sprintf(' <span>(%d)</span>', $one_type->object_type_count);
1292
  $str_types_select .= sprintf(' (%d)', $one_type->object_type_count);
1293
 
1294
- // Close link and li
1295
- $str_types .= "</a> | ";
1296
- $str_types .= "</li>";
1297
-
1298
  // Close option
1299
  $str_types_select .= "\n</option>";
1300
 
@@ -1305,9 +1301,6 @@ function simple_history_print_nav() {
1305
 
1306
  } // foreach arr types
1307
 
1308
- $str_types .= "</ul>";
1309
- $str_types = str_replace("| </li></ul>", "</li></ul>", $str_types);
1310
-
1311
  $str_types_select .= "\n</select>";
1312
 
1313
  // Output filters
@@ -1349,9 +1342,6 @@ function simple_history_print_nav() {
1349
  $simple_history_user_to_show = "";
1350
  }
1351
 
1352
- $str_users = "";
1353
- $str_users .= "<ul class='simple-history-filter simple-history-filter-user'>";
1354
-
1355
  $str_users_select = "";
1356
  $str_users_select .= "<select name='' class='simple-history-filter simple-history-filter-user'>";
1357
 
@@ -1364,7 +1354,6 @@ function simple_history_print_nav() {
1364
 
1365
  // All users
1366
  $link = esc_html(add_query_arg("simple_history_user_to_show", ""));
1367
- $str_users .= "<li $css><a href='$link'>" . __("By all users", 'simple-history') ."</a> | </li>";
1368
 
1369
  $str_users_select .= sprintf(
1370
  '<option data-simple-history-filter-user-id="%4$s" value="%3$s" %2$s>%1s</option>',
@@ -1392,12 +1381,6 @@ function simple_history_print_nav() {
1392
  // all users must have username and email
1393
  $str_user_name = sprintf('%1$s (%2$s)', esc_attr($user->user_login), esc_attr($user->user_email));
1394
  // if ( ! empty( $user_info["first_name"] ) $user_info["last_name"] );
1395
-
1396
- $str_users .= "<li $css>";
1397
- $str_users .= "<a href='$link'>";
1398
- $str_users .= $str_user_name;
1399
- $str_users .= "</a> | ";
1400
- $str_users .= "</li>";
1401
 
1402
  $str_users_select .= sprintf(
1403
  '<option data-simple-history-filter-user-id="%4$s" %2$s value="%1$s">%1$s</option>',
@@ -1409,13 +1392,9 @@ function simple_history_print_nav() {
1409
 
1410
  }
1411
 
1412
- $str_users .= "</ul>";
1413
- $str_users = str_replace("| </li></ul>", "</li></ul>", $str_users);
1414
-
1415
  $str_users_select .= "</select>";
1416
 
1417
- if ( ! empty($str_users) ) {
1418
- // echo $str_users;
1419
  echo $str_users_select;
1420
  }
1421
 
@@ -1428,8 +1407,6 @@ function simple_history_print_nav() {
1428
  <input type='button' value='$str_search' class='button' />
1429
  </p>";
1430
  echo $search;
1431
-
1432
- // echo simple_history_get_pagination();
1433
 
1434
  }
1435
 
@@ -1823,12 +1800,12 @@ function simple_history_print_history($args = null) {
1823
  $media_dims = "";
1824
  if ( ! empty( $attachment_metadata['width'] ) && ! empty( $attachment_metadata['height'] ) ) {
1825
  $media_dims .= "<span>{$attachment_metadata['width']}&nbsp;&times;&nbsp;{$attachment_metadata['height']}</span>";
1826
-
1827
  }
1828
 
1829
  // Generate string with metainfo
 
1830
  $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("File name:"), esc_html( basename( $attachment_file ) ) );;
1831
- $object_image_out .= sprintf('<p>%1$s %2$s %3$s</p>', __("File size:", "simple-history"), round( $attachment_filesize, 0 ), $sizes[$u] );
1832
  // $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("File type:"), $file_type_out );
1833
  if ( ! empty( $media_dims ) ) $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("Dimensions:"), $media_dims );
1834
  if ( ! empty( $attachment_metadata["length_formatted"] ) ) $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("Length:"), $attachment_metadata["length_formatted"] );
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.4
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.4");
31
  define( "SIMPLE_HISTORY_NAME", "Simple History");
32
 
33
  // Find the plugin directory URL
1188
  $css = "class='selected'";
1189
  }
1190
 
 
 
 
 
1191
  // Begin select
1192
  $str_types_select = "";
1193
  $str_types_select .= "<select name='' class='simple-history-filter simple-history-filter-type'>";
1200
  // First filter is "all types"
1201
  $link = esc_html(add_query_arg("simple_history_type_to_show", ""));
1202
  $str_types_desc = __("All types", 'simple-history');
 
1203
 
1204
  $str_types_select .= sprintf('<option data-simple-history-filter-type="" data-simple-history-filter-subtype="" value="%1$s">%2$s (%3$d)</option>', $link, esc_html($str_types_desc), $total_object_num_count );
1205
 
1219
  $option_selected = " selected ";
1220
  }
1221
 
 
 
 
1222
  // Create link to filter this type + subtype
1223
  $arg = "";
1224
  if ($one_type->object_subtype) {
1227
  $arg = $one_type->object_type;
1228
  }
1229
  $link = esc_html(add_query_arg("simple_history_type_to_show", $arg));
 
1230
 
1231
  // Begin option
1232
  $str_types_select .= sprintf(
1239
 
1240
  // Some built in types we translate with built in translation, the others we use simple history for
1241
  // TODO: use WP-function to get all built in types?
 
1242
  $object_type_translated = "";
1243
  $object_subtype_translated = "";
1244
 
1247
 
1248
  $object_type_translated = "";
1249
  $object_subtype_translated = "";
1250
+
1251
+ // For built in types
1252
  if ( in_array( $one_type->object_type, $arr_built_in_post_types ) ) {
1253
 
1254
+ // Get name of main type
1255
  $object_post_type_object = get_post_type_object( $one_type->object_type );
1256
+ $object_type_translated = $object_post_type_object->labels->name;
1257
+
1258
+ // Get name of subtype
1259
  $object_subtype_post_type_object = get_post_type_object( $one_type->object_subtype );
1260
  if ( ! is_null( $object_subtype_post_type_object ) ) {
1261
+ $object_subtype_translated = $object_subtype_post_type_object->labels->name;;
1262
  }
1263
 
1264
  }
1272
  }
1273
 
1274
  // Add name of type (post / attachment / user / etc.)
1275
+
1276
+ // built in types use only subtype
1277
+ if ( in_array( $one_type->object_type, $arr_built_in_post_types ) && ! empty($object_subtype_translated) ) {
1278
 
1279
+ $str_types_select .= $object_subtype_translated;
1280
+
1281
+ } else {
1282
+
1283
+ $str_types_select .= $object_type_translated;
1284
 
1285
+ // And subtype, if different from main type
1286
+ if ($object_subtype_translated && $object_subtype_translated != $object_type_translated) {
1287
+ $str_types_select .= "/" . $object_subtype_translated;
1288
+ }
1289
+
1290
+ }
1291
  // Add object count
 
1292
  $str_types_select .= sprintf(' (%d)', $one_type->object_type_count);
1293
 
 
 
 
 
1294
  // Close option
1295
  $str_types_select .= "\n</option>";
1296
 
1301
 
1302
  } // foreach arr types
1303
 
 
 
 
1304
  $str_types_select .= "\n</select>";
1305
 
1306
  // Output filters
1342
  $simple_history_user_to_show = "";
1343
  }
1344
 
 
 
 
1345
  $str_users_select = "";
1346
  $str_users_select .= "<select name='' class='simple-history-filter simple-history-filter-user'>";
1347
 
1354
 
1355
  // All users
1356
  $link = esc_html(add_query_arg("simple_history_user_to_show", ""));
 
1357
 
1358
  $str_users_select .= sprintf(
1359
  '<option data-simple-history-filter-user-id="%4$s" value="%3$s" %2$s>%1s</option>',
1381
  // all users must have username and email
1382
  $str_user_name = sprintf('%1$s (%2$s)', esc_attr($user->user_login), esc_attr($user->user_email));
1383
  // if ( ! empty( $user_info["first_name"] ) $user_info["last_name"] );
 
 
 
 
 
 
1384
 
1385
  $str_users_select .= sprintf(
1386
  '<option data-simple-history-filter-user-id="%4$s" %2$s value="%1$s">%1$s</option>',
1392
 
1393
  }
1394
 
 
 
 
1395
  $str_users_select .= "</select>";
1396
 
1397
+ if ( ! empty($str_users_select) ) {
 
1398
  echo $str_users_select;
1399
  }
1400
 
1407
  <input type='button' value='$str_search' class='button' />
1408
  </p>";
1409
  echo $search;
 
 
1410
 
1411
  }
1412
 
1800
  $media_dims = "";
1801
  if ( ! empty( $attachment_metadata['width'] ) && ! empty( $attachment_metadata['height'] ) ) {
1802
  $media_dims .= "<span>{$attachment_metadata['width']}&nbsp;&times;&nbsp;{$attachment_metadata['height']}</span>";
 
1803
  }
1804
 
1805
  // Generate string with metainfo
1806
+ $size_unit = ($u == -1) ? __("bytes", "simple-history") : $sizes[$u];
1807
  $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("File name:"), esc_html( basename( $attachment_file ) ) );;
1808
+ $object_image_out .= sprintf('<p>%1$s %2$s %3$s</p>', __("File size:", "simple-history"), round( $attachment_filesize, 0 ), $size_unit );
1809
  // $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("File type:"), $file_type_out );
1810
  if ( ! empty( $media_dims ) ) $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("Dimensions:"), $media_dims );
1811
  if ( ! empty( $attachment_metadata["length_formatted"] ) ) $object_image_out .= sprintf('<p>%1$s %2$s</p>', __("Length:"), $attachment_metadata["length_formatted"] );
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.3.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
 
@@ -175,6 +175,10 @@ to only use the secret RSS feed to keep track of the changes on you web site/Wor
175
 
176
  == Changelog ==
177
 
 
 
 
 
178
  = 1.3.3 =
179
  - Capability for viewing settings changed from edit_pages to the more correct [manage_options](http://codex.wordpress.org/Roles_and_Capabilities#manage_options)
180
 
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.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
 
175
 
176
  == Changelog ==
177
 
178
+ = 1.3.4 =
179
+ - Changed the way post types show in the dropdown. Now uses plural names + not prefixed with main post type. Looks better I think. Thank to Hassan for the suggestion!
180
+ - Added "bytes" to size units that an attachment can have. Also fixes undefined notice warning when attachment had a size less that 1 KB.
181
+
182
  = 1.3.3 =
183
  - Capability for viewing settings changed from edit_pages to the more correct [manage_options](http://codex.wordpress.org/Roles_and_Capabilities#manage_options)
184