Version Description
Download this release
Release Info
Developer | bennettmcelwee |
Plugin | Search Meter |
Version | 2.3 |
Comparing to | |
See all releases |
Version 2.3
- readme.txt +65 -0
- screenshot-1.gif +0 -0
- search-meter.php +756 -0
readme.txt
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Search Meter ===
|
2 |
+
Contributors: bennettmcelwee
|
3 |
+
Donate link: http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/
|
4 |
+
Tags: search, statistics, widget, admin
|
5 |
+
Requires at least: 1.5
|
6 |
+
Tested up to: 2.7
|
7 |
+
Stable tag: 2.3
|
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 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
If you have a Search box on your blog, Search Meter automatically records what people are searching for -- and whether they are finding what they are looking for. Search Meter's admin interface shows you what people have been searching for in the last couple of days, and in the last week or month. It also shows you which searches have been unsuccessful. If people search your blog and get no results, they'll probably go elsewhere. With Search Meter, you'll be able to find out what people are searching for, and give them what they want by creating new posts on those topics.
|
14 |
+
|
15 |
+
You can also show your readers what the most popular searches are. The Popular Searches widget displays a configurable list of recent popular successful search terms on your blog, with each term hyperlinked to the actual search results. There's also a Recent Searches widget, which simply displays the most recent searches. If you are happy to edit your theme, both of these functions are also available as template tags.
|
16 |
+
|
17 |
+
Search Meter installs easily and requires no configuration. Just install it, activate it, and it starts tracking your visitors' searches.
|
18 |
+
|
19 |
+
= View Statistics =
|
20 |
+
|
21 |
+
To see your search statistics, Log in to WordPress Admin, go to the Dashboard page and click Search Meter. You'll see the most popular searches in the last day, week and month. Click "Last 100 Searches" or "Last 500 Searches" to see lists of all recent searches.
|
22 |
+
|
23 |
+
= Manage Statistics =
|
24 |
+
|
25 |
+
There are a couple of management option available if you go to the Options page 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 Presentation page and click Widgets. You can drag the appropriate widget to the sidebar of your choice, and click the Configure 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 |
+
|
37 |
+
`sm_list_popular_searches()`
|
38 |
+
Show a simple list of the 5 most popular recent successful search terms, hyperlinked to the actual search results.
|
39 |
+
|
40 |
+
`sm_list_popular_searches('<h2>Popular Searches</h2>')`
|
41 |
+
Show the list as above, with the heading "Popular Searches". If there have been no successful searches, then this tag displays no heading and no list.
|
42 |
+
|
43 |
+
`sm_list_popular_searches('<li><h2>Popular Searches</h2>', '</li>')`
|
44 |
+
Show the headed list as above; this form of the tag should be used in the default WordPress theme. Put it in the `sidebar.php` file.
|
45 |
+
|
46 |
+
`sm_list_popular_searches('<li><h2>Popular Searches</h2>', '</li>', 10)`
|
47 |
+
This is the same as the above, but it shows the 10 most popular searches.
|
48 |
+
|
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. Upload `search-meter.php` to the `/wp-content/plugins/` directory
|
55 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
56 |
+
|
57 |
+
== Frequently Asked Questions ==
|
58 |
+
|
59 |
+
= Where can I find out more information? =
|
60 |
+
|
61 |
+
The [Search Meter home page](http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/) has more information and a form to submit comments and questions.
|
62 |
+
|
63 |
+
== Screenshots ==
|
64 |
+
|
65 |
+
1. The Search Meter administration interface, showing some of the reports available.
|
screenshot-1.gif
ADDED
Binary file
|
search-meter.php
ADDED
@@ -0,0 +1,756 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
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 <a href="index.php?page=search-meter.php">Search Meter Statistics</a> page to see what your visitors are searching for on your blog.
|
6 |
+
Version: 2.3
|
7 |
+
Author: Bennett McElwee
|
8 |
+
Author URI: http://www.thunderguy.com/semicolon/
|
9 |
+
|
10 |
+
$Revision: 109 $
|
11 |
+
|
12 |
+
|
13 |
+
INSTRUCTIONS
|
14 |
+
|
15 |
+
1. Copy this file into the plugins directory in your WordPress installation
|
16 |
+
(wp-content/plugins).
|
17 |
+
2. Log in to WordPress administration. Go to the Plugins page and Activate
|
18 |
+
this plugin.
|
19 |
+
|
20 |
+
* To see search statistics, log in to WordPress Admin, go to the Dashboard
|
21 |
+
page and click Search Meter.
|
22 |
+
* To control search statistics, log in to WordPress Admin, go to the Options
|
23 |
+
page and click Search Meter.
|
24 |
+
* To display recent and popular searches, use the Recent Searches and
|
25 |
+
Popular Searches widgets, or the sm_list_popular_searches() and
|
26 |
+
sm_list_recent_searches() template tags.
|
27 |
+
* For full details, see http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/
|
28 |
+
|
29 |
+
Thanks to Kaufman (http://www.terrik.com/wordpress/) and the many others who have for valuable coding suggestions.
|
30 |
+
The many other users who have offered suggestions.
|
31 |
+
|
32 |
+
|
33 |
+
Copyright (C) 2005-07 Bennett McElwee (bennett at thunderguy dotcom)
|
34 |
+
|
35 |
+
This program is free software; you can redistribute it and/or
|
36 |
+
modify it under the terms of version 2 of the GNU General Public
|
37 |
+
License as published by the Free Software Foundation.
|
38 |
+
|
39 |
+
This program is distributed in the hope that it will be useful,
|
40 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
41 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
42 |
+
GNU General Public License for more details, available at
|
43 |
+
http://www.gnu.org/copyleft/gpl.html
|
44 |
+
or by writing to the Free Software Foundation, Inc.,
|
45 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
46 |
+
*/
|
47 |
+
|
48 |
+
|
49 |
+
if (!is_plugin_page()) :
|
50 |
+
|
51 |
+
|
52 |
+
// Parameters (you can change these if you know what you're doing)
|
53 |
+
|
54 |
+
define('TGUY_SM_HISTORY_SIZE', 500);
|
55 |
+
// The number of recent searches that will be saved. The table can
|
56 |
+
// contain up to 100 more rows than this number
|
57 |
+
|
58 |
+
define('TGUY_SM_ALLOW_EMPTY_REFERER', false);
|
59 |
+
// Searches with an empty referer header are often bogus requests
|
60 |
+
// from Google's AdSense crawler or something similar, so they are
|
61 |
+
// excluded. Set this to true to record all such searches.
|
62 |
+
|
63 |
+
define('TGUY_SM_ALLOW_DUPLICATE_SAVES', false);
|
64 |
+
// It may be that the filter gets called more than once for a given
|
65 |
+
// request. Search Meter ignores these duplicates. Set this to true
|
66 |
+
// to record duplicates (the fact that it's a dupe will be recorded
|
67 |
+
// in the details). This will mess up the stats, but could be useful
|
68 |
+
// for troubleshooting.
|
69 |
+
|
70 |
+
define('TGUY_SM_STATS_CAPABILITY_LEVEL', 1);
|
71 |
+
// Minimum user capability level for users to be able to see stats.
|
72 |
+
|
73 |
+
define('TGUY_SM_OPTIONS_CAPABILITY_LEVEL', 10);
|
74 |
+
// Minimum user capability level for users to be able to set options.
|
75 |
+
|
76 |
+
|
77 |
+
// Template Tags
|
78 |
+
|
79 |
+
|
80 |
+
function sm_list_popular_searches($before = '', $after = '', $count = 5) {
|
81 |
+
// List the most popular searches in the last month in decreasing order of popularity.
|
82 |
+
global $wpdb, $table_prefix;
|
83 |
+
$count = intval($count);
|
84 |
+
// This is a simpler query than the report query, and may produce
|
85 |
+
// slightly different results. This query returns searches if they
|
86 |
+
// have ever had any hits, even if the last search yielded no hits.
|
87 |
+
// This makes for a more efficient search -- important if this
|
88 |
+
// function will be used in a sidebar.
|
89 |
+
$results = $wpdb->get_results(
|
90 |
+
"SELECT `terms`,
|
91 |
+
SUM( `count` ) AS countsum
|
92 |
+
FROM `{$table_prefix}searchmeter`
|
93 |
+
WHERE DATE_SUB( CURDATE( ) , INTERVAL 30 DAY ) <= `date`
|
94 |
+
AND 0 < `last_hits`
|
95 |
+
GROUP BY `terms`
|
96 |
+
ORDER BY countsum DESC, `terms` ASC
|
97 |
+
LIMIT $count");
|
98 |
+
if (count($results)) {
|
99 |
+
echo "$before\n<ul>\n";
|
100 |
+
foreach ($results as $result) {
|
101 |
+
echo '<li><a href="'. get_settings('home') . '/search/' . urlencode($result->terms) . '">'. htmlspecialchars($result->terms) .'</a></li>'."\n";
|
102 |
+
}
|
103 |
+
echo "</ul>\n$after\n";
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
function sm_list_recent_searches($before = '', $after = '', $count = 5) {
|
108 |
+
// List the most recent successful searches.
|
109 |
+
global $wpdb, $table_prefix;
|
110 |
+
$count = intval($count);
|
111 |
+
$results = $wpdb->get_results(
|
112 |
+
"SELECT `terms`, `datetime`
|
113 |
+
FROM `{$table_prefix}searchmeter_recent`
|
114 |
+
WHERE 0 < `hits`
|
115 |
+
ORDER BY `datetime` DESC
|
116 |
+
LIMIT $count");
|
117 |
+
if (count($results)) {
|
118 |
+
echo "$before\n<ul>\n";
|
119 |
+
foreach ($results as $result) {
|
120 |
+
echo '<li><a href="'. get_settings('home') . '/search/' . urlencode($result->terms) . '">'. htmlspecialchars($result->terms) .'</a></li>'."\n";
|
121 |
+
}
|
122 |
+
echo "</ul>\n$after\n";
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
// Hooks
|
128 |
+
|
129 |
+
|
130 |
+
if (function_exists('register_activation_hook')) {
|
131 |
+
register_activation_hook(__FILE__, 'tguy_sm_init');
|
132 |
+
} else {
|
133 |
+
add_action('init', 'tguy_sm_init');
|
134 |
+
}
|
135 |
+
add_action('init', 'tguy_sm_register_widgets');
|
136 |
+
add_filter('the_posts', 'tguy_sm_save_search', 20); // run after other plugins
|
137 |
+
add_action('admin_head', 'tguy_sm_stats_css');
|
138 |
+
add_action('admin_menu', 'tguy_sm_add_admin_pages');
|
139 |
+
|
140 |
+
|
141 |
+
// Functionality
|
142 |
+
|
143 |
+
|
144 |
+
function tguy_sm_init() {
|
145 |
+
tguy_sm_create_summary_table();
|
146 |
+
tguy_sm_create_recent_table();
|
147 |
+
}
|
148 |
+
|
149 |
+
// Widgets
|
150 |
+
|
151 |
+
function sm_list_popular_searches_widget($args) {
|
152 |
+
$options = get_option('tguy_search_meter');
|
153 |
+
$number = sm_constrain_widget_search_count((int)$options['popular-searches-number']);
|
154 |
+
sm_list_popular_searches('<h2 class="widgettitle">Popular Searches</h2>', '', $number);
|
155 |
+
}
|
156 |
+
|
157 |
+
function sm_list_popular_searches_control() {
|
158 |
+
$options = get_option('tguy_search_meter');
|
159 |
+
if ($_POST["popular-searches-submit"]) {
|
160 |
+
$options['popular-searches-number'] = (int) $_POST["popular-searches-number"];
|
161 |
+
update_option('tguy_search_meter', $options);
|
162 |
+
}
|
163 |
+
$number = sm_constrain_widget_search_count((int)$options['popular-searches-number']);
|
164 |
+
?>
|
165 |
+
<p>This widget shows the most popular successful search terms in the last month.</p>
|
166 |
+
<p><label for="popular-searches-number"><?php _e('Number of searches to show:'); ?> <input style="width: 5ex; text-align: center;" id="popular-searches-number" name="popular-searches-number" type="text" value="<?php echo $number; ?>" /></label></p>
|
167 |
+
<p><em>Powered by Search Meter</em></p>
|
168 |
+
<input type="hidden" id="popular-searches-submit" name="popular-searches-submit" value="1" />
|
169 |
+
<?php
|
170 |
+
}
|
171 |
+
|
172 |
+
function sm_list_recent_searches_widget($args) {
|
173 |
+
$options = get_option('tguy_search_meter');
|
174 |
+
$number = sm_constrain_widget_search_count((int)$options['recent-searches-number']);
|
175 |
+
sm_list_recent_searches('<h2 class="widgettitle">Recent Searches</h2>', '', $number);
|
176 |
+
}
|
177 |
+
|
178 |
+
function sm_list_recent_searches_control() {
|
179 |
+
$options = get_option('tguy_search_meter');
|
180 |
+
if ($_POST["recent-searches-submit"]) {
|
181 |
+
$options['recent-searches-number'] = (int) $_POST["recent-searches-number"];
|
182 |
+
update_option('tguy_search_meter', $options);
|
183 |
+
}
|
184 |
+
$number = sm_constrain_widget_search_count((int)$options['recent-searches-number']);
|
185 |
+
?>
|
186 |
+
<p>This widget shows the most recent successful search terms.</p>
|
187 |
+
<p><label for="recent-searches-number"><?php _e('Number of searches to show:'); ?> <input style="width: 5ex; text-align: center;" id="recent-searches-number" name="recent-searches-number" type="text" value="<?php echo $number; ?>" /></label></p>
|
188 |
+
<p><em>Powered by Search Meter</em></p>
|
189 |
+
<input type="hidden" id="recent-searches-submit" name="recent-searches-submit" value="1" />
|
190 |
+
<?php
|
191 |
+
}
|
192 |
+
|
193 |
+
function sm_constrain_widget_search_count($number) {
|
194 |
+
if (!$number) {
|
195 |
+
$number = 5;
|
196 |
+
} else if ($number < 1) {
|
197 |
+
$number = 1;
|
198 |
+
} else if (100 < $number) {
|
199 |
+
$number = 100;
|
200 |
+
}
|
201 |
+
return $number;
|
202 |
+
}
|
203 |
+
|
204 |
+
function tguy_sm_register_widgets() {
|
205 |
+
if (function_exists('register_sidebar_widget') ) {
|
206 |
+
register_sidebar_widget('Recent Searches', 'sm_list_recent_searches_widget', 'recent_searches');
|
207 |
+
register_sidebar_widget('Popular Searches', 'sm_list_popular_searches_widget', 'popular_searches');
|
208 |
+
register_widget_control('Recent Searches', 'sm_list_recent_searches_control', '', '120px');
|
209 |
+
register_widget_control('Popular Searches', 'sm_list_popular_searches_control', '', '120px');
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
// Keep track of how many times SM has been called for this request.
|
214 |
+
// Normally we only record the first time.
|
215 |
+
$tguy_sm_action_count = 0;
|
216 |
+
|
217 |
+
function tguy_sm_save_search(&$posts) {
|
218 |
+
// Check if the request is a search, and if so then save details.
|
219 |
+
// This is a filter but does not change the posts.
|
220 |
+
global $wpdb, $wp_query, $table_prefix, $tguy_sm_action_count;
|
221 |
+
|
222 |
+
++$tguy_sm_action_count;
|
223 |
+
if (is_search()
|
224 |
+
&& !is_paged() // not the second or subsequent page of a previously-counted search
|
225 |
+
&& !is_admin() // not using the administration console
|
226 |
+
&& (1 == $tguy_sm_action_count || TGUY_SM_ALLOW_DUPLICATE_SAVES)
|
227 |
+
&& ($_SERVER['HTTP_REFERER'] || TGUY_SM_ALLOW_EMPTY_REFERER) // proper referrer (otherwise could be search engine, cache...)
|
228 |
+
) {
|
229 |
+
// Get all details of this search
|
230 |
+
// search string is the raw query
|
231 |
+
$search_string = $wp_query->query_vars['s'];
|
232 |
+
if (get_magic_quotes_gpc()) {
|
233 |
+
$search_string = stripslashes($search_string);
|
234 |
+
}
|
235 |
+
// search terms is the words in the query
|
236 |
+
$search_terms = $search_string;
|
237 |
+
$search_terms = preg_replace('/[," ]+/', ' ', $search_terms);
|
238 |
+
$search_terms = trim($search_terms);
|
239 |
+
// This actually only returns a maximum of the number of posts per page
|
240 |
+
$hit_count = count($posts);
|
241 |
+
// Other useful details of the search
|
242 |
+
$details = '';
|
243 |
+
$options = get_option('tguy_search_meter');
|
244 |
+
if ($options['sm_details_verbose']) {
|
245 |
+
if (TGUY_SM_ALLOW_DUPLICATE_SAVES) {
|
246 |
+
$details .= "Search Meter action count: $tguy_sm_action_count\n";
|
247 |
+
}
|
248 |
+
foreach (array('REQUEST_URI','REQUEST_METHOD','QUERY_STRING','REMOTE_ADDR','HTTP_USER_AGENT','HTTP_REFERER')
|
249 |
+
as $header) {
|
250 |
+
$details .= $header . ': ' . $_SERVER[$header] . "\n";
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
// Sanitise as necessary
|
255 |
+
$search_string = addslashes($search_string);
|
256 |
+
$search_terms = addslashes($search_terms);
|
257 |
+
$details = addslashes($details);
|
258 |
+
|
259 |
+
// Save the individual search to the DB
|
260 |
+
$query = "INSERT INTO `{$table_prefix}searchmeter_recent` (`terms`,`datetime`,`hits`,`details`)
|
261 |
+
VALUES ('$search_string',NOW(),$hit_count,'$details')";
|
262 |
+
$success = mysql_query($query);
|
263 |
+
// If it failed, maybe the table was never created.
|
264 |
+
// Try to create it and then try again.
|
265 |
+
if (!$success) {
|
266 |
+
if (tguy_sm_create_recent_table()) {
|
267 |
+
$success = mysql_query($query);
|
268 |
+
}
|
269 |
+
}
|
270 |
+
if ($success) {
|
271 |
+
// Ensure table never grows larger than TGUY_SM_HISTORY_SIZE + 100
|
272 |
+
$rowcount = $wpdb->get_var(
|
273 |
+
"SELECT count(`datetime`) as rowcount
|
274 |
+
FROM `{$table_prefix}searchmeter_recent`");
|
275 |
+
if ((TGUY_SM_HISTORY_SIZE + 100) < $rowcount) {
|
276 |
+
// find time of (TGUY_SM_HISTORY_SIZE)th entry
|
277 |
+
$dateZero = $wpdb->get_var(
|
278 |
+
"SELECT `datetime`
|
279 |
+
FROM `{$table_prefix}searchmeter_recent`
|
280 |
+
ORDER BY `datetime` DESC LIMIT ".TGUY_SM_HISTORY_SIZE.", 1");
|
281 |
+
$query = "DELETE FROM `{$table_prefix}searchmeter_recent` WHERE `datetime` < '$dateZero'";
|
282 |
+
$success = mysql_query($query);
|
283 |
+
}
|
284 |
+
}
|
285 |
+
// Save search summary into the DB. Usually this will be a new query, so try to insert first
|
286 |
+
$query = "INSERT INTO `{$table_prefix}searchmeter` (`terms`,`date`,`count`,`last_hits`)
|
287 |
+
VALUES ('$search_terms',CURDATE(),1,$hit_count)";
|
288 |
+
$success = mysql_query($query);
|
289 |
+
if (!$success) {
|
290 |
+
$query = "UPDATE `{$table_prefix}searchmeter` SET
|
291 |
+
`count` = `count` + 1,
|
292 |
+
`last_hits` = $hit_count
|
293 |
+
WHERE `terms` = '$search_terms' AND `date` = CURDATE()";
|
294 |
+
$success = mysql_query($query);
|
295 |
+
// Table should always exist, so don't try to create again
|
296 |
+
}
|
297 |
+
}
|
298 |
+
return $posts;
|
299 |
+
}
|
300 |
+
|
301 |
+
function tguy_sm_create_summary_table() {
|
302 |
+
// Create the table if not already there.
|
303 |
+
global $wpdb, $table_prefix;
|
304 |
+
$table_name = $table_prefix . "searchmeter";
|
305 |
+
if ($wpdb->get_var("show tables like '$table_name'") != $table_name) {
|
306 |
+
if (file_exists(ABSPATH . 'wp-admin/includes/upgrade.php')) {
|
307 |
+
require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
|
308 |
+
} else { // Wordpress 2.2 or earlier
|
309 |
+
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
|
310 |
+
}
|
311 |
+
dbDelta("CREATE TABLE `{$table_name}` (
|
312 |
+
`terms` VARCHAR(50) NOT NULL,
|
313 |
+
`date` DATE NOT NULL,
|
314 |
+
`count` INT(11) NOT NULL,
|
315 |
+
`last_hits` INT(11) NOT NULL,
|
316 |
+
PRIMARY KEY (`terms`,`date`)
|
317 |
+
);
|
318 |
+
");
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
function tguy_sm_create_recent_table() {
|
323 |
+
// Create the table if not already there.
|
324 |
+
global $wpdb, $table_prefix;
|
325 |
+
$table_name = $table_prefix . "searchmeter_recent";
|
326 |
+
if ($wpdb->get_var("show tables like '$table_name'") != $table_name) {
|
327 |
+
if (file_exists(ABSPATH . 'wp-admin/includes/upgrade.php')) {
|
328 |
+
require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
|
329 |
+
} else { // Wordpress 2.2 or earlier
|
330 |
+
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
|
331 |
+
}
|
332 |
+
dbDelta("CREATE TABLE `{$table_name}` (
|
333 |
+
`terms` VARCHAR(50) NOT NULL,
|
334 |
+
`datetime` DATETIME NOT NULL,
|
335 |
+
`hits` INT(11) NOT NULL,
|
336 |
+
`details` TEXT NOT NULL,
|
337 |
+
KEY `datetimeindex` (`datetime`)
|
338 |
+
);
|
339 |
+
");
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
function tguy_sm_reset_stats() {
|
344 |
+
global $wpdb, $table_prefix;
|
345 |
+
tguy_sm_create_recent_table();
|
346 |
+
// Delete all records
|
347 |
+
$wpdb->query("DELETE FROM `{$table_prefix}searchmeter`");
|
348 |
+
$wpdb->query("DELETE FROM `{$table_prefix}searchmeter_recent`");
|
349 |
+
}
|
350 |
+
|
351 |
+
function tguy_sm_add_admin_pages() {
|
352 |
+
add_submenu_page('index.php', 'Search Meter Statistics', 'Search Meter', TGUY_SM_STATS_CAPABILITY_LEVEL, __FILE__, 'tguy_sm_stats_page');
|
353 |
+
add_options_page('Search Meter', 'Search Meter', TGUY_SM_OPTIONS_CAPABILITY_LEVEL, __FILE__, 'tguy_sm_options_page');
|
354 |
+
}
|
355 |
+
|
356 |
+
|
357 |
+
// Display information
|
358 |
+
|
359 |
+
|
360 |
+
function tguy_sm_stats_css() {
|
361 |
+
?>
|
362 |
+
<style type="text/css">
|
363 |
+
#search_meter_menu {
|
364 |
+
margin: 0;
|
365 |
+
padding: 0;
|
366 |
+
}
|
367 |
+
#search_meter_menu li {
|
368 |
+
display: inline; list-style-type: none; list-style-image: none; list-style-position: outside; text-align: center;
|
369 |
+
margin: 0;
|
370 |
+
line-height: 170%;
|
371 |
+
}
|
372 |
+
#search_meter_menu li.current {
|
373 |
+
font-weight: bold;
|
374 |
+
background-color: #fff;
|
375 |
+
color: #000;
|
376 |
+
padding: 5px;
|
377 |
+
}
|
378 |
+
#search_meter_menu a {
|
379 |
+
background-color: #fff;
|
380 |
+
color: #69c;
|
381 |
+
padding: 4px;
|
382 |
+
font-size: 12px;
|
383 |
+
border-bottom: none;
|
384 |
+
}
|
385 |
+
#search_meter_menu a:hover {
|
386 |
+
background-color: #69c;
|
387 |
+
color: #fff;
|
388 |
+
}
|
389 |
+
#search_meter_menu + .wrap {
|
390 |
+
margin-top: 0;
|
391 |
+
}
|
392 |
+
div.sm-stats-table {
|
393 |
+
float: left;
|
394 |
+
padding-right: 5em;
|
395 |
+
padding-bottom: 3ex;
|
396 |
+
}
|
397 |
+
div.sm-stats-table h3 {
|
398 |
+
margin-top: 0;
|
399 |
+
}
|
400 |
+
div.sm-stats-table .left {
|
401 |
+
text-align: left;
|
402 |
+
}
|
403 |
+
div.sm-stats-table .right {
|
404 |
+
text-align: right;
|
405 |
+
}
|
406 |
+
div.sm-stats-clear {
|
407 |
+
clear: both;
|
408 |
+
}
|
409 |
+
</style>
|
410 |
+
<?php
|
411 |
+
}
|
412 |
+
|
413 |
+
function tguy_sm_stats_page() {
|
414 |
+
$recent_count = intval($_GET['recent']);
|
415 |
+
if (0 < $recent_count) {
|
416 |
+
$do_show_details = intval($_GET['details']);
|
417 |
+
tguy_sm_recent_page($recent_count, $do_show_details);
|
418 |
+
} else {
|
419 |
+
tguy_sm_summary_page();
|
420 |
+
}
|
421 |
+
}
|
422 |
+
|
423 |
+
function tguy_sm_summary_page() {
|
424 |
+
global $wpdb, $table_prefix;
|
425 |
+
|
426 |
+
$options = get_option('tguy_search_meter');
|
427 |
+
$is_disable_donation = $options['sm_disable_donation'];
|
428 |
+
|
429 |
+
// Delete old records
|
430 |
+
$result = $wpdb->query(
|
431 |
+
"DELETE FROM `{$table_prefix}searchmeter`
|
432 |
+
WHERE `date` < DATE_SUB( CURDATE() , INTERVAL 30 DAY)");
|
433 |
+
echo "<!-- Search Meter: deleted $result old rows -->\n";
|
434 |
+
?>
|
435 |
+
<div class="wrap">
|
436 |
+
<?php if (!$is_disable_donation) { tguy_sm_show_donation_bar(); } ?>
|
437 |
+
|
438 |
+
<ul id="search_meter_menu">
|
439 |
+
<li class="current">Summary</li>
|
440 |
+
<li><a href="<?php echo $_SERVER['PHP_SELF'] . "?page=" . $_REQUEST['page'] . "&recent=100" ?>">Last 100 Searches</a></li>
|
441 |
+
<li><a href="<?php echo $_SERVER['PHP_SELF'] . "?page=" . $_REQUEST['page'] . "&recent=500" ?>">Last 500 Searches</a></li>
|
442 |
+
</ul>
|
443 |
+
|
444 |
+
<h2>Search summary</h2>
|
445 |
+
|
446 |
+
<p>These tables show the most popular searches on your blog for the given time periods. <strong>Term</strong> is the text that was searched for; you can click it to see which posts contain that term. (This won't be counted as another search.) <strong>Searches</strong> is the number of times the term was searched for. <strong>Results</strong> is the number of posts that were returned from the <em>last</em> search for that term.</p>
|
447 |
+
|
448 |
+
<div class="sm-stats-table">
|
449 |
+
<h3>Yesterday and today</h3>
|
450 |
+
<?php tguy_sm_summary_table($results, 1, true); ?>
|
451 |
+
</div>
|
452 |
+
<div class="sm-stats-table">
|
453 |
+
<h3>Last 7 days</h3>
|
454 |
+
<?php tguy_sm_summary_table($results, 7, true); ?>
|
455 |
+
</div>
|
456 |
+
<div class="sm-stats-table">
|
457 |
+
<h3>Last 30 days</h3>
|
458 |
+
<?php tguy_sm_summary_table($results, 30, true); ?>
|
459 |
+
</div>
|
460 |
+
<div class="sm-stats-clear"></div>
|
461 |
+
|
462 |
+
<h2>Unsuccessful search summary</h2>
|
463 |
+
|
464 |
+
<p>These tables show only the search terms for which the last search yielded no results. People are searching your blog for these terms; maybe you should give them what they want.</p>
|
465 |
+
|
466 |
+
<div class="sm-stats-table">
|
467 |
+
<h3>Yesterday and today</h3>
|
468 |
+
<?php tguy_sm_summary_table($results, 1, false); ?>
|
469 |
+
</div>
|
470 |
+
<div class="sm-stats-table">
|
471 |
+
<h3>Last 7 days</h3>
|
472 |
+
<?php tguy_sm_summary_table($results, 7,false); ?>
|
473 |
+
</div>
|
474 |
+
<div class="sm-stats-table">
|
475 |
+
<h3>Last 30 days</h3>
|
476 |
+
<?php tguy_sm_summary_table($results, 30, false); ?>
|
477 |
+
</div>
|
478 |
+
<div class="sm-stats-clear"></div>
|
479 |
+
|
480 |
+
<h2>Notes</h2>
|
481 |
+
|
482 |
+
<?php if (current_user_can(TGUY_SM_OPTIONS_CAPABILITY_LEVEL)) : ?>
|
483 |
+
<p>To manage your search statistics, go to your <a href="<?php bloginfo('wpurl'); ?>/wp-admin/options-general.php?page=search-meter.php">Search Meter Options page</a>.</p>
|
484 |
+
<?php endif; ?>
|
485 |
+
|
486 |
+
<p>For information and updates, see the <a href="http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/">Search Meter home page</a>. You can also offer suggestions, request new features or report problems.</p>
|
487 |
+
|
488 |
+
</div>
|
489 |
+
<?php
|
490 |
+
}
|
491 |
+
|
492 |
+
function tguy_sm_summary_table($results, $days, $do_include_successes = false) {
|
493 |
+
global $wpdb, $table_prefix;
|
494 |
+
// Explanation of the query:
|
495 |
+
// We group by terms, because we want all rows for a term to be combined.
|
496 |
+
// For the search count, we simply SUM the count of all searches for the term.
|
497 |
+
// For the result count, we only want the number of results for the latest search. Each row
|
498 |
+
// contains the result for the latest search on that row's date. So for each date,
|
499 |
+
// CONCAT the date with the number of results, and take the MAX. This gives us the
|
500 |
+
// latest date combined with its hit count. Then strip off the date with SUBSTRING.
|
501 |
+
// This Rube Goldberg-esque procedure should work in older MySQL versions that
|
502 |
+
// don't allow subqueries. It's inefficient, but that doesn't matter since it's
|
503 |
+
// only used in admin pages and the tables involved won't be too big.
|
504 |
+
$hits_selector = $do_include_successes ? '' : 'HAVING hits = 0';
|
505 |
+
$results = $wpdb->get_results(
|
506 |
+
"SELECT `terms`,
|
507 |
+
SUM( `count` ) AS countsum,
|
508 |
+
SUBSTRING( MAX( CONCAT( `date` , ' ', `last_hits` ) ) , 12 ) AS hits
|
509 |
+
FROM `{$table_prefix}searchmeter`
|
510 |
+
WHERE DATE_SUB( CURDATE( ) , INTERVAL $days DAY ) <= `date`
|
511 |
+
GROUP BY `terms`
|
512 |
+
$hits_selector
|
513 |
+
ORDER BY countsum DESC, `terms` ASC
|
514 |
+
LIMIT 20");
|
515 |
+
if (count($results)) {
|
516 |
+
?>
|
517 |
+
<table cellpadding="3" cellspacing="2">
|
518 |
+
<tbody>
|
519 |
+
<tr class="alternate"><th class="left">Term</th><th>Searches</th>
|
520 |
+
<?php
|
521 |
+
if ($do_include_successes) {
|
522 |
+
?><th>Results</th><?php
|
523 |
+
}
|
524 |
+
?></tr><?php
|
525 |
+
$class= '';
|
526 |
+
foreach ($results as $result) {
|
527 |
+
?>
|
528 |
+
<tr class="<?php echo $class ?>">
|
529 |
+
<td><a href="<?php echo get_bloginfo('wpurl').'/wp-admin/edit.php?s='.urlencode($result->terms).'&submit=Search' ?>"><?php echo htmlspecialchars($result->terms) ?></a></td>
|
530 |
+
<td class="right"><?php echo $result->countsum ?></td>
|
531 |
+
<?php
|
532 |
+
if ($do_include_successes) {
|
533 |
+
?>
|
534 |
+
<td class="right"><?php echo $result->hits ?></td></tr>
|
535 |
+
<?php
|
536 |
+
}
|
537 |
+
$class = ($class == '' ? 'alternate' : '');
|
538 |
+
}
|
539 |
+
?>
|
540 |
+
</tbody>
|
541 |
+
</table>
|
542 |
+
<?php
|
543 |
+
} else {
|
544 |
+
?><p>No searches recorded for this period.</p><?php
|
545 |
+
}
|
546 |
+
}
|
547 |
+
|
548 |
+
function tguy_sm_recent_page($max_lines, $do_show_details) {
|
549 |
+
global $wpdb, $table_prefix;
|
550 |
+
tguy_sm_create_recent_table();
|
551 |
+
|
552 |
+
$options = get_option('tguy_search_meter');
|
553 |
+
$is_details_available = $options['sm_details_verbose'];
|
554 |
+
$is_disable_donation = $options['sm_disable_donation'];
|
555 |
+
$this_url_base = $_SERVER['PHP_SELF'] . '?page=' . $_REQUEST['page'];
|
556 |
+
$this_url_recent_arg = '&recent=' . $max_lines;
|
557 |
+
?>
|
558 |
+
<div class="wrap">
|
559 |
+
<?php if (!$is_disable_donation) { tguy_sm_show_donation_bar(); } ?>
|
560 |
+
|
561 |
+
<ul id="search_meter_menu">
|
562 |
+
<li><a href="<?php echo $this_url_base ?>">Summary</a></li>
|
563 |
+
<?php if (100 == $max_lines) : ?>
|
564 |
+
<li class="current">Last 100 Searches</li>
|
565 |
+
<?php else : ?>
|
566 |
+
<li><a href="<?php echo $this_url_base . '&recent=100' ?>">Last 100 Searches</a></li>
|
567 |
+
<?php endif ?>
|
568 |
+
<?php if (500 == $max_lines) : ?>
|
569 |
+
<li class="current">Last 500 Searches</li>
|
570 |
+
<?php else : ?>
|
571 |
+
<li><a href="<?php echo $this_url_base . '&recent=500' ?>">Last 500 Searches</a></li>
|
572 |
+
<?php endif ?>
|
573 |
+
</ul>
|
574 |
+
|
575 |
+
<h2>Recent searches</h2>
|
576 |
+
|
577 |
+
<p>This table shows the last <?php echo $max_lines; ?> searches on this blog. <strong>Term</strong> is the text that was searched for; you can click it to see which posts contain that term. (This won't be counted as another search.) <strong>Results</strong> is the number of posts that were returned from the search.
|
578 |
+
</p>
|
579 |
+
|
580 |
+
<div class="sm-stats-table">
|
581 |
+
<?php
|
582 |
+
$query =
|
583 |
+
"SELECT `datetime`, `terms`, `hits`, `details`
|
584 |
+
FROM `{$table_prefix}searchmeter_recent`
|
585 |
+
ORDER BY `datetime` DESC, `terms` ASC
|
586 |
+
LIMIT $max_lines";
|
587 |
+
$results = $wpdb->get_results($query);
|
588 |
+
if (!$results) {
|
589 |
+
if (tguy_sm_create_recent_table()) {
|
590 |
+
$results = $wpdb->get_results($query);
|
591 |
+
}
|
592 |
+
}
|
593 |
+
if (count($results)) {
|
594 |
+
?>
|
595 |
+
<table cellpadding="3" cellspacing="2">
|
596 |
+
<tbody>
|
597 |
+
<tr class="alternate"><th class="left">Date & time</th><th class="left">Term</th><th class="right">Results</th>
|
598 |
+
<?php if ($do_show_details) { ?>
|
599 |
+
<th class="left">Details</th>
|
600 |
+
<?php } else if ($is_details_available) { ?>
|
601 |
+
<th class="left"><a href="<?php echo $this_url_base . $this_url_recent_arg . '&details=1' ?>">Show details</a></th>
|
602 |
+
<?php } ?>
|
603 |
+
</tr>
|
604 |
+
<?php
|
605 |
+
$class= '';
|
606 |
+
foreach ($results as $result) {
|
607 |
+
?>
|
608 |
+
<tr valign="top" class="<?php echo $class ?>">
|
609 |
+
<td><?php echo $result->datetime ?></td>
|
610 |
+
<td><a href="<?php echo get_bloginfo('wpurl').'/wp-admin/edit.php?s='.urlencode($result->terms).'&submit=Search' ?>"><?php echo htmlspecialchars($result->terms) ?></a></td>
|
611 |
+
<td class="right"><?php echo $result->hits ?></td>
|
612 |
+
<?php if ($do_show_details) : ?>
|
613 |
+
<td><?php echo str_replace("\n", "<br />", htmlspecialchars($result->details)) ?></td>
|
614 |
+
<?php endif ?>
|
615 |
+
</tr>
|
616 |
+
<?php
|
617 |
+
$class = ($class == '' ? 'alternate' : '');
|
618 |
+
}
|
619 |
+
?>
|
620 |
+
</tbody>
|
621 |
+
</table>
|
622 |
+
<?php
|
623 |
+
} else {
|
624 |
+
?><p>No searches recorded.</p><?php
|
625 |
+
}
|
626 |
+
?>
|
627 |
+
</div>
|
628 |
+
<div class="sm-stats-clear"></div>
|
629 |
+
|
630 |
+
<h2>Notes</h2>
|
631 |
+
|
632 |
+
<?php if (current_user_can(TGUY_SM_OPTIONS_CAPABILITY_LEVEL)) : ?>
|
633 |
+
<p>To manage your search statistics, go to your <a href="<?php bloginfo('wpurl'); ?>/wp-admin/options-general.php?page=search-meter.php">Search Meter Options page</a>.</p>
|
634 |
+
<?php endif; ?>
|
635 |
+
|
636 |
+
<p>For information and updates, see the <a href="http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/">Search Meter home page</a>. You can also offer suggestions, request new features or report problems.</p>
|
637 |
+
|
638 |
+
</div>
|
639 |
+
<?php
|
640 |
+
}
|
641 |
+
|
642 |
+
|
643 |
+
endif; // if (!is_plugin_page())
|
644 |
+
|
645 |
+
|
646 |
+
function tguy_sm_options_page() {
|
647 |
+
if (isset($_POST['submitted'])) {
|
648 |
+
check_admin_referer('search-meter-update-options_all');
|
649 |
+
$options = get_option('tguy_search_meter');
|
650 |
+
$options['sm_details_verbose'] = (bool)($_POST['sm_details_verbose']);
|
651 |
+
$options['sm_disable_donation'] = (bool)($_POST['sm_disable_donation']);
|
652 |
+
update_option('tguy_search_meter', $options);
|
653 |
+
echo '<div id="message" class="updated fade"><p><strong>Plugin settings saved.</strong></p></div>';
|
654 |
+
} else if (isset($_POST['tguy_sm_reset'])) {
|
655 |
+
check_admin_referer('search-meter-reset-stats');
|
656 |
+
tguy_sm_reset_stats();
|
657 |
+
echo '<div id="message" class="updated fade"><p><strong>Statistics have been reset.</strong></p></div>';
|
658 |
+
}
|
659 |
+
$options = get_option('tguy_search_meter');
|
660 |
+
?>
|
661 |
+
<div class="wrap">
|
662 |
+
|
663 |
+
<h2>Search Meter Options</h2>
|
664 |
+
|
665 |
+
<?php if (!$options['sm_disable_donation']) { tguy_sm_show_donation_box(); } ?>
|
666 |
+
<form name="searchmeter" action="<?php echo $action_url; ?>" method="post">
|
667 |
+
<?php
|
668 |
+
if (function_exists('wp_nonce_field')) {
|
669 |
+
wp_nonce_field('search-meter-update-options_all');
|
670 |
+
}
|
671 |
+
?>
|
672 |
+
|
673 |
+
<input type="hidden" name="submitted" value="1" />
|
674 |
+
|
675 |
+
<fieldset class="options">
|
676 |
+
<ul>
|
677 |
+
<li>
|
678 |
+
<label for="sm_details_verbose">
|
679 |
+
<input type="checkbox" id="sm_details_verbose" name="sm_details_verbose" <?php echo ($options['sm_details_verbose']==true?"checked=\"checked\"":"") ?> />
|
680 |
+
Keep detailed information about recent searches (taken from HTTP headers)
|
681 |
+
</label>
|
682 |
+
</li>
|
683 |
+
<li>
|
684 |
+
<label for="sm_disable_donation">
|
685 |
+
<input type="checkbox" id="sm_disable_donation" name="sm_disable_donation" <?php echo ($options['sm_disable_donation']==true?"checked=\"checked\"":"") ?> />
|
686 |
+
Hide the “Do you find this plugin useful?” box
|
687 |
+
</label>
|
688 |
+
</li>
|
689 |
+
</ul>
|
690 |
+
</fieldset>
|
691 |
+
<p class="submit">
|
692 |
+
<input type="submit" name="Submit" value="Save changes »" />
|
693 |
+
</p>
|
694 |
+
</form>
|
695 |
+
|
696 |
+
<h2>Reset statistics</h2>
|
697 |
+
|
698 |
+
<p>Click this button to reset all search statistics. This will delete all information about previous searches.</p>
|
699 |
+
|
700 |
+
<form name="tguy_sm_admin" action="<?php echo $action_url; ?>" method="post">
|
701 |
+
<?php
|
702 |
+
if (function_exists('wp_nonce_field')) {
|
703 |
+
wp_nonce_field('search-meter-reset-stats');
|
704 |
+
}
|
705 |
+
?>
|
706 |
+
<p class="submit">
|
707 |
+
<input type="submit" name="tguy_sm_reset" value="Reset statistics »" onclick="return confirm('You are about to delete all saved search statistics.\n \'Cancel\' to stop, \'OK\' to delete.');" />
|
708 |
+
</p>
|
709 |
+
</form>
|
710 |
+
|
711 |
+
<h2>Notes</h2>
|
712 |
+
|
713 |
+
<p>To see your search statistics, go to your <a href="<?php bloginfo('wpurl'); ?>/wp-admin/index.php?page=search-meter.php">Search Meter Statistics page</a>.</p>
|
714 |
+
|
715 |
+
<p>For information and updates, see the <a href="http://www.thunderguy.com/semicolon/wordpress/search-meter-wordpress-plugin/">Search Meter home page</a>. At that page, you can also offer suggestions, request new features or report problems.</p>
|
716 |
+
|
717 |
+
</div>
|
718 |
+
<?php
|
719 |
+
}
|
720 |
+
|
721 |
+
function tguy_sm_show_donation_bar() {
|
722 |
+
?>
|
723 |
+
<div style="width:30%; background:#EEEEEE none repeat scroll 0%; border:1px solid #6699CC; float:right; font-size:90%; margin:0 0 -20px 0; padding:0;"><div style="margin:0; padding:0 0 0 2ex; float: right;">
|
724 |
+
<?php tguy_sm_show_donation_button() ?>
|
725 |
+
</div>
|
726 |
+
<p style="margin:0; padding:0.5em">Do you find this plugin useful?</p>
|
727 |
+
|
728 |
+
</div>
|
729 |
+
<?php
|
730 |
+
}
|
731 |
+
|
732 |
+
function tguy_sm_show_donation_box() {
|
733 |
+
?>
|
734 |
+
<div style="width:30%; background:#EEEEEE none repeat scroll 0%; border:1px solid #6699CC; float:right; font-size:90%; margin:0 0 1em 1em; padding:1em;">
|
735 |
+
|
736 |
+
<div style="margin: 0; padding: 0 2ex 0.25ex 0; float: left;">
|
737 |
+
<?php tguy_sm_show_donation_button() ?>
|
738 |
+
</div>
|
739 |
+
<p style="margin: 0; padding: 0"><strong>Do you find this plugin useful?</strong><br />
|
740 |
+
I write WordPress plugins because I enjoy doing it, but it does take up a lot
|
741 |
+
of my time. If you think this plugin is useful, please consider donating some appropriate
|
742 |
+
amount by clicking here. Thank you.</p>
|
743 |
+
|
744 |
+
</div>
|
745 |
+
<?php
|
746 |
+
}
|
747 |
+
|
748 |
+
function tguy_sm_show_donation_button() {
|
749 |
+
?><form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="margin:0; padding:0;"
|
750 |
+
><input name="cmd" value="_s-xclick" type="hidden" style="margin:0; padding:0;"
|
751 |
+
/><input src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" border="0" type="image" style="margin:0; padding:0;"
|
752 |
+
/><input name="encrypted" value="-----BEGIN PKCS7-----MIIHXwYJKoZIhvcNAQcEoIIHUDCCB0wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaW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