Search Meter - Version 2.5

Version Description

  • Improve formatting on the Options page
  • Fix database error caused by duplicate searches
  • Users of Search Meter version 1 will need to deactivate and reactivate the plugin to use version 2.5.
Download this release

Release Info

Developer bennettmcelwee
Plugin Icon 128x128 Search Meter
Version 2.5
Comparing to
See all releases

Code changes from version 2.4 to 2.5

Files changed (2) hide show
  1. readme.txt +26 -9
  2. search-meter.php +10 -22
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: bennettmcelwee
3
  Donate link: http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/
4
  Tags: search, meter, search-meter, statistics, widget, admin
5
  Requires at least: 1.5
6
- Tested up to: 2.7
7
- Stable tag: 2.4
8
 
9
  Search Meter tracks what your readers are searching for on your blog. View full details of recent searches or stats for the last day, week or month.
10
 
@@ -24,13 +24,21 @@ To see your search statistics, Log in to WordPress Admin, go to the Dashboard se
24
 
25
  There are a couple of management option available if you go to the Settings section and click Search Meter. Use the Reset Statistics button to clear all past search statistics; Search Meter will immediately start gathering fresh statistics. If you're technically-minded, you might want to check the "Keep detailed information" checkbox to make Search Meter save technical information about every search (the information is taken from the HTTP headers).
26
 
27
- = Popular and Recent Searches =
 
 
 
 
 
 
28
 
29
  The Popular Searches widget displays a list of the most popular successful search terms on your blog during the last 30 days. The Recent Searches widget displays a simple list of the most recent successful search terms. In both cases, the search terms in the lists are hyperlinked to the actual search results; readers can click the search term to show the results for that search. Also, you can configure the maximum number of searches that each widget will display.
30
 
31
  To add these widgets to your sidebar, log in to WordPress Admin, go to the Appearance section and click Widgets. You can drag the appropriate widget to the sidebar of your choice, and click the Edit button to set the number of searches to display.
32
 
33
- Widget support depends on the version of WordPress and the theme you're using. In some cases you will not be able to use the widgets. In any case, you can always use the Search Meter template tags to display the same information. You'll need to edit your theme to use them.
 
 
34
 
35
  The `sm_list_popular_searches()` template tag displays a list of the 5 most popular successful search terms on your blog during the last 30 days. Each term is a hyperlink; readers can click the search term to show the results for that search. Here are some examples of using this template tag.
36
 
@@ -49,11 +57,6 @@ This is the same as the above, but it shows the 10 most popular searches.
49
  `sm_list_recent_searches()`
50
  Show a simple list of the 5 most recent successful search terms, hyperlinked to the actual search results. You can also use the same options as for the `sm_list_popular_searches` tag.
51
 
52
- == Installation ==
53
-
54
- 1. Just install the plugin as usual - in WordPress 2.7 and higher you can simply upload the search-meter.zip file. For older version, unzip & upload to the /wp-content/plugins/search-meter directory
55
- 1. Activate the plugin through the 'Plugins' section in WordPress
56
-
57
  == Frequently Asked Questions ==
58
 
59
  = Where can I find out more information? =
@@ -63,3 +66,17 @@ The [Search Meter home page](http://www.thunderguy.com/semicolon/wordpress/searc
63
  == Screenshots ==
64
 
65
  1. The Search Meter administration interface, showing some of the reports available.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Donate link: http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/
4
  Tags: search, meter, search-meter, statistics, widget, admin
5
  Requires at least: 1.5
6
+ Tested up to: 2.8
7
+ Stable tag: 2.5
8
 
9
  Search Meter tracks what your readers are searching for on your blog. View full details of recent searches or stats for the last day, week or month.
10
 
24
 
25
  There are a couple of management option available if you go to the Settings section and click Search Meter. Use the Reset Statistics button to clear all past search statistics; Search Meter will immediately start gathering fresh statistics. If you're technically-minded, you might want to check the "Keep detailed information" checkbox to make Search Meter save technical information about every search (the information is taken from the HTTP headers).
26
 
27
+ == Installation ==
28
+
29
+ You can find, download and install Search Meter directly from the **Plugins** section in WordPress.
30
+
31
+ If you have an older version of WordPress, download and unzip the search-meter.zip file and upload to the `/wp-content/plugins/search-meter` directory. Then activate the plugin through the **Plugins** section in WordPress.
32
+
33
+ = Widgets: Popular and Recent Searches =
34
 
35
  The Popular Searches widget displays a list of the most popular successful search terms on your blog during the last 30 days. The Recent Searches widget displays a simple list of the most recent successful search terms. In both cases, the search terms in the lists are hyperlinked to the actual search results; readers can click the search term to show the results for that search. Also, you can configure the maximum number of searches that each widget will display.
36
 
37
  To add these widgets to your sidebar, log in to WordPress Admin, go to the Appearance section and click Widgets. You can drag the appropriate widget to the sidebar of your choice, and click the Edit button to set the number of searches to display.
38
 
39
+ = Template Tags =
40
+
41
+ If you are using an older version of WordPress or an old theme, you may not be able to use the widgets. In any case, you can always use the Search Meter template tags to display the same information. You'll need to edit your theme to use them.
42
 
43
  The `sm_list_popular_searches()` template tag displays a list of the 5 most popular successful search terms on your blog during the last 30 days. Each term is a hyperlink; readers can click the search term to show the results for that search. Here are some examples of using this template tag.
44
 
57
  `sm_list_recent_searches()`
58
  Show a simple list of the 5 most recent successful search terms, hyperlinked to the actual search results. You can also use the same options as for the `sm_list_popular_searches` tag.
59
 
 
 
 
 
 
60
  == Frequently Asked Questions ==
61
 
62
  = Where can I find out more information? =
66
  == Screenshots ==
67
 
68
  1. The Search Meter administration interface, showing some of the reports available.
69
+
70
+ == Changelog ==
71
+
72
+ = 2.5 =
73
+ * Improve formatting on the Options page
74
+ * Fix database error caused by duplicate searches
75
+ * Users of Search Meter version 1 will need to deactivate and reactivate the plugin to use version 2.5.
76
+
77
+ = 2.4 =
78
+ * Fix the links to the Statistics and Options pages, which broke in WordPress 2.7.
79
+ * Add donation buttons, with an option to hide them. (Thanks for your consideration.)
80
+
81
+ = Earlier versions =
82
+ * [Contact the author](http://www.thunderguy.com/semicolon/contact/) for details
search-meter.php CHANGED
@@ -3,11 +3,11 @@
3
  Plugin Name: Search Meter
4
  Plugin URI: http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/
5
  Description: Keeps track of what your visitors are searching for. After you have activated this plugin, you can check the Search Meter section in the Dashboard to see what your visitors are searching for on your blog.
6
- Version: 2.4
7
  Author: Bennett McElwee
8
  Author URI: http://www.thunderguy.com/semicolon/
9
 
10
- $Revision: 113 $
11
 
12
 
13
  INSTRUCTIONS
@@ -251,13 +251,6 @@ function tguy_sm_save_search(&$posts) {
251
  $query = "INSERT INTO `{$table_prefix}searchmeter_recent` (`terms`,`datetime`,`hits`,`details`)
252
  VALUES ('$search_string',NOW(),$hit_count,'$details')";
253
  $success = $wpdb->query($query);
254
- // If it failed, maybe the table was never created.
255
- // Try to create it and then try again.
256
- if (!$success) {
257
- if (tguy_sm_create_recent_table()) {
258
- $success = $wpdb->query($query);
259
- }
260
- }
261
  if ($success) {
262
  // Ensure table never grows larger than TGUY_SM_HISTORY_SIZE + 100
263
  $rowcount = $wpdb->get_var(
@@ -276,14 +269,16 @@ function tguy_sm_save_search(&$posts) {
276
  // Save search summary into the DB. Usually this will be a new row, so try to insert first
277
  $query = "INSERT INTO `{$table_prefix}searchmeter` (`terms`,`date`,`count`,`last_hits`)
278
  VALUES ('$search_terms',CURDATE(),1,$hit_count)";
 
 
279
  $success = $wpdb->query($query);
 
280
  if (!$success) {
281
  $query = "UPDATE `{$table_prefix}searchmeter` SET
282
  `count` = `count` + 1,
283
  `last_hits` = $hit_count
284
  WHERE `terms` = '$search_terms' AND `date` = CURDATE()";
285
  $success = $wpdb->query($query);
286
- // Table should always exist, so don't try to create again
287
  }
288
  }
289
  return $posts;
@@ -333,7 +328,6 @@ function tguy_sm_create_recent_table() {
333
 
334
  function tguy_sm_reset_stats() {
335
  global $wpdb, $table_prefix;
336
- tguy_sm_create_recent_table();
337
  // Delete all records
338
  $wpdb->query("DELETE FROM `{$table_prefix}searchmeter`");
339
  $wpdb->query("DELETE FROM `{$table_prefix}searchmeter_recent`");
@@ -539,7 +533,6 @@ function tguy_sm_summary_table($results, $days, $do_include_successes = false) {
539
 
540
  function tguy_sm_recent_page($max_lines, $do_show_details) {
541
  global $wpdb, $table_prefix;
542
- tguy_sm_create_recent_table();
543
 
544
  $options = get_option('tguy_search_meter');
545
  $is_details_available = $options['sm_details_verbose'];
@@ -576,11 +569,6 @@ function tguy_sm_recent_page($max_lines, $do_show_details) {
576
  ORDER BY `datetime` DESC, `terms` ASC
577
  LIMIT $max_lines";
578
  $results = $wpdb->get_results($query);
579
- if (!$results) {
580
- if (tguy_sm_create_recent_table()) {
581
- $results = $wpdb->get_results($query);
582
- }
583
- }
584
  if (count($results)) {
585
  ?>
586
  <table cellpadding="3" cellspacing="2">
@@ -655,7 +643,7 @@ function tguy_sm_options_page() {
655
 
656
  <h2>Search Meter Options</h2>
657
 
658
- <form name="searchmeter" action="<?php echo $action_url; ?>" method="post">
659
  <?php
660
  if (function_exists('wp_nonce_field')) {
661
  wp_nonce_field('search-meter-update-options_all');
@@ -684,7 +672,7 @@ function tguy_sm_options_page() {
684
  </table>
685
 
686
  <p class="submit">
687
- <input type="submit" name="Submit" value="Save changes &raquo;" />
688
  </p>
689
  </form>
690
 
@@ -692,14 +680,14 @@ function tguy_sm_options_page() {
692
 
693
  <p>Click this button to reset all search statistics. This will delete all information about previous searches.</p>
694
 
695
- <form name="tguy_sm_admin" action="<?php echo $action_url; ?>" method="post">
696
  <?php
697
  if (function_exists('wp_nonce_field')) {
698
  wp_nonce_field('search-meter-reset-stats');
699
  }
700
  ?>
701
- <p>
702
- <input type="submit" name="tguy_sm_reset" value="Reset statistics &raquo;" class="button-secondary delete" onclick="return confirm('You are about to delete all saved search statistics.\n \'Cancel\' to stop, \'OK\' to delete.');" />
703
  </p>
704
  </form>
705
 
3
  Plugin Name: Search Meter
4
  Plugin URI: http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/
5
  Description: Keeps track of what your visitors are searching for. After you have activated this plugin, you can check the Search Meter section in the Dashboard to see what your visitors are searching for on your blog.
6
+ Version: 2.5
7
  Author: Bennett McElwee
8
  Author URI: http://www.thunderguy.com/semicolon/
9
 
10
+ $Revision: 93952 $
11
 
12
 
13
  INSTRUCTIONS
251
  $query = "INSERT INTO `{$table_prefix}searchmeter_recent` (`terms`,`datetime`,`hits`,`details`)
252
  VALUES ('$search_string',NOW(),$hit_count,'$details')";
253
  $success = $wpdb->query($query);
 
 
 
 
 
 
 
254
  if ($success) {
255
  // Ensure table never grows larger than TGUY_SM_HISTORY_SIZE + 100
256
  $rowcount = $wpdb->get_var(
269
  // Save search summary into the DB. Usually this will be a new row, so try to insert first
270
  $query = "INSERT INTO `{$table_prefix}searchmeter` (`terms`,`date`,`count`,`last_hits`)
271
  VALUES ('$search_terms',CURDATE(),1,$hit_count)";
272
+ // Temporarily suppress errors, as this query is expected to fail on duplicate searches in a single day. Thanks to James Collins.
273
+ $suppress = $wpdb->suppress_errors();
274
  $success = $wpdb->query($query);
275
+ $wpdb->suppress_errors($suppress);
276
  if (!$success) {
277
  $query = "UPDATE `{$table_prefix}searchmeter` SET
278
  `count` = `count` + 1,
279
  `last_hits` = $hit_count
280
  WHERE `terms` = '$search_terms' AND `date` = CURDATE()";
281
  $success = $wpdb->query($query);
 
282
  }
283
  }
284
  return $posts;
328
 
329
  function tguy_sm_reset_stats() {
330
  global $wpdb, $table_prefix;
 
331
  // Delete all records
332
  $wpdb->query("DELETE FROM `{$table_prefix}searchmeter`");
333
  $wpdb->query("DELETE FROM `{$table_prefix}searchmeter_recent`");
533
 
534
  function tguy_sm_recent_page($max_lines, $do_show_details) {
535
  global $wpdb, $table_prefix;
 
536
 
537
  $options = get_option('tguy_search_meter');
538
  $is_details_available = $options['sm_details_verbose'];
569
  ORDER BY `datetime` DESC, `terms` ASC
570
  LIMIT $max_lines";
571
  $results = $wpdb->get_results($query);
 
 
 
 
 
572
  if (count($results)) {
573
  ?>
574
  <table cellpadding="3" cellspacing="2">
643
 
644
  <h2>Search Meter Options</h2>
645
 
646
+ <form name="searchmeter" action="" method="post">
647
  <?php
648
  if (function_exists('wp_nonce_field')) {
649
  wp_nonce_field('search-meter-update-options_all');
672
  </table>
673
 
674
  <p class="submit">
675
+ <input name="Submit" class="button-primary" value="Save Changes" type="submit">
676
  </p>
677
  </form>
678
 
680
 
681
  <p>Click this button to reset all search statistics. This will delete all information about previous searches.</p>
682
 
683
+ <form name="tguy_sm_admin" action="" method="post">
684
  <?php
685
  if (function_exists('wp_nonce_field')) {
686
  wp_nonce_field('search-meter-reset-stats');
687
  }
688
  ?>
689
+ <p class="submit">
690
+ <input name="tguy_sm_reset" class="button-secondary delete" value="Reset Statistics" type="submit" onclick="return confirm('You are about to delete all saved search statistics.\n \'Cancel\' to stop, \'OK\' to delete.');" />
691
  </p>
692
  </form>
693