Simple History - Version 0.7

Version Description

  • Do not show on dashboard by default to avoid clutter. Can be enabled in settings.
  • Add link to settings from plugin list
  • Settings are now available as it's own page under Settings -> Simple Fields. It was previosly on the General settings page and some people had difficulties finding it there.
  • Added filters: simple_history_show_settings_page, simple_history_show_on_dashboard, simple_history_show_as_page
Download this release

Release Info

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

Code changes from version 0.6 to 0.7

Files changed (2) hide show
  1. index.php +59 -21
  2. readme.txt +7 -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: 0.6
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", "0.6");
31
  define( "SIMPLE_HISTORY_NAME", "Simple History");
32
  define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
33
 
@@ -43,8 +43,17 @@ define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
43
  add_action( 'admin_menu', array($this, 'admin_menu') );
44
  add_action( 'wp_dashboard_setup', array($this, 'wp_dashboard_setup') );
45
  add_action( 'wp_ajax_simple_history_ajax', array($this, 'ajax') );
 
46
 
47
- }
 
 
 
 
 
 
 
 
48
 
49
  function wp_dashboard_setup() {
50
  if (simple_history_setting_show_on_dashboard()) {
@@ -72,13 +81,6 @@ define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
72
  add_action("edit_comment", "simple_history_edit_comment");
73
  add_action("delete_comment", "simple_history_delete_comment");
74
  add_action("wp_set_comment_status", "simple_history_set_comment_status", 10, 2);
75
-
76
- // other things
77
- add_settings_section("simple_history_settings_general", SIMPLE_HISTORY_NAME, "simple_history_settings_page", "general");
78
- add_settings_field("simple_history_settings_field_1", "Show Simple History", "simple_history_settings_field", "general", "simple_history_settings_general");
79
- add_settings_field("simple_history_settings_field_2", "RSS feed", "simple_history_settings_field_rss", "general", "simple_history_settings_general");
80
- register_setting("general", "simple_history_show_on_dashboard");
81
- register_setting("general", "simple_history_show_as_page");
82
 
83
  $this->check_upgrade_stuff();
84
 
@@ -135,14 +137,42 @@ define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
135
 
136
  }
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  function admin_menu() {
139
 
140
- #define( "SIMPLE_HISTORY_PAGE_FILE", menu_page_url("simple_history_page", false)); // no need yet
141
-
142
  // show as page?
143
  if (simple_history_setting_show_as_page()) {
144
  add_dashboard_page(SIMPLE_HISTORY_NAME, __("History", 'simple-history'), "edit_pages", "simple_history_page", "simple_history_management_page");
145
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  }
148
 
@@ -189,7 +219,7 @@ define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
189
  $object_type = ucwords($one_item->object_type);
190
  $object_name = esc_html($one_item->object_name);
191
  $user = get_user_by("id", $one_item->user_id);
192
- $user_nicename = esc_html($user->user_nicename);
193
  $description = "";
194
  if ($user_nicename) {
195
  $description .= sprintf(__("By %s", 'simple-history'), $user_nicename);
@@ -274,11 +304,10 @@ define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
274
 
275
  } // class
276
 
 
277
  $simple_history = new simple_history;
278
 
279
 
280
-
281
-
282
  function simple_history_dashboard() {
283
  simple_history_purge_db();
284
  simple_history_print_nav();
@@ -286,15 +315,21 @@ function simple_history_dashboard() {
286
  }
287
 
288
  function simple_history_settings_page() {
289
- // never remove this function, it must exist.
290
- echo "<div id='simple-history-settings-page'></div>";
291
  }
292
 
 
293
  function simple_history_setting_show_on_dashboard() {
294
- return (bool) get_option("simple_history_show_on_dashboard", 1);
 
 
295
  }
296
  function simple_history_setting_show_as_page() {
297
- return (bool) get_option("simple_history_show_as_page", 1);
 
 
 
298
  }
299
 
300
  function simple_history_settings_field() {
@@ -308,7 +343,7 @@ function simple_history_settings_field() {
308
  <br />
309
 
310
  <input <?php echo $show_as_page ? "checked='checked'" : "" ?> type="checkbox" value="1" name="simple_history_show_as_page" id="simple_history_show_as_page" />
311
- <label for="simple_history_show_as_page"><?php _e("as a page under the tools menu", 'simple-history') ?></label>
312
 
313
  <?php
314
  #$version = get_option("simple_history_version", "0.3.8");
@@ -680,7 +715,10 @@ function simple_history_add($args) {
680
  $wpdb->query($sql);
681
  }
682
 
683
-
 
 
 
684
  function simple_history_purge_db() {
685
  global $wpdb;
686
  $tableprefix = $wpdb->prefix;
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: 0.7
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", "0.7");
31
  define( "SIMPLE_HISTORY_NAME", "Simple History");
32
  define( "SIMPLE_HISTORY_URL", WP_PLUGIN_URL . '/simple-history/');
33
 
43
  add_action( 'admin_menu', array($this, 'admin_menu') );
44
  add_action( 'wp_dashboard_setup', array($this, 'wp_dashboard_setup') );
45
  add_action( 'wp_ajax_simple_history_ajax', array($this, 'ajax') );
46
+ add_filter( 'plugin_action_links_simple-history/index.php', array($this, "plugin_action_links"), 10, 4);
47
 
48
+ }
49
+
50
+ function plugin_action_links($actions, $b, $c, $d) {
51
+ // http://playground.ep/wordpress/wp-admin/options-general.php?page=simple_history_settings_menu_slug
52
+ $settings_page_url = menu_page_url("simple_history_settings_menu_slug", 0);
53
+ $actions[] = "<a href='$settings_page_url'>Settings</a>";
54
+ return $actions;
55
+
56
+ }
57
 
58
  function wp_dashboard_setup() {
59
  if (simple_history_setting_show_on_dashboard()) {
81
  add_action("edit_comment", "simple_history_edit_comment");
82
  add_action("delete_comment", "simple_history_delete_comment");
83
  add_action("wp_set_comment_status", "simple_history_set_comment_status", 10, 2);
 
 
 
 
 
 
 
84
 
85
  $this->check_upgrade_stuff();
86
 
137
 
138
  }
139
 
140
+ function settings_page() {
141
+
142
+ ?>
143
+ <div class="wrap">
144
+ <form method="post" action="options.php">
145
+ <h2><?php _e("Simple History Settings", "simple-history") ?></h2>
146
+ <?php do_settings_sections("simple_history_settings_menu_slug"); ?>
147
+ <?php settings_fields("simple_history_settings_group"); ?>
148
+ <?php submit_button(); ?>
149
+ </form>
150
+ </div>
151
+ <?
152
+
153
+ }
154
+
155
  function admin_menu() {
156
 
 
 
157
  // show as page?
158
  if (simple_history_setting_show_as_page()) {
159
  add_dashboard_page(SIMPLE_HISTORY_NAME, __("History", 'simple-history'), "edit_pages", "simple_history_page", "simple_history_management_page");
160
  }
161
+
162
+ // add page for settings
163
+ $show_settings_page = TRUE;
164
+ $show_settings_page = apply_filters("simple_history_show_settings_page", $show_settings_page);
165
+ if ($show_settings_page) {
166
+ add_options_page(__('Simple History Settings', "simple-history"), SIMPLE_HISTORY_NAME, 'edit_pages', "simple_history_settings_menu_slug", array($this, 'settings_page'));
167
+ }
168
+
169
+ add_settings_section("simple_history_settings_section", __("", "simple-history"), "simple_history_settings_page", "simple_history_settings_menu_slug");
170
+
171
+ add_settings_field("simple_history_settings_field_1", __("Show Simple History", "simple-history"), "simple_history_settings_field", "simple_history_settings_menu_slug", "simple_history_settings_section");
172
+ add_settings_field("simple_history_settings_field_2", __("RSS feed", "simple-history"), "simple_history_settings_field_rss", "simple_history_settings_menu_slug", "simple_history_settings_section");
173
+
174
+ register_setting("simple_history_settings_group", "simple_history_show_on_dashboard");
175
+ register_setting("simple_history_settings_group", "simple_history_show_as_page");
176
 
177
  }
178
 
219
  $object_type = ucwords($one_item->object_type);
220
  $object_name = esc_html($one_item->object_name);
221
  $user = get_user_by("id", $one_item->user_id);
222
+ $user_nicename = esc_html(@$user->user_nicename);
223
  $description = "";
224
  if ($user_nicename) {
225
  $description .= sprintf(__("By %s", 'simple-history'), $user_nicename);
304
 
305
  } // class
306
 
307
+ // Boot up
308
  $simple_history = new simple_history;
309
 
310
 
 
 
311
  function simple_history_dashboard() {
312
  simple_history_purge_db();
313
  simple_history_print_nav();
315
  }
316
 
317
  function simple_history_settings_page() {
318
+ // never remove this function, it must exist.
319
+ // echo "Please choose options for simple history ...";
320
  }
321
 
322
+ // get settings if plugin should be visible on dasboard. default in no since 0.7
323
  function simple_history_setting_show_on_dashboard() {
324
+ $show_on_dashboard = get_option("simple_history_show_on_dashboard", 0);
325
+ $show_on_dashboard = apply_filters("simple_history_show_on_dashboard", $show_on_dashboard);
326
+ return (bool) $show_on_dashboard;
327
  }
328
  function simple_history_setting_show_as_page() {
329
+ $setting = get_option("simple_history_show_as_page", 0);
330
+ $setting = apply_filters("simple_history_show_as_page", $setting);
331
+ return (bool) $setting;
332
+
333
  }
334
 
335
  function simple_history_settings_field() {
343
  <br />
344
 
345
  <input <?php echo $show_as_page ? "checked='checked'" : "" ?> type="checkbox" value="1" name="simple_history_show_as_page" id="simple_history_show_as_page" />
346
+ <label for="simple_history_show_as_page"><?php _e("as a page under the dashboard menu", 'simple-history') ?></label>
347
 
348
  <?php
349
  #$version = get_option("simple_history_version", "0.3.8");
715
  $wpdb->query($sql);
716
  }
717
 
718
+ /**
719
+ * Removes old entries from the db
720
+ * @todo: let user set value, if any
721
+ */
722
  function simple_history_purge_db() {
723
  global $wpdb;
724
  $tableprefix = $wpdb->prefix;
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
5
  Requires at least: 3.0
6
  Tested up to: 3.4.2
7
- Stable tag: 0.6
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
@@ -85,6 +85,12 @@ to only use the secret RSS feed to keep track of the changes on you web site/Wor
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
88
  = 0.6 =
89
  - Changed widget name to just "History" instead of "Simple History". Keep it simple. Previous name implied there also was an "Advanced History" somewhere.
90
  - Made the widget look a bit WordPress-ish by borrwing some of the looks from the comments widget.
4
  Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, cms, dashboard, admin
5
  Requires at least: 3.0
6
  Tested up to: 3.4.2
7
+ Stable tag: 0.7
8
 
9
  View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
10
 
85
 
86
  == Changelog ==
87
 
88
+ = 0.7 =
89
+ - Do not show on dashboard by default to avoid clutter. Can be enabled in settings.
90
+ - Add link to settings from plugin list
91
+ - Settings are now available as it's own page under Settings -> Simple Fields. It was previosly on the General settings page and some people had difficulties finding it there.
92
+ - Added filters: simple_history_show_settings_page, simple_history_show_on_dashboard, simple_history_show_as_page
93
+
94
  = 0.6 =
95
  - Changed widget name to just "History" instead of "Simple History". Keep it simple. Previous name implied there also was an "Advanced History" somewhere.
96
  - Made the widget look a bit WordPress-ish by borrwing some of the looks from the comments widget.